wireshark的filter的使用

wireshark 有兩種過濾器。

  • 捕獲過濾器

  • 顯示過濾器

捕獲過濾器----Capture---->Options---->Capture Filter。


BPF限定詞(Berkeley Packet Filter)

     例子:     host、net、port、src、dst、ether、ip、tcp、udp、http、ftp。


操作符:         &&         ||         !。


比如:dst host 200.0.0.1 && tcp port 80

port http但不能是http。

icmp[0]==8表示數據包偏移量爲0的位置值爲8。

icmp[0:2]==0x0301表示數據包偏移量爲0再延續兩個字節,值爲0x0301。

icmp數據包格式:

0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Type      |     Code      |          Checksum             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                             unused                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |      Internet Header + 64 bits of Original Data Datagram      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
詳見:http://www.ietf.org/rfc/rfc792.txt
TCP Header Format

                                    
    0                   1                   2                   3   
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |          Source Port          |       Destination Port        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        Sequence Number                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Acknowledgment Number                      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Data |           |U|A|P|R|S|F|                               |
   | Offset| Reserved  |R|C|S|S|Y|I|            Window             |
   |       |           |G|K|H|T|N|N|                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |           Checksum            |         Urgent Pointer        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Options                    |    Padding    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                             data                              |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            TCP Header Format
詳見:http://www.ietf.org/rfc/rfc793.txt
只捕獲tcp標誌爲是RST的數據包了?
tcp[13]&4==4,數據包位偏移13字節,那“&4”是什麼意思了?因爲RST在這第13字節代表數字4[*(128) *(64) urg(32) ack(16) psh(8) rst(4) syn(2) fin(0)]。
那syn+ack了?tcp[13]==18。
顯示過濾器

點擊expression後可指定詳細的表達式。下面是些常用的:
ip.addr==192.168.1.1
frame.len<=128幀長度小於等於128字節。
ip.addr==1.1.1.1 || ip.addr==2.2.2.2
tcp.port==80或者http。填寫好後點擊apply就可以生效了。

具體的自己可以慢慢研究。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章