在Raspbian上通过USB启用RTL8188CUS的监控模式

Mat*_*t M 10 linux linux-kernel wifi wificonfiguration raspbian

我正在尝试使用覆盆子pi型号b +(或任何覆盆子pi)上的RTL8188CUS芯片组启用USB wifi加密狗的监控模式.

$ lsusb
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; Invalid argument.
Run Code Online (Sandbox Code Playgroud)

根据github / raspberrypi / linux/issues/369,您需要启用内核分发包含但未编译的rtlwifi/rtl8192cu内核模块.这需要对一些文件进行微小修改,如下面"STEP 2"中所述.

该线程中提到的USB问题已从4.1.6+开始解决,因此rtlwifi驱动程序应该可以工作.

在新鲜的覆盆子pi(模型B +)上重新创建的步骤......

第0步:将现有模块和内核更新到最新版本

$ sudo apt-get update
$ sudo rpi-update
$ uname -a
Linux raspberrypi 4.1.7+ #815 PREEMPT Thu Sep 17 17:59:24 BST 2015 armv6l GNU/Linux
Run Code Online (Sandbox Code Playgroud)

第1步:获取raspbian内核源代码并添加缺少的依赖项

$ git clone --depth=1 https://github.com/raspberrypi/linux
$ sudo apt-get install bc lshw
Run Code Online (Sandbox Code Playgroud)

第2步:为RTL8188CUS(RTL8192)启用rtlwifi(内核)驱动程序

edit linux/drivers/net/wireless/Kconfig
-#source "drivers/net/wireless/rtlwifi/Kconfig"
-source "drivers/net/wireless/rtl8192cu/Kconfig"
+source "drivers/net/wireless/rtlwifi/Kconfig"
+#source "drivers/net/wireless/rtl8192cu/Kconfig"

(Wheezy) edit linux/drivers/net/wireless/Makefile
-#obj-$(CONFIG_RTLWIFI)         += rtlwifi/
+obj-$(CONFIG_RTLWIFI)          += rtlwifi/

(Jessie) edit linux/drivers/net/wireless/realtek/Makefile
-#obj-$(CONFIG_RTLWIFI)         += rtlwifi/
+obj-$(CONFIG_RTLWIFI)          += rtlwifi/
Run Code Online (Sandbox Code Playgroud)

第3步:编译并安装内核(耗时数小时)

内核构建文档中总结.

$ cd linux
$ KERNEL=kernel
$ make bcmrpi_defconfig

$ make zImage modules dtbs
$ sudo make modules_install
$ sudo cp arch/arm/boot/dts/*.dtb /boot/
$ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
$ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
$ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img
Run Code Online (Sandbox Code Playgroud)

第4步:重新启动

$ sudo reboot
Run Code Online (Sandbox Code Playgroud)

步骤5:检查是否已加载rtlwifi/rtl8192cu模块

$ lsmod | fgrep rtl8192cu
rtl8192cu             100806  0 
rtl_usb                14781  1 rtl8192cu
rtl8192c_common        72091  1 rtl8192cu
rtlwifi               101122  3 rtl_usb,rtl8192c_common,rtl8192cu
mac80211              623281  3 rtl_usb,rtlwifi,rtl8192cu
$
$ lshw
  *-network:0
       description: Ethernet interface
       physical id: 1
       bus info: usb@1:1.3
       logical name: wlan0
       serial: 00:0b:81:94:e9:a3
       capabilities: ethernet physical
       configuration: broadcast=yes driver=rtl8192cu driverversion=4.1.7+ firmware=N/A link=no multicast=yes
Run Code Online (Sandbox Code Playgroud)

第6步:尝试激活监控模式

$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; Operation not supported.
Run Code Online (Sandbox Code Playgroud)

我错过了什么?
问题369似乎表明它可以与rtlwifi驱动程序一起使用?

Mat*_*t M 10

原来重新编译和加载rtlwifi模块的步骤是正确的.问题是iwconfig在这种情况下无法启用/确定监控模式.

相反,我使用了Steven Gordon概述的iw - 在监控模式下使用iw捕获WiFi并且它工作正常.

总结一下:

步骤6b:列出可用的物理网络接口

$ iw dev
Run Code Online (Sandbox Code Playgroud)

步骤7:确定物理接口是否支持监控模式

$ iw phy phy0 info
... lots of stuff ...
Supported interface modes:
     * IBSS
     * managed
     * AP
     * AP/VLAN
     * monitor
     * mesh point
     * P2P-client
     * P2P-GO
... lots more stuff ...
Run Code Online (Sandbox Code Playgroud)

步骤8:为该物理卡添加监控接口

您需要为您拥有的硬件明确添加"监控"界面.

$ sudo iw phy phy0 interface add mon0 type monitor
Run Code Online (Sandbox Code Playgroud)

第8步:开始监控

在我的情况下,我使用tshark来促进监控,显示一些有用的字段而不是很多噪音.

$ sudo apt-get install tshark
$ sudo tshark -i mon0 -f 'broadcast' -T fields -e frame.time_epoch -e wlan.sa -e radiotap.dbm_antsignal -e wlan.fc.type -e wlan.fc.subtype
Run Code Online (Sandbox Code Playgroud)

完成.