mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-22 15:16:47 -08:00
New string functions & better seperation of display functions
This commit is contained in:
@@ -68,15 +68,15 @@ void Accesspoints::print(int num, bool header, bool footer) {
|
|||||||
prntln(AP_TABLE_HEADER);
|
prntln(AP_TABLE_HEADER);
|
||||||
prntln(AP_TABLE_DIVIDER);
|
prntln(AP_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
prnt(buildString(String(), (String)num, 2));
|
prnt(leftRight(String(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE) + getSSID(num), String(), 33));
|
prnt(leftRight(String(SPACE) + getSSID(num), String(), 33));
|
||||||
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
prnt(leftRight(String(SPACE) + getNameStr(num), String(), 17));
|
||||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
prnt(leftRight(String(SPACE), (String)getCh(num), 3));
|
||||||
prnt(buildString(String(SPACE), (String)getRSSI(num), 5));
|
prnt(leftRight(String(SPACE), (String)getRSSI(num), 5));
|
||||||
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
prnt(leftRight(String(SPACE), getEncStr(num), 5));
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prnt(leftRight(String(SPACE) + getMacStr(num), String(), 18));
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
prnt(leftRight(String(SPACE) + getVendorStr(num), String(), 9));
|
||||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
prntln(leftRight(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
prntln(AP_TABLE_DIVIDER);
|
prntln(AP_TABLE_DIVIDER);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ extern "C" {
|
|||||||
extern Names names;
|
extern Names names;
|
||||||
|
|
||||||
extern String searchVendor(uint8_t* mac);
|
extern String searchVendor(uint8_t* mac);
|
||||||
extern String buildString(String left, String right, int maxLen);
|
extern String leftRight(String a, String b, int len);
|
||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,11 @@ extern Scan scan;
|
|||||||
extern Attack attack;
|
extern Attack attack;
|
||||||
extern uint32_t currentTime;
|
extern uint32_t currentTime;
|
||||||
|
|
||||||
extern String buildString(String left, String right, int maxLen);
|
extern String leftRight(String a, String b, int len);
|
||||||
|
extern String center(String a, int len);
|
||||||
|
extern String left(String a, int len);
|
||||||
|
extern String right(String a, int len);
|
||||||
|
extern String leftRight(String a, String b, int len);
|
||||||
extern String replaceUtf8(String str, String r);
|
extern String replaceUtf8(String str, String r);
|
||||||
|
|
||||||
// different display modes
|
// different display modes
|
||||||
@@ -82,6 +86,19 @@ class DisplayUI {
|
|||||||
bool highlightLED = false;
|
bool highlightLED = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ===== adjustable ===== //
|
||||||
|
void configInit();
|
||||||
|
void configOn();
|
||||||
|
void configOff();
|
||||||
|
void updatePrefix();
|
||||||
|
void updateSuffix();
|
||||||
|
void drawString(int x, int y, String str);
|
||||||
|
void drawString(int row, String str);
|
||||||
|
void drawLine(int x1, int y1, int x2, int y2);
|
||||||
|
uint8_t maxLen = 18;
|
||||||
|
uint8_t lineHeight = 12;
|
||||||
|
// ====================== //
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void on();
|
void on();
|
||||||
void off();
|
void off();
|
||||||
@@ -112,12 +129,13 @@ class DisplayUI {
|
|||||||
bool deauthSelected = false;
|
bool deauthSelected = false;
|
||||||
bool probeSelected = false;
|
bool probeSelected = false;
|
||||||
|
|
||||||
|
String getChannel();
|
||||||
|
|
||||||
// functions for buttons
|
// functions for buttons
|
||||||
bool updateButton(Button* button); // read and update
|
bool updateButton(Button* button); // read and update
|
||||||
|
|
||||||
// draw functions
|
// draw functions
|
||||||
void draw();
|
void draw();
|
||||||
void drawString(int x, int y, String str);
|
|
||||||
void drawButtonTest();
|
void drawButtonTest();
|
||||||
void drawMenu();
|
void drawMenu();
|
||||||
void drawLoadingScan();
|
void drawLoadingScan();
|
||||||
|
|||||||
@@ -143,13 +143,13 @@ void Names::print(int num, bool header, bool footer) {
|
|||||||
prntln(N_TABLE_DIVIDER);
|
prntln(N_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
prnt(buildString(String(), (String)num, 2));
|
prnt(leftRight(String(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prnt(leftRight(String(SPACE) + getMacStr(num), String(), 18));
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
prnt(leftRight(String(SPACE) + getVendorStr(num), String(), 9));
|
||||||
prnt(buildString(String(SPACE) + getName(num), String(), 17));
|
prnt(leftRight(String(SPACE) + getName(num), String(), 17));
|
||||||
prnt(buildString(String(SPACE) + getBssidStr(num), String(), 18));
|
prnt(leftRight(String(SPACE) + getBssidStr(num), String(), 18));
|
||||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
prnt(leftRight(String(SPACE), (String)getCh(num), 3));
|
||||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
prntln(leftRight(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||||
|
|
||||||
if (footer) prntln(N_TABLE_DIVIDER);
|
if (footer) prntln(N_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,104 +1,104 @@
|
|||||||
#ifndef Names_h
|
#ifndef Names_h
|
||||||
#define Names_h
|
#define Names_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "SimpleList.h"
|
#include "SimpleList.h"
|
||||||
|
|
||||||
#define NAME_LIST_SIZE 25
|
#define NAME_LIST_SIZE 25
|
||||||
#define NAME_MAX_LENGTH 16
|
#define NAME_MAX_LENGTH 16
|
||||||
|
|
||||||
extern void checkFile(String path, String data);
|
extern void checkFile(String path, String data);
|
||||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||||
extern bool writeFile(String path, String& buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern bool appendFile(String path, String& buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool strToMac(String macStr, uint8_t* mac);
|
extern bool strToMac(String macStr, uint8_t* mac);
|
||||||
extern String searchVendor(uint8_t* mac);
|
extern String searchVendor(uint8_t* mac);
|
||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
extern String buildString(String left, String right, int maxLen);
|
extern String leftRight(String a, String b, int len);
|
||||||
extern String escape(String str);
|
extern String escape(String str);
|
||||||
extern String bytesToStr(uint8_t* b, uint32_t size);
|
extern String bytesToStr(uint8_t* b, uint32_t size);
|
||||||
|
|
||||||
class Names {
|
class Names {
|
||||||
public:
|
public:
|
||||||
Names();
|
Names();
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void load(String filepath);
|
void load(String filepath);
|
||||||
void save(bool force);
|
void save(bool force);
|
||||||
void save(bool force, String filepath);
|
void save(bool force, String filepath);
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
String find(uint8_t* mac);
|
String find(uint8_t* mac);
|
||||||
int findID(uint8_t* mac);
|
int findID(uint8_t* mac);
|
||||||
|
|
||||||
void print(int num);
|
void print(int num);
|
||||||
void print(int num, bool header, bool footer);
|
void print(int num, bool header, bool footer);
|
||||||
void select(int num);
|
void select(int num);
|
||||||
void select(String name);
|
void select(String name);
|
||||||
void deselect(int num);
|
void deselect(int num);
|
||||||
void deselect(String name);
|
void deselect(String name);
|
||||||
void add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force);
|
void add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected, bool force);
|
||||||
void add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force);
|
void add(String macStr, String name, String bssidStr, uint8_t ch, bool selected, bool force);
|
||||||
void replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected);
|
void replace(int num, String macStr, String name, String bssidStr, uint8_t ch, bool selected);
|
||||||
void remove(int num);
|
void remove(int num);
|
||||||
|
|
||||||
void printAll();
|
void printAll();
|
||||||
void printSelected();
|
void printSelected();
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void deselectAll();
|
void deselectAll();
|
||||||
void removeAll();
|
void removeAll();
|
||||||
|
|
||||||
uint8_t* getMac(int num);
|
uint8_t* getMac(int num);
|
||||||
uint8_t* getBssid(int num);
|
uint8_t* getBssid(int num);
|
||||||
String getMacStr(int num);
|
String getMacStr(int num);
|
||||||
String getBssidStr(int num);
|
String getBssidStr(int num);
|
||||||
String getName(int num);
|
String getName(int num);
|
||||||
String getVendorStr(int num);
|
String getVendorStr(int num);
|
||||||
String getSelectedStr(int num);
|
String getSelectedStr(int num);
|
||||||
uint8_t getCh(int num);
|
uint8_t getCh(int num);
|
||||||
bool getSelected(int num);
|
bool getSelected(int num);
|
||||||
bool isStation(int num);
|
bool isStation(int num);
|
||||||
|
|
||||||
void setName(int num, String name);
|
void setName(int num, String name);
|
||||||
void setMac(int num, String macStr);
|
void setMac(int num, String macStr);
|
||||||
void setCh(int num, uint8_t ch);
|
void setCh(int num, uint8_t ch);
|
||||||
void setBSSID(int num, String bssidStr);
|
void setBSSID(int num, String bssidStr);
|
||||||
|
|
||||||
int count();
|
int count();
|
||||||
int selected();
|
int selected();
|
||||||
int stations();
|
int stations();
|
||||||
|
|
||||||
bool check(int num);
|
bool check(int num);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String FILE_PATH = "/names.json";
|
String FILE_PATH = "/names.json";
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
struct Device {
|
struct Device {
|
||||||
uint8_t* mac; // mac address
|
uint8_t* mac; // mac address
|
||||||
char * name; // name of saved device
|
char * name; // name of saved device
|
||||||
uint8_t* apBssid; // mac address of AP (if saved device is a station)
|
uint8_t* apBssid; // mac address of AP (if saved device is a station)
|
||||||
uint8_t ch; // Wi-Fi channel of Device
|
uint8_t ch; // Wi-Fi channel of Device
|
||||||
bool selected; // select for attacking
|
bool selected; // select for attacking
|
||||||
};
|
};
|
||||||
|
|
||||||
SimpleList<Device>* list;
|
SimpleList<Device>* list;
|
||||||
|
|
||||||
int binSearch(uint8_t* searchBytes, int lowerEnd, int upperEnd);
|
int binSearch(uint8_t* searchBytes, int lowerEnd, int upperEnd);
|
||||||
bool internal_check(int num);
|
bool internal_check(int num);
|
||||||
void internal_select(int num);
|
void internal_select(int num);
|
||||||
void internal_deselect(int num);
|
void internal_deselect(int num);
|
||||||
void internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected);
|
void internal_add(uint8_t* mac, String name, uint8_t* bssid, uint8_t ch, bool selected);
|
||||||
void internal_add(String macStr, String name, String bssidStr, uint8_t ch, bool selected);
|
void internal_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
|
#endif // ifndef Names_h
|
||||||
|
|||||||
@@ -254,9 +254,9 @@ void SSIDs::print(int num, bool header, bool footer) {
|
|||||||
prntln(SS_TABLE_DIVIDER);
|
prntln(SS_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
prnt(buildString(String(), (String)num, 2));
|
prnt(leftRight(String(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE), getEncStr(num), 5));
|
prnt(leftRight(String(SPACE), getEncStr(num), 5));
|
||||||
prntln(buildString(String(SPACE) + getName(num), String(), 33));
|
prntln(leftRight(String(SPACE) + getName(num), String(), 33));
|
||||||
|
|
||||||
if (footer) prntln(SS_TABLE_DIVIDER);
|
if (footer) prntln(SS_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,87 +1,87 @@
|
|||||||
#ifndef SSIDs_h
|
#ifndef SSIDs_h
|
||||||
#define SSIDs_h
|
#define SSIDs_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "SimpleList.h"
|
#include "SimpleList.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "Accesspoints.h"
|
#include "Accesspoints.h"
|
||||||
|
|
||||||
#define SSID_LIST_SIZE 60
|
#define SSID_LIST_SIZE 60
|
||||||
|
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
extern uint32_t currentTime;
|
extern uint32_t currentTime;
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
|
|
||||||
extern void checkFile(String path, String data);
|
extern void checkFile(String path, String data);
|
||||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer);
|
||||||
extern bool appendFile(String path, String& buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool writeFile(String path, String& buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern void readFileToSerial(String path);
|
extern void readFileToSerial(String path);
|
||||||
extern String fixUtf8(String str);
|
extern String fixUtf8(String str);
|
||||||
extern String buildString(String left, String right, int maxLen);
|
extern String leftRight(String a, String b, int len);
|
||||||
extern String escape(String str);
|
extern String escape(String str);
|
||||||
|
|
||||||
class SSIDs {
|
class SSIDs {
|
||||||
public:
|
public:
|
||||||
SSIDs();
|
SSIDs();
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void load(String filepath);
|
void load(String filepath);
|
||||||
void save(bool force);
|
void save(bool force);
|
||||||
void save(bool force, String filepath);
|
void save(bool force, String filepath);
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void print(int num);
|
void print(int num);
|
||||||
void print(int num, bool header, bool footer);
|
void print(int num, bool header, bool footer);
|
||||||
void add(String name, bool wpa2, int clones, bool force);
|
void add(String name, bool wpa2, int clones, bool force);
|
||||||
void cloneSelected(bool force);
|
void cloneSelected(bool force);
|
||||||
void remove(int num);
|
void remove(int num);
|
||||||
void enableRandom(uint32_t randomInterval);
|
void enableRandom(uint32_t randomInterval);
|
||||||
void disableRandom();
|
void disableRandom();
|
||||||
bool getRandom();
|
bool getRandom();
|
||||||
|
|
||||||
String getName(int num);
|
String getName(int num);
|
||||||
bool getWPA2(int num);
|
bool getWPA2(int num);
|
||||||
String getEncStr(int num);
|
String getEncStr(int num);
|
||||||
int getLen(int num);
|
int getLen(int num);
|
||||||
|
|
||||||
void setWPA2(int num, bool wpa2);
|
void setWPA2(int num, bool wpa2);
|
||||||
void replace(int num, String name, bool wpa2);
|
void replace(int num, String name, bool wpa2);
|
||||||
|
|
||||||
void printAll();
|
void printAll();
|
||||||
void removeAll();
|
void removeAll();
|
||||||
|
|
||||||
int count();
|
int count();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool randomMode = false;
|
bool randomMode = false;
|
||||||
uint32_t randomInterval = 2000;
|
uint32_t randomInterval = 2000;
|
||||||
uint32_t randomTime = 0;
|
uint32_t randomTime = 0;
|
||||||
|
|
||||||
struct SSID {
|
struct SSID {
|
||||||
String name; // SSID
|
String name; // SSID
|
||||||
bool wpa2; // WPA2 encrypted or not
|
bool wpa2; // WPA2 encrypted or not
|
||||||
uint8_t len; // original length (before editing it to be 32 characters)
|
uint8_t len; // original length (before editing it to be 32 characters)
|
||||||
};
|
};
|
||||||
|
|
||||||
String FILE_PATH = "/ssids.json";
|
String FILE_PATH = "/ssids.json";
|
||||||
|
|
||||||
SimpleList<SSID>* list;
|
SimpleList<SSID>* list;
|
||||||
|
|
||||||
bool check(int num);
|
bool check(int num);
|
||||||
String randomize(String name);
|
String randomize(String name);
|
||||||
|
|
||||||
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
|
#endif // ifndef SSIDs_h
|
||||||
|
|||||||
@@ -1,426 +1,443 @@
|
|||||||
#include "Scan.h"
|
#include "Scan.h"
|
||||||
|
|
||||||
Scan::Scan() {
|
Scan::Scan() {
|
||||||
list = new SimpleList<uint16_t>;
|
list = new SimpleList<uint16_t>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
void Scan::sniffer(uint8_t* buf, uint16_t len) {
|
||||||
if (!isSniffing()) return;
|
if (!isSniffing()) return;
|
||||||
|
|
||||||
packets++;
|
packets++;
|
||||||
|
|
||||||
if (len < 28) return; // drop frames that are too short to have a valid MAC header
|
if (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++;
|
tmpDeauths++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop beacon frames, probe requests/responses and deauth/disassociation frames
|
// 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
|
// only allow data frames
|
||||||
// if(buf[12] != 0x08 && buf[12] != 0x88) return;
|
// if(buf[12] != 0x08 && buf[12] != 0x88) return;
|
||||||
|
|
||||||
uint8_t* macTo = &buf[16];
|
uint8_t* macTo = &buf[16];
|
||||||
uint8_t* macFrom = &buf[22];
|
uint8_t* macFrom = &buf[22];
|
||||||
|
|
||||||
if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) ||
|
if (macBroadcast(macTo) || macBroadcast(macFrom) || !macValid(macTo) || !macValid(macFrom) || macMulticast(macTo) ||
|
||||||
macMulticast(macFrom)) return;
|
macMulticast(macFrom)) return;
|
||||||
|
|
||||||
int accesspointNum = findAccesspoint(macFrom);
|
int accesspointNum = findAccesspoint(macFrom);
|
||||||
|
|
||||||
if (accesspointNum >= 0) {
|
if (accesspointNum >= 0) {
|
||||||
stations.add(macTo, accesspoints.getID(accesspointNum));
|
stations.add(macTo, accesspoints.getID(accesspointNum));
|
||||||
} else {
|
} else {
|
||||||
accesspointNum = findAccesspoint(macTo);
|
accesspointNum = findAccesspoint(macTo);
|
||||||
|
|
||||||
if (accesspointNum >= 0) {
|
if (accesspointNum >= 0) {
|
||||||
stations.add(macFrom, accesspoints.getID(accesspointNum));
|
stations.add(macFrom, accesspoints.getID(accesspointNum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scan::findAccesspoint(uint8_t* mac) {
|
int Scan::findAccesspoint(uint8_t* mac) {
|
||||||
for (int i = 0; i < accesspoints.count(); i++) {
|
for (int i = 0; i < accesspoints.count(); i++) {
|
||||||
if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i;
|
if (memcmp(accesspoints.getMac(i), mac, 6) == 0) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::start(uint8_t mode) {
|
void Scan::start(uint8_t mode) {
|
||||||
start(mode, sniffTime, scan_continue_mode, continueTime, channelHop, wifi_channel);
|
start(mode, sniffTime, scan_continue_mode, continueTime, channelHop, wifi_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
||||||
uint8_t channel) {
|
uint8_t channel) {
|
||||||
if (mode != SCAN_MODE_OFF) stop();
|
if (mode != SCAN_MODE_OFF) stop();
|
||||||
|
|
||||||
setWifiChannel(channel);
|
setWifiChannel(channel);
|
||||||
Scan::continueStartTime = currentTime;
|
Scan::continueStartTime = currentTime;
|
||||||
Scan::snifferPacketTime = continueStartTime;
|
Scan::snifferPacketTime = continueStartTime;
|
||||||
Scan::snifferOutputTime = continueStartTime;
|
Scan::snifferOutputTime = continueStartTime;
|
||||||
Scan::continueTime = continueTime;
|
Scan::continueTime = continueTime;
|
||||||
Scan::sniffTime = time;
|
Scan::sniffTime = time;
|
||||||
Scan::channelHop = channelHop;
|
Scan::channelHop = channelHop;
|
||||||
Scan::scanMode = mode;
|
Scan::scanMode = mode;
|
||||||
Scan::scan_continue_mode = nextmode;
|
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,
|
// 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);
|
// time, scan_continue_mode, continueTime, channelHop, channel);
|
||||||
|
|
||||||
/* AP Scan */
|
/* AP Scan */
|
||||||
if ((mode == SCAN_MODE_APS) || (mode == SCAN_MODE_ALL)) {
|
if ((mode == SCAN_MODE_APS) || (mode == SCAN_MODE_ALL)) {
|
||||||
// remove old results
|
// remove old results
|
||||||
accesspoints.removeAll();
|
accesspoints.removeAll();
|
||||||
stations.removeAll();
|
stations.removeAll();
|
||||||
// start AP scan
|
// start AP scan
|
||||||
prntln(SC_START_AP);
|
prntln(SC_START_AP);
|
||||||
WiFi.scanNetworks(true, true);
|
WiFi.scanNetworks(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Station Scan */
|
/* Station Scan */
|
||||||
else if (mode == SCAN_MODE_STATIONS) {
|
else if (mode == SCAN_MODE_STATIONS) {
|
||||||
// start station scan
|
// start station scan
|
||||||
if (accesspoints.count() < 1) {
|
if (accesspoints.count() < 1) {
|
||||||
start(SCAN_MODE_ALL);
|
start(SCAN_MODE_ALL);
|
||||||
// Serial.println(str(SC_ERROR_NO_AP));
|
// Serial.println(str(SC_ERROR_NO_AP));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
snifferStartTime = currentTime;
|
snifferStartTime = currentTime;
|
||||||
prnt(SC_START_CLIENT);
|
prnt(SC_START_CLIENT);
|
||||||
|
|
||||||
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
||||||
else prnt(SC_INFINITELY);
|
else prnt(SC_INFINITELY);
|
||||||
|
|
||||||
if (!channelHop) {
|
if (!channelHop) {
|
||||||
prnt(SC_ON_CHANNEL);
|
prnt(SC_ON_CHANNEL);
|
||||||
prnt(wifi_channel);
|
prnt(wifi_channel);
|
||||||
}
|
}
|
||||||
prntln();
|
prntln();
|
||||||
|
|
||||||
// enable sniffer
|
// enable sniffer
|
||||||
stopAP();
|
stopAP();
|
||||||
wifi_promiscuous_enable(true);
|
wifi_promiscuous_enable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (mode == SCAN_MODE_SNIFFER) {
|
else if (mode == SCAN_MODE_SNIFFER) {
|
||||||
deauths = tmpDeauths;
|
deauths = tmpDeauths;
|
||||||
tmpDeauths = 0;
|
tmpDeauths = 0;
|
||||||
snifferStartTime = currentTime;
|
snifferStartTime = currentTime;
|
||||||
prnt(SS_START_SNIFFER);
|
prnt(SS_START_SNIFFER);
|
||||||
|
|
||||||
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
if (sniffTime > 0) prnt(String(sniffTime / 1000) + S);
|
||||||
else prnt(SC_INFINITELY);
|
else prnt(SC_INFINITELY);
|
||||||
prnt(SC_ON_CHANNEL);
|
prnt(SC_ON_CHANNEL);
|
||||||
prntln(channelHop ? str(SC_ONE_TO) + (String)settings.getMaxCh() : (String)wifi_channel);
|
prntln(channelHop ? str(SC_ONE_TO) + (String)14 : (String)wifi_channel);
|
||||||
|
|
||||||
// enable sniffer
|
// enable sniffer
|
||||||
stopAP();
|
stopAP();
|
||||||
wifi_promiscuous_enable(true);
|
wifi_promiscuous_enable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop scan */
|
/* Stop scan */
|
||||||
else if (mode == SCAN_MODE_OFF) {
|
else if (mode == SCAN_MODE_OFF) {
|
||||||
wifi_promiscuous_enable(false);
|
wifi_promiscuous_enable(false);
|
||||||
|
|
||||||
if (settings.getWebInterface()) resumeAP();
|
if (settings.getWebInterface()) resumeAP();
|
||||||
prntln(SC_STOPPED);
|
prntln(SC_STOPPED);
|
||||||
save(true);
|
save(true);
|
||||||
|
|
||||||
if (scan_continue_mode != SCAN_MODE_OFF) {
|
if (scan_continue_mode != SCAN_MODE_OFF) {
|
||||||
prnt(SC_RESTART);
|
prnt(SC_RESTART);
|
||||||
prnt(int(continueTime / 1000));
|
prnt(int(continueTime / 1000));
|
||||||
prntln(SC_CONTINUE);
|
prntln(SC_CONTINUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
else {
|
else {
|
||||||
prnt(SC_ERROR_MODE);
|
prnt(SC_ERROR_MODE);
|
||||||
prntln(mode);
|
prntln(mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::update() {
|
void Scan::update() {
|
||||||
if (scanMode == SCAN_MODE_OFF) {
|
if (scanMode == SCAN_MODE_OFF) {
|
||||||
// restart scan if it is continuous
|
// restart scan if it is continuous
|
||||||
if (scan_continue_mode != SCAN_MODE_OFF) {
|
if (scan_continue_mode != SCAN_MODE_OFF) {
|
||||||
if (currentTime - continueStartTime > continueTime) start(scan_continue_mode);
|
if (currentTime - continueStartTime > continueTime) start(scan_continue_mode);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sniffer
|
// sniffer
|
||||||
if (isSniffing()) {
|
if (isSniffing()) {
|
||||||
// update packet list every 1s
|
// update packet list every 1s
|
||||||
if (currentTime - snifferPacketTime > 1000) {
|
if (currentTime - snifferPacketTime > 1000) {
|
||||||
snifferPacketTime = currentTime;
|
snifferPacketTime = currentTime;
|
||||||
list->add(packets);
|
list->add(packets);
|
||||||
|
|
||||||
if (list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0);
|
if (list->size() > SCAN_PACKET_LIST_SIZE) list->remove(0);
|
||||||
deauths = tmpDeauths;
|
deauths = tmpDeauths;
|
||||||
tmpDeauths = 0;
|
tmpDeauths = 0;
|
||||||
packets = 0;
|
packets = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print status every 3s
|
// print status every 3s
|
||||||
if (currentTime - snifferOutputTime > 3000) {
|
if (currentTime - snifferOutputTime > 3000) {
|
||||||
char s[100];
|
char s[100];
|
||||||
|
|
||||||
if (sniffTime > 0) {
|
if (sniffTime > 0) {
|
||||||
sprintf(s, str(SC_OUTPUT_A).c_str(), getPercentage(), packets, stations.count(), deauths);
|
sprintf(s, str(SC_OUTPUT_A).c_str(), getPercentage(), packets, stations.count(), deauths);
|
||||||
} else {
|
} else {
|
||||||
sprintf(s, str(SC_OUTPUT_B).c_str(), packets, stations.count(), deauths);
|
sprintf(s, str(SC_OUTPUT_B).c_str(), packets, stations.count(), deauths);
|
||||||
}
|
}
|
||||||
prnt(String(s));
|
prnt(String(s));
|
||||||
snifferOutputTime = currentTime;
|
snifferOutputTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// channel hopping
|
// channel hopping
|
||||||
if (channelHop && (currentTime - snifferChannelTime > settings.getChTime())) {
|
if (channelHop && (currentTime - snifferChannelTime > settings.getChTime())) {
|
||||||
snifferChannelTime = currentTime;
|
snifferChannelTime = currentTime;
|
||||||
|
|
||||||
if (scanMode == SCAN_MODE_STATIONS) nextChannel(); // go to next channel an AP is on
|
if (scanMode == SCAN_MODE_STATIONS) nextChannel(); // go to next channel an AP is on
|
||||||
else setChannel(wifi_channel + 1); // go to next channel
|
else setChannel(wifi_channel + 1); // go to next channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// APs
|
// APs
|
||||||
if ((scanMode == SCAN_MODE_APS) || (scanMode == SCAN_MODE_ALL)) {
|
if ((scanMode == SCAN_MODE_APS) || (scanMode == SCAN_MODE_ALL)) {
|
||||||
int16_t results = WiFi.scanComplete();
|
int16_t results = WiFi.scanComplete();
|
||||||
|
|
||||||
if (results >= 0) {
|
if (results >= 0) {
|
||||||
for (int16_t i = 0; i < results && i < 256; i++) {
|
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.sort();
|
||||||
accesspoints.printAll();
|
accesspoints.printAll();
|
||||||
|
|
||||||
if (scanMode == SCAN_MODE_ALL) {
|
if (scanMode == SCAN_MODE_ALL) {
|
||||||
delay(30);
|
delay(30);
|
||||||
start(SCAN_MODE_STATIONS);
|
start(SCAN_MODE_STATIONS);
|
||||||
}
|
}
|
||||||
else start(SCAN_MODE_OFF);
|
else start(SCAN_MODE_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stations
|
// Stations
|
||||||
else if ((sniffTime > 0) && (currentTime > snifferStartTime + sniffTime)) {
|
else if ((sniffTime > 0) && (currentTime > snifferStartTime + sniffTime)) {
|
||||||
wifi_promiscuous_enable(false);
|
wifi_promiscuous_enable(false);
|
||||||
|
|
||||||
if (scanMode == SCAN_MODE_STATIONS) {
|
if (scanMode == SCAN_MODE_STATIONS) {
|
||||||
stations.sort();
|
stations.sort();
|
||||||
stations.printAll();
|
stations.printAll();
|
||||||
}
|
}
|
||||||
start(SCAN_MODE_OFF);
|
start(SCAN_MODE_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::setup() {
|
void Scan::setup() {
|
||||||
save(true);
|
save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::stop() {
|
void Scan::stop() {
|
||||||
scan_continue_mode = SCAN_MODE_OFF;
|
scan_continue_mode = SCAN_MODE_OFF;
|
||||||
start(SCAN_MODE_OFF);
|
start(SCAN_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::setChannel(uint8_t ch) {
|
void Scan::setChannel(uint8_t ch) {
|
||||||
if (ch > settings.getMaxCh()) ch = 1;
|
if (ch > 14) ch = 1;
|
||||||
else if (ch < 1) ch = settings.getMaxCh();
|
else if (ch < 1) ch = 14;
|
||||||
|
|
||||||
wifi_promiscuous_enable(0);
|
wifi_promiscuous_enable(0);
|
||||||
setWifiChannel(ch);
|
setWifiChannel(ch);
|
||||||
wifi_promiscuous_enable(1);
|
wifi_promiscuous_enable(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::nextChannel() {
|
void Scan::nextChannel() {
|
||||||
if (accesspoints.count() > 1) {
|
if (accesspoints.count() > 1) {
|
||||||
uint8_t ch = wifi_channel;
|
uint8_t ch = wifi_channel;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ch++;
|
ch++;
|
||||||
|
|
||||||
if (ch > settings.getMaxCh()) ch = 1;
|
if (ch > 14) ch = 1;
|
||||||
} while (!apWithChannel(ch));
|
} while (!apWithChannel(ch));
|
||||||
setChannel(ch);
|
setChannel(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::apWithChannel(uint8_t ch) {
|
bool Scan::apWithChannel(uint8_t ch) {
|
||||||
for (int i = 0; i < accesspoints.count(); i++)
|
for (int i = 0; i < accesspoints.count(); i++)
|
||||||
if (accesspoints.getCh(i) == ch) return true;
|
if (accesspoints.getCh(i) == ch) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::save(bool force, String filePath) {
|
void Scan::save(bool force, String filePath) {
|
||||||
String tmp = FILE_PATH;
|
String tmp = FILE_PATH;
|
||||||
|
|
||||||
FILE_PATH = filePath;
|
FILE_PATH = filePath;
|
||||||
save(true);
|
save(true);
|
||||||
FILE_PATH = tmp;
|
FILE_PATH = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::save(bool force) {
|
void Scan::save(bool force) {
|
||||||
if (!(accesspoints.changed || stations.changed) && !force) return;
|
if (!(accesspoints.changed || stations.changed) && !force) return;
|
||||||
|
|
||||||
// Accesspoints
|
// Accesspoints
|
||||||
String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String(
|
String buf = String(OPEN_CURLY_BRACKET) + String(DOUBLEQUOTES) + str(SC_JSON_APS) + String(DOUBLEQUOTES) + String(
|
||||||
DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[
|
DOUBLEPOINT) + String(OPEN_BRACKET); // {"aps":[
|
||||||
|
|
||||||
if (!writeFile(FILE_PATH, buf)) { // overwrite old file
|
if (!writeFile(FILE_PATH, buf)) { // overwrite old file
|
||||||
prnt(F_ERROR_SAVING);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
buf = String(); // clear buffer
|
||||||
uint32_t apCount = accesspoints.count();
|
uint32_t apCount = accesspoints.count();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < apCount; i++) {
|
for (uint32_t i = 0; i < apCount; i++) {
|
||||||
buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + escape(accesspoints.getSSID(i)) + String(DOUBLEQUOTES) +
|
buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + escape(accesspoints.getSSID(i)) + String(DOUBLEQUOTES) +
|
||||||
String(COMMA); // ["ssid",
|
String(COMMA); // ["ssid",
|
||||||
buf += String(DOUBLEQUOTES) + escape(accesspoints.getNameStr(i)) + String(DOUBLEQUOTES) + String(COMMA); // "name",
|
buf += String(DOUBLEQUOTES) + escape(accesspoints.getNameStr(i)) + String(DOUBLEQUOTES) + String(COMMA); // "name",
|
||||||
buf += String(accesspoints.getCh(i)) + String(COMMA); // 1,
|
buf += String(accesspoints.getCh(i)) + String(COMMA); // 1,
|
||||||
buf += String(accesspoints.getRSSI(i)) + String(COMMA); // -30,
|
buf += String(accesspoints.getRSSI(i)) + String(COMMA); // -30,
|
||||||
buf += String(DOUBLEQUOTES) + accesspoints.getEncStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "wpa2",
|
buf += String(DOUBLEQUOTES) + accesspoints.getEncStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "wpa2",
|
||||||
buf += String(DOUBLEQUOTES) + accesspoints.getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22",
|
buf += String(DOUBLEQUOTES) + accesspoints.getMacStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "00:11:22:00:11:22",
|
||||||
buf += String(DOUBLEQUOTES) + accesspoints.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor",
|
buf += String(DOUBLEQUOTES) + accesspoints.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor",
|
||||||
buf += b2s(accesspoints.getSelected(i)) + String(CLOSE_BRACKET); // false]
|
buf += b2s(accesspoints.getSelected(i)) + String(CLOSE_BRACKET); // false]
|
||||||
|
|
||||||
if (i < apCount - 1) buf += String(COMMA); // ,
|
if (i < apCount - 1) buf += String(COMMA); // ,
|
||||||
|
|
||||||
if (buf.length() >= 1024) {
|
if (buf.length() >= 1024) {
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
if (!appendFile(FILE_PATH, buf)) {
|
||||||
prnt(F_ERROR_SAVING);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
buf = String(); // clear buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stations
|
// Stations
|
||||||
buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) +
|
buf += String(CLOSE_BRACKET) + String(COMMA) + String(DOUBLEQUOTES) + str(SC_JSON_STATIONS) + String(DOUBLEQUOTES) +
|
||||||
String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"stations":[;
|
String(DOUBLEPOINT) + String(OPEN_BRACKET); // ],"stations":[;
|
||||||
uint32_t stationCount = stations.count();
|
uint32_t stationCount = stations.count();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < stationCount; i++) {
|
for (uint32_t i = 0; i < stationCount; i++) {
|
||||||
buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + stations.getMacStr(i) + String(DOUBLEQUOTES) +
|
buf += String(OPEN_BRACKET) + String(DOUBLEQUOTES) + stations.getMacStr(i) + String(DOUBLEQUOTES) +
|
||||||
String(COMMA); // ["00:11:22:00:11:22",
|
String(COMMA); // ["00:11:22:00:11:22",
|
||||||
buf += String(stations.getCh(i)) + String(COMMA); // 1,
|
buf += String(stations.getCh(i)) + String(COMMA); // 1,
|
||||||
buf += String(DOUBLEQUOTES) + stations.getNameStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "name",
|
buf += String(DOUBLEQUOTES) + stations.getNameStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "name",
|
||||||
buf += String(DOUBLEQUOTES) + stations.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor",
|
buf += String(DOUBLEQUOTES) + stations.getVendorStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "vendor",
|
||||||
buf += String(*stations.getPkts(i)) + String(COMMA); // 123,
|
buf += String(*stations.getPkts(i)) + String(COMMA); // 123,
|
||||||
buf += String(stations.getAP(i)) + String(COMMA); // 0,
|
buf += String(stations.getAP(i)) + String(COMMA); // 0,
|
||||||
buf += String(DOUBLEQUOTES) + stations.getTimeStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "<1min",
|
buf += String(DOUBLEQUOTES) + stations.getTimeStr(i) + String(DOUBLEQUOTES) + String(COMMA); // "<1min",
|
||||||
buf += b2s(stations.getSelected(i)) + String(CLOSE_BRACKET); // false]
|
buf += b2s(stations.getSelected(i)) + String(CLOSE_BRACKET); // false]
|
||||||
|
|
||||||
if (i < stationCount - 1) buf += String(COMMA); // ,
|
if (i < stationCount - 1) buf += String(COMMA); // ,
|
||||||
|
|
||||||
if (buf.length() >= 1024) {
|
if (buf.length() >= 1024) {
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
if (!appendFile(FILE_PATH, buf)) {
|
||||||
prnt(F_ERROR_SAVING);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = String(); // clear buffer
|
buf = String(); // clear buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]}
|
buf += String(CLOSE_BRACKET) + String(CLOSE_CURLY_BRACKET); // ]}
|
||||||
|
|
||||||
if (!appendFile(FILE_PATH, buf)) {
|
if (!appendFile(FILE_PATH, buf)) {
|
||||||
prnt(F_ERROR_SAVING);
|
prnt(F_ERROR_SAVING);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
accesspoints.changed = false;
|
accesspoints.changed = false;
|
||||||
stations.changed = false;
|
stations.changed = false;
|
||||||
prnt(SC_SAVED_IN);
|
prnt(SC_SAVED_IN);
|
||||||
prntln(FILE_PATH);
|
prntln(FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::countSelected() {
|
uint32_t Scan::countSelected() {
|
||||||
return accesspoints.selected() + stations.selected() + names.selected();
|
return accesspoints.selected() + stations.selected() + names.selected();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::countAll() {
|
uint32_t Scan::countAll() {
|
||||||
return accesspoints.count() + stations.count() + names.count();
|
return accesspoints.count() + stations.count() + names.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::isScanning() {
|
bool Scan::isScanning() {
|
||||||
return scanMode != SCAN_MODE_OFF;
|
return scanMode != SCAN_MODE_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scan::isSniffing() {
|
bool Scan::isSniffing() {
|
||||||
return scanMode == SCAN_MODE_STATIONS || scanMode == SCAN_MODE_SNIFFER;
|
return scanMode == SCAN_MODE_STATIONS || scanMode == SCAN_MODE_SNIFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Scan::getPercentage() {
|
uint8_t Scan::getPercentage() {
|
||||||
if (!isSniffing()) return 0;
|
if (!isSniffing()) return 0;
|
||||||
|
|
||||||
return (currentTime - snifferStartTime) / (sniffTime / 100);
|
return (currentTime - snifferStartTime) / (sniffTime / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::selectAll() {
|
void Scan::selectAll() {
|
||||||
accesspoints.selectAll();
|
accesspoints.selectAll();
|
||||||
stations.selectAll();
|
stations.selectAll();
|
||||||
names.selectAll();
|
names.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::deselectAll() {
|
void Scan::deselectAll() {
|
||||||
accesspoints.deselectAll();
|
accesspoints.deselectAll();
|
||||||
stations.deselectAll();
|
stations.deselectAll();
|
||||||
names.deselectAll();
|
names.deselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::printAll() {
|
void Scan::printAll() {
|
||||||
accesspoints.printAll();
|
accesspoints.printAll();
|
||||||
stations.printAll();
|
stations.printAll();
|
||||||
names.printAll();
|
names.printAll();
|
||||||
ssids.printAll();
|
ssids.printAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan::printSelected() {
|
void Scan::printSelected() {
|
||||||
accesspoints.printSelected();
|
accesspoints.printSelected();
|
||||||
stations.printSelected();
|
stations.printSelected();
|
||||||
names.printSelected();
|
names.printSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Scan::getPackets(int i) {
|
uint32_t Scan::getPackets(int i) {
|
||||||
if (list->size() < SCAN_PACKET_LIST_SIZE) {
|
if (list->size() < SCAN_PACKET_LIST_SIZE) {
|
||||||
uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size();
|
uint8_t translatedNum = SCAN_PACKET_LIST_SIZE - list->size();
|
||||||
|
|
||||||
if (i >= translatedNum) return list->get(i - translatedNum);
|
if (i >= translatedNum) return list->get(i - translatedNum);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return list->get(i);
|
return list->get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double Scan::getScaleFactor(uint8_t height) {
|
String Scan::getMode(){
|
||||||
return (double)height / (double)getMaxPacket();
|
switch(scanMode) {
|
||||||
}
|
case SCAN_MODE_OFF:
|
||||||
|
return String(SC_MODE_OFF);
|
||||||
uint32_t Scan::getMaxPacket() {
|
case SCAN_MODE_APS:
|
||||||
uint16_t max = 0;
|
return String(SC_MODE_AP);
|
||||||
|
case SCAN_MODE_STATIONS:
|
||||||
for (uint8_t i = 0; i < list->size(); i++) {
|
return String(SC_MODE_ST);
|
||||||
if (list->get(i) > max) max = list->get(i);
|
case SCAN_MODE_ALL:
|
||||||
}
|
return String(SC_MODE_ALL);
|
||||||
return max;
|
case SCAN_MODE_SNIFFER:
|
||||||
}
|
return String(SC_MODE_SNIFFER);
|
||||||
|
default:
|
||||||
uint32_t Scan::getPacketRate() {
|
return String();
|
||||||
return list->get(list->size() - 1);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Scan::getScaleFactor(uint8_t height) {
|
||||||
|
return (double)height / (double)getMaxPacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Scan::getMaxPacket() {
|
||||||
|
uint16_t max = 0;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < list->size(); i++) {
|
||||||
|
if (list->get(i) > max) max = list->get(i);
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Scan::getPacketRate() {
|
||||||
|
return list->get(list->size() - 1);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,98 +1,99 @@
|
|||||||
#ifndef Scan_h
|
#ifndef Scan_h
|
||||||
#define Scan_h
|
#define Scan_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Accesspoints.h"
|
#include "Accesspoints.h"
|
||||||
#include "Stations.h"
|
#include "Stations.h"
|
||||||
#include "Names.h"
|
#include "Names.h"
|
||||||
#include "SSIDs.h"
|
#include "SSIDs.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "SimpleList.h"
|
#include "SimpleList.h"
|
||||||
|
|
||||||
#define SCAN_MODE_OFF 0
|
#define SCAN_MODE_OFF 0
|
||||||
#define SCAN_MODE_APS 1
|
#define SCAN_MODE_APS 1
|
||||||
#define SCAN_MODE_STATIONS 2
|
#define SCAN_MODE_STATIONS 2
|
||||||
#define SCAN_MODE_ALL 3
|
#define SCAN_MODE_ALL 3
|
||||||
#define SCAN_MODE_SNIFFER 4
|
#define SCAN_MODE_SNIFFER 4
|
||||||
#define SCAN_DEFAULT_TIME 15000
|
#define SCAN_DEFAULT_TIME 15000
|
||||||
#define SCAN_DEFAULT_CONTINUE_TIME 10000
|
#define SCAN_DEFAULT_CONTINUE_TIME 10000
|
||||||
#define SCAN_PACKET_LIST_SIZE 64
|
#define SCAN_PACKET_LIST_SIZE 64
|
||||||
|
|
||||||
extern Accesspoints accesspoints;
|
extern Accesspoints accesspoints;
|
||||||
extern Stations stations;
|
extern Stations stations;
|
||||||
extern Names names;
|
extern Names names;
|
||||||
extern SSIDs ssids;
|
extern SSIDs ssids;
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
extern uint8_t wifiMode;
|
extern uint8_t wifiMode;
|
||||||
|
|
||||||
extern void setWifiChannel(uint8_t ch);
|
extern void setWifiChannel(uint8_t ch);
|
||||||
extern bool appendFile(String path, String& buf);
|
extern bool appendFile(String path, String& buf);
|
||||||
extern bool writeFile(String path, String& buf);
|
extern bool writeFile(String path, String& buf);
|
||||||
extern void readFileToSerial(const String path);
|
extern void readFileToSerial(const String path);
|
||||||
extern void resumeAP();
|
extern void resumeAP();
|
||||||
extern void stopAP();
|
extern void stopAP();
|
||||||
extern String escape(String str);
|
extern String escape(String str);
|
||||||
|
|
||||||
class Scan {
|
class Scan {
|
||||||
public:
|
public:
|
||||||
Scan();
|
Scan();
|
||||||
|
|
||||||
void sniffer(uint8_t* buf, uint16_t len);
|
void sniffer(uint8_t* buf, uint16_t len);
|
||||||
void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
void start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continueTime, bool channelHop,
|
||||||
uint8_t channel);
|
uint8_t channel);
|
||||||
void start(uint8_t mode);
|
void start(uint8_t mode);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void update();
|
void update();
|
||||||
void stop();
|
void stop();
|
||||||
void save(bool force);
|
void save(bool force);
|
||||||
void save(bool force, String filePath);
|
void save(bool force, String filePath);
|
||||||
|
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void deselectAll();
|
void deselectAll();
|
||||||
void printAll();
|
void printAll();
|
||||||
void printSelected();
|
void printSelected();
|
||||||
|
|
||||||
uint8_t getPercentage();
|
uint8_t getPercentage();
|
||||||
uint32_t getPackets(int i);
|
uint32_t getPackets(int i);
|
||||||
uint32_t countAll();
|
uint32_t countAll();
|
||||||
uint32_t countSelected();
|
uint32_t countSelected();
|
||||||
bool isScanning();
|
bool isScanning();
|
||||||
bool isSniffing();
|
bool isSniffing();
|
||||||
|
|
||||||
void nextChannel();
|
void nextChannel();
|
||||||
void setChannel(uint8_t newChannel);
|
void setChannel(uint8_t newChannel);
|
||||||
|
|
||||||
double getScaleFactor(uint8_t height);
|
String getMode();
|
||||||
uint32_t getMaxPacket();
|
double getScaleFactor(uint8_t height);
|
||||||
uint32_t getPacketRate();
|
uint32_t getMaxPacket();
|
||||||
|
uint32_t getPacketRate();
|
||||||
uint16_t deauths = 0;
|
|
||||||
uint16_t packets = 0;
|
uint16_t deauths = 0;
|
||||||
|
uint16_t packets = 0;
|
||||||
private:
|
|
||||||
SimpleList<uint16_t>* list; // packet list
|
private:
|
||||||
|
SimpleList<uint16_t>* list; // packet list
|
||||||
uint32_t sniffTime = SCAN_DEFAULT_TIME; // how long the scan runs
|
|
||||||
uint32_t snifferStartTime = 0; // when the scan started
|
uint32_t sniffTime = SCAN_DEFAULT_TIME; // how long the scan runs
|
||||||
uint32_t snifferOutputTime = 0; // last info output (every 3s)
|
uint32_t snifferStartTime = 0; // when the scan started
|
||||||
uint32_t snifferChannelTime = 0; // last time the channel was changed
|
uint32_t snifferOutputTime = 0; // last info output (every 3s)
|
||||||
uint32_t snifferPacketTime = 0; // last time the packet rate was reseted (every 1s)
|
uint32_t snifferChannelTime = 0; // last time the channel was changed
|
||||||
|
uint32_t snifferPacketTime = 0; // last time the packet rate was reseted (every 1s)
|
||||||
uint8_t scanMode = 0;
|
|
||||||
|
uint8_t scanMode = 0;
|
||||||
uint8_t scan_continue_mode = 0; // restart mode after scan stopped
|
|
||||||
uint32_t continueTime = SCAN_DEFAULT_CONTINUE_TIME; // time in ms to wait until scan restarts
|
uint8_t scan_continue_mode = 0; // restart mode after scan stopped
|
||||||
uint32_t continueStartTime = 0; // when scan restarted
|
uint32_t continueTime = SCAN_DEFAULT_CONTINUE_TIME; // time in ms to wait until scan restarts
|
||||||
|
uint32_t continueStartTime = 0; // when scan restarted
|
||||||
bool channelHop = true;
|
|
||||||
uint16_t tmpDeauths = 0;
|
bool channelHop = true;
|
||||||
|
uint16_t tmpDeauths = 0;
|
||||||
bool apWithChannel(uint8_t ch);
|
|
||||||
int findAccesspoint(uint8_t* mac);
|
bool apWithChannel(uint8_t ch);
|
||||||
|
int findAccesspoint(uint8_t* mac);
|
||||||
String FILE_PATH = "/scan.json";
|
|
||||||
};
|
String FILE_PATH = "/scan.json";
|
||||||
|
};
|
||||||
#endif // ifndef Scan_h
|
|
||||||
|
#endif // ifndef Scan_h
|
||||||
|
|||||||
@@ -100,15 +100,15 @@ void Stations::print(int num, bool header, bool footer) {
|
|||||||
prntln(ST_TABLE_DIVIDER);
|
prntln(ST_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
prnt(buildString(String(), (String)num, 2));
|
prnt(leftRight(String(), (String)num, 2));
|
||||||
prnt(buildString(String(SPACE) + getMacStr(num), String(), 18));
|
prnt(leftRight(String(SPACE) + getMacStr(num), String(), 18));
|
||||||
prnt(buildString(String(SPACE), (String)getCh(num), 3));
|
prnt(leftRight(String(SPACE), (String)getCh(num), 3));
|
||||||
prnt(buildString(String(SPACE) + getNameStr(num), String(), 17));
|
prnt(leftRight(String(SPACE) + getNameStr(num), String(), 17));
|
||||||
prnt(buildString(String(SPACE) + getVendorStr(num), String(), 9));
|
prnt(leftRight(String(SPACE) + getVendorStr(num), String(), 9));
|
||||||
prnt(buildString(String(SPACE), (String) * getPkts(num), 9));
|
prnt(leftRight(String(SPACE), (String) * getPkts(num), 9));
|
||||||
prnt(buildString(String(SPACE) + getAPStr(num), String(), 33));
|
prnt(leftRight(String(SPACE) + getAPStr(num), String(), 33));
|
||||||
prnt(buildString(String(SPACE) + getTimeStr(num), String(), 10));
|
prnt(leftRight(String(SPACE) + getTimeStr(num), String(), 10));
|
||||||
prntln(buildString(String(SPACE) + getSelectedStr(num), String(), 9));
|
prntln(leftRight(String(SPACE) + getSelectedStr(num), String(), 9));
|
||||||
|
|
||||||
if (footer) prntln(ST_TABLE_DIVIDER);
|
if (footer) prntln(ST_TABLE_DIVIDER);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -268,11 +268,12 @@ const char D_MSG_DISPLAY_OFF[] PROGMEM = "Turned display off";
|
|||||||
const char D_MSG_DISPLAY_ON[] PROGMEM = "Turned display on";
|
const char D_MSG_DISPLAY_ON[] PROGMEM = "Turned display on";
|
||||||
|
|
||||||
// LOADING SCREEN
|
// LOADING SCREEN
|
||||||
const char D_LOADING_SCREEN_0[] PROGMEM = "Scanning...";
|
const char DSP_SCAN_FOR[] PROGMEM = "Scan for";
|
||||||
const char D_LOADING_SCREEN_1[] PROGMEM = "APs: ";
|
const char DSP_APS[] PROGMEM = "APs";
|
||||||
const char D_LOADING_SCREEN_2[] PROGMEM = "Stations: ";
|
const char DSP_STS[] PROGMEM = "STs";
|
||||||
const char D_LOADING_SCREEN_3[] PROGMEM = "Searching for";
|
const char DSP_PKTS[] PROGMEM = "Pkts";
|
||||||
const char D_LOADING_SCREEN_4[] PROGMEM = "Access Points...";
|
const char DSP_S[] PROGMEM = "/s";
|
||||||
|
const char DSP_SCAN_DONE[] PROGMEM = "Done";
|
||||||
|
|
||||||
// ALL MENUS
|
// ALL MENUS
|
||||||
const char D_BACK[] PROGMEM = "[BACK]";
|
const char D_BACK[] PROGMEM = "[BACK]";
|
||||||
@@ -325,10 +326,10 @@ const char D_STOP_ATTACK[] PROGMEM = "STOP";
|
|||||||
const char D_ENCRYPTION[] PROGMEM = "Encryption:";
|
const char D_ENCRYPTION[] PROGMEM = "Encryption:";
|
||||||
const char D_RSSI[] PROGMEM = "RSSI:";
|
const char D_RSSI[] PROGMEM = "RSSI:";
|
||||||
const char D_CHANNEL[] PROGMEM = "Channel:";
|
const char D_CHANNEL[] PROGMEM = "Channel:";
|
||||||
const char D_CH[] PROGMEM = "CH:";
|
const char D_CH[] PROGMEM = "Ch";
|
||||||
const char D_VENDOR[] PROGMEM = "Vendor:";
|
const char D_VENDOR[] PROGMEM = "Vendor:";
|
||||||
const char D_AP[] PROGMEM = "AP:";
|
const char D_AP[] PROGMEM = "AP:";
|
||||||
const char D_PKTS[] PROGMEM = "Pkts:";
|
const char D_PKTS[] PROGMEM = "pkts";
|
||||||
const char D_SEEN[] PROGMEM = "Seen:";
|
const char D_SEEN[] PROGMEM = "Seen:";
|
||||||
|
|
||||||
// ===== STATIONS ===== //
|
// ===== STATIONS ===== //
|
||||||
@@ -388,7 +389,7 @@ const char S_ERROR_VERSION[] PROGMEM = "Sorry, you can't change the version numb
|
|||||||
const char S_ERROR_NOT_FOUND[] PROGMEM = "ERROR: No setting found for ";
|
const char S_ERROR_NOT_FOUND[] PROGMEM = "ERROR: No setting found for ";
|
||||||
const char S_CHANGED_SETTING[] PROGMEM = "Changed setting ";
|
const char S_CHANGED_SETTING[] PROGMEM = "Changed setting ";
|
||||||
const char S_CHANNEL_CHANGE[] PROGMEM = "Switched to Channel ";
|
const char S_CHANNEL_CHANGE[] PROGMEM = "Switched to Channel ";
|
||||||
const char S_CHANNEL_ERROR[] PROGMEM = "ERROR: Channel must be between 1 and ";
|
const char S_CHANNEL_ERROR[] PROGMEM = "ERROR: Channel must be between 1 and 14";
|
||||||
const char S_ERROR_SSID_LEN[] PROGMEM = "ERROR: SSID must be between 1 and 32 characters";
|
const char S_ERROR_SSID_LEN[] PROGMEM = "ERROR: SSID must be between 1 and 32 characters";
|
||||||
const char S_ERROR_PASSWORD_LEN[] PROGMEM = "ERROR: Password must be between 8 and 32 characters";
|
const char S_ERROR_PASSWORD_LEN[] PROGMEM = "ERROR: Password must be between 8 and 32 characters";
|
||||||
const char S_RANDOM[] PROGMEM = "random";
|
const char S_RANDOM[] PROGMEM = "random";
|
||||||
@@ -492,6 +493,11 @@ const char SC_JSON_STATIONS[] PROGMEM = "stations";
|
|||||||
const char SC_JSON_NAMES[] PROGMEM = "names";
|
const char SC_JSON_NAMES[] PROGMEM = "names";
|
||||||
const char SC_SAVED[] PROGMEM = "Saved scan results";
|
const char SC_SAVED[] PROGMEM = "Saved scan results";
|
||||||
const char SC_SAVED_IN[] PROGMEM = "Scan results saved in ";
|
const char SC_SAVED_IN[] PROGMEM = "Scan results saved in ";
|
||||||
|
const char SC_MODE_OFF[] PROGMEM = "-";
|
||||||
|
const char SC_MODE_AP[] PROGMEM = "APs";
|
||||||
|
const char SC_MODE_ST[] PROGMEM = "STs";
|
||||||
|
const char SC_MODE_ALL[] PROGMEM = "AP+ST";
|
||||||
|
const char SC_MODE_SNIFFER[] PROGMEM = "Sniffer";
|
||||||
|
|
||||||
// ===== FUNCTIONS ===== //
|
// ===== FUNCTIONS ===== //
|
||||||
const char F_ERROR_MAC[] PROGMEM = "ERROR: MAC address invalid";
|
const char F_ERROR_MAC[] PROGMEM = "ERROR: MAC address invalid";
|
||||||
|
|||||||
Reference in New Issue
Block a user