>
CyberShellsServicesPricingBlogBook a scoping call →
◆ OSWP · Module 03

Linux Wireless Tools

Everything under the surface of your Wi-Fi card: how Linux loads its driver, the one command that rules them all, and the stack that makes monitor mode possible.

Where this falls

Why a pentester learns the plumbing

Most of the time you drive a wireless card through a friendly tool and never think about what sits beneath it. Then comes the engagement that breaks that comfort: a remote wireless test, where a sysadmin has plugged a card into a box on-site and handed you nothing but SSH.

PICTURE IT

Normally you drive an automatic car and never open the hood. A remote wireless test is being dropped into an unfamiliar car, in the dark, over the phone. If the engine won't start you can't call roadside assistance. You have to know where the battery, the fuses and the starter are yourself. These tools are the fuse box.

You don't get to choose the hardware. The card might be one you've never touched, the driver might misbehave, and your only way to diagnose and fix it is the command-line toolkit in this module. Three things to walk away able to do:

  1. Identify any card's chipset and driver from scratch.
  2. Load, unload and reload drivers when they fight or hang.
  3. Put a card into monitor mode by hand with iw, no helper scripts.
OSWP framing Tools like airmon-ng are just wrappers over the commands here. When the wrapper fails on strange hardware, this is what you fall back to. Knowing the layer underneath is the difference between "the card doesn't work" and "the card works now."

01 · Identify & load

Loading and unloading drivers

When you plug a card in, Linux usually loads the right driver automatically. Your first job is to find out which driver and which chipset you're dealing with.

Step 1 — what driver claimed my card?

identify.sh · airmon-ng
$ sudo airmon-ng

PHY     Interface   Driver        Chipset
phy0    wlan0       ath9k_htc     Qualcomm Atheros AR9271 802.11n

Driver = ath9k_htc, chipset = Atheros AR9271. Confirm the raw USB identity with lsusb:

lsusb
$ sudo lsusb
Bus 001 Device 002: ID 0cf3:9271 Qualcomm Atheros AR9271 802.11n
# 0cf3 = vendor id (Qualcomm Atheros), 9271 = product id (AR9271)
WINDOWS vs LINUX

On Windows every device needs its own installed driver. On Linux, one driver can cover 50+ devices that share a chipset. The Alfa AWUS036NHA, the TP-Link WN722N v1, and dozens more all ride on ath9k_htc — and because it ships in the kernel, there's nothing to install.

Step 2 — inspect the driver with modinfo

Most drivers are Loadable Kernel Modules (LKM): loaded only when needed to save memory. modinfo reveals a driver's file path, firmware, dependencies and tunable parameters.

modinfo ath9k_htc · trimmed
$ sudo modinfo ath9k_htc
filename:   /lib/modules/<kernel>/.../ath9k_htc.ko
firmware:   ath9k_htc/htc_9271-1.4.0.fw
depends:    mac80211,ath9k_hw,ath9k_common,ath,cfg80211,usbcore
alias:      usb:v0CF3p9271d*...         # matches vendor/product id
vermagic:   4.16.0-kali2-amd64 SMP
parm:       blink:Enable LED blink on activity (int)
  • filename — where the .ko lives: /lib/modules/<kernel version>.
  • firmware — firmware blobs the driver loads onto the card.
  • alias — the usb:v0CF3p9271 pattern is how the kernel matches card → driver.
  • depends — modules auto-loaded alongside it (the tree in the next section).
  • parm — tunable options you can set at load time.

Step 3 — load with a parameter

