diff --git a/esp8266_deauther/A_config.h b/esp8266_deauther/A_config.h index 6b82f78..50b57cc 100644 --- a/esp8266_deauther/A_config.h +++ b/esp8266_deauther/A_config.h @@ -1,5 +1,6 @@ -#ifndef config_h -#define config_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #define ENABLE_DEBUG #define DEBUG_PORT Serial @@ -699,6 +700,4 @@ // ========== ERROR CHECKS ========== // #if LED_MODE_BRIGHTNESS == 0 #error LED_MODE_BRIGHTNESS must not be zero! -#endif /* if LED_MODE_BRIGHTNESS == 0 */ - -#endif /* ifndef config_h */ \ No newline at end of file +#endif /* if LED_MODE_BRIGHTNESS == 0 */ \ No newline at end of file diff --git a/esp8266_deauther/Accesspoints.cpp b/esp8266_deauther/Accesspoints.cpp index 70030ce..61697b1 100644 --- a/esp8266_deauther/Accesspoints.cpp +++ b/esp8266_deauther/Accesspoints.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "Accesspoints.h" Accesspoints::Accesspoints() { @@ -170,6 +172,7 @@ String Accesspoints::getMacStr(int num) { if (!check(num)) return String(); uint8_t* mac = getMac(num); + return bytesToStr(mac, 6); } diff --git a/esp8266_deauther/Accesspoints.h b/esp8266_deauther/Accesspoints.h index 5726bfb..f060ef6 100644 --- a/esp8266_deauther/Accesspoints.h +++ b/esp8266_deauther/Accesspoints.h @@ -1,5 +1,6 @@ -#ifndef Accesspoints_h -#define Accesspoints_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include @@ -76,6 +77,4 @@ class Accesspoints { void internal_select(int num); void internal_deselect(int num); void internal_remove(int num); -}; - -#endif // ifndef Accesspoints_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/Attack.cpp b/esp8266_deauther/Attack.cpp index 03e90d3..aa94777 100644 --- a/esp8266_deauther/Attack.cpp +++ b/esp8266_deauther/Attack.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "Attack.h" #include "settings.h" @@ -285,11 +287,11 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_ // build deauth packet packetSize = sizeof(deauthPacket); - + uint8_t deauthpkt[packetSize]; memcpy(deauthpkt, deauthPacket, packetSize); - + memcpy(&deauthpkt[4], stMac, 6); memcpy(&deauthpkt[10], apMac, 6); memcpy(&deauthpkt[16], apMac, 6); @@ -305,8 +307,9 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_ // send disassociate frame uint8_t disassocpkt[packetSize]; + memcpy(disassocpkt, deauthpkt, packetSize); - + disassocpkt[0] = 0xa0; if (sendPacket(disassocpkt, packetSize, ch, 1)) { @@ -372,6 +375,7 @@ bool Attack::sendBeacon(uint8_t* mac, const char* ssid, uint8_t ch, bool wpa2) { // ===== uint16_t tmpPacketSize = (packetSize - 32) + ssidLen; // calc size uint8_t* tmpPacket = new uint8_t[tmpPacketSize]; // create packet buffer + memcpy(&tmpPacket[0], &beaconPacket[0], 38 + ssidLen); // copy first half of packet into buffer tmpPacket[37] = ssidLen; // update SSID length byte memcpy(&tmpPacket[38 + ssidLen], &beaconPacket[70], wpa2 ? 39 : 13); // copy second half of packet into buffer diff --git a/esp8266_deauther/Attack.h b/esp8266_deauther/Attack.h index 6718136..bb35c63 100644 --- a/esp8266_deauther/Attack.h +++ b/esp8266_deauther/Attack.h @@ -1,5 +1,6 @@ -#ifndef Attack_h -#define Attack_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include @@ -12,7 +13,7 @@ extern "C" { #include "SSIDs.h" #include "Scan.h" -extern SSIDs ssids; +extern SSIDs ssids; extern Accesspoints accesspoints; extern Stations stations; extern Scan scan; @@ -151,16 +152,16 @@ class Attack { }; uint8_t beaconPacket[109] = { - /* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame - /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast - /* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source - /* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source + /* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame + /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast + /* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source + /* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source // Fixed parameters - /* 22 - 23 */ 0x00, 0x00, // Fragment & sequence number (will be done by the SDK) - /* 24 - 31 */ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, // Timestamp - /* 32 - 33 */ 0xe8, 0x03, // Interval: 0x64, 0x00 => every 100ms - 0xe8, 0x03 => every 1s - /* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation + /* 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 */ 0xe8, 0x03, // Interval: 0x64, 0x00 => every 100ms - 0xe8, 0x03 => every 1s + /* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation // Tagged parameters @@ -195,11 +196,9 @@ class Attack { /* 85 - 86 */ 0x01, 0x00, /* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02, /* 91 - 92 */ 0x02, 0x00, - /* 93 - 100 */ 0x00, 0x0f, 0xac, 0x04, 0x00, 0x0f, 0xac, 0x04, /*Fix: changed 0x02(TKIP) to 0x04(CCMP) is default. WPA2 with TKIP not supported by many devices*/ + /* 93 - 100 */ 0x00, 0x0f, 0xac, 0x04, 0x00, 0x0f, 0xac, 0x04, /*Fix: changed 0x02(TKIP) to 0x04(CCMP) is default. WPA2 with TKIP not supported by many devices*/ /* 101 - 102 */ 0x01, 0x00, /* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02, /* 107 - 108 */ 0x00, 0x00 }; -}; - -#endif // ifndef Attack_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/CLI.cpp b/esp8266_deauther/CLI.cpp index 9d01c0c..d2d9e98 100644 --- a/esp8266_deauther/CLI.cpp +++ b/esp8266_deauther/CLI.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "CLI.h" #include diff --git a/esp8266_deauther/CLI.h b/esp8266_deauther/CLI.h index 096d83f..715338d 100644 --- a/esp8266_deauther/CLI.h +++ b/esp8266_deauther/CLI.h @@ -1,5 +1,6 @@ -#ifndef CLI_h -#define CLI_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include @@ -16,8 +17,8 @@ extern "C" { #include "DisplayUI.h" #include "led.h" -extern Names names; -extern SSIDs ssids; +extern Names names; +extern SSIDs ssids; extern Accesspoints accesspoints; extern Stations stations; extern Scan scan; @@ -64,8 +65,8 @@ class CLI { private: bool enabled = false; - SimpleList*list; - SimpleList*queue; + SimpleList* list; + SimpleList* queue; bool delayed = false; uint32_t delayTime = 0; @@ -85,6 +86,4 @@ class CLI { int toInt(String str); uint32_t getTime(String time); bool eqlsCMD(int i, const char* keyword); -}; - -#endif // ifndef CLI_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/DisplayUI.cpp b/esp8266_deauther/DisplayUI.cpp index 98a8997..e23cb97 100644 --- a/esp8266_deauther/DisplayUI.cpp +++ b/esp8266_deauther/DisplayUI.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "DisplayUI.h" #include "settings.h" diff --git a/esp8266_deauther/DisplayUI.h b/esp8266_deauther/DisplayUI.h index f3262f7..bb8a7ab 100644 --- a/esp8266_deauther/DisplayUI.h +++ b/esp8266_deauther/DisplayUI.h @@ -1,5 +1,6 @@ -#ifndef DisplayUI_h -#define DisplayUI_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "language.h" #include "A_config.h" @@ -664,6 +665,4 @@ const uint8_t DejaVu_Sans_Mono_12[] PROGMEM = { 0x00, 0x00, 0x60, 0x40, 0x80, 0x67, 0x08, 0x1C, 0x84, 0x03, 0x60, // 253 0x00, 0x00, 0xFC, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 254 0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255 -}; - -#endif // ifndef DisplayUI_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/EEPROMHelper.h b/esp8266_deauther/EEPROMHelper.h index fc73a85..700997e 100644 --- a/esp8266_deauther/EEPROMHelper.h +++ b/esp8266_deauther/EEPROMHelper.h @@ -1,5 +1,6 @@ -#ifndef EEPROMHELPER_H -#define EEPROMHELPER_H +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once // ========== Includes ========== // #include @@ -58,6 +59,4 @@ class EEPROMHelper { for (unsigned long i = 0; i @@ -258,6 +260,7 @@ void Names::setMac(int num, String macStr) { if (!check(num)) return; uint8_t mac[6]; + strToMac(macStr, mac); internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num)); prntln(N_CHANGED_MAC); @@ -280,6 +283,7 @@ void Names::setBSSID(int num, String bssidStr) { if (!check(num)) return; uint8_t mac[6]; + strToMac(bssidStr, mac); internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num)); prntln(N_CHANGED_BSSID); @@ -362,6 +366,7 @@ String Names::getMacStr(int num) { if (!check(num)) return String(); uint8_t* mac = getMac(num); + return bytesToStr(mac, 6); } @@ -471,6 +476,7 @@ void Names::internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, if ((ch < 1) || (ch > 14)) ch = 1; Device newDevice; + newDevice.mac = deviceMac; newDevice.name = deviceName; newDevice.apBssid = deviceBssid; diff --git a/esp8266_deauther/Names.h b/esp8266_deauther/Names.h index 0def998..2531566 100644 --- a/esp8266_deauther/Names.h +++ b/esp8266_deauther/Names.h @@ -1,5 +1,6 @@ -#ifndef Names_h -#define Names_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include extern "C" { @@ -97,6 +98,4 @@ class Names { void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected); void internal_remove(int num); void internal_removeAll(); -}; - -#endif // ifndef Names_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/SSIDs.cpp b/esp8266_deauther/SSIDs.cpp index bdcf494..f76bcdb 100644 --- a/esp8266_deauther/SSIDs.cpp +++ b/esp8266_deauther/SSIDs.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "SSIDs.h" #include @@ -42,6 +44,7 @@ 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) + @@ -233,6 +236,7 @@ void SSIDs::replace(int num, String name, bool wpa2) { if (len > 32) len = 32; SSID newSSID; + newSSID.name = randomize(name); newSSID.wpa2 = wpa2; newSSID.len = (uint8_t)len; @@ -301,6 +305,7 @@ void SSIDs::internal_add(String name, bool wpa2, int len) { name = fixUtf8(name); SSID newSSID; + newSSID.name = name; newSSID.wpa2 = wpa2; newSSID.len = (uint8_t)len; @@ -314,4 +319,4 @@ void SSIDs::internal_remove(int num) { void SSIDs::internal_removeAll() { list->clear(); -} +} \ No newline at end of file diff --git a/esp8266_deauther/SSIDs.h b/esp8266_deauther/SSIDs.h index fe4b7ff..07d55dd 100644 --- a/esp8266_deauther/SSIDs.h +++ b/esp8266_deauther/SSIDs.h @@ -1,5 +1,6 @@ -#ifndef SSIDs_h -#define SSIDs_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include @@ -80,6 +81,4 @@ class SSIDs { void internal_add(String name, bool wpa2, int add); void internal_remove(int num); void internal_removeAll(); -}; - -#endif // ifndef SSIDs_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/Scan.cpp b/esp8266_deauther/Scan.cpp index 06fbc5f..a334ce3 100644 --- a/esp8266_deauther/Scan.cpp +++ b/esp8266_deauther/Scan.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "Scan.h" #include "settings.h" diff --git a/esp8266_deauther/Scan.h b/esp8266_deauther/Scan.h index abd56f8..6baedf5 100644 --- a/esp8266_deauther/Scan.h +++ b/esp8266_deauther/Scan.h @@ -1,5 +1,6 @@ -#ifndef Scan_h -#define Scan_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include "Accesspoints.h" @@ -23,7 +24,7 @@ extern Stations stations; extern Names names; extern SSIDs ssids; -extern uint8_t wifiMode; +extern uint8_t wifiMode; extern void setWifiChannel(uint8_t ch); extern bool appendFile(String path, String& buf); @@ -90,6 +91,4 @@ class Scan { int findAccesspoint(uint8_t* mac); String FILE_PATH = "/scan.json"; -}; - -#endif // ifndef Scan_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/SimpleList.h b/esp8266_deauther/SimpleList.h index a298858..6fde625 100644 --- a/esp8266_deauther/SimpleList.h +++ b/esp8266_deauther/SimpleList.h @@ -1,12 +1,6 @@ -#ifndef SimpleList_h -#define SimpleList_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ -/* - =========================================== - Copyright (c) 2018 Stefan Kremser - github.com/spacehuhn - =========================================== - */ +#pragma once #include #include @@ -166,6 +160,7 @@ void SimpleList::add(int index, T obj) { } SimpleListNode* newNode = new SimpleListNode(); + newNode->data = obj; if (index == 0) { @@ -191,6 +186,7 @@ void SimpleList::insert(T obj) { // create new node SimpleListNode* newNode = new SimpleListNode(); + newNode->data = obj; if (listSize == 0) { @@ -516,6 +512,4 @@ void SimpleList::sort() { } this->sorted = true; -} - -#endif // ifndef SimpleList_h \ No newline at end of file +} \ No newline at end of file diff --git a/esp8266_deauther/Stations.cpp b/esp8266_deauther/Stations.cpp index a6bcc02..231621e 100644 --- a/esp8266_deauther/Stations.cpp +++ b/esp8266_deauther/Stations.cpp @@ -1,3 +1,5 @@ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "Stations.h" Stations::Stations() { @@ -133,6 +135,7 @@ String Stations::getAPMacStr(int num) { if (!check(num)) return String(); uint8_t* mac = getAPMac(num); + return bytesToStr(mac, 6); } @@ -164,6 +167,7 @@ String Stations::getMacStr(int num) { if (!check(num)) return String(); uint8_t* mac = getMac(num); + return bytesToStr(mac, 6); } @@ -256,7 +260,7 @@ void Stations::remove(int num) { prnt(ST_REMOVED_STATION); prntln(num); - + internal_remove(num); changed = true; } @@ -342,6 +346,7 @@ void Stations::internal_add(uint8_t* mac, int accesspointNum) { if (count() >= STATION_LIST_SIZE) removeOldest(); Station newStation; + newStation.ap = accesspointNum; newStation.ch = wifi_channel; newStation.mac = (uint8_t*)malloc(6); @@ -365,4 +370,4 @@ void Stations::internal_removeAll() { free(getTime(i)); } list->clear(); -} +} \ No newline at end of file diff --git a/esp8266_deauther/Stations.h b/esp8266_deauther/Stations.h index 438ea57..711da23 100644 --- a/esp8266_deauther/Stations.h +++ b/esp8266_deauther/Stations.h @@ -1,5 +1,6 @@ -#ifndef Stations_h -#define Stations_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" extern "C" { @@ -93,6 +94,4 @@ class Stations { void internal_add(uint8_t* mac, int accesspointNum); void internal_remove(int num); void internal_removeAll(); -}; - -#endif // ifndef Stations_h \ No newline at end of file +}; \ No newline at end of file diff --git a/esp8266_deauther/debug.h b/esp8266_deauther/debug.h index 2c7fec5..83aecc8 100644 --- a/esp8266_deauther/debug.h +++ b/esp8266_deauther/debug.h @@ -1,8 +1,4 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ #pragma once diff --git a/esp8266_deauther/esp8266_deauther.ino b/esp8266_deauther/esp8266_deauther.ino index 3803502..19a7b85 100644 --- a/esp8266_deauther/esp8266_deauther.ino +++ b/esp8266_deauther/esp8266_deauther.ino @@ -1,9 +1,7 @@ -/* - =========================================== - Copyright (c) 2018 Stefan Kremser - github.com/spacehuhn - =========================================== - */ +/* ===================== + This software is licensed under the MIT License: + https://github.com/spacehuhntech/esp8266_deauther + ===================== */ extern "C" { // Please follow this tutorial: diff --git a/esp8266_deauther/functions.h b/esp8266_deauther/functions.h index 9728e95..a4959dd 100644 --- a/esp8266_deauther/functions.h +++ b/esp8266_deauther/functions.h @@ -1,5 +1,6 @@ -#ifndef functions_h -#define functions_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" #include @@ -827,6 +828,4 @@ String formatBytes(size_t bytes) { else if (bytes < (1024 * 1024)) return String(bytes / 1024.0) + "KB"; else if (bytes < (1024 * 1024 * 1024)) return String(bytes / 1024.0 / 1024.0) + "MB"; else return String(bytes / 1024.0 / 1024.0 / 1024.0) + "GB"; -} - -#endif // ifndef functions_h \ No newline at end of file +} \ No newline at end of file diff --git a/esp8266_deauther/language.h b/esp8266_deauther/language.h index 59cde40..03f2fc5 100644 --- a/esp8266_deauther/language.h +++ b/esp8266_deauther/language.h @@ -1,5 +1,6 @@ -#ifndef language_h -#define language_h +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + +#pragma once #include "Arduino.h" @@ -541,7 +542,7 @@ const char W_BAD_ARGS[] PROGMEM = "BAD ARGS"; const char W_BAD_PATH[] PROGMEM = "BAD PATH"; const char W_FILE_NOT_FOUND[] PROGMEM = "ERROR 404 File Not Found"; const char W_STARTED_AP[] PROGMEM = "Started AP"; -const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files +const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang"; const char W_HTML[] PROGMEM = "text/html"; @@ -619,5 +620,4 @@ const char S_JSON_LEDENABLED[] PROGMEM = "led"; // Display const char S_JSON_DISPLAYINTERFACE[] PROGMEM = "display"; -const char S_JSON_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout"; -#endif // ifndef language_h \ No newline at end of file +const char S_JSON_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout"; \ No newline at end of file diff --git a/esp8266_deauther/led.cpp b/esp8266_deauther/led.cpp index cf585a2..8207b96 100644 --- a/esp8266_deauther/led.cpp +++ b/esp8266_deauther/led.cpp @@ -1,8 +1,4 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ #include "led.h" diff --git a/esp8266_deauther/led.h b/esp8266_deauther/led.h index 65dddee..e08c0de 100644 --- a/esp8266_deauther/led.h +++ b/esp8266_deauther/led.h @@ -1,8 +1,4 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ #pragma once @@ -14,7 +10,7 @@ enum LED_MODE { }; namespace led { - void setup(); - void update(); - void setMode(LED_MODE new_mode, bool force = false); + void setup(); + void update(); + void setMode(LED_MODE new_mode, bool force = false); } \ No newline at end of file diff --git a/esp8266_deauther/settings.cpp b/esp8266_deauther/settings.cpp index be717c1..7ffa118 100644 --- a/esp8266_deauther/settings.cpp +++ b/esp8266_deauther/settings.cpp @@ -1,13 +1,9 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ - +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #include "settings.h" -#include "A_config.h" // Default Settings -#include "language.h" // prnt and prntln +#include "A_config.h" // Default Settings +#include "language.h" // prnt and prntln #include "EEPROMHelper.h" // To load and save settings_t #include "debug.h" @@ -17,29 +13,29 @@ extern bool writeFile(String path, String& buf); extern void getRandomMac(uint8_t* mac); extern bool macValid(uint8_t* mac); -#define JSON_FLAG(_NAME,_VALUE)\ - str += String('"') + String(FPSTR(_NAME)) + String(F("\":")) + String(_VALUE?"true":"false") + String(','); +#define JSON_FLAG(_NAME, _VALUE)\ + str += String('"') + String(FPSTR(_NAME)) + String(F("\":")) + String(_VALUE ? "true" : "false") + String(','); -#define JSON_VALUE(_NAME,_VALUE)\ +#define JSON_VALUE(_NAME, _VALUE)\ str += String('"') + String(FPSTR(_NAME)) + String(F("\":\"")) + String(_VALUE) + String(F("\",")); -#define JSON_INT(_NAME,_VALUE)\ +#define JSON_INT(_NAME, _VALUE)\ str += String('"') + String(FPSTR(_NAME)) + String(F("\":")) + String(_VALUE) + String(','); -#define JSON_HEX(_NAME,_BYTES,_LEN)\ +#define JSON_HEX(_NAME, _BYTES, _LEN)\ str += String('"') + String(FPSTR(_NAME)) + String(F("\":\""));\ for (int i = 0; i<_LEN; i++) {\ - if (i > 0) str += ':';\ + if (i > 0) str += ':';\ if (_BYTES[i] < 0x10) str += '0';\ - str += String(_BYTES[i], HEX);\ + str += String(_BYTES[i], HEX);\ }\ str += String(F("\",")); -#define JSON_DEC(_NAME,_BYTES,_LEN)\ +#define JSON_DEC(_NAME, _BYTES, _LEN)\ str += String(F("\"")) + String(FPSTR(_NAME)) + String(F("\":\""));\ for (int i = 0; i<_LEN; i++) {\ if (i > 0) str += '.';\ - str += String(_BYTES[i]);\ + str += String(_BYTES[i]);\ }\ str += String(F("\",")); @@ -47,7 +43,7 @@ extern bool macValid(uint8_t* mac); namespace settings { // ========== PRIVATE ========== // const char* SETTINGS_PATH = "/settings.json"; - + settings_t data; bool changed = false; @@ -56,7 +52,7 @@ namespace settings { str.reserve(600); str += '{'; - + // Version JSON_VALUE(S_JSON_VERSION, DEAUTHER_VERSION); @@ -104,7 +100,7 @@ namespace settings { // Display JSON_FLAG(S_JSON_DISPLAYINTERFACE, data.display.enabled); JSON_INT(S_JSON_DISPLAY_TIMEOUT, data.display.timeout); - + str.setCharAt(str.length()-1, '}'); } @@ -114,21 +110,23 @@ namespace settings { // read data from eeproms settings_t newData; + EEPROMHelper::getObject(SETTINGS_ADDR, newData); // calc and check hash if (newData.magic_num == MAGIC_NUM) { - data = newData; - data.version.major = DEAUTHER_VERSION_MAJOR; - data.version.minor = DEAUTHER_VERSION_MINOR; + data = newData; + data.version.major = DEAUTHER_VERSION_MAJOR; + data.version.minor = DEAUTHER_VERSION_MINOR; data.version.revision = DEAUTHER_VERSION_REVISION; debuglnF("OK"); save(); } else { debuglnF("Invalid Hash"); + /*debug(data.magic_num); - debugF(" != "); - debugln(MAGIC_NUM);*/ + debugF(" != "); + debugln(MAGIC_NUM);*/ reset(); save(); @@ -143,47 +141,48 @@ namespace settings { void reset() { data.magic_num = MAGIC_NUM; - - data.version.major = DEAUTHER_VERSION_MAJOR; - data.version.minor = DEAUTHER_VERSION_MINOR; + + data.version.major = DEAUTHER_VERSION_MAJOR; + data.version.minor = DEAUTHER_VERSION_MINOR; data.version.revision = DEAUTHER_VERSION_REVISION; - - data.attack.attack_all_ch = ATTACK_ALL_CH; - data.attack.random_tx = RANDOM_TX; - data.attack.timeout = ATTACK_TIMEOUT; - data.attack.deauths_per_target = DEAUTHS_PER_TARGET; - data.attack.deauth_reason = DEAUTH_REASON; - data.attack.beacon_interval = beacon_interval_t::INTERVAL_100MS; + + data.attack.attack_all_ch = ATTACK_ALL_CH; + data.attack.random_tx = RANDOM_TX; + data.attack.timeout = ATTACK_TIMEOUT; + data.attack.deauths_per_target = DEAUTHS_PER_TARGET; + data.attack.deauth_reason = DEAUTH_REASON; + data.attack.beacon_interval = beacon_interval_t::INTERVAL_100MS; data.attack.probe_frames_per_ssid = PROBE_FRAMES_PER_SSID; - + data.wifi.channel = 1; getRandomMac(data.wifi.mac_st); getRandomMac(data.wifi.mac_ap); - data.sniffer.channel_time = CH_TIME; + data.sniffer.channel_time = CH_TIME; data.sniffer.min_deauth_frames = MIN_DEAUTH_FRAMES; strncpy(data.ap.ssid, AP_SSID, 32); strncpy(data.ap.password, AP_PASSWD, 64); data.ap.hidden = AP_HIDDEN; uint8_t ip[4] = AP_IP_ADDR; + memcpy(data.ap.ip, ip, 4); - data.web.enabled = WEB_ENABLED; + data.web.enabled = WEB_ENABLED; data.web.captive_portal = WEB_CAPTIVE_PORTAL; - data.web.use_spiffs = WEB_USE_SPIFFS; + data.web.use_spiffs = WEB_USE_SPIFFS; memcpy(data.web.lang, DEFAULT_LANG, 3); - data.cli.enabled = CLI_ENABLED; + data.cli.enabled = CLI_ENABLED; data.cli.serial_echo = CLI_ECHO; data.led.enabled = USE_LED; data.display.enabled = USE_DISPLAY; data.display.timeout = DISPLAY_TIMEOUT; - + changed = true; - + debuglnF("Settings reset to default"); } @@ -192,7 +191,7 @@ namespace settings { EEPROMHelper::saveObject(SETTINGS_ADDR, data); changed = false; - + String json_buffer; get_json(json_buffer); @@ -205,9 +204,10 @@ namespace settings { debugln(SETTINGS_PATH); } } - + void print() { String json_buffer; + get_json(json_buffer); json_buffer.replace("\":", ": "); @@ -267,7 +267,7 @@ namespace settings { const display_settings_t& getDisplaySettings() { return data.display; } - + // ===== SETTERS ===== // void setAllSettings(settings_t& newSettings) { diff --git a/esp8266_deauther/settings.h b/esp8266_deauther/settings.h index 5593891..6d6f532 100644 --- a/esp8266_deauther/settings.h +++ b/esp8266_deauther/settings.h @@ -1,12 +1,8 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ - +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ + #pragma once -#include // Arduino String, Serial +#include // Arduino String, Serial #include "A_config.h" // ===== VERSION ===== // @@ -24,7 +20,7 @@ typedef struct autosave_settings_t { // ===== ATTACK ===== // typedef enum beacon_interval_t { - INTERVAL_1S = 0, + INTERVAL_1S = 0, INTERVAL_100MS = 1 } beacon_interval_t; @@ -114,11 +110,11 @@ namespace settings { void print(); const settings_t& getAllSettings(); - const version_t & getVersion(); + const version_t& getVersion(); const autosave_settings_t& getAutosaveSettings(); - const attack_settings_t & getAttackSettings(); - const wifi_settings_t & getWifiSettings(); - const sniffer_settings_t & getSnifferSettings(); + const attack_settings_t& getAttackSettings(); + const wifi_settings_t& getWifiSettings(); + const sniffer_settings_t& getSnifferSettings(); const access_point_settings_t& getAccessPointSettings(); const web_settings_t& getWebSettings(); const cli_settings_t& getCLISettings(); diff --git a/esp8266_deauther/wifi.cpp b/esp8266_deauther/wifi.cpp index 8c703f5..25b2b63 100644 --- a/esp8266_deauther/wifi.cpp +++ b/esp8266_deauther/wifi.cpp @@ -1,8 +1,4 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ #include "wifi.h" diff --git a/esp8266_deauther/wifi.h b/esp8266_deauther/wifi.h index 64d0c96..e10a60c 100644 --- a/esp8266_deauther/wifi.h +++ b/esp8266_deauther/wifi.h @@ -1,8 +1,4 @@ -/* - Copyright (c) 2020 Stefan Kremser (@Spacehuhn) - This software is licensed under the MIT License. See the license file for details. - Source: github.com/spacehuhn/esp8266_deauther - */ +/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */ #pragma once @@ -13,13 +9,13 @@ namespace wifi { String getMode(); void printStatus(); - + void startNewAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal); - //void startAP(String path); + // void startAP(String path); void startAP(); void stopAP(); void resumeAP(); - + void update(); } \ No newline at end of file