Updated copyright in code

This commit is contained in:
Spacehuhn
2021-01-11 18:14:55 +01:00
parent d95d7c7aa7
commit d01bd2bfc4
29 changed files with 172 additions and 186 deletions

View File

@@ -1,5 +1,6 @@
#ifndef config_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define config_h
#pragma once
#define ENABLE_DEBUG #define ENABLE_DEBUG
#define DEBUG_PORT Serial #define DEBUG_PORT Serial
@@ -699,6 +700,4 @@
// ========== ERROR CHECKS ========== // // ========== ERROR CHECKS ========== //
#if LED_MODE_BRIGHTNESS == 0 #if LED_MODE_BRIGHTNESS == 0
#error LED_MODE_BRIGHTNESS must not be zero! #error LED_MODE_BRIGHTNESS must not be zero!
#endif /* if LED_MODE_BRIGHTNESS == 0 */ #endif /* if LED_MODE_BRIGHTNESS == 0 */
#endif /* ifndef config_h */

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "Accesspoints.h" #include "Accesspoints.h"
Accesspoints::Accesspoints() { Accesspoints::Accesspoints() {
@@ -170,6 +172,7 @@ String Accesspoints::getMacStr(int num) {
if (!check(num)) return String(); if (!check(num)) return String();
uint8_t* mac = getMac(num); uint8_t* mac = getMac(num);
return bytesToStr(mac, 6); return bytesToStr(mac, 6);
} }

View File

@@ -1,5 +1,6 @@
#ifndef Accesspoints_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define Accesspoints_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
@@ -76,6 +77,4 @@ class Accesspoints {
void internal_select(int num); void internal_select(int num);
void internal_deselect(int num); void internal_deselect(int num);
void internal_remove(int num); void internal_remove(int num);
}; };
#endif // ifndef Accesspoints_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "Attack.h" #include "Attack.h"
#include "settings.h" #include "settings.h"
@@ -285,11 +287,11 @@ bool Attack::deauthDevice(uint8_t* apMac, uint8_t* stMac, uint8_t reason, uint8_
// build deauth packet // build deauth packet
packetSize = sizeof(deauthPacket); packetSize = sizeof(deauthPacket);
uint8_t deauthpkt[packetSize]; uint8_t deauthpkt[packetSize];
memcpy(deauthpkt, deauthPacket, packetSize); memcpy(deauthpkt, deauthPacket, packetSize);
memcpy(&deauthpkt[4], stMac, 6); memcpy(&deauthpkt[4], stMac, 6);
memcpy(&deauthpkt[10], apMac, 6); memcpy(&deauthpkt[10], apMac, 6);
memcpy(&deauthpkt[16], 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 // send disassociate frame
uint8_t disassocpkt[packetSize]; uint8_t disassocpkt[packetSize];
memcpy(disassocpkt, deauthpkt, packetSize); memcpy(disassocpkt, deauthpkt, packetSize);
disassocpkt[0] = 0xa0; disassocpkt[0] = 0xa0;
if (sendPacket(disassocpkt, packetSize, ch, 1)) { 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 uint16_t tmpPacketSize = (packetSize - 32) + ssidLen; // calc size
uint8_t* tmpPacket = new uint8_t[tmpPacketSize]; // create packet buffer uint8_t* tmpPacket = new uint8_t[tmpPacketSize]; // create packet buffer
memcpy(&tmpPacket[0], &beaconPacket[0], 38 + ssidLen); // copy first half of packet into buffer memcpy(&tmpPacket[0], &beaconPacket[0], 38 + ssidLen); // copy first half of packet into buffer
tmpPacket[37] = ssidLen; // update SSID length byte tmpPacket[37] = ssidLen; // update SSID length byte
memcpy(&tmpPacket[38 + ssidLen], &beaconPacket[70], wpa2 ? 39 : 13); // copy second half of packet into buffer memcpy(&tmpPacket[38 + ssidLen], &beaconPacket[70], wpa2 ? 39 : 13); // copy second half of packet into buffer

View File

@@ -1,5 +1,6 @@
#ifndef Attack_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define Attack_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
@@ -12,7 +13,7 @@ extern "C" {
#include "SSIDs.h" #include "SSIDs.h"
#include "Scan.h" #include "Scan.h"
extern SSIDs ssids; extern SSIDs ssids;
extern Accesspoints accesspoints; extern Accesspoints accesspoints;
extern Stations stations; extern Stations stations;
extern Scan scan; extern Scan scan;
@@ -151,16 +152,16 @@ class Attack {
}; };
uint8_t beaconPacket[109] = { uint8_t beaconPacket[109] = {
/* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame /* 0 - 3 */ 0x80, 0x00, 0x00, 0x00, // Type/Subtype: managment beacon frame
/* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast /* 4 - 9 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Destination: broadcast
/* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source /* 10 - 15 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source
/* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source /* 16 - 21 */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // Source
// Fixed parameters // 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 /* 24 - 31 */ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, // Timestamp
/* 32 - 33 */ 0xe8, 0x03, // Interval: 0x64, 0x00 => every 100ms - 0xe8, 0x03 => every 1s /* 32 - 33 */ 0xe8, 0x03, // Interval: 0x64, 0x00 => every 100ms - 0xe8, 0x03 => every 1s
/* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation /* 34 - 35 */ 0x31, 0x00, // capabilities Tnformation
// Tagged parameters // Tagged parameters
@@ -195,11 +196,9 @@ class Attack {
/* 85 - 86 */ 0x01, 0x00, /* 85 - 86 */ 0x01, 0x00,
/* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02, /* 87 - 90 */ 0x00, 0x0f, 0xac, 0x02,
/* 91 - 92 */ 0x02, 0x00, /* 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, /* 101 - 102 */ 0x01, 0x00,
/* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02, /* 103 - 106 */ 0x00, 0x0f, 0xac, 0x02,
/* 107 - 108 */ 0x00, 0x00 /* 107 - 108 */ 0x00, 0x00
}; };
}; };
#endif // ifndef Attack_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "CLI.h" #include "CLI.h"
#include <LittleFS.h> #include <LittleFS.h>

View File

@@ -1,5 +1,6 @@
#ifndef CLI_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define CLI_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
@@ -16,8 +17,8 @@ extern "C" {
#include "DisplayUI.h" #include "DisplayUI.h"
#include "led.h" #include "led.h"
extern Names names; extern Names names;
extern SSIDs ssids; extern SSIDs ssids;
extern Accesspoints accesspoints; extern Accesspoints accesspoints;
extern Stations stations; extern Stations stations;
extern Scan scan; extern Scan scan;
@@ -64,8 +65,8 @@ class CLI {
private: private:
bool enabled = false; bool enabled = false;
SimpleList<String>*list; SimpleList<String>* list;
SimpleList<String>*queue; SimpleList<String>* queue;
bool delayed = false; bool delayed = false;
uint32_t delayTime = 0; uint32_t delayTime = 0;
@@ -85,6 +86,4 @@ class CLI {
int toInt(String str); int toInt(String str);
uint32_t getTime(String time); uint32_t getTime(String time);
bool eqlsCMD(int i, const char* keyword); bool eqlsCMD(int i, const char* keyword);
}; };
#endif // ifndef CLI_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "DisplayUI.h" #include "DisplayUI.h"
#include "settings.h" #include "settings.h"

View File

@@ -1,5 +1,6 @@
#ifndef DisplayUI_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define DisplayUI_h
#pragma once
#include "language.h" #include "language.h"
#include "A_config.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, 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, 0xFC, 0x7F, 0x20, 0x08, 0x20, 0x08, 0x20, 0x08, 0xC0, 0x07, // 254
0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255 0x00, 0x00, 0x60, 0x40, 0x88, 0x67, 0x00, 0x1C, 0x88, 0x03, 0x60 // 255
}; };
#endif // ifndef DisplayUI_h

View File

@@ -1,5 +1,6 @@
#ifndef EEPROMHELPER_H /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define EEPROMHELPER_H
#pragma once
// ========== Includes ========== // // ========== Includes ========== //
#include <EEPROM.h> #include <EEPROM.h>
@@ -58,6 +59,4 @@ class EEPROMHelper {
for (unsigned long i = 0; i<size; i++) EEPROM.write(i, 0x00); for (unsigned long i = 0; i<size; i++) EEPROM.write(i, 0x00);
EEPROM.commit(); EEPROM.commit();
} }
}; };
#endif /* ifndef EEPROMHELPER_H */

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "Names.h" #include "Names.h"
#include <LittleFS.h> #include <LittleFS.h>
@@ -258,6 +260,7 @@ void Names::setMac(int num, String macStr) {
if (!check(num)) return; if (!check(num)) return;
uint8_t mac[6]; uint8_t mac[6];
strToMac(macStr, mac); strToMac(macStr, mac);
internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num)); internal_add(mac, getName(num), getBssid(num), getCh(num), getSelected(num));
prntln(N_CHANGED_MAC); prntln(N_CHANGED_MAC);
@@ -280,6 +283,7 @@ void Names::setBSSID(int num, String bssidStr) {
if (!check(num)) return; if (!check(num)) return;
uint8_t mac[6]; uint8_t mac[6];
strToMac(bssidStr, mac); strToMac(bssidStr, mac);
internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num)); internal_add(getMac(num), getName(num), mac, getCh(num), getSelected(num));
prntln(N_CHANGED_BSSID); prntln(N_CHANGED_BSSID);
@@ -362,6 +366,7 @@ String Names::getMacStr(int num) {
if (!check(num)) return String(); if (!check(num)) return String();
uint8_t* mac = getMac(num); uint8_t* mac = getMac(num);
return bytesToStr(mac, 6); 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; if ((ch < 1) || (ch > 14)) ch = 1;
Device newDevice; Device newDevice;
newDevice.mac = deviceMac; newDevice.mac = deviceMac;
newDevice.name = deviceName; newDevice.name = deviceName;
newDevice.apBssid = deviceBssid; newDevice.apBssid = deviceBssid;

View File

@@ -1,5 +1,6 @@
#ifndef Names_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define Names_h
#pragma once
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
extern "C" { extern "C" {
@@ -97,6 +98,4 @@ class Names {
void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected); void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected);
void internal_remove(int num); void internal_remove(int num);
void internal_removeAll(); void internal_removeAll();
}; };
#endif // ifndef Names_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "SSIDs.h" #include "SSIDs.h"
#include <LittleFS.h> #include <LittleFS.h>
@@ -42,6 +44,7 @@ void SSIDs::save(bool force) {
if (!force && !changed) return; if (!force && !changed) return;
String buf = String(); // create buffer String buf = String(); // create buffer
buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String( buf += String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SS_JSON_RANDOM) + String(DOUBLEQUOTES) + String(
DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false, DOUBLEPOINT) + b2s(randomMode) + String(COMMA); // {"random":false,
buf += String(DOUBLEQUOTES) + str(SS_JSON_SSIDS) + String(DOUBLEQUOTES) + String(DOUBLEPOINT) + 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; if (len > 32) len = 32;
SSID newSSID; SSID newSSID;
newSSID.name = randomize(name); newSSID.name = randomize(name);
newSSID.wpa2 = wpa2; newSSID.wpa2 = wpa2;
newSSID.len = (uint8_t)len; newSSID.len = (uint8_t)len;
@@ -301,6 +305,7 @@ void SSIDs::internal_add(String name, bool wpa2, int len) {
name = fixUtf8(name); name = fixUtf8(name);
SSID newSSID; SSID newSSID;
newSSID.name = name; newSSID.name = name;
newSSID.wpa2 = wpa2; newSSID.wpa2 = wpa2;
newSSID.len = (uint8_t)len; newSSID.len = (uint8_t)len;
@@ -314,4 +319,4 @@ void SSIDs::internal_remove(int num) {
void SSIDs::internal_removeAll() { void SSIDs::internal_removeAll() {
list->clear(); list->clear();
} }

View File

@@ -1,5 +1,6 @@
#ifndef SSIDs_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define SSIDs_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
@@ -80,6 +81,4 @@ class SSIDs {
void internal_add(String name, bool wpa2, int add); void internal_add(String name, bool wpa2, int add);
void internal_remove(int num); void internal_remove(int num);
void internal_removeAll(); void internal_removeAll();
}; };
#endif // ifndef SSIDs_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "Scan.h" #include "Scan.h"
#include "settings.h" #include "settings.h"

View File

@@ -1,5 +1,6 @@
#ifndef Scan_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define Scan_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include "Accesspoints.h" #include "Accesspoints.h"
@@ -23,7 +24,7 @@ extern Stations stations;
extern Names names; extern Names names;
extern SSIDs ssids; extern SSIDs ssids;
extern uint8_t wifiMode; extern uint8_t wifiMode;
extern void setWifiChannel(uint8_t ch); extern void setWifiChannel(uint8_t ch);
extern bool appendFile(String path, String& buf); extern bool appendFile(String path, String& buf);
@@ -90,6 +91,4 @@ class Scan {
int findAccesspoint(uint8_t* mac); int findAccesspoint(uint8_t* mac);
String FILE_PATH = "/scan.json"; String FILE_PATH = "/scan.json";
}; };
#endif // ifndef Scan_h

View File

@@ -1,12 +1,6 @@
#ifndef SimpleList_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define SimpleList_h
/* #pragma once
===========================================
Copyright (c) 2018 Stefan Kremser
github.com/spacehuhn
===========================================
*/
#include <type_traits> #include <type_traits>
#include <cstddef> #include <cstddef>
@@ -166,6 +160,7 @@ void SimpleList<T>::add(int index, T obj) {
} }
SimpleListNode<T>* newNode = new SimpleListNode<T>(); SimpleListNode<T>* newNode = new SimpleListNode<T>();
newNode->data = obj; newNode->data = obj;
if (index == 0) { if (index == 0) {
@@ -191,6 +186,7 @@ void SimpleList<T>::insert(T obj) {
// create new node // create new node
SimpleListNode<T>* newNode = new SimpleListNode<T>(); SimpleListNode<T>* newNode = new SimpleListNode<T>();
newNode->data = obj; newNode->data = obj;
if (listSize == 0) { if (listSize == 0) {
@@ -516,6 +512,4 @@ void SimpleList<T>::sort() {
} }
this->sorted = true; this->sorted = true;
} }
#endif // ifndef SimpleList_h

View File

@@ -1,3 +1,5 @@
/* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#include "Stations.h" #include "Stations.h"
Stations::Stations() { Stations::Stations() {
@@ -133,6 +135,7 @@ String Stations::getAPMacStr(int num) {
if (!check(num)) return String(); if (!check(num)) return String();
uint8_t* mac = getAPMac(num); uint8_t* mac = getAPMac(num);
return bytesToStr(mac, 6); return bytesToStr(mac, 6);
} }
@@ -164,6 +167,7 @@ String Stations::getMacStr(int num) {
if (!check(num)) return String(); if (!check(num)) return String();
uint8_t* mac = getMac(num); uint8_t* mac = getMac(num);
return bytesToStr(mac, 6); return bytesToStr(mac, 6);
} }
@@ -256,7 +260,7 @@ void Stations::remove(int num) {
prnt(ST_REMOVED_STATION); prnt(ST_REMOVED_STATION);
prntln(num); prntln(num);
internal_remove(num); internal_remove(num);
changed = true; changed = true;
} }
@@ -342,6 +346,7 @@ void Stations::internal_add(uint8_t* mac, int accesspointNum) {
if (count() >= STATION_LIST_SIZE) removeOldest(); if (count() >= STATION_LIST_SIZE) removeOldest();
Station newStation; Station newStation;
newStation.ap = accesspointNum; newStation.ap = accesspointNum;
newStation.ch = wifi_channel; newStation.ch = wifi_channel;
newStation.mac = (uint8_t*)malloc(6); newStation.mac = (uint8_t*)malloc(6);
@@ -365,4 +370,4 @@ void Stations::internal_removeAll() {
free(getTime(i)); free(getTime(i));
} }
list->clear(); list->clear();
} }

View File

@@ -1,5 +1,6 @@
#ifndef Stations_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define Stations_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
extern "C" { extern "C" {
@@ -93,6 +94,4 @@ class Stations {
void internal_add(uint8_t* mac, int accesspointNum); void internal_add(uint8_t* mac, int accesspointNum);
void internal_remove(int num); void internal_remove(int num);
void internal_removeAll(); void internal_removeAll();
}; };
#endif // ifndef Stations_h

View File

@@ -1,8 +1,4 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#pragma once #pragma once

View File

@@ -1,9 +1,7 @@
/* /* =====================
=========================================== This software is licensed under the MIT License:
Copyright (c) 2018 Stefan Kremser https://github.com/spacehuhntech/esp8266_deauther
github.com/spacehuhn ===================== */
===========================================
*/
extern "C" { extern "C" {
// Please follow this tutorial: // Please follow this tutorial:

View File

@@ -1,5 +1,6 @@
#ifndef functions_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define functions_h
#pragma once
#include "Arduino.h" #include "Arduino.h"
#include <LittleFS.h> #include <LittleFS.h>
@@ -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)) return String(bytes / 1024.0) + "KB";
else if (bytes < (1024 * 1024 * 1024)) return String(bytes / 1024.0 / 1024.0) + "MB"; 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"; else return String(bytes / 1024.0 / 1024.0 / 1024.0) + "GB";
} }
#endif // ifndef functions_h

