Politician 1.0.0
WiFi Auditing Library for ESP32
Loading...
Searching...
No Matches
PoliticianTypes.h
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3#include <Arduino.h>
4
5namespace politician {
6
7// ─── Capture Types ────────────────────────────────────────────────────────────
8#define CAP_PMKID 0x01 // PMKID fishing (fake association)
9#define CAP_EAPOL 0x02 // Passive EAPOL (natural client reconnection)
10#define CAP_EAPOL_CSA 0x03 // EAPOL triggered by CSA beacon injection
11
12// ─── Attack Selection Bits ────────────────────────────────────────────────────
13#define ATTACK_PMKID 0x01 // PMKID fishing
14#define ATTACK_CSA 0x02 // CSA beacon injection
15#define ATTACK_PASSIVE 0x04 // Passive EAPOL capture
16#define ATTACK_DEAUTH 0x08 // Classic Reason 7 Deauthentication
17#define ATTACK_STIMULATE 0x10 // Zero-delay QoS Null Client Stimulation
18#define ATTACK_ALL 0x1F
19
20// ─── Capture Filters ──────────────────────────────────────────────────────────
21// NOTE: Logging High-Frequency Intel (like Beacons) via standard SPI (SD.h) will
22// create massive blocking delays (20-50ms per flush) that destroy the hopper's
23// attack loop. If you enable LOG_FILTER_BEACONS or LOG_FILTER_ALL, you MUST
24// use a board wired for SDMMC (4-bit DMA) for non-blocking background writes.
25#define LOG_FILTER_HANDSHAKES 0x01 // EAPOLs, PMKIDs (Crackable info, SPI Safe)
26#define LOG_FILTER_PROBES 0x02 // Probe Requests & Responses (Scouting, SPI Safe)
27#define LOG_FILTER_BEACONS 0x04 // Beacons (Network Mapping, SDMMC ONLY!)
28#define LOG_FILTER_ALL 0xFF // Everything (SDMMC ONLY!)
29
30// ─── Logging Callback ─────────────────────────────────────────────────────────
31typedef void (*LogCb)(const char *msg);
32
33// ─── Callbacks ────────────────────────────────────────────────────────────────
34struct ApRecord;
35struct HandshakeRecord;
37
38typedef void (*ApFoundCb)(const ApRecord &ap);
39typedef void (*PacketCb)(const uint8_t *payload, uint16_t len, int8_t rssi, uint32_t ts_usec);
40typedef void (*EapolCb)(const HandshakeRecord &rec);
41typedef void (*IdentityCb)(const EapIdentityRecord &rec);
42typedef bool (*TargetFilterCb)(const ApRecord &ap);
43
44// ─── Packet Logging Callback ──────────────────────────────────────────────────
45typedef void (*PacketCb)(const uint8_t *payload, uint16_t len, int8_t rssi, uint32_t timestamp_us);
46
47// ─── Error Codes ──────────────────────────────────────────────────────────────
55
56/**
57 * @brief Configuration for the Politician engine.
58 */
59struct Config {
60 uint16_t hop_dwell_ms = 200; // Time per channel
61 uint32_t m1_lock_ms = 800; // How long to stay on channel after seeing M1
62 uint32_t fish_timeout_ms = 2000; // Time for PMKID association
63 uint8_t fish_max_retries = 2; // PMKID retries before giving up or CSA
64 uint32_t csa_wait_ms = 4000; // How long to wait for reconnect after CSA
65 uint8_t csa_beacon_count = 8; // Number of CSA beacons to burst
66 uint8_t deauth_burst_count = 16; // Number of classic Deauth frames to send
67 uint8_t probe_aggr_interval_s = 30; // Seconds to wait between attacking same AP
68 uint32_t session_timeout_ms = 60000; // How long orphaned handshakes live in RAM
69 bool capture_half_handshakes = false; // Save M2-only captures and pivot to active attack
70 bool skip_immune_networks = true; // Ignore Pure WPA3 / PMF Required networks
71 uint8_t csa_deauth_count = 15; // Number of standard deauths to append
72 uint8_t capture_filter = LOG_FILTER_HANDSHAKES | LOG_FILTER_PROBES; // Exclude Beacons by default to save SD storage
73};
74
75// ─── AP Record ────────────────────────────────────────────────────────────────
76struct ApRecord {
77 uint8_t bssid[6];
78 char ssid[33];
79 uint8_t ssid_len;
80 uint8_t channel;
81 int8_t rssi;
82 uint8_t enc; // 0=open, 1=WEP, 2=WPA, 3=WPA2, 4=WPA3
83};
84
85// ─── Frame Stats ──────────────────────────────────────────────────────────────
86struct Stats {
87 uint32_t total;
88 uint32_t mgmt;
89 uint32_t ctrl;
90 uint32_t data;
91 uint32_t eapol;
92 uint32_t pmkid_found;
93 uint32_t beacons;
94 uint32_t captures;
95};
96
97// ─── Handshake Record ─────────────────────────────────────────────────────────
99 uint8_t type; // CAP_PMKID / CAP_EAPOL / ...
100 uint8_t channel;
101 int8_t rssi;
102 uint8_t bssid[6];
103 uint8_t sta[6];
104 char ssid[33];
105 uint8_t ssid_len;
106 // PMKID path
107 uint8_t pmkid[16];
108 // EAPOL path
109 uint8_t anonce[32];
110 uint8_t mic[16];
111 uint8_t eapol_m2[256];
112 uint16_t eapol_m2_len;
115};
116
117// ─── 802.1X Enterprise Identity Record ─────────────────────────────────────────
119 uint8_t bssid[6]; // Access Point MAC
120 uint8_t client[6]; // Enterprise Client MAC
121 char identity[65]; // The Plaintext Identity / Email Address
122 uint8_t channel;
123 int8_t rssi;
124};
125
126} // namespace politician
#define LOG_FILTER_HANDSHAKES
#define LOG_FILTER_PROBES
void(* EapolCb)(const HandshakeRecord &rec)
void(* LogCb)(const char *msg)
void(* PacketCb)(const uint8_t *payload, uint16_t len, int8_t rssi, uint32_t ts_usec)
void(* ApFoundCb)(const ApRecord &ap)
void(* IdentityCb)(const EapIdentityRecord &rec)
bool(* TargetFilterCb)(const ApRecord &ap)
Configuration for the Politician engine.