💡 Inspiration
Wi-Fi security is something billions of people rely on every single day — yet almost nobody understands what actually happens when their device connects to a network. I kept hearing about WPA2 being "secure" without any accessible explanation of why or how. Then I discovered KRACK — a vulnerability that silently broke the encryption of every WPA2 device on the planet for over a decade before anyone noticed. That gap between widespread trust and actual understanding is what inspired KRACKLens. I wanted to build something that doesn't just tell people Wi-Fi security can fail — it shows them, step by step, packet by packet, key by key — right inside a browser, with no setup required.
🔍 What It Does
KRACKLens is a containerized WPA2 security analysis platform with a fully interactive web dashboard that makes Wi-Fi cryptography visible, inspectable, and understandable to anyone.
1. Simulates a Real WPA2 Network
Two Docker containers — one acting as an Access Point running hostapd and one acting as a
client running wpa_supplicant — perform a genuine WPA2 4-way handshake over Linux virtual
radio interfaces. These are real cryptographic protocols running on real software, not a
simulation of a simulation.
2. Analyzes the Handshake Cryptographically A custom Python analyzer derives the complete WPA2 key hierarchy from scratch — PMK, PTK, KCK, KEK, and Temporal Key — using only the password and captured nonces, then mathematically verifies all three Message Integrity Codes.
3. Demonstrates the KRACK Attack Using Mathy Vanhoef's original proof-of-concept scripts, KRACKLens replays MSG3 of the 4-way handshake repeatedly. On a vulnerable system this resets the encryption nonce to zero, breaking AES-CCMP entirely. On a patched system it shows exactly why the 2017 fix works and what it protects against.
4. Interactive Web Dashboard The centerpiece of KRACKLens is a browser-based security dashboard that brings everything to life visually:
- Live animated 4-way handshake diagram showing each EAPOL message flowing between AP and client in real time
- Built-in pcap analyzer where users drop their own capture file and watch the dashboard independently derive every cryptographic key from scratch
- MIC verification cards showing MSG2, MSG3, and MSG4 validity
- Full EAPOL frame table with timestamps, Key Information bitmasks, and nonce previews
- KRACK attack visualizer that animates the MSG3 replay sequence and nonce reset
- Terminal-style output window showing the full key derivation process step by step — running entirely in the browser using the Web Crypto API, no backend required
🛠️ How I Built It
Infrastructure
I started with the mac80211_hwsim Linux kernel module to create virtual 802.11 radio
interfaces — wlan0, wlan1, and wlan2 — on a single Ubuntu 22.04 VM, giving me real
wireless interfaces without needing physical hardware.
Containerization
Rather than running everything directly on the host — which caused interface conflicts,
NetworkManager interference, and state pollution between test runs — I moved the AP and
client into separate Docker containers using host networking mode and NET_ADMIN
capabilities, achieving full process isolation and clean teardown with a single
docker-compose down.
Packet Capture
tcpdump running on the hwsim0 monitor interface captured all four EAPOL frames into a
pcap file readable by Wireshark, providing ground truth for all subsequent analysis.
Cryptographic Verification I wrote a custom Python analyzer that parses the pcap, extracts MAC addresses and nonces, runs PBKDF2-SHA1 to derive the PMK, PRF-512 to derive the PTK, slices it into KCK, KEK, and TK, then recomputes the HMAC-SHA1 MIC for each handshake message and compares it against the captured value.
KRACK Demonstration
I deployed Mathy Vanhoef's original krackattacks-scripts, configured wlan2 as the
attacker AP, and orchestrated the four-terminal attack setup with careful startup ordering
to ensure clean captures.
Web Dashboard I built a single-file interactive dashboard in HTML, CSS, and vanilla JavaScript that ports the entire cryptographic analysis pipeline to the browser using the Web Crypto API — PBKDF2-SHA1 for PMK derivation, HMAC-SHA1 for MIC verification, and a custom PRF-512 implementation for PTK derivation. The dashboard parses real pcap files dropped by the user, animates the 4-way handshake and KRACK attack sequences, renders live terminal output, and displays MIC verification results — all without any backend, server, or installation.
⚡ Challenges I Ran Into
Kernel-Level Interface Conflicts
Running mac80211_hwsim directly on the host caused NetworkManager to manage the virtual
radios, leading to address conflicts and inconsistent state between test runs. The solution
was Docker containers with host networking, which took significant iteration to get right.
Startup Ordering
The client container would attempt to connect before hostapd had fully initialized,
causing silent failures. I solved this with an 8-second startup delay and the depends_on
directive in docker-compose.
KRACK Capture Isolation
Running tcpdump on hwsim0 picked up traffic from all virtual radios simultaneously,
making it impossible to cleanly isolate KRACK replay frames. I solved this by capturing
directly on wlan2 instead.
MIC Verification Both the Python analyzer and the browser dashboard required careful attention to the WPA2 specification — specifically that MIC verification requires zeroing the MIC field in the frame before computing the HMAC. This caused incorrect results until I got it exactly right in both implementations.
Porting Cryptography to the Browser The Web Crypto API does not natively support HMAC-SHA1 in the exact configuration WPA2 requires for PTK derivation via PRF-512. I had to implement the PRF-512 pseudorandom function manually in JavaScript, chaining HMAC-SHA1 calls with carefully structured label and data inputs matching the IEEE 802.11i specification byte for byte.
Pcap Parsing in Pure JavaScript
Writing a custom binary parser from scratch — reading the global pcap header, iterating
packet records, walking Ethernet and LLC headers to find the EAPOL layer, and extracting
802.11 radiotap MAC addresses — all from a raw ArrayBuffer with no library dependencies,
was one of the most technically demanding parts of the project.
🏆 Accomplishments That I'm Proud Of
A Fully Browser-Native WPA2 Cryptographic Analyzer The dashboard parses a real pcap file, extracts EAPOL frames, derives the complete key hierarchy — PMK, PTK, KCK, KEK, TK — and verifies all three MICs entirely in the browser using the Web Crypto API. No server. No backend. No installation. Anyone with a capture file and a browser can run it.
Complete Cryptographic Verification from First Principles
The Python analyzer independently derives every key in the WPA2 hierarchy and verifies all
three MICs without relying on any external cryptographic tooling beyond standard Python
libraries. Seeing MSG2, MSG3, and MSG4 all return VALID on the first clean run was a
genuinely satisfying moment.
A Fully Reproducible Lab Environment
The entire setup — AP container, client container, packet capture, and KRACK demo — spins
up from a single docker-compose command and tears down completely cleanly. Anyone can
reproduce every result on any Ubuntu 22.04 machine with Docker installed.
Wireshark-Verified Packet Captures Having real EAPOL frames in a pcap file that Wireshark decodes correctly — with all four handshake messages, correct Key Information bitmasks, and visible MIC fields — bridges the gap between theory and observable reality in a way that pure simulation never could.
Successful KRACK Replay Demonstration
Getting MSG3 to replay six times cleanly, with the client responding to each replay, and
seeing the patched wpa_supplicant correctly reject PTK reinstallation, proved the entire
attack infrastructure worked end to end at the protocol level.
A Polished, Accessible Dashboard The animated handshake visualizer, terminal-style crypto output, MIC verification cards, and EAPOL frame table turn what would otherwise be an intimidating command-line lab into something a security student with no Linux experience can open in a browser and immediately understand.
📚 What I Learned
WPA2 Cryptography Is Elegant but Implementation-Dependent The underlying mathematics — PBKDF2, PRF-512, HMAC-SHA1, AES-CCMP — are sound. KRACK didn't break any cipher. It broke an assumption in the protocol state machine: that MSG3 would only ever be processed once. That distinction between cryptographic soundness and implementation correctness is one of the most important lessons in applied security.
Nonce Reuse Is Catastrophic in Counter-Mode Ciphers AES-CCMP in CTR mode generates a keystream from the key and nonce. If the same nonce is used twice, the same keystream is generated twice. XORing two ciphertexts encrypted with identical keystreams gives you the XOR of the plaintexts — and from there, full plaintext recovery is straightforward. KRACK made that theoretical danger real and measurable.
Containerization Is Transformative for Security Research The difference between running this lab directly on the host versus inside Docker containers was not just convenience — it was the difference between unreproducible chaos and a clean, shareable, version-controlled experiment.
The Web Crypto API Is Powerful but Specification-Strict Implementing WPA2 key derivation in the browser taught me that cryptographic APIs are deliberately low-level. Every byte of label string, every concatenation order, every HMAC input structure has to match the IEEE 802.11i specification exactly — one wrong byte and every key in the chain is silently wrong.
Patch Management Has Real Cryptographic Consequences
Devices running wpa_supplicant v2.3 or older remain vulnerable today. The 2017 patches
were not optional security hygiene — they were the difference between functional encryption
and none at all.
🚀 What's Next for KRACKLens
Vulnerable Client Mode
I plan to package an older wpa_supplicant binary inside a dedicated vulnerable-client
container so users can observe the actual PTK reinstallation and nonce reset — making the
danger of running unpatched software tangible, observable, and measurable in the dashboard.
Live Dashboard Integration with the Lab The next step is connecting the dashboard and the Docker lab via a lightweight WebSocket server so the dashboard updates in real time as the lab runs — showing each EAPOL frame appear the moment it is captured and lighting up MIC cards as they are verified.
WPA3 Comparison Module Adding a parallel SAE (Simultaneous Authentication of Equals) handshake demonstration would let users directly compare WPA2 and WPA3 side by side, showing exactly how WPA3 eliminates the reinstallation attack surface that KRACK exploits.
Expanded CVE Coverage KRACK is one of several protocol-level Wi-Fi vulnerabilities. Future versions of KRACKLens could demonstrate PMKID attacks, PMKSA caching vulnerabilities, and beacon frame injection to build a comprehensive Wi-Fi security education platform.
CTF Integration Packaging KRACKLens as a Capture The Flag challenge — where participants must analyze a provided pcap, derive the keys, and extract a hidden flag from encrypted traffic — would make it a practical training tool for security competitions and university courses.


Log in or sign up for Devpost to join the conversation.