modprobe loads a module from the kernel directory and pulls in its dependencies. Here we disable the activity LED (handy when you don't want a blinking card giving you away):

modprobe with param
$ sudo modprobe ath9k_htc blink=0
# no output = success. Errors print to console.
Blacklisting — the driver fight If two drivers claim the same card (classic case: open-source vs closed-source Broadcom), they fight over the hardware and you get chaos. Only one driver may own a device at a time, so you blacklist the loser in /etc/modprobe.d/.

modprobe vs insmod

CommandLoads fromHandles dependencies?Use when
modprobekernel modules diryes, automaticNormal loading
insmoda specific file pathnoTesting a driver you compiled, e.g. insmod rtl8812au.ko

02 · The module tree

The dependency tree

A wireless driver never loads alone. It sits on top of a stack of helper modules, and lsmod shows the whole pile with a "used by" count. To unload cleanly you reverse the tree: dependents first, foundation last.

ath9k_htc the driver ath9k_common ath9k_hw ath mac80211 usbcore cfg80211 rfkill

Figure 1 — Load order flows top → bottom. Unload order is bottom → top.

lsmod · used-by counts
$ lsmod
Module          Size    Used by
ath9k_htc       81920   0
ath9k_common    20480   1 ath9k_htc
ath9k_hw        487424  2 ath9k_htc,ath9k_common
ath             32768   3 ath9k_htc,ath9k_hw,ath9k_common
mac80211        802816  1 ath9k_htc
cfg80211        737280  4 ath9k_htc,mac80211,ath,ath9k_common
# col 3 = how many (and which) modules depend on this one

Unloading in the right order

Try to pull a foundation module while something still needs it and the kernel refuses:

wrong way
$ sudo rmmod ath
rmmod: ERROR: Module ath is in use by: ath9k_htc ath9k_hw ath9k_common

Remove the dependents first, foundation last (left to right = top of tree to bottom):

right way
$ sudo rmmod ath9k_htc ath9k_common ath9k_hw ath
# unsure what's safe to remove next? run lsmod again,
# pick any module with a used-by count of 0

03 · The old guard

Legacy tools: iwconfig & friends

These date from the early 2000s and the old ieee80211 framework. They still work through a compatibility layer, but they're deprecated and limited. Know them so you recognise them in old guides; reach for iw in practice.

The deprecated Wireless Extensions utilities
ToolDoes what
iwconfigBasic params: change mode, set channel, set keys
iwlistStart scans, list frequencies, bit rates, encryption
iwspyPer-node link quality (rarely implemented by drivers)
iwprivDriver-specific Wireless Extensions tweaks
iwlist · channels/frequencies
$ sudo iwlist wlan0 frequency
wlan0  14 channels in total; available frequencies:
       Channel 01 : 2.412 GHz
       Channel 06 : 2.437 GHz
       Channel 11 : 2.462 GHz
       ...
# output varies by geography (regulatory domain)
Rule of thumb If a tutorial tells you to iwconfig wlan0 mode monitor, you're reading an old tutorial. The modern equivalent lives in the next section.

04 · One utility to rule them all

The iw utility

iw is built for the modern mac80211 framework and replaces the entire legacy set. Its syntax looks dense but follows one simple shape: what device → what to do → with what options.

iw list — the card's full capability sheet

Before an engagement, this tells you what the card can and can't do: which modes it supports and which frequencies are legal.

iw list · trimmed
$ sudo iw list
Wiphy phy0
   Supported interface modes:
      * managed          # normal client
      * AP               # act as an access point
      * monitor          # capture raw frames ← what we want
      * mesh point / IBSS / P2P ...
   Frequencies:
      * 2412 MHz [1]  (20.0 dBm)
      * 2462 MHz [11] (20.0 dBm)
      * 2484 MHz [14] (disabled)   # forbidden here
First thing to check on strange hardware Does monitor appear under "Supported interface modes"? No monitor = no capture = that card is useless for most of OSWP. This one command saves you an hour of fighting a card that was never going to work.

Scanning for networks and their channels

The channel a target sits on is critical — you tune your capture to it. Filter the scan to just SSIDs and channels:

iw scan · SSID + channel
$ sudo iw dev wlan0 scan | egrep "DS Parameter set|SSID:"
   SSID: wifu
   DS Parameter set: channel 3
   SSID: 6F36E6
   DS Parameter set: channel 11

05 · The core skill

Monitor mode, step by step

This is the manual version of what airmon-ng start does for you. Four commands: create a virtual monitor interface, bring it up, verify it, and (later) tear it down.

ADD
Create a virtual monitor interfacesudo iw dev wlan0 interface add wlan0mon type monitor
UP
Bring it up (new interfaces start down)sudo ip link set wlan0mon up
INFO
Verify type = monitorsudo iw dev wlan0mon info
TEST
Prove it captures raw 802.11sudo tcpdump -i wlan0mon
DEL
Tear down when finishedsudo iw dev wlan0mon interface del
PICTURE IT

A normal (managed) interface is a phone that only shows calls meant for you. Monitor mode is a police scanner — it picks up every transmission in the air regardless of who it was addressed to. A Virtual Interface (VIF) lets you run that scanner alongside the normal interface on the same physical card.

verify.sh · iw dev info
$ sudo iw dev wlan0mon info
Interface wlan0mon
   addr 0c:0c:ac:ab:a9:08
   type monitor
   channel 11 (2462 MHz), width: 20 MHz
test.sh · tcpdump sees beacons
$ sudo tcpdump -i wlan0mon
listening on wlan0mon, link-type IEEE802_11_RADIO
13:39:17 ... 2412 MHz 11b -20dB signal Beacon (wifu) ESS CH: 3, PRIVACY
# Ctrl+C to stop. A beacon = monitor mode is working.
Teardown gotcha After interface del, running info on it returns No such device (-19). That error is confirmation the VIF is gone, not a failure.

06 · Playing by the rules

Regulatory domains & CRDA

Wireless law differs by country: which channels are legal, how much power you may transmit, whether radar-avoidance (DFS) applies. The Central Regulatory Domain Agent (CRDA) enforces the rules for your location, and iw reg queries or changes them.

iw reg · get and set
$ sudo iw reg get
global
country 00: DFS-UNSET      # Kali's default = world domain

$ sudo iw reg set US        # 2-letter ISO code; no output = success
# in-memory only! persist it in /etc/default/crda → REGDOMAIN=US
PICTURE IT

The regulatory domain is a speed-limit sign the card obeys. Set it to a stricter country and channels vanish; set it to a looser one and more appear — but the card still obeys the most restrictive rule that applies. On a 2.4 GHz card, US unlocks only channels 1–11, while GB would allow 12 and 13.

It can be overridden without you Even after you set US, the domain can be overridden — an AP that advertises a country in its beacons, or a card that advertises its own domain through the driver (the Alfa AWUS036NHA announces GB). The card always resolves to the most restrictive combination, which is why channels 12–13 show as disabled in iw list even when GB would allow them.

07 · The kill switch

rfkill

Sometimes the card is fine but the radio is simply switched off. rfkill enables and disables radios — Wi-Fi, Bluetooth, LTE, GPS, NFC, anything. If a card shows up in lsmod but refuses to transmit, check here first.

Soft block
software, fixable

Set by rfkill itself (or another app). You can clear it with unblock.

Hard block
physical / BIOS

A physical switch or BIOS setting. rfkill cannot clear this — flip the switch.

rfkill.sh
$ sudo rfkill list
0: hci0: Bluetooth     Soft blocked: no   Hard blocked: no
1: phy0: Wireless LAN  Soft blocked: no   Hard blocked: no

$ sudo rfkill block 1       # disable device #1 (Wi-Fi)
$ sudo rfkill unblock 1     # re-enable it
$ sudo rfkill block all     # kill every radio
$ sudo rfkill unblock all   # bring them all back
Troubleshooting reflex Card detected but dead silent? rfkill list. A Soft blocked: yes is a one-command fix. A Hard blocked: yes means go find the physical switch.

08 · Two generations

The two wireless stacks

Linux has had two wireless subsystems. The old one explains why older tools and tutorials look the way they do; the new one is what everything modern is built on.

ieee80211 (wext) vs mac80211
 ieee80211 / wextmac80211
Eraearly Wi-Fi → ~802.11g/nmodern, all current kernels
Toolsiwconfig, iwlist, iwpriviw
Common codeeach driver reimplemented itcentralised in the framework
Interface namesinconsistent (eth, ath, wifi…)wlan* / wlp* / wlx*
WPA / master modeoften unsupportedwpa_supplicant / hostapd
Statusdeprecatedstandard
Why the old stack was painful Under wext, most drivers couldn't do master mode, couldn't change power output, and often couldn't do WPA. Each chipset shipped its own incompatible utility with its own syntax. mac80211 fixed this by standardising the common functions so drivers inherit them for free.

09 · The modern stack

mac80211, cfg80211 & nl80211

mac80211 doesn't work alone — it's part of a small family of libraries that carry a command from your terminal down to the card's radio. Here's the path a request takes.

user tools iw · wpa_supplicant · hostapd · aircrack-ng · wireshark nl80211 (NetLink) cfg80211 (kernel config API for 802.11) mac80211 SoftMAC path FullMAC path (direct) iwlwifi (Intel) SoftMAC driver brcmfmac (Broadcom) FullMAC driver wireless hardware (the radio)

Figure 2 — SoftMAC drivers route through mac80211; FullMAC drivers talk to cfg80211 directly.

nl80211
NetLink library

The messenger. Lets tools (iw, wpa_supplicant, aircrack-ng) talk to drivers via cfg80211.

cfg80211
kernel config API

The 802.11 configuration API. Talks to FullMAC directly, to SoftMAC through mac80211, and enforces CRDA.

mac80211
SoftMAC framework

Implements the wireless functions SoftMAC radios need. Where shared bug fixes and features live.

10 · Where the logic lives

FullMAC vs SoftMAC

The split is about where the Wi-Fi brain sits — in the card's own firmware, or in the Linux driver. It decides how the card behaves and who ships its bug fixes.

Both revolve around the MLME (MAC Sublayer Management Entity), which handles the management operations: authentication, deauthentication, association, disassociation, reassociation, and beaconing.

Who does the MLME work?
 FullMACSoftMAC
MLME runs incard firmware / hardwarethe driver software (mac80211)
Driver sizeminimalcomplex
Typical usephones, low-power / mobilelaptops, USB adapters
Examplebrcmfmac (Broadcom)iwlwifi (Intel)
Power uselowerhigher
Who ships fixesthe vendorthe kernel (everyone at once)
PICTURE IT

FullMAC is a car with a sealed automatic gearbox — efficient, but you depend on the manufacturer to fix anything inside it. SoftMAC is a manual gearbox exposed to the mechanic — more work, but any improvement to the shared toolkit (mac80211) upgrades every car at once. For a pentester, SoftMAC's openness is usually the friendlier ground.

Why it matters to you SoftMAC cards inherit every security fix and new feature the kernel ships — the whole class improves together. FullMAC cards wait on their vendor. When choosing an adapter for wireless testing, a well-supported SoftMAC chipset (like the Atheros used all through this module) is the safe bet.

11 · Keep this open

Command cheat sheet

linux-wireless-quickref.sh
# ---- IDENTIFY ----
$ sudo airmon-ng                 # driver + chipset
$ sudo lsusb                     # vendor:product id
$ sudo modinfo ath9k_htc         # deps, firmware, params
$ lsmod                          # loaded modules + used-by

# ---- LOAD / UNLOAD ----
$ sudo modprobe ath9k_htc        # load (+deps)
$ sudo modprobe ath9k_htc blink=0
$ sudo rmmod ath9k_htc ath9k_common ath9k_hw ath
$ sudo insmod ./rtl8812au.ko     # load from a path

# ---- INSPECT CARD ----
$ sudo iw list                   # modes + frequencies
$ sudo iw dev wlan0 scan | egrep "DS Parameter set|SSID:"

# ---- MONITOR MODE (manual) ----
$ sudo iw dev wlan0 interface add wlan0mon type monitor
$ sudo ip link set wlan0mon up
$ sudo iw dev wlan0mon info
$ sudo tcpdump -i wlan0mon
$ sudo iw dev wlan0mon interface del

# ---- REGULATORY ----
$ sudo iw reg get
$ sudo iw reg set US

# ---- RADIO KILL SWITCH ----
$ sudo rfkill list
$ sudo rfkill unblock 1          # clear soft block
The one-line map Card acting up? → rfkill list (radio off?), iw list (monitor supported?), lsmod (driver loaded?), iw reg get (channels blocked?). Those four answers explain almost every "my card doesn't work" on a remote test.