Merge pull request #21 from n0xa/fixWifiSpam

Fix wifi spam
This commit is contained in:
Noah Axon 2023-11-18 00:58:55 -06:00 committed by GitHub
commit 3486c26877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 115 deletions

View File

@ -7,7 +7,7 @@
//#define CARDPUTER //#define CARDPUTER
// -=-=- Uncommenting more than one at a time will result in errors -=-=- // -=-=- Uncommenting more than one at a time will result in errors -=-=-
String buildver="2.0.0rc1"; String buildver="2.0.0rc2";
#define BGCOLOR BLACK #define BGCOLOR BLACK
#define FGCOLOR GREEN #define FGCOLOR GREEN
@ -65,7 +65,6 @@ QRCODE qrcodes[] = {
// -=-=- FEATURES -=-=- // -=-=- FEATURES -=-=-
#define KB #define KB
#define HID #define HID
#define ACTIVE_LOW_IR
// -=-=- ALIASES -=-=- // -=-=- ALIASES -=-=-
#define DISP M5Cardputer.Display #define DISP M5Cardputer.Display
#endif #endif
@ -138,7 +137,7 @@ void switcher_button_proc() {
void check_kb(){ void check_kb(){
M5Cardputer.update(); M5Cardputer.update();
if (M5Cardputer.Keyboard.isChange()) { if (M5Cardputer.Keyboard.isChange()) {
delay(250); delay(100);
} }
} }
#endif #endif
@ -214,7 +213,7 @@ void mmenu_setup() {
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
mmenu_drawmenu(); mmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void mmenu_loop() { void mmenu_loop() {
@ -297,7 +296,7 @@ void mmenu_loop() {
cursor = (screen_dim_time / 5) - 1; cursor = (screen_dim_time / 5) - 1;
rstOverride = true; rstOverride = true;
dmenu_drawmenu(); dmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void dmenu_loop() { void dmenu_loop() {
@ -386,7 +385,7 @@ void smenu_setup() {
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
smenu_drawmenu(); smenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void smenu_loop() { void smenu_loop() {
@ -436,7 +435,7 @@ int rotation = 1;
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
rmenu_drawmenu(); rmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void rmenu_loop() { void rmenu_loop() {
@ -482,7 +481,7 @@ int rotation = 1;
float b = M5.Axp.GetVbatData() * 1.1 / 1000; float b = M5.Axp.GetVbatData() * 1.1 / 1000;
int battery = ((b - 3.0) / 1.2) * 100; int battery = ((b - 3.0) / 1.2) * 100;
battery_drawmenu(battery, b, c); battery_drawmenu(battery, b, c);
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void battery_loop() { void battery_loop() {
@ -525,14 +524,10 @@ void tvbgone_setup() {
void tvbgone_loop() void tvbgone_loop()
{ {
if (check_select_press()) { if (check_select_press()) {
delay_ten_us(40000); delay(250);
while (check_select_press()) { Serial.println("triggered TVBG");
delay_ten_us(500);
yield();
}
sendAllCodes(); sendAllCodes();
} }
yield();
} }
/// TVBG-Region MENU /// /// TVBG-Region MENU ///
@ -583,8 +578,7 @@ void tvbgmenu_loop() {
} }
} }
void sendAllCodes() void sendAllCodes() {
{
bool endingEarly = false; //will be set to true if the user presses the button during code-sending bool endingEarly = false; //will be set to true if the user presses the button during code-sending
if (region == NA) { if (region == NA) {
num_codes = num_NAcodes; num_codes = num_NAcodes;
@ -621,20 +615,19 @@ void sendAllCodes()
#endif #endif
DISP.setTextSize(TINY_TEXT); DISP.setTextSize(TINY_TEXT);
DISP.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime); DISP.printf("rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime);
Serial.printf("TVBG: rti = %d Pair = %d, %d\n", ti >> 1, ontime, offtime);
rawData[k * 2] = offtime * 10; rawData[k * 2] = offtime * 10;
rawData[(k * 2) + 1] = ontime * 10; rawData[(k * 2) + 1] = ontime * 10;
yield();
} }
irsend.sendRaw(rawData, (numpairs * 2) , freq); irsend.sendRaw(rawData, (numpairs * 2) , freq);
#if defined(ACTIVE_LOW_IR) #if defined(ACTIVE_LOW_IR)
// Set Active Low IRLED high to turn it off after each burst. // Set Active Low IRLED high to turn it off after each burst.
digitalWrite(IRLED, HIGH); digitalWrite(IRLED, HIGH);
#endif #endif
yield();
bitsleft_r = 0; bitsleft_r = 0;
delay_ten_us(20500); delay_ten_us(20500);
#if defined(AXP) #if defined(AXP)
if (M5.Axp.GetBtnPress()){ if (M5.Axp.GetBtnPress()) {
endingEarly = true; endingEarly = true;
current_proc = 1; current_proc = 1;
isSwitching = true; isSwitching = true;
@ -642,13 +635,13 @@ void sendAllCodes()
break; break;
} }
#endif #endif
#if defined(KB)
check_kb();
#endif
if (check_select_press()){ if (check_select_press()){
while (check_select_press()) { Serial.println("endingearly");
yield();
}
endingEarly = true; endingEarly = true;
quickflashLEDx(4); delay(250);
break; break;
} }
} }
@ -780,7 +773,7 @@ void btmenu_setup() {
maelstrom = false; maelstrom = false;
rstOverride = true; rstOverride = true;
btmenu_drawmenu(); btmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void btmenu_loop() { void btmenu_loop() {
@ -1114,14 +1107,16 @@ void aj_adv(){
#if defined(M5LED) #if defined(M5LED)
digitalWrite(M5_LED, LOW); //LED ON on Stick C Plus digitalWrite(M5_LED, LOW); //LED ON on Stick C Plus
delay(10); delay(10);
digitalWrite(M5_LED, HIGH); //LED OFF on Stick C Plus digitalWrite(M5_LED, HIGH); //LED OFF on Stick C Plus
#endif #endif
} }
if (check_next_press()) { if (check_next_press()) {
if (sourApple || swiftPair || maelstrom){ if (sourApple || swiftPair || maelstrom){
isSwitching = true;
current_proc = 16; current_proc = 16;
btmenu_drawmenu(); btmenu_drawmenu();
} else { } else {
isSwitching = true;
current_proc = 8; current_proc = 8;
aj_drawmenu(); aj_drawmenu();
} }
@ -1178,9 +1173,6 @@ void wifispam_setup() {
packetSize -= 26; packetSize -= 26;
} }
// generate random mac address
randomMac();
//change WiFi mode //change WiFi mode
WiFi.mode(WIFI_MODE_STA); WiFi.mode(WIFI_MODE_STA);
@ -1210,7 +1202,7 @@ void wifispam_setup() {
DISP.print(rickrollssids); DISP.print(rickrollssids);
break; break;
case 3: case 3:
// placed here for consistency. no-op since display handled in loop. DISP.printf(" - Random SSIDs\n", ct);
break; break;
} }
DISP.setTextSize(SMALL_TEXT); DISP.setTextSize(SMALL_TEXT);
@ -1233,14 +1225,14 @@ void wifispam_loop() {
while(i < len){ while(i < len){
i++; i++;
} }
beaconSpam(funnyssids); beaconSpamList(funnyssids);
break; break;
case 2: case 2:
len = sizeof(rickrollssids); len = sizeof(rickrollssids);
while(i < len){ while(i < len){
i++; i++;
} }
beaconSpam(rickrollssids); beaconSpamList(rickrollssids);
break; break;
case 3: case 3:
char* randoms = randomSSID(); char* randoms = randomSSID();
@ -1248,7 +1240,7 @@ void wifispam_loop() {
while(i < len){ while(i < len){
i++; i++;
} }
beaconSpam(randoms); beaconSpamList(randoms);
break; break;
} }
} }
@ -1263,13 +1255,17 @@ void btmaelstrom_loop(){
swiftPair = false; swiftPair = false;
sourApple = true; sourApple = true;
aj_adv(); aj_adv();
swiftPair = true; if (maelstrom){
sourApple = false; swiftPair = true;
aj_adv(); sourApple = false;
swiftPair = false; aj_adv();
sourApple = false; }
aj_loop(); // roll a random device ID if (maelstrom){
aj_adv(); swiftPair = false;
sourApple = false;
aj_loop(); // roll a random device ID
aj_adv();
}
} }
/// WIFI MENU /// /// WIFI MENU ///
@ -1295,7 +1291,7 @@ void wsmenu_setup() {
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
wsmenu_drawmenu(); wsmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void wsmenu_loop() { void wsmenu_loop() {
@ -1359,7 +1355,7 @@ void wscan_result_setup() {
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
wscan_drawmenu(); wscan_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void wscan_result_loop(){ void wscan_result_loop(){
@ -1475,7 +1471,7 @@ void bootScreen(){
M5Cardputer.update(); M5Cardputer.update();
if (M5Cardputer.Keyboard.isChange()) { if (M5Cardputer.Keyboard.isChange()) {
mmenu_drawmenu(); mmenu_drawmenu();
delay(500); delay(250);
break; break;
} }
} }
@ -1501,7 +1497,7 @@ void qrmenu_setup() {
cursor = 0; cursor = 0;
rstOverride = true; rstOverride = true;
qrmenu_drawmenu(); qrmenu_drawmenu();
delay(250); // Prevent switching after menu loads up delay(500); // Prevent switching after menu loads up
} }
void qrmenu_loop() { void qrmenu_loop() {

View File

@ -76,31 +76,18 @@ const char rickrollssids[] PROGMEM = {
"08 and hurt you\n" "08 and hurt you\n"
}; };
const char foobar[] PROGMEM = { // run-time variables
"abh\nfoooo\nbarrr\nbaz\nbat\ngarply\nquux\nheyfuckface\n" char emptySSID[32];
}; char beaconSSID[32];
char randomName[32];
#define SSIDLEN 375 /* Change to whatever length you need */ uint8_t channelIndex = 0;
uint8_t macAddr[6];
char* randomSSID(){ uint8_t wifi_channel = 1;
/* Change to allowable characters */ uint32_t currentTime = 0;
const char possible[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -.!)(,?%"; uint32_t packetSize = 0;
static char ssid[SSIDLEN + 1]; uint32_t packetCounter = 0;
for(int p = 0, i = 0; i < SSIDLEN; i++){ uint32_t attackTime = 0;
int r = random(0, strlen(possible)); uint32_t packetRateTime = 0;
if(r % 7 == 0){
ssid[p++] = '\n'; // inject newlines occasionally :D
}
ssid[p++] = possible[r];
}
ssid[SSIDLEN] = '\n'; DISP.setTextSize(1);
DISP.fillScreen(BLACK);
DISP.setCursor(0, 0, 1);
DISP.println("Spamming Random SSIDs:");
// Maximum broadcast SSID length is 32, but the strings might show longer in the output. Sorry.
DISP.print(ssid);
return ssid;
}
#include <WiFi.h> #include <WiFi.h>
@ -121,17 +108,28 @@ const char* generateRandomName() {
return randomName; return randomName;
} }
char* randomSSID() {
const char* charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int len = rand() % 22 + 7; // Generate a random length between 1 and 10
for (int i = 0; i < len; ++i) {
randomName[i] = charset[rand() % strlen(charset)]; // S elect random characters from the charset
}
randomName[len] = '\0'; // Null-terminate the string
return randomName;
}
// run-time variables
char emptySSID[32]; uint8_t packet[128] = { 0x80, 0x00, 0x00, 0x00, //Frame Control, Duration
uint8_t channelIndex = 0; /*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Destination address
uint8_t macAddr[6]; /*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //Source address - overwritten later
uint8_t wifi_channel = 1; /*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //BSSID - overwritten to the same as the source address
uint32_t currentTime = 0; /*22*/ 0xc0, 0x6c, //Seq-ctl
uint32_t packetSize = 0; /*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, //timestamp - the number of microseconds the AP has been active
uint32_t packetCounter = 0; /*32*/ 0x64, 0x00, //Beacon interval
uint32_t attackTime = 0; /*34*/ 0x01, 0x04, //Capability info
uint32_t packetRateTime = 0; /* SSID */
/*36*/ 0x00
};
// beacon frame definition // beacon frame definition
uint8_t beaconPacket[109] = { uint8_t beaconPacket[109] = {
@ -200,26 +198,46 @@ void nextChannel() {
} }
} }
// generates random MAC void beaconSpam(const char ESSID[]){
void randomMac() { Serial.printf("WiFi SSID: %s\n", ESSID);
for (int i = 0; i < 6; i++) int set_channel = random(1,12);
macAddr[i] = random(256); esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
delay(1);
packet[10] = packet[16] = random(256);
packet[11] = packet[17] = random(256);
packet[12] = packet[18] = random(256);
packet[13] = packet[19] = random(256);
packet[14] = packet[20] = random(256);
packet[15] = packet[21] = random(256);
int realLen = strlen(ESSID);
int ssidLen = random(realLen, 33);
int numSpace = ssidLen - realLen;
//int rand_len = sizeof(rand_reg);
int fullLen = ssidLen;
packet[37] = fullLen;
for(int i = 0; i < realLen; i++)
packet[38 + i] = ESSID[i];
for(int i = 0; i < numSpace; i++)
packet[38 + realLen + i] = 0x20;
packet[50 + fullLen] = set_channel;
esp_wifi_80211_tx(WIFI_IF_STA, packet, sizeof(packet), false);
esp_wifi_80211_tx(WIFI_IF_STA, packet, sizeof(packet), false);
esp_wifi_80211_tx(WIFI_IF_STA, packet, sizeof(packet), false);
} }
void beaconSpam(const char list[]){ void beaconSpamList(const char list[]){
attackTime = currentTime; // Parses the char array and splits it into SSIDs
// temp variables
int i = 0; int i = 0;
int j = 0; int j = 0;
int ssidNum = 1; int ssidNum = 1;
char tmp; char tmp;
int ssidsLen = strlen_P(list); int ssidsLen = strlen_P(list);
bool sent = false; bool sent = false;
// go to next channel
nextChannel();
while (i < ssidsLen) { while (i < ssidsLen) {
// read out next SSID // read out next SSID
j = 0; j = 0;
@ -227,31 +245,10 @@ void beaconSpam(const char list[]){
tmp = pgm_read_byte(list + i + j); tmp = pgm_read_byte(list + i + j);
j++; j++;
} while (tmp != '\n' && j <= 32 && i + j < ssidsLen); } while (tmp != '\n' && j <= 32 && i + j < ssidsLen);
uint8_t ssidLen = j - 1; uint8_t ssidLen = j - 1;
memcpy_P(&beaconSSID, &list[i], ssidLen);
// set MAC address beaconSpam(beaconSSID);
macAddr[5] = ssidNum; memcpy_P(&beaconSSID, &emptySSID, 32);
ssidNum++;
// write MAC address into beacon frame
memcpy(&beaconPacket[10], macAddr, 6);
memcpy(&beaconPacket[16], macAddr, 6);
// reset SSID
memcpy(&beaconPacket[38], emptySSID, 32);
// write new SSID into beacon frame
memcpy_P(&beaconPacket[38], &list[i], ssidLen);
// set channel for beacon frame
beaconPacket[82] = wifi_channel;
// send packet
for (int k = 0; k < 3; k++) {
packetCounter += esp_wifi_80211_tx(WIFI_IF_STA, beaconPacket, packetSize, 0) == 0;
delay(1);
}
i += j; i += j;
} }
} }