ubuntu-os-capture-wireless-beacon-frame-by-wireshark

Version

  • Wireshark: 3.6.2
  • iw: 5.16
  • wifi: Realtek Semiconductor Co., Ltd. RTL8852AE 802.11ax PCIe Wireless Network Adapter by lspci

安装wireshark

1
2
3
sudo apt -y install iw ethtool wireshark
sudo dpkg-reconfigure wireshark-common # Yes for non-superusers
sudo usermod -aG wireshark $USER

然后logout或重启系统

Wi-Fi断开连接

这里需要将无线网卡的wifi断开连接, 即不连接任何路由器, 不然切换monitor模式时会自动切回来.

可以将wifi设置所有SSID忘记密码.

设置Wi-Fi为monitor模式

1
2
3
sudo ip link set wlp2s0 down
sudo iwconfig wlp2s0 mode monitor
sudo ip link set wlp2s0 up

设置完之后可通过以下命令查看是否切换成monitor模式

1
2
3
4
/ # iwconfig wlp2s0
wlp2s0 IEEE 802.11 Mode:Monitor Frequency:2.457 GHz Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on

开始抓包

启动Wireshark.

选择wlp2s0网卡.

过滤框输入: wlan.fc.type_subtype==0x08, 表示只看beacon帧.

Wireshark菜单栏 -> View -> Wireless Toolbar选上, 这样才能选择抓不同信道的beacon帧.

如下图所示, 选上后会在过滤框下方多出一栏, 可以选择特定信道.

enable_wireless_toolbar

恢复Wi-Fi

以上抓包完成后, 需要恢复Wi-Fi

1
2
3
sudo ip link set wlp2s0 down
sudo iwconfig wlp2s0 mode managed
sudo ip link set wlp2s0 up

设置完之后可通过以下命令查看是否切换成managed模式

1
2
3
4
5
/ # iwconfig wlp2s0
wlp2s0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on