一.过滤规则
1.基于协议的过滤规则
(1)链路层
- 以太网:
eth
(2)网络层
- IP(网际协议) :
ip
- ICMP(Internet互联网控制报文协议):
icmp
- IGMP(Internet组织管理协议):
igmp
- ARP(地址解析协议):
arp
(3)传输层
- TCP(传输控制协议):
tcp
- UDP(用户数据报协议):
udp
(4)应用层
- HTTP(HyperText Transfer Protocol,超文本传输协议):
http
- DHCP(Dynamic Host Configuration Protocol,动态主机配置协议):
bootp
- DNS(Domain Name System,域名服务协议):
dns
- FTP(File Transfer Protocol,文件传输协议)-
ftp
- SMTP(Simple Mail Transfer ProtocolSimple Mail Transfer Protocol,简单邮件传输协议)-
smtp
- POP3(Post Office Protocol - Version 3,邮局协议版本3)-
pop3
- SSL(Secure Sockets Layer 安全套接层Secure Sockets Layer 安全套接层):
ssl
2.基于特定规则的过滤
(1)基于IP
- 来源IP
ip.src == 192.168.1.107
- 目标IP
ip.dst == 192.168.1.107
(2)基于MAC地址
- 目标MAC
eth.dst == A0: 00: 00: 04: C5: 84
- 来源MAC
eth.src == A0: 00: 00: 04: C5: 84
(3)基于端口
- 源端口和目的端口都为80:
tcp.port==80
- 源端口:
tcp.srcport==80
- 目的端口:
tcp.dstport==80
(4)基于HTTP
- 以Request的 Host Header作为过滤条件:
http.host contains csdn
- 以Request的 Method Header作为过滤条件:
http.request.method=="GET"
orhttp.request.method=="POST"
- 以Request的 URL作为过滤条件:
http.request.uri == "/img/logo-edu.gif"
二.符号使用
1.连接符
(1)and(&&)
过滤ip为192.168.101.8并且为 HTTP 协议的包:ip.src==192.168.101.8 and http
(2)or(||)
过滤源IP或者目标IP等于某个IP:ip.src == 192.168.1.107 or ip.dst == 192.168.1.107
(3)not(!)
排除某种协议的数据包:not tcp
(4)in
过滤只使用某些范围内的端口:tcp.port in {80 443}
参考:https://www.wireshark.org/docs/wsug_html_chunked/ChWorkBuildDisplayFilterSection.html
2.比较符
(1)==
IP为10.0.0.5:ip.src==10.0.0.5
(2)!=
IP不等于10.0.0.5:ip.src!=10.0.0.5
(3)>
包长度大于10:frame.len > 10
(4)<
包长度小于10:frame.len < 128
(5)contains
HTTP中包括“sogou”关键字:http contains "sogou"
参考:https://www.wireshark.org/docs/wsug_html_chunked/ChWorkBuildDisplayFilterSection.html
三.参考
- wireshark-Comparing values
- wireshark-display filter expressions
- wireshark过滤表达式实例介绍
- 使用wireshark常用的过滤命令