A framework that exploits CVE-2019-18370/18371 to turn a $15 Xiaomi Mi Router 4C into a headless Wi-Fi penetration testing implant — silently flashing a custom OpenWrt firmware and exposing monitor mode, packet injection, and RF control through a Go-based host controller.
#Go
#OpenWrt
#Firmware
#Wi-Fi
#Penetration Testing
#Networking
Overview
Pwn4C is a full-stack offensive framework that weaponizes a stock Xiaomi Mi Router 4C — a $15 consumer router — into a silent, headless Wi-Fi penetration testing drone. The project exploits two authenticated RCE vulnerabilities in the router’s stock firmware (CVE-2019-18370 and CVE-2019-18371) to silently overwrite the entire operating system over LAN with a stripped-down custom OpenWrt build, then exposes a rich attack surface through a Go-based host controller.
Once flashed, the router becomes a remotely managed implant that requires no physical interaction, no serial cable, and no JTAG — just a network connection to the host controller.
How It Works
The exploitation chain is entirely air-gapped from the target network:
- Firmware Exploitation: CVE-2019-18370 (path traversal in the backup restore endpoint) and CVE-2019-18371 (command injection in the network diagnostics interface) are chained to gain unauthenticated RCE on the stock Xiaomi firmware.
- Silent Flashing: A custom OpenWrt image is transferred and flashed directly over LAN without triggering the router’s integrity checks — no factory reset, no telltale reboots visible to the upstream network.
- Drone OS: The custom firmware strips the standard OpenWrt stack down to bare essentials and exposes a lightweight TCP daemon (
pwn4c-daemon) that handles all RF operations and telemetry reporting.
- Go Host Controller: A cross-platform CLI (
pwn4c) communicates with the daemon over the LAN, translating high-level attack commands into low-level iw, iwconfig, and tc operations on the drone’s radio.
Capabilities
- Monitor Mode: Puts the radio into full 802.11 monitor mode with optional BPF channel filtering and live PCAP streaming to the host
- Packet Injection: Sends crafted 802.11 frames directly — deauth floods, probe floods, and custom frame injection
- Channel Hopping: Autonomous drone-side hopping across specified channels for passive RF surveillance
- AP Survey: Scans nearby access points including hidden SSIDs (reported with length) across all channels
- Station Mode: Joins the drone to any upstream Wi-Fi network — including hidden SSIDs — and NATs its LAN behind the uplink, enabling internet-connected covert deployments
- RF Tuning: Adjusts TX power, randomizes or spoofs MAC addresses, and restores normal mode on demand
- OTA Firmware Update: Pushes new firmware images to the drone with SHA-256 integrity verification and waits for the reboot cycle
- Live Telemetry: Queries drop counters, radio state, TX/RX stats, and link quality in real time
CLI Reference
The host controller exposes a clean command surface:
pwn4c flash — Exploit stock firmware and flash Pwn4C OS (air-gapped)
pwn4c scan — Discover active Pwn4C drones on the subnet via UDP broadcast
pwn4c status — Query live telemetry, drop counters, and radio state
pwn4c monitor — Start 802.11 monitor mode with optional BPF/channel hopper
pwn4c hop — Start autonomous channel hopping on the drone radio
pwn4c rf — Adjust TX power, spoof or randomize MAC, restore normal mode
pwn4c survey — Survey nearby APs (hidden SSIDs shown with their length)
pwn4c connect — Join upstream Wi-Fi and NAT the drone LAN behind the link
pwn4c status — Show current upstream station link info
pwn4c deauth — Leave upstream network and return radio to idle
pwn4c update — OTA firmware update with SHA-256 verification
pwn4c reboot — Reboot the drone and wait for re-announcement
pwn4c shell — Interactive single-session menu for all of the above
Technical Stack
- Host Controller: Go — single binary, no runtime dependencies, cross-platform
- Drone OS: Custom OpenWrt — stripped to ~8MB, no LuCI, no unnecessary services
- Daemon: C — lightweight TCP server running directly on the MIPS SoC
- Radio Driver: Modified
ath9k / cfg80211 stack with custom injection patches
- Build System: GitHub Actions CI with automated firmware builds, CLI binary releases, and integration tests