wireshark是一个抓包小能手,排查网络问题的时候常常离不开,网上的使用教程也有很多,但多数是抓的有线数据包,本文主要介绍使用wireshark抓空口包的方法和常用命令。
-----再牛逼的梦想,也抵不住傻逼般的坚持! --2024-06-24 16:10
前言:
什么是空口包? 这里大家可以思考下:笔记本电脑通过网线连接路由器和通过wifi连接路由器访问百度,淘宝等有什么区别?
个人理解:是传播介质不同,一个通过网线,另外一种是通过空气。
那么,网线传输,我们可以通过网线分流去抓包,空气抓包要如何做呢?这里就是我这篇博客的目的了,通过空气作为介质传播的包通常就叫做空口包,我们需要使用wifi usb 抓包网卡,或者笔记本自身的wifi网卡,使其处于监听模式,时刻监听空气中的包,以此来完成抓空口包的目的。
一. wireshark抓空口报文
wireshark抓取有线报文的方式,这里就不再做记录了,有疑问的同学可以留言或者私信。这里主要纪律下抓空口包的两种方式。
wireshark抓取空口报文方式有两种:
- 电脑外接一个usb wifi网卡,安装这个网卡的特定驱动(用于抓包),之后打开wireshark进行抓包。
- 电脑切换到ubuntu系统,将电脑自身的wifi网卡切换到监听模式,然后打开wireshark进行抓包。
linux下切换网卡至监听(monitor)模式的命令如下:
sudo airmon-ng wlan0 start;
sudo wireshark
如上两种各有优缺点,最大的区别在于,wifi6即80211ax目前只能在linux系统下进行抓包,即使用方式2。
二. 常见过滤wifi空口包命令
空口报文与有线抓包的报文有些区别,如有线抓包我们通常只需要分析网络,传输,应用层的协议即可,如:arp, icmp, tcp, udp, http, https等等,但空口包,我们往往还需要分析很多链路层的报文。
wifi链路层报文过滤命令如下
Management frame
wlan.fc.type == 0Control frame
wlan.fc.type == 1Data frame
wlan.fc.type == 2Association request
wlan.fc.type_subtype == 0x00Association response
wlan.fc.type_subtype == 0x01Reassociation request
wlan.fc.type_subtype == 0x02Reassociation response
wlan.fc.type_subtype == 0x03Probe request
wlan.fc.type_subtype == 0x04Probe response
wlan.fc.type_subtype == 0x05Beacon
wlan.fc.type_subtype == 0x08Disassociate
wlan.fc.type_subtype == 0x0AAuthentication
wlan.fc.type_subtype == 0x0BDeauthentication
wlan.fc.type_subtype == 0x0CAction frame
wlan.fc.type_subtype == 0x0DBlock ACK requests
wlan.fc.type_subtype == 0x18Block ACK
wlan.fc.type_subtype == 0x19Power save poll
wlan.fc.type_subtype == 0x1ARequest to send
wlan.fc.type_subtype == 0x1BClear to send
wlan.fc.type_subtype == 0x1CACK
wlan.fc.type_subtype == 0x1DContention free period end
wlan.fc.type_subtype == 0x1ENULL data
wlan.fc.type_subtype == 0x24QoS data
wlan.fc.type_subtype == 0x28Null QoS data
wlan.fc.type_subtype == 0x2C