过滤需要的数据
概述
众所周知,Wireshark是功能强大的网络数据包分析软件。在工作中,与charles或fiddler相比,使用相对较少,由于工作业务需要,如抓取G网数据就不得不使用,可进一步查看之前的文章使用Wireshark抓4G网络包
使用的人都知道,这么疯狂的刷,还怎么看数据。作为一款功能强大的工具,肯定有过滤功能,赶紧翻翻官方文档,后文会贴出官方链接
wireshark使用手册
过滤表达式
过滤特定协议的数据
- 仅需要展示tcp的数据包,可在filter输入框输入tcp,同理,仅需要展示http的数据包,输入http
- 结合逻辑操作符:如http or telnet、not arp、!tcp
操作数
- request相关:http.request.uri、http.request.full_uri、http.request.uri.path、http.request.uri.query、http.request.uri.query.parameter、http.request.method等
- response相关:http.response.code
- 其他:http.host、http.cookie、http.server、http.content_type、http.content_encoding、ip.src、ip.dst、tcp.port、udp.port
以上操作数需结合操作符使用,更多操作数可参考官方文档或通过过滤输入框的联想功能查看
比较操作符
英文比较符 | c风格比较符 | 描述 | 例子 |
---|---|---|---|
eq | == | 相等 | ip.src==10.0.0.5 |
ne | != | 不等 | ip.src!=10.0.0.5 |
gt | > | 大于 | frame.len > 10 |
lt | < | 小于 | frame.len < 128 |
ge | >= | 大于等于 | frame.len ge 0x100 |
le | <= | 小于等于 | frame.len <= 0x20 |
contains | 包含 | sip.To contains "a1762" |
|
matches | ~ | 匹配正则表达式(perl 兼容的正则表达式(PCRE)) | http.host matches "acme\\.(org|com|net)" |
注:
ip.addr != 1.2.3.4
并不是过滤所有不包含ip为1.2.3.4的数据包(因为数据包包含source 和destination 地址,除非 source 和 destination 都为1.2.3.4才会被过滤掉)。正确的表达式应该为!(ip.addr == 1.2.3.4)
逻辑操作符
英文操作符 | c风格操作符 | 描述 | 例子 |
---|---|---|---|
and | && | 与 | ip.src==10.0.0.5 and tcp.flags.fin |
or | || | 或 | ip.src==10.0.0.5 or ip.src==192.1.1.1 |
xor | ^^ | 异或 | tr.dst[0:3] == 0.6.29 xor tr.src[0:3] == 0.6.29 |
not | ! | 非 | not llc |
[…] | 切片 | eth.src[0:3] == 00:00:83 |
|
in | 集合 | http.request.method in {"HEAD" "GET"} |
函数
函数 | 描述 | 例子 |
---|---|---|
upper | 转大写 | upper(http.server) contains "APACHE" |
lower | 转小写 | lower(http.server) contains "apache" |
len | 长度(byte) | len(http.request.uri) > 100 |
count | 数量 | count(ip.addr) > 2 |
string | 转字符串 | string(frame.number) matches "[13579]$" |