Linux: set wlan interface on monitor mode at startup
(Wi-Fi hacking on Raspbian)
I have had a lot of Raspberry products in these years: Pi 1B, Zero, Zero W, Zero WH, 4B (4GB).
[TLDR? Jump to post core]
I always used Raspbian, primarily for its automated installation procedure with NOOBS (see under “Advanced usage”).
A frequent, basic requirement to play with a lot of hacking software (Reaver/Bully, PixieWPS, Aircrack, Wifite2… etc) is to have a Wi-Fi USB adapter/dongle capable to be put in monitor mode. Better than this, to have one in monitor mode directly after plugging in or startup (linked to Kismet, for example).
And yesterday, I finally found a solution; it works, and does it so well (it’s so general) that now, after startup, I can have two or more wlan interfaces already ready! 😃
In my case, the two adapters are an old TP-Link WN7200ND (very good for 2.4GHz, installed and used without problems), and a new Alfa Awus03-6ach (long-range 2.4/5GHz, that required a bit of work to make && make install the relative drivers).
If wlan0 is integrated Broadcom interface of Pi 4, then:
$ sudo -s# nano /etc/network/interfaces
...some stuff already there...
allow-hotplug wlan1
iface wlan1 inet manual
pre-up iw dev wlan1 set type monitor
pre-up ip link set wlan1 name wlan1mon
pre-up iw wlan1mon set txpower fixed 3000
pre-up ip link set wlan1mon up
And repeat for wlan2, wlan3… etc, if you want.
Note that:
- I chose to rename wlan1 to wlan1mon not only for clarity, but also because the addition of wlan1mon interface to relative physical device, and the following removal of original wlan1, as seen in other tutorials:
pre-up iw phy phy1 interface add wlan1mon type monitor
pre-up iw dev wlan1 del
…is not supported from my Alfa adapter, bringing to boot problems when it’s inserted;
- before changing interfaces file, I put down interface with:
and tested each pre-up command in a root terminal (omitting “pre-up”), to verify compatibility;
- I’m not sure what happens if first pre-up command fails; apparently nothing, but, if your adapter configuration may vary, ensure about interface mode with:
or airmon-ng, or similar;
- wlan interfaces seems to be randomly assigned; I removed all “auto” directive in interfaces file, getting always wlan0 on Pi 4 integrated Wi-Fi and wlan1mon/wlan2mon sometimes on TP-Link/Alfa, sometimes on vice versa; assigning from udev could guarantee a better result, maybe.
Hth && by(t)e! 😉
Output by Album at 18:48:42 | 13:15:15