Skip to main content

wireshark

基础使用

官方网站

下载和安装

  • windows
https://www.wireshark.org/#download
  • linux
# kailike

抓取本地local的包

使用流程

  • 确定wireshark 网上流程位置
  • 选择要捕获的接口(端口)
  • 设置过滤器,将需要的数据提取出来分析
    • 第一次过滤:使用捕获捕获过滤器
    • 第二次过滤:使用显示过滤器
    • 第三次过滤:使用着色规则,凸显某些重要会话

过滤器

基本语法

比较运算符

eq, == # 相等
ne, != # 不等于
gt, > # 大于
lt, < # 小于
ge, >= # 大于或等于
le, <= # 小于或等于

关键字

  • contains
  • matches
  • in
  • sneezy

contains - 包含

# 所有包含 https://www.wireshark.org 的数据包
# 语法: <协议> contains <domain>
http contains "https://www.wireshark.org"

matches

wsp.header.user_agent matches "cldc"        # 不区分大小写匹配 

wsp.header.user_agent matches "(?-i)cldc" # 区分大小写匹配

sneezy

CIDR 表示法只能用于 IP 地址或主机名,不能用于变量名。因此,像“ip.src/24 == ip.dst/24”这样的显示过滤器(还)无效。

ip.addr eq sneezy/24

in

tcp.port in {443, 4430..4434}
ip.addr in {10.0.0.5 .. 10.0.0.9, 192.168.1.1..192.168.1.9}
frame.time_delta in {10 .. 10.5}

内置函数

upper(string-field) # - 将字符串字段转换为大写
lower(string-field) # - 将字符串字段转换为小写
len(field) # - 返回字符串或字节字段的字节长度
count(field) # - 返回数量帧中出现的
string string(field)# - 将非字符串字段转换为字符串

upper() 和 lower() 可用于执行不区分大小写的字符串比较。

upper(ncp.nds_stream_name) contains "MACRO"
lower(mount.dump.hostname) == "angel"
string(frame.number) matches "[13579]$"

使用示例

image-20220825110320264

通过协议查找

tcp.flags.ack == 1
tcp.flags.cwr

arp
tcp.flags.syn == 1

通过ip查找

# 不区分源或者目标地址,只要包含该ip
ip.addr == x.x.x.x

# 指定源地址
ip.src_host==192.168.1.1

# 指定源地址和目标地址
ip.src_host==192.168.1.1 or ip.dst_host==192.168.1.1

通过端口

tcp.port in {80, 443, 8080}
tcp.port == 80 or tcp.port == 443 or tcp.port == 8080

网卡

以太网地址和字节数组由十六进制数字表示。十六进制数字可以用冒号、句点或连字符分隔:

eth.dst eq ff:ff:ff:ff:ff:ff
aim.data == 0.1.0.d
fddi.src == aa-aa-aa-aa-aa-aa
echo.data == 7a

HTTP

# 请求的method是POST的
http.request.method == "POST"
browser.comment == "An embedded \" double-quote"
http.request.method == "\x48EAD" # 16进制查找
http.request.method == "\110EAD" # 8进制查找
http.request.method in {"HEAD", "GET"}
http.request.method == "GET"
http.request.method == 47.45.54

斜杠写法

在“smb.path”中查找 \\SERVER\SHARE

smb.path contains "\\\\SERVER\\SHARE"      # 与py相同,采用多个\
smb.path contains r"\\SERVER\SHARE" # 类似py的 raw strings 大法

切片写法

匹配 content_type 的前4位内容为 "text"

http.content_type[0:4] == "text"    # 与py的切片非常相似

IPV4 地址

IPv4 地址可以用与数字相同的逻辑关系进行比较:eq、ne、gt、ge、lt 和 le。IPv4 地址按主机顺序存储,因此在显示过滤器中使用 IPv4 地址时不必担心它的字节顺序。

ip.src == 192.168.1.1 
ip.dst eq www.mit.edu
# 斜线后面的数字表示用于表示网络的位数
ip.addr == 129.111.0.0/16

功能介绍

  • 混杂模式和普通模式

文献