2012-03-26 1075 views
18

我一直試圖根據數據包長度來過濾tcpdump輸出。但我沒有運氣。如何根據數據包長度過濾tcpdump輸出

這是一個命令的簡單輸出;

的tcpdump -n -i eth0的目標端口443 -A

17:03:30.866890 IP 192.168.0.149.45104 > 62.75.148.60.443: Flags [S], seq 2685064927, win 14600, options [mss 1460,sackOK,TS val 7028787 ecr 0,nop,wscale 4], length 0 
E..<[email protected]@.......>K.<.0... 
........9............ 
[email protected] 


17:03:30.867658 IP 192.168.0.149.45104 > 62.75.148.60.443: Flags [.], ack 2285019097, win 913, options [nop,nop,TS val 7028787 ecr 974439509], length 0 
[email protected]@.......>K.<.0... 
...2............. 
[email protected]:..U 


17:03:30.867928 IP 192.168.0.149.45104 > 62.75.148.60.443: Flags [P.], seq 0:171, ack 1, win 913, options [nop,nop,TS val 7028787 ecr 974439509], length 171 
[email protected]@..f....>K.<.0... 
...2............. 
[email protected]:..U...........Opw2.....l..".T.7.q.]h..8W..%.....H... 
.......9.8.......5... .....E.D.3.2...........A...../......... 
...1.........alice.sni.velox.ch. 
.................#.. 


17:03:30.869712 IP 192.168.0.149.45104 > 62.75.148.60.443: Flags [.], ack 1319, win 1078, options [nop,nop,TS val 7028788 ecr 974439511], length 0 
[email protected]@.......>K.<.0... 
...2.....6....... 
[email protected]:..W 


17:03:30.870724 IP 192.168.0.149.45104 > 62.75.148.60.443: Flags [P.], seq 171:178, ack 1319, win 1078, options [nop,nop,TS val 7028788 ecr 974439511], length 7 
E..;[email protected]@.......>K.<.0... 
...2.....6....... 
[email protected]:..W......0 

我想看看包裝,只有當他們有更多的則100字節的長度。對於這種情況,只有第三個數據包。

選項[NOP,NOP,TS VAL 7028787 ECR 974439509],長171

我已經看過手冊頁tcpdump的,但找不到任何有用的參數。這裏提到的表達「更大的長度」; http://www.ethereal.com/docs/man-pages/tcpdump.8.html但我也無法使用該表達式。

$ tcpdump -n -i eth0 dst port 443 -A -x greater 100 
tcpdump: syntax error 

感謝任何幫助。

回答

26

greater長度的作品,但你必須把它作爲一個完整的過濾器表達式的一部分,和過濾器表達式來所有命令行標誌參數後。

工作實施例:

tcpdump -n -i eth0 -A -x dst port 443 and greater 100 

應工作 - dst port 443 and greater 100是一個完整的過濾器表達式,檢查是否有任何被髮送到TCP或UDP端口443和具有一個長度的分組(包括鏈路層,IP和TCP報頭)大於100

不工作!例如:

tcpdump -n -i eth0 dst port 443 -A -x greater 100 

將無法​​正常工作 - 在dst port 443dst被視爲一個過濾器表達式的開始,這意味着它和一切後,包括-A-x,作爲過濾器表達式的一部分治療,但-A-x不是過濾器表達式的有效組件。它們大概是命令行選項,所以它們必須在之前之前的所有非標誌參數,包括過濾器表達式的組件。