host 192.168.1.2
src host 192.168.1.2
dst host 192.168.1.3
port 80
src port 80
dst port 89
net 192.168
src net 192.168.1
dst net 10.10
arp
ip
tcp
udp
icmp
非:
!
not
且:
&&
and
或:
||
or
规则组合:
支持用英文括号将规则组合起来
tcpdump -i eth1 '((tcp) and ((dst net 192.168) and (not dst host 192.168.1.200)))'
一些比较有意思的应用。
tcpdump -i eth1 'tcp[tcpflags] = tcp-syn'
tcpdump -i eth1 'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack != 0'
tcpdump -i eth1 '((port 25) and (tcp[(tcp[12]>>2):4] = 0x4d41494c))'
TCP的Payload开始字符为”MAIL”,0x4d41494c是”MAIL”的16进制表示。
“0x4d41494c” -> “MAIL”
tcpdump -i eth1 'tcp[(tcp[12]>>2):4] = 0x47455420'
“0x47455420” -> “GET”
tcpdump eth1 'tcp[(tcp[12]>>2):4] = 0x5353482D'"
“0x5353482D” -> “SSH-“