- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2023-04-26T14:03:04+09:00","default:honma","honma")
#author("2023-04-26T14:59:30+09:00","default:honma","honma")
* WiFiパケットの取得 [#r3cf1b8b]
ちょっと、お仕事でWiFiパケットを取得する必要が出たので環境構築。~
ちょっと、おうちでWiFiパケットを取得する必要が出たので環境構築。~
必要なのはWiFiのUSBドングルとLinuxの仮想マシンだけ。
今回、使用したWiFiドングルは[[TOKAIZ:https://www.tokaiz.jp/product/twa-001/]]の[[TWA-001:https://amzn.to/3NeFcUJ]]というWiFiドングルで、11ACをサポートしている。~
[[Amazon:https://amzn.to/3NeFcUJ]]などから1000円ちょっとで購入できる。
[[Amazon:https://amzn.to/3NeFcUJ]]や[[楽天市場:https://a.r10.to/hPiDdI]]などから1000円ちょっとで、技適対応のものが購入できるのも魅力的。
ちなみに、技適の番号(210-138110)から中身はCOMFASTのCF-811ACらしいのだが...
** ドライバの導入 [#nf6177e1]
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:https://www.realtek.com/ja/products/communications-network-ics/category/802-11ac-abgn]]で確認してみる...~
#style(addstyle=float:left;margin:0px;){{
|デバイス名|規格|備考|
|RTL8811AU |802.11ac |1x1|
|RTL8811CU |802.11ac |1x1, Wave-2 compatible with MU-MIMO|
|RTL8812AU |802.11ac |2x2|
|RTL8812BU |802.11ac |2x2, Wave-2 compatible with MU-MIMO|
|RTL8814AU |802.11ac |4x4, 3 spatial streams MIMO|
}}
#style(style=clear:both;,end)
433Mbps対応なので RTL8811AU か RTL8811CU になるけど、RTL8811CU は Host interface の記述が「USB2.0 for WLAN and BT controller」~
CF-811ACがベースで、RTL8811CU だとサイトもあるけどホント?
今回は、[[8821cu-20210916:https://github.com/morrownr/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
*** 環境のアップデート [#l995e455]
$ sudo apt update && sudo apt upgrade
*** 必要なツール群の導入 [#r69d2c63]
$ sudo apt install -y linux-headers-$(uname -r) build-essential bc dkms git libelf-dev rfkill iw
*** ソースコードの導入 [#g20f86ad]
$ mkdir -p ~/src
$ cd ~/src
$ git clone https://github.com/morrownr/8821cu-20210916.git
$ cd ~/src/8821cu-20210916
*** ビルド [#iaf21596]
$ sudo ./install-driver.sh
*** 導入ドライバの確認 [#v1761141]
$ 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
と、ここまでは悩むことなく進みました。
*** モニターモードの設定 [#w4d46335]
WiFiパケットを取得するために設定をモニターモードに変更します。~
iwコマンドの設定をまとめたスクリプトが提供されているので導入します。
$ cd ~/src
$ git clone https://github.com/morrownr/Monitor_Mode.git
$ cd ~/src/Monitor_Mode
$ sudo ./start-mon.sh wlx<MACアドレス>
幾つかの問いに答えてモニターモードとして動作させる。~
** WireShark の導入 [#v2f44266]
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
~
~
#htmlinsert(amazon_pc.html);