WiFiパケットの取得

ちょっと、おうちでWiFiパケットを取得する必要が出たので環境構築。
必要なのはWiFiのUSBドングルとLinuxの仮想マシンだけ。

今回、使用したWiFiドングルはTOKAIZTWA-001というWiFiドングルで、11ACをサポートしている。
Amazon楽天市場などから1000円ちょっとで、技適対応のものが購入できるのも魅力的。

ちなみに、技適の番号(210-138110)から中身はCOMFASTのCF-811ACらしいのだが...

ドライバの導入

lsusbで見ると

$ lsusb
Bus 002 Device 002: ID 0bda:c811 Realtek Semiconductor Corp. 802.11ac NIC
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 001 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 001 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

こんな感じ。

Realtekで確認してみる...

デバイス名規格備考
RTL8811AU802.11ac1x1
RTL8811CU802.11ac1x1, Wave-2 compatible with MU-MIMO
RTL8812AU802.11ac2x2
RTL8812BU802.11ac2x2, Wave-2 compatible with MU-MIMO
RTL8814AU802.11ac4x4, 3 spatial streams MIMO

433Mbps対応なので RTL8811AU か RTL8811CU になるけど、RTL8811CU は Host interface の記述が「USB2.0 for WLAN and BT controller」
CF-811ACがベースで、RTL8811CU だとサイトもあるけどホント?

今回は、8821cu-20210916を利用して作業着手。

ちなみに、Linuxの仮想マシンはDebian環境。

$ uname -a
Linux debian 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux

環境のアップデート

$ sudo apt update && sudo apt upgrade

必要なツール群の導入

$ sudo apt install -y linux-headers-$(uname -r) build-essential bc dkms git libelf-dev rfkill iw

ソースコードの導入

$ mkdir -p ~/src
$ cd ~/src

$ git clone https://github.com/morrownr/8821cu-20210916.git

$ cd ~/src/8821cu-20210916

ビルド

$ sudo ./install-driver.sh

導入ドライバの確認

$ ls /sys/class/net/
ens33  lo  wlx<MACアドレス>

$ ls /sys/class/net/wlx<MACアドレス>/device/driver/module/drivers/
usb:rtl8821cu

$ lsmod | grep 8821
8821cu               2678784  0
cfg80211              983040  1 8821cu
usbcore               331776  6 ehci_pci,usbhid,8821cu,ehci_hcd,btusb,uhci_hcd

と、ここまでは悩むことなく進みました。

モニターモードの設定

WiFiパケットを取得するために設定をモニターモードに変更します。
iwコマンドの設定をまとめたスクリプトが提供されているので導入します。

$ cd ~/src

$ git clone https://github.com/morrownr/Monitor_Mode.git

$ cd ~/src/Monitor_Mode

$ sudo ./start-mon.sh wlx<MACアドレス>

幾つかの問いに答えてモニターモードとして動作させる。

WireShark の導入

WireShark の導入も実にシンプル。

$ sudo apt install wireshark

だけ

Dumpcap can be installed in a way that allows members of the "wireshark" system group to capture packets. This is recommended over the alternative of
running Wireshark/Tshark directly as root, because less of the code will run with elevated privileges.

For more detailed information please see /usr/share/doc/wireshark-common/README.Debian.gz once the package is installed.

Enabling this feature may be a security risk, so it is disabled by default. If in doubt, it is suggested to leave it disabled.

Should non-superusers be able to capture packets?

という質問があるが、「非スーパーユーザーがパケットをキャプチャできるようにする必要があるのか?」ということなので自身の環境に合わせて答える。

実際には「はい」を選択しても、dumpcap のアクセス権の問題で起動しない。

$ ls -l /usr/bin/dumpcap
-rwxr-xr-- 1 root wireshark 117248 12月  9  2021 /usr/bin/dumpcap

今回は、下記のようにアクセス権を付与

$ sudo chmod +x /usr/bin/dumpcap

$ ls -l /usr/bin/dumpcap
-rwxr-xr-x 1 root wireshark 117248 12月  9  2021 /usr/bin/dumpcap

仕事で使うならアクセス権の付与は要考慮かなぁ
ちなみに、下記のようにすれば再設定が可能。

$ sudo dpkg-reconfigure wireshark-common




トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-04-26 (水) 14:59:30