Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wireshark的基本使用 #49

Open
BruceChen7 opened this issue Mar 8, 2023 · 0 comments
Open

wireshark的基本使用 #49

BruceChen7 opened this issue Mar 8, 2023 · 0 comments

Comments

@BruceChen7
Copy link
Owner

BruceChen7 commented Mar 8, 2023

参考资料

Display filter is not a capture filter

  • 捕获过滤器(如 tcp port 80 )不要与显示过滤器(如 tcp.port == 80 )混淆。
    • Wireshark 提供了一种显示过滤语言,使能够精确控制显示哪些数据包。
    • 它们可用于检查协议或字段的存在、字段的值,甚至能将两个字段相互比较。
  • 最简单的显示过滤器是显示单一协议的过滤器,
    • 要仅显示 TCP 数据包,请在 Wireshark 的显示过滤器工具栏中键入 tcp,
    • 仅显示 HTTP 请求,请在 Wireshark 的显示过滤器工具栏中键入 http.request。
  • 可用协议和字段的完整列表可通过菜单项视图 → 内部 → 支持的协议获得。

字段类型

  • 所有协议字段都有一个类型
    • 无符号整数
    • 有符号整数
    • bool 值,1 or "True", 0 or false
    • 以太网地址 6 个字节,由冒号 (:)、点 (.) 或破折号 (-) 分隔
    • IPv4 地址 ip.addr == 192.168.0.1
    • 日期和时间 ntp.xmt ge "2020-07-04 12:34:56"

切片运算符

# 使用 n:m 格式来指定单个范围。在这种情况下,n 是起始偏移量,m 是指定范围的长度
eth.src[0:3] == 00:00:83

# 使用 n-m 格式来指定单个范围。在这种情况下,n 是开始偏移量,m 是结束偏移量。
eth.src[1-2] == 00:83
# 示例使用 :m 格式,它获取从序列开头到偏移量 m 的所有内容。相当于0:m
eth.src[:4] == 00:00:83:00

例子

# 仅显示 SMTP(端口 25)和 ICMP 流量:
tcp.port eq 25 or icmp

# 显示指定的源ip和目的ip信息
ip.src==19

# TCP 缓冲区已满——源正在指示目标停止发送数据
tcp.window_size == 0 && tcp.flags.reset != 1

# 用来显示sync包
tcp.flags.syn == 1

# 匹配在 UDP 有效负载开头包含(任意)3 字节序列 0x81、0x60、0x03 的数据包,跳过 8 字节 UDP 标头。
# 请注意,字节序列的值隐式仅为十六进制。 (对于匹配本地数据包协议很有用。)
udp[8:3]==81:60:03

# 匹配在 UDP 标头或负载中的任何位置包含 3 字节序列 0x81、0x60、0x03 的数据包:
udp contains 81:60:03

# matches 或 ~ 运算符能使用正则表达式在字符串字段和字节序列中搜索文本, 使用 Perl 正则表达式语法
http.request.uri matches "gl=se$"

Capture filter is not a display filter

  • 捕获过滤器(如 tcp port 80 )不要与显示过滤器(如 tcp.port == 80 )混淆。
  • 前者的限制要多得多,用于减少原始数据包捕获的大小。
  • 捕获过滤器在开始数据包捕获之前设置,并且在捕获期间不能修改。
  • 另一方面,显示过滤器没有此限制,能随时更改它们。

Capture filter 的位置

  • img
  • 例子
    # 仅捕获进出 IP 地址 172.18.5.4 的流量:
    host 172.18.5.4
    
    # 捕获进出一系列 IP 地址的流量
    net 192.168.0.0/24
    
    # 从一系列 IP 地址捕获流量:
    src net 192.168.0.0/24
    
    # 从一系列 IP 地址捕获流量:
    dst net 192.168.0.0/24
    
    # 仅捕获 DNS(端口 53)流量:
    port 53
    
    # 捕获服务器上的非 HTTP 和非 SMTP 流量(两者是等效的):
    host www.example.com and not (port 80 or port 25)
    host www.example.com and not port 80 and not port 25

#type/networking #type/tools #public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant