Wireshark 显示过滤器速查
一、协议过滤
| 关键字 |
说明 |
示例 |
http、dns、tcp、udp、arp、icmp、tls、quic、dhcp、ftp、smtp、ssh、snmp、ntp、sip、rtp、mqtt、websocket |
直接写协议名,表示“该协议解析器在本帧生效”;它判断的是协议解析结果,与端口号无关 |
http |
!协议名 |
排除某协议 |
!arp |
协议名1 or 协议名2 |
多协议 |
dns or dhcp |
注意:http 不等于 tcp.port == 80。用 8080 端口传 HTTP 时 http 能匹配,tcp.port == 80 不能。
二、地址过滤
| 关键字 |
说明 |
示例 |
ip.addr |
双向匹配,源或目的命中即可 |
ip.addr == 192.168.1.10 |
ip.src、ip.dst |
单向 |
ip.src == 192.168.1.10 |
ip.addr == x/24 |
网段匹配 |
ip.addr == 192.168.1.0/24 |
ip.addr in {…} |
集合匹配(3.0+) |
ip.addr in {10.0.0.1, 10.0.0.2} |
ipv6.addr、ipv6.src、ipv6.dst |
IPv6 对应字段 |
ipv6.addr == 240e::1 |
eth.addr、eth.src、eth.dst |
MAC 地址,格式用冒号或短横线 |
eth.src == 00:1a:2b:3c:4d:5e |
arp.src.proto_ipv4 |
ARP 里的发送方 IP |
arp.src.proto_ipv4 == 192.168.1.1 |
易混点:ip.addr == 1.2.3.4 会同时命中“发给它”和“它发出”的包;只想看请求方向就用 ip.dst。
三、端口过滤
| 关键字 |
说明 |
示例 |
tcp.port / udp.port |
同时匹配源端口和目的端口 |
tcp.port == 443 |
tcp.srcport / tcp.dstport |
单向 |
tcp.dstport == 22 |
| 端口范围 |
用比较运算符组合 |
tcp.port >= 1 and tcp.port <= 1024 |
| 端口 + 协议 |
避免把 UDP 也算进来 |
tcp.port == 53 or udp.port == 53 |
四、比较运算符
| 写法 |
等价别名 |
说明 |
== |
eq |
等于 |
!= |
ne |
不等于 |
> < >= <= |
gt lt ge le |
数值比较 |
contains |
— |
子串/字节匹配,区分大小写 |
matches |
~ |
PCRE 正则匹配 |
in {a, b} |
— |
集合成员判断(3.0+) |
& |
— |
按位与,常用于标志位 |
1 2 3 4
| http.host contains "example" # 主机名里含 example http.request.uri matches "\.(jpg|png)$" # 正则:以 jpg/png 结尾 frame.number in {1, 5, 9} tcp.flags & 0x02 # 按位判断 SYN 位
|
易混点:contains 是纯子串,matches 是正则;正则里的 . ? + 要加反斜杠转义,否则含义完全不同(\.jpg 才是“点 jpg”)。
五、逻辑组合
1 2 3 4
| ip.addr == 192.168.1.10 and tcp.port == 80 # 与(&&) http or dns # 或(||) not arp # 非(!) (ip.src == 10.0.0.1 or ip.src == 10.0.0.2) and tcp # 括号改变优先级
|
not 的优先级高于 and,and 高于 or。复合表达式一律加括号,别靠记忆。
六、TCP 标志位
| 关键字 |
说明 |
示例 |
tcp.flags.syn == 1 |
SYN 置位 |
tcp.flags.syn == 1 and tcp.flags.ack == 0(纯 SYN,建连请求) |
tcp.flags.ack == 1 |
ACK 置位 |
tcp.flags.ack == 1 |
tcp.flags.fin == 1 |
结束连接 |
tcp.flags.fin == 1 |
tcp.flags.reset == 1 |
RST,连接被拒/被断 |
tcp.flags.reset == 1 |
tcp.flags.push == 1 |
PSH |
tcp.flags.push == 1 |
tcp.flags.urg == 1 |
URG |
tcp.flags.urg == 1 |
TCP 异常(排障最常用)
| 关键字 |
含义 |
tcp.analysis.retransmission |
重传 |
tcp.analysis.fast_retransmission |
快速重传 |
tcp.analysis.spurious_retransmission |
伪重传 |
tcp.analysis.duplicate_ack |
重复 ACK |
tcp.analysis.zero_window |
零窗口(接收方处理不过来) |
tcp.analysis.window_full |
窗口满 |
tcp.analysis.out_of_order |
乱序 |
tcp.analysis.lost_segment |
疑似丢段 |
tcp.analysis.flags |
以上问题任意一个 |
1
| tcp.analysis.flags and ip.addr == 192.168.1.10
|
七、内容匹配
| 关键字 |
说明 |
示例 |
frame contains |
在整帧(含各层头)里找字节串 |
frame contains "GET /api" |
tcp contains |
只在 TCP 载荷里找 |
tcp contains "password" |
data contains |
只在与协议无关的载荷里找 |
data contains "flag{" |
frame matches |
整帧正则 |
frame matches "(?i)user-agent" |
HTTP
1 2 3 4 5 6 7 8 9
| http.request.method == "GET" http.request.method == "POST" http.response.code == 404 http.response.code >= 500 http.host == "caito.top" http.request.uri contains "/api/" http.user_agent contains "curl" http.content_type contains "json" http.request.full_uri contains "token"
|
DNS
1 2 3 4 5
| dns.qry.name == "caito.top" dns.qry.name contains "doubleclick" dns.flags.response == 0 # 0=查询,1=响应 dns.flags.rcode != 0 # 非 0 即解析失败 dns.time > 1 # 响应耗时超过 1 秒
|
TLS
1 2 3
| tls.handshake.type == 1 # ClientHello tls.handshake.extensions_server_name == "caito.top" # SNI tls.record.version == 0x0303 # TLS 1.2
|
ICMP / ARP / DHCP
1 2 3 4 5 6 7
| icmp.type == 8 # Echo 请求(ping) icmp.type == 0 # Echo 应答 icmp.type == 3 # 目的不可达 arp.opcode == 1 # ARP 请求 arp.opcode == 2 # ARP 应答 dhcp.option.dhcp == 3 # DHCP Request dhcp.option.dhcp == 5 # DHCP ACK
|
八、帧与时间
1 2 3 4 5
| frame.number == 100 frame.len > 1400 # 超大帧,怀疑分片/MTU 问题 frame.time_delta > 1 # 与上一帧间隔超过 1 秒 frame.time_relative > 10 # 抓包开始 10 秒之后 frame.time >= "2026-11-09 20:00:00"
|
九、典型场景组合
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| # 某台机器与某个站点的全部交互 ip.addr == 192.168.1.10 and ip.addr == 93.184.216.34
# 某 IP 的 HTTP 请求(排除响应) ip.addr == 192.168.1.10 and http.request
# 连接被拒绝:SYN 之后来了 RST tcp.flags.syn == 1 and tcp.flags.ack == 0 and tcp.port == 443 tcp.flags.reset == 1 and tcp.port == 443
# 建连失败(SYN 反复重传,无人应答) tcp.flags.syn == 1 and tcp.flags.ack == 0 and tcp.analysis.retransmission
# 页面加载慢:找出所有重传和零窗口 tcp.analysis.flags and tcp.port == 443
# 排除内网噪音,只看公网流量 not (arp or dns or mdns or llmnr or nbns or ssdp or icmpv6) and ip.addr != 192.168.1.0/24
# 排除广播与组播(按 MAC 最低位判断) not (eth.dst[0] & 1)
# 明文凭据排查 http.authorization or ftp.request.command == "PASS" or telnet
# 找 DNS 解析失败 dns.flags.rcode != 0
# 只看某个 TLS 站点 tls.handshake.extensions_server_name == "caito.top" or (tcp.port == 443 and ip.addr == 93.184.216.34)
|
十、易混淆点汇总
ip.addr 是双向的,ip.src/ip.dst 才是单向;tcp.port 同理双向,srcport/dstport 单向。
== 与 eq 完全等价,可混写;但字符串值必须加双引号,数字不用。
contains 区分大小写,要忽略大小写用 matches "(?i)..."。
http 与 tcp.port == 80 不等价,前者靠解析器识别,后者只看端口。
- 否定要加括号:
!(http or dns) 写错成 !http or dns 会变成“非 http 的,或所有 dns”。
- 字段名全小写,写成
ip.Addr 会直接报语法错误。
frame contains 搜全帧,会把 TCP 头、IP 头里的字节也算进去,误报多;定位应用层内容优先用 tcp contains 或具体协议字段。
- **十六进制直接写
0x**:tcp.flags & 0x12 判断 SYN+ACK 组合位。
in {} 是 3.0 以后才有,老版本用 == a or == b。
- 过滤表达式存为按钮:过滤器输入框右侧书签图标可保存常用表达式,
Ctrl+/ 快速聚焦过滤栏,Ctrl+Shift+F 应用为过滤条件。