Skip to content

Commit fd2e789

Browse files
authored
Update esp8266_beaconSpam.ino
Added functionality to handle 20,000+ SSIDs using "classic" (sequential) MAC addresses; I was only able to compile a little over 23,000 SSID names for testing. This requires the 4th and 5th octets of the MAC address to roll-over, as needed. Changed how the PRNG is seeded, using "mayhem" mode, account of this bug - arduino/Arduino#11811
1 parent 5b006fb commit fd2e789

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

Diff for: esp8266_beaconSpam/esp8266_beaconSpam.ino

+25-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
const char ssidList[][33] PROGMEM = {
2121

2222
// "12345678901234567890123456789012" // as a point of reference, this is 32 ASCII characters
23-
23+
2424
"The Password is...",
2525
"Untrusted Network",
2626
"404 Network Unavailable",
@@ -41,6 +41,7 @@ const char ssidList[][33] PROGMEM = {
4141
"The LAN Before Time",
4242
"Get off my LAN",
4343
"Silence of the LAN"
44+
4445
};
4546

4647
//////// channels ////////
@@ -67,7 +68,7 @@ const bool wpa2 = false;
6768
// can be used to "synchronise" two or more devices
6869
// seed is printed to serial port at start-up
6970
const uint64_t randomMacSeed = os_random(); // random seed on startup
70-
//const uint64_t randomMacSeed = 0x1234abcd ; // fixed seed; make it your own
71+
//const uint64_t randomMacSeed = 0x12345abc ; // fixed seed; make it your own
7172

7273
//////// Includes ////////
7374
#include <ESP8266WiFi.h>
@@ -84,6 +85,7 @@ const uint64_t randomMacSeed = os_random(); // random seed on startup
8485
// run-time variables
8586
uint16_t channelIndex = 0;
8687
uint8_t macAddr[5];
88+
uint8_t macAddr_b[5];
8789
uint8_t wifi_channel = channels[0];
8890
uint32_t packetSize = 0;
8991
uint32_t loopStartTime = 0;
@@ -187,13 +189,12 @@ void randomMac() {
187189
macAddr[2] = uint8_t(random(0x0, 0x100));
188190
macAddr[3] = uint8_t(random(0x0, 0x100));
189191
macAddr[4] = uint8_t(random(0x0, 0x100));
190-
//macAddr[5] = uint8_t(0x00); // this one gets assigned sequentially,
192+
macAddr[5] = uint8_t(0x00); // this one gets assigned sequentially,
191193
// later on, when this mode is in use
192194
}
193195

194196
void mayhemMac(uint32_t ssidNum) {
195197
// SEE COMMENTS, ABOVE
196-
randomSeed(uint32_t((randomMacSeed) + (ssidNum)));
197198
macAddr[0] = uint8_t(random(0x0, 0x100)) & 0xfe | 0x02 ; // SEE COMMENTS, ABOVE
198199
macAddr[1] = uint8_t(random(0x0, 0x100));
199200
macAddr[2] = uint8_t(random(0x0, 0x100));
@@ -241,7 +242,7 @@ void setup() {
241242

242243
///////////////////////////////
243244
// mac and ssid startup message
244-
Serial.println("\n//// Atom Smasher's Beacon Spammer v1.0 ////\n\n// MACs: SSIDs:");
245+
Serial.println("\n//// Atom Smasher's Beacon Spammer v1.1 ////\n\n// MACs: SSIDs:");
245246
ssidCount = sizeof(ssidList) / sizeof(ssidList[0]);
246247
i = 0;
247248
if (0 == macMode) {
@@ -250,12 +251,18 @@ void setup() {
250251
for (i = 0; i < ssidCount; i++) {
251252
yield(); // needed for extra-large lists
252253
Serial.printf(" %02x:%02x:%02x:%02x:%02x:%02x %s\n",
253-
macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5] + i + 1,
254+
macAddr[0],
255+
macAddr[1],
256+
macAddr[2],
257+
uint8_t(macAddr[3] + ((macAddr[4] + (i / 0x100)) / 0x100)), // rollover mac address for large ssid lists
258+
uint8_t(macAddr[4] + (i / 0x100)), // rollover mac address for large ssid lists
259+
uint8_t(i), // "i" bound by uint8 is effectively "i % 0x100", and it becomes "macAddr[5]"
254260
ssidList[i]);
255261
// end start macMode=0
256262
}
257263
} else {
258264
// start macMode=1
265+
randomSeed(uint32_t(randomMacSeed));
259266
for (i = 0; i < ssidCount; i++) {
260267
yield(); // needed for extra-large lists
261268
mayhemMac(i);
@@ -276,6 +283,10 @@ void setup() {
276283
// during the first iteration of the packet counter loop
277284
loopStartTime = packetRateTime = millis();
278285

286+
287+
macAddr_b[3] = macAddr[3]; // rollover safety
288+
macAddr_b[4] = macAddr[4]; // rollover safety
289+
279290
}
280291

281292
void loop() {
@@ -287,16 +298,22 @@ void loop() {
287298

288299
uint32_t ssidNum = 0;
289300

301+
if (1 == macMode) {
302+
randomSeed(uint32_t(randomMacSeed));
303+
}
304+
290305
// for each ssid ...
291306
for (i = 0; i < ssidCount; i++) {
292307

293308
///////////////
294309
// if mayhemMac
295310
if (1 == macMode) {
296311
mayhemMac(ssidNum);
297-
//////
298312
} else {
299-
macAddr[5] = ssidNum;
313+
// classic mac mode
314+
macAddr[5] = uint8_t(ssidNum);
315+
macAddr[4] = uint8_t(macAddr_b[4] + (ssidNum / 0x100)); // gracefully handle >256 SSIDs
316+
macAddr[3] = uint8_t(macAddr_b[3] + ((macAddr_b[4] + (ssidNum / 0x100)) / 0x100)); // gracefully handle >256 SSIDs
300317
}
301318

302319
ssidNum++;

0 commit comments

Comments
 (0)