View File

@@ -1,5 +1,6 @@
#ifndef language_h /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
#define language_h
#pragma once
#include "Arduino.h" #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_BAD_PATH[] PROGMEM = "BAD PATH";
const char W_FILE_NOT_FOUND[] PROGMEM = "ERROR 404 File Not Found"; const char W_FILE_NOT_FOUND[] PROGMEM = "ERROR 404 File Not Found";
const char W_STARTED_AP[] PROGMEM = "Started AP"; 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_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
const char W_HTML[] PROGMEM = "text/html"; const char W_HTML[] PROGMEM = "text/html";
@@ -619,5 +620,4 @@ const char S_JSON_LEDENABLED[] PROGMEM = "led";
// Display // Display
const char S_JSON_DISPLAYINTERFACE[] PROGMEM = "display"; const char S_JSON_DISPLAYINTERFACE[] PROGMEM = "display";
const char S_JSON_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout"; const char S_JSON_DISPLAY_TIMEOUT[] PROGMEM = "displayTimeout";
#endif // ifndef language_h

View File

@@ -1,8 +1,4 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#include "led.h" #include "led.h"

View File

@@ -1,8 +1,4 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#pragma once #pragma once
@@ -14,7 +10,7 @@ enum LED_MODE {
}; };
namespace led { namespace led {
void setup(); void setup();
void update(); void update();
void setMode(LED_MODE new_mode, bool force = false); void setMode(LED_MODE new_mode, bool force = false);
} }

View File

@@ -1,13 +1,9 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#include "settings.h" #include "settings.h"
#include "A_config.h" // Default Settings #include "A_config.h" // Default Settings
#include "language.h" // prnt and prntln #include "language.h" // prnt and prntln
#include "EEPROMHelper.h" // To load and save settings_t #include "EEPROMHelper.h" // To load and save settings_t
#include "debug.h" #include "debug.h"
@@ -17,29 +13,29 @@ extern bool writeFile(String path, String& buf);
extern void getRandomMac(uint8_t* mac); extern void getRandomMac(uint8_t* mac);
extern bool macValid(uint8_t* mac); extern bool macValid(uint8_t* mac);
#define JSON_FLAG(_NAME,_VALUE)\ #define JSON_FLAG(_NAME, _VALUE)\
str += String('"') + String(FPSTR(_NAME)) + String(F("\":")) + String(_VALUE?"true":"false") + String(','); 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("\",")); 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(','); 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("\":\""));\ str += String('"') + String(FPSTR(_NAME)) + String(F("\":\""));\
for (int i = 0; i<_LEN; i++) {\ for (int i = 0; i<_LEN; i++) {\
if (i > 0) str += ':';\ if (i > 0) str += ':';\
if (_BYTES[i] < 0x10) str += '0';\ if (_BYTES[i] < 0x10) str += '0';\
str += String(_BYTES[i], HEX);\ str += String(_BYTES[i], HEX);\
}\ }\
str += String(F("\",")); str += String(F("\","));
#define JSON_DEC(_NAME,_BYTES,_LEN)\ #define JSON_DEC(_NAME, _BYTES, _LEN)\
str += String(F("\"")) + String(FPSTR(_NAME)) + String(F("\":\""));\ str += String(F("\"")) + String(FPSTR(_NAME)) + String(F("\":\""));\
for (int i = 0; i<_LEN; i++) {\ for (int i = 0; i<_LEN; i++) {\
if (i > 0) str += '.';\ if (i > 0) str += '.';\
str += String(_BYTES[i]);\ str += String(_BYTES[i]);\
}\ }\
str += String(F("\",")); str += String(F("\","));
@@ -47,7 +43,7 @@ extern bool macValid(uint8_t* mac);
namespace settings { namespace settings {
// ========== PRIVATE ========== // // ========== PRIVATE ========== //
const char* SETTINGS_PATH = "/settings.json"; const char* SETTINGS_PATH = "/settings.json";
settings_t data; settings_t data;
bool changed = false; bool changed = false;
@@ -56,7 +52,7 @@ namespace settings {
str.reserve(600); str.reserve(600);
str += '{'; str += '{';
// Version // Version
JSON_VALUE(S_JSON_VERSION, DEAUTHER_VERSION); JSON_VALUE(S_JSON_VERSION, DEAUTHER_VERSION);
@@ -104,7 +100,7 @@ namespace settings {
// Display // Display
JSON_FLAG(S_JSON_DISPLAYINTERFACE, data.display.enabled); JSON_FLAG(S_JSON_DISPLAYINTERFACE, data.display.enabled);
JSON_INT(S_JSON_DISPLAY_TIMEOUT, data.display.timeout); JSON_INT(S_JSON_DISPLAY_TIMEOUT, data.display.timeout);
str.setCharAt(str.length()-1, '}'); str.setCharAt(str.length()-1, '}');
} }
@@ -114,21 +110,23 @@ namespace settings {
// read data from eeproms // read data from eeproms
settings_t newData; settings_t newData;
EEPROMHelper::getObject(SETTINGS_ADDR, newData); EEPROMHelper::getObject(SETTINGS_ADDR, newData);
// calc and check hash // calc and check hash
if (newData.magic_num == MAGIC_NUM) { if (newData.magic_num == MAGIC_NUM) {
data = newData; data = newData;
data.version.major = DEAUTHER_VERSION_MAJOR; data.version.major = DEAUTHER_VERSION_MAJOR;
data.version.minor = DEAUTHER_VERSION_MINOR; data.version.minor = DEAUTHER_VERSION_MINOR;
data.version.revision = DEAUTHER_VERSION_REVISION; data.version.revision = DEAUTHER_VERSION_REVISION;
debuglnF("OK"); debuglnF("OK");
save(); save();
} else { } else {
debuglnF("Invalid Hash"); debuglnF("Invalid Hash");
/*debug(data.magic_num); /*debug(data.magic_num);
debugF(" != "); debugF(" != ");
debugln(MAGIC_NUM);*/ debugln(MAGIC_NUM);*/
reset(); reset();
save(); save();
@@ -143,47 +141,48 @@ namespace settings {
void reset() { void reset() {
data.magic_num = MAGIC_NUM; data.magic_num = MAGIC_NUM;
data.version.major = DEAUTHER_VERSION_MAJOR; data.version.major = DEAUTHER_VERSION_MAJOR;
data.version.minor = DEAUTHER_VERSION_MINOR; data.version.minor = DEAUTHER_VERSION_MINOR;
data.version.revision = DEAUTHER_VERSION_REVISION; data.version.revision = DEAUTHER_VERSION_REVISION;
data.attack.attack_all_ch = ATTACK_ALL_CH; data.attack.attack_all_ch = ATTACK_ALL_CH;
data.attack.random_tx = RANDOM_TX; data.attack.random_tx = RANDOM_TX;
data.attack.timeout = ATTACK_TIMEOUT; data.attack.timeout = ATTACK_TIMEOUT;
data.attack.deauths_per_target = DEAUTHS_PER_TARGET; data.attack.deauths_per_target = DEAUTHS_PER_TARGET;
data.attack.deauth_reason = DEAUTH_REASON; data.attack.deauth_reason = DEAUTH_REASON;
data.attack.beacon_interval = beacon_interval_t::INTERVAL_100MS; data.attack.beacon_interval = beacon_interval_t::INTERVAL_100MS;
data.attack.probe_frames_per_ssid = PROBE_FRAMES_PER_SSID; data.attack.probe_frames_per_ssid = PROBE_FRAMES_PER_SSID;
data.wifi.channel = 1; data.wifi.channel = 1;
getRandomMac(data.wifi.mac_st); getRandomMac(data.wifi.mac_st);
getRandomMac(data.wifi.mac_ap); 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; data.sniffer.min_deauth_frames = MIN_DEAUTH_FRAMES;
strncpy(data.ap.ssid, AP_SSID, 32); strncpy(data.ap.ssid, AP_SSID, 32);
strncpy(data.ap.password, AP_PASSWD, 64); strncpy(data.ap.password, AP_PASSWD, 64);
data.ap.hidden = AP_HIDDEN; data.ap.hidden = AP_HIDDEN;
uint8_t ip[4] = AP_IP_ADDR; uint8_t ip[4] = AP_IP_ADDR;
memcpy(data.ap.ip, ip, 4); 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.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); memcpy(data.web.lang, DEFAULT_LANG, 3);
data.cli.enabled = CLI_ENABLED; data.cli.enabled = CLI_ENABLED;
data.cli.serial_echo = CLI_ECHO; data.cli.serial_echo = CLI_ECHO;
data.led.enabled = USE_LED; data.led.enabled = USE_LED;
data.display.enabled = USE_DISPLAY; data.display.enabled = USE_DISPLAY;
data.display.timeout = DISPLAY_TIMEOUT; data.display.timeout = DISPLAY_TIMEOUT;
changed = true; changed = true;
debuglnF("Settings reset to default"); debuglnF("Settings reset to default");
} }
@@ -192,7 +191,7 @@ namespace settings {
EEPROMHelper::saveObject(SETTINGS_ADDR, data); EEPROMHelper::saveObject(SETTINGS_ADDR, data);
changed = false; changed = false;
String json_buffer; String json_buffer;
get_json(json_buffer); get_json(json_buffer);
@@ -205,9 +204,10 @@ namespace settings {
debugln(SETTINGS_PATH); debugln(SETTINGS_PATH);
} }
} }
void print() { void print() {
String json_buffer; String json_buffer;
get_json(json_buffer); get_json(json_buffer);
json_buffer.replace("\":", ": "); json_buffer.replace("\":", ": ");
@@ -267,7 +267,7 @@ namespace settings {
const display_settings_t& getDisplaySettings() { const display_settings_t& getDisplaySettings() {
return data.display; return data.display;
} }
// ===== SETTERS ===== // // ===== SETTERS ===== //
void setAllSettings(settings_t& newSettings) { void setAllSettings(settings_t& newSettings) {

View File

@@ -1,12 +1,8 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#pragma once #pragma once
#include <Arduino.h> // Arduino String, Serial #include <Arduino.h> // Arduino String, Serial
#include "A_config.h" #include "A_config.h"
// ===== VERSION ===== // // ===== VERSION ===== //
@@ -24,7 +20,7 @@ typedef struct autosave_settings_t {
// ===== ATTACK ===== // // ===== ATTACK ===== //
typedef enum beacon_interval_t { typedef enum beacon_interval_t {
INTERVAL_1S = 0, INTERVAL_1S = 0,
INTERVAL_100MS = 1 INTERVAL_100MS = 1
} beacon_interval_t; } beacon_interval_t;
@@ -114,11 +110,11 @@ namespace settings {
void print(); void print();
const settings_t& getAllSettings(); const settings_t& getAllSettings();
const version_t & getVersion(); const version_t& getVersion();
const autosave_settings_t& getAutosaveSettings(); const autosave_settings_t& getAutosaveSettings();
const attack_settings_t & getAttackSettings(); const attack_settings_t& getAttackSettings();
const wifi_settings_t & getWifiSettings(); const wifi_settings_t& getWifiSettings();
const sniffer_settings_t & getSnifferSettings(); const sniffer_settings_t& getSnifferSettings();
const access_point_settings_t& getAccessPointSettings(); const access_point_settings_t& getAccessPointSettings();
const web_settings_t& getWebSettings(); const web_settings_t& getWebSettings();
const cli_settings_t& getCLISettings(); const cli_settings_t& getCLISettings();

View File

@@ -1,8 +1,4 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#include "wifi.h" #include "wifi.h"

View File

@@ -1,8 +1,4 @@
/* /* This software is licensed under the MIT License: https://github.com/spacehuhntech/esp8266_deauther */
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
*/
#pragma once #pragma once
@@ -13,13 +9,13 @@ namespace wifi {
String getMode(); String getMode();
void printStatus(); void printStatus();
void startNewAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal); 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 startAP();
void stopAP(); void stopAP();
void resumeAP(); void resumeAP();
void update(); void update();
} }