Compare commits

...

17 Commits

Author SHA1 Message Date
Just Call Me Koko
ec4fc7487f Release v0.9.5 2022-01-18 23:30:10 -05:00
Just Call Me Koko
71ced23041 Settings actually work 2022-01-18 23:20:42 -05:00
Just Call Me Koko
8e874c493b Actually made settings work 2022-01-18 03:29:45 -05:00
Just Call Me Koko
373482822a Make settings available on Menu 2021-07-28 23:24:18 -04:00
Just Call Me Koko
bca0f70073 Add specific setting retrieval 2021-07-27 22:06:04 -04:00
Just Call Me Koko
37c65bf6f1 Add settings function 2021-07-25 21:33:21 -04:00
Just Call Me Koko
b7be44d5ea Update Display.h 2021-07-25 11:54:29 -04:00
Just Call Me Koko
503e65e012 Update README.md for version 0.9.3 2021-07-24 12:23:56 -04:00
Just Call Me Koko
a78d5b792c Create MarauderOTA firmware 2021-07-24 12:00:11 -04:00
Just Call Me Koko
38098cb9e5 Release v0.9.3 2021-07-24 09:03:17 -04:00
Just Call Me Koko
466d5fbb1a Fix definitions 2021-07-24 01:20:17 -04:00
Just Call Me Koko
51a7ff7e26 Add deauthentication attack 2021-07-24 00:16:56 -04:00
Just Call Me Koko
f166c7a4df Pre ESP-IDF v4.4 2021-07-24 00:14:23 -04:00
Just Call Me Koko
9e1fe534b0 Move Marauder splash screen to byte array 2021-07-22 17:48:56 -04:00
Just Call Me Koko
a23e7a4c48 Add kit firmware modifications 2021-07-08 18:44:47 -04:00
Just Call Me Koko
f801ba0bc5 Update README.md 2021-07-01 11:06:54 -04:00
Just Call Me Koko
31687c10cb Fake wifi functions 2021-06-15 16:33:45 -04:00
28 changed files with 6808 additions and 4667 deletions

297
MarauderOTA/MarauderOTA.ino Normal file

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@
<!---[![Build Status](https://travis-ci.com/justcallmekoko/ESP32Marauder.svg?branch=master)](https://travis-ci.com/justcallmekoko/ESP32Marauder)--->
<!---Shields/Badges https://shields.io/--->
# ESP32 Marauder v0.9.1
# ESP32 Marauder v0.9.3
<p align="center"><img alt="Marauder logo" src="https://github.com/justcallmekoko/ESP32Marauder/blob/master/pictures/marauder3L.jpg?raw=true" width="300"></p>
<p align="center">
<b>A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32</b>
@@ -19,8 +19,6 @@
<br>
<a href="https://www.twitch.tv/willstunforfood"><img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c540.png" alt="Twitch WillStunForFood" width="200"></a>
</p>
Catch my live stream on [Twitch](https://www.twitch.tv/willstunforfood) where I play games, have just chatting sessions to talk tech, and just generally be an ordinary person who can't figure out how to make proper life decisions.
## Getting Started
Download the [latest release](https://github.com/justcallmekoko/ESP32Marauder/releases/latest) of the firmware.

File diff suppressed because one or more lines are too long

View File

@@ -1,41 +1,44 @@
#ifndef Buffer_h
#define Buffer_h
#include "Arduino.h"
#include "FS.h"
//#include "SD_MMC.h"
#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
#define SNAP_LEN 2324 // max len of each recieved packet
//extern bool useSD;
class Buffer {
public:
Buffer();
void open(fs::FS* fs, String fn = "");
void close(fs::FS* fs);
void addPacket(uint8_t* buf, uint32_t len);
void save(fs::FS* fs);
void forceSave(fs::FS* fs);
private:
void write(int32_t n);
void write(uint32_t n);
void write(uint16_t n);
void write(uint8_t* buf, uint32_t len);
uint8_t* bufA;
uint8_t* bufB;
uint32_t bufSizeA = 0;
uint32_t bufSizeB = 0;
bool writing = false; // acceppting writes to buffer
bool useA = true; // writing to bufA or bufB
bool saving = false; // currently saving onto the SD card
String fileName = "/0.pcap";
File file;
};
#endif
#ifndef Buffer_h
#define Buffer_h
#include "Arduino.h"
#include "FS.h"
#include "settings.h"
//#include "SD_MMC.h"
#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn
#define SNAP_LEN 2324 // max len of each recieved packet
//extern bool useSD;
extern Settings settings_obj;
class Buffer {
public:
Buffer();
void open(fs::FS* fs, String fn = "");
void close(fs::FS* fs);
void addPacket(uint8_t* buf, uint32_t len);
void save(fs::FS* fs);
void forceSave(fs::FS* fs);
private:
void write(int32_t n);
void write(uint32_t n);
void write(uint16_t n);
void write(uint8_t* buf, uint32_t len);
uint8_t* bufA;
uint8_t* bufB;
uint32_t bufSizeA = 0;
uint32_t bufSizeB = 0;
bool writing = false; // acceppting writes to buffer
bool useA = true; // writing to bufA or bufB
bool saving = false; // currently saving onto the SD card
String fileName = "/0.pcap";
File file;
};
#endif

View File

@@ -51,10 +51,10 @@ void Display::RunSetup()
// Initialize file system
// This should probably have its own class
if (!SPIFFS.begin()) {
Serial.println(F("SPIFFS initialisation failed!"));
while (1) yield(); // Stay here twiddling thumbs waiting
}
//if (!SPIFFS.begin()) {
// Serial.println(F("SPIFFS initialisation failed!"));
//while (1) yield(); // Stay here twiddling thumbs waiting
//}
//this->initLVGL();
@@ -68,6 +68,10 @@ void Display::RunSetup()
//digitalWrite(TFT_BL, HIGH);
//delay(5000);
#ifdef KIT
pinMode(KIT_LED_BUILTIN, OUTPUT);
#endif
}
/* Interrupt driven periodic handler */
@@ -140,6 +144,33 @@ bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
return false;
}*/
void Display::drawFrame()
{
tft.drawRect(FRAME_X, FRAME_Y, FRAME_W, FRAME_H, TFT_BLACK);
}
void Display::tftDrawRedOnOffButton() {
tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_RED);
tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_DARKGREY);
drawFrame();
tft.setTextColor(TFT_WHITE);
tft.setTextSize(2);
tft.setTextDatum(MC_DATUM);
tft.drawString("ON", GREENBUTTON_X + (GREENBUTTON_W / 2), GREENBUTTON_Y + (GREENBUTTON_H / 2));
this->SwitchOn = false;
}
void Display::tftDrawGreenOnOffButton() {
tft.fillRect(GREENBUTTON_X, GREENBUTTON_Y, GREENBUTTON_W, GREENBUTTON_H, TFT_GREEN);
tft.fillRect(REDBUTTON_X, REDBUTTON_Y, REDBUTTON_W, REDBUTTON_H, TFT_DARKGREY);
drawFrame();
tft.setTextColor(TFT_WHITE);
tft.setTextSize(2);
tft.setTextDatum(MC_DATUM);
tft.drawString("OFF", REDBUTTON_X + (REDBUTTON_W / 2) + 1, REDBUTTON_Y + (REDBUTTON_H / 2));
this->SwitchOn = true;
}
void Display::tftDrawGraphObjects(byte x_scale)
{
//draw the graph objects
@@ -440,18 +471,21 @@ void Display::scrollAddress(uint16_t vsp) {
void Display::drawJpeg(const char *filename, int xpos, int ypos) {
// Open the named file (the Jpeg decoder library will close it after rendering image)
fs::File jpegFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
//fs::File jpegFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
//jpegFile.close();
//ESP32 always seems to return 1 for jpegFile so this null trap does not work
if ( !jpegFile ) {
Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
return;
}
//if ( !jpegFile ) {
// Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
// return;
//}
// Use one of the three following methods to initialise the decoder,
// the filename can be a String or character array type:
boolean decoded = JpegDec.decodeFsFile(filename); // or pass the filename (leading / distinguishes SPIFFS files)
//boolean decoded = JpegDec.decodeFsFile(filename); // or pass the filename (leading / distinguishes SPIFFS files)
boolean decoded = JpegDec.decodeArray(MarauderTitle, 13578);
if (decoded) {
// print information about the image to the serial port
@@ -615,7 +649,7 @@ void Display::jpegRender(int xpos, int ypos) {
// Print information decoded from the Jpeg image
//====================================================================================
void Display::jpegInfo() {
/*
Serial.println("===============");
Serial.println("JPEG image info");
Serial.println("===============");
@@ -629,7 +663,7 @@ void Display::jpegInfo() {
Serial.print ("MCU height :"); Serial.println(JpegDec.MCUHeight);
Serial.println("===============");
Serial.println("");
*/
}
//====================================================================================

View File

@@ -1,179 +1,204 @@
#ifndef Display_h
#define Display_h
#include <FS.h>
#include <functional>
#include <JPEGDecoder.h>
//#include <SimpleList.h>
#include <LinkedList.h>
#include <SPI.h>
#include <lvgl.h>
#include <Ticker.h>
//#include <M5Stack.h>
#include "SPIFFS.h"
#include "Assets.h"
#include <TFT_eSPI.h>
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 27
#define TFT_DC 26
#define TFT_RST 5
#define TFT_BL 32
#define TOUCH_CS 21
#define SD_CS 4
// WiFi stuff
#define OTA_UPDATE 100
#define SHOW_INFO 101
#define WIFI_SCAN_OFF 0
#define WIFI_SCAN_PROBE 1
#define WIFI_SCAN_AP 2
#define WIFI_SCAN_PWN 3
#define WIFI_SCAN_EAPOL 4
#define WIFI_SCAN_DEAUTH 5
#define WIFI_SCAN_ALL 6
#define WIFI_PACKET_MONITOR 7
#define WIFI_ATTACK_BEACON_SPAM 8
#define WIFI_ATTACK_RICK_ROLL 9
#define BT_SCAN_ALL 10
#define BT_SCAN_SKIMMERS 11
#define WIFI_SCAN_ESPRESSIF 12
#define LV_JOIN_WIFI 13
#define LV_ADD_SSID 14
#define WIFI_ATTACK_BEACON_LIST 15
#define TFT_SHIELD
//#define TFT_DIY
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define HEIGHT_1 240
#define WIDTH_1 320
#define STANDARD_FONT_CHAR_LIMIT 40 // number of characters on a single line with normal font
#define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
#define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
#define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
#define YMAX 320 // Bottom of screen area
#define minimum(a,b) (((a) < (b)) ? (a) : (b))
//#define MENU_FONT NULL
#define MENU_FONT &FreeMono9pt7b // Winner
//#define MENU_FONT &FreeMonoBold9pt7b
//#define MENU_FONT &FreeSans9pt7b
//#define MENU_FONT &FreeSansBold9pt7b
#define BUTTON_ARRAY_LEN 9
#define STATUS_BAR_WIDTH 16
#define LVGL_TICK_PERIOD 6
#define STATUSBAR_COLOR 0x4A49
/*
PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
PROGMEM static lv_disp_buf_t disp_buf;
PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
PROGMEM static void keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
// lvgl stuff
PROGMEM static lv_obj_t *kb;
*/
class Display
{
private:
bool run_setup = true;
// For the byte we read from the serial port
byte data = 0;
// A few test variables used during debugging
boolean change_colour = 1;
boolean selected = 1;
//void addNodes(Menu* menu, String name, Menu* child, std::function<void()> callable);
//void changeMenu(Menu* menu);
//void showMenuList(Menu* menu, int layer);
//static void lv_tick_handler();
public:
Display();
//Ticker tick;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
const String PROGMEM version_number = "v0.9.1";
bool printing = false;
bool loading = false;
bool tteBar = false;
bool draw_tft = false;
bool exit_draw = false;
int TOP_FIXED_AREA_2 = 48;
int print_delay_1, print_delay_2 = 10;
int current_banner_pos = SCREEN_WIDTH;
//Menu* current_menu;
//Menu mainMenu;
//Menu wifiMenu;
//Menu bluetoothMenu;
LinkedList<String>* display_buffer;
// The initial y coordinate of the top of the bottom text line
uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
// Keep track of the drawing x coordinate
uint16_t xPos = 0;
// The initial y coordinate of the top of the scrolling area
uint16_t yStart = TOP_FIXED_AREA_2;
// yArea must be a integral multiple of TEXT_HEIGHT
uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
// We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
// for a full width line, meanwhile the serial buffer may be filling... and overflowing
// We can speed up scrolling of short text lines by just blanking the character we drew
int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
//void initLVGL();
//void deinitLVGL();
//void joinWiFiGFX();
void tftDrawGraphObjects(byte x_scale);
void tftDrawEapolColorKey();
void tftDrawColorKey();
void tftDrawXScaleButtons(byte x_scale);
void tftDrawYScaleButtons(byte y_scale);
void tftDrawChannelScaleButtons(int set_channel);
void tftDrawExitScaleButtons();
void buildBanner(String msg, int xpos);
void clearScreen();
void displayBuffer(bool do_clear = false);
void drawJpeg(const char *filename, int xpos, int ypos);
void setupDraw();
void drawStylus();
void getTouchWhileFunction(bool pressed);
void initScrollValues(bool tte = false);
void jpegInfo();
void jpegRender(int xpos, int ypos);
void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
void listFiles();
void main(uint8_t scan_mode);
void RunSetup();
void scrollAddress(uint16_t vsp);
int scroll_line(uint32_t color);
void setupScrollArea(uint16_t tfa, uint16_t bfa);
void showCenterText(String text, int y);
void touchToExit();
void twoPartDisplay(String center_text);
void updateBanner(String msg);
};
#endif
#ifndef Display_h
#define Display_h
#include <FS.h>
#include <functional>
#include <JPEGDecoder.h>
//#include <SimpleList.h>
#include <LinkedList.h>
#include <SPI.h>
#include <lvgl.h>
#include <Ticker.h>
//#include <M5Stack.h>
#include "SPIFFS.h"
#include "Assets.h"
#include <TFT_eSPI.h>
#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 27
#define TFT_DC 26
#define TFT_RST 5
#define TFT_BL 32
#define TOUCH_CS 21
#define SD_CS 4
// WiFi stuff
#define OTA_UPDATE 100
#define SHOW_INFO 101
#define WIFI_SCAN_OFF 0
#define WIFI_SCAN_PROBE 1
#define WIFI_SCAN_AP 2
#define WIFI_SCAN_PWN 3
#define WIFI_SCAN_EAPOL 4
#define WIFI_SCAN_DEAUTH 5
#define WIFI_SCAN_ALL 6
#define WIFI_PACKET_MONITOR 7
#define WIFI_ATTACK_BEACON_SPAM 8
#define WIFI_ATTACK_RICK_ROLL 9
#define BT_SCAN_ALL 10
#define BT_SCAN_SKIMMERS 11
#define WIFI_SCAN_ESPRESSIF 12
#define LV_JOIN_WIFI 13
#define LV_ADD_SSID 14
#define WIFI_ATTACK_BEACON_LIST 15
#define TFT_SHIELD
//#define TFT_DIY
//#define KIT
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#define HEIGHT_1 240
#define WIDTH_1 320
#define STANDARD_FONT_CHAR_LIMIT 40 // number of characters on a single line with normal font
#define TEXT_HEIGHT 16 // Height of text to be printed and scrolled
#define BOT_FIXED_AREA 0 // Number of lines in bottom fixed area (lines counted from bottom of screen)
#define TOP_FIXED_AREA 48 // Number of lines in top fixed area (lines counted from top of screen)
#define YMAX 320 // Bottom of screen area
#define minimum(a,b) (((a) < (b)) ? (a) : (b))
//#define MENU_FONT NULL
#define MENU_FONT &FreeMono9pt7b // Winner
//#define MENU_FONT &FreeMonoBold9pt7b
//#define MENU_FONT &FreeSans9pt7b
//#define MENU_FONT &FreeSansBold9pt7b
#define BUTTON_ARRAY_LEN 9
#define STATUS_BAR_WIDTH 16
#define LVGL_TICK_PERIOD 6
#define FRAME_X 100
#define FRAME_Y 64
#define FRAME_W 120
#define FRAME_H 50
// Red zone size
#define REDBUTTON_X FRAME_X
#define REDBUTTON_Y FRAME_Y
#define REDBUTTON_W (FRAME_W/2)
#define REDBUTTON_H FRAME_H
// Green zone size
#define GREENBUTTON_X (REDBUTTON_X + REDBUTTON_W)
#define GREENBUTTON_Y FRAME_Y
#define GREENBUTTON_W (FRAME_W/2)
#define GREENBUTTON_H FRAME_H
#define STATUSBAR_COLOR 0x4A49
#define KIT_LED_BUILTIN 13
/*
PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
PROGMEM static lv_disp_buf_t disp_buf;
PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
PROGMEM static void keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
// lvgl stuff
PROGMEM static lv_obj_t *kb;
*/
class Display
{
private:
bool SwitchOn = false;
bool run_setup = true;
// For the byte we read from the serial port
byte data = 0;
// A few test variables used during debugging
boolean change_colour = 1;
boolean selected = 1;
void drawFrame();
//void addNodes(Menu* menu, String name, Menu* child, std::function<void()> callable);
//void changeMenu(Menu* menu);
//void showMenuList(Menu* menu, int layer);
//static void lv_tick_handler();
public:
Display();
//Ticker tick;
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
const String PROGMEM version_number = "v0.9.5";
bool printing = false;
bool loading = false;
bool tteBar = false;
bool draw_tft = false;
bool exit_draw = false;
int TOP_FIXED_AREA_2 = 48;
int print_delay_1, print_delay_2 = 10;
int current_banner_pos = SCREEN_WIDTH;
//Menu* current_menu;
//Menu mainMenu;
//Menu wifiMenu;
//Menu bluetoothMenu;
LinkedList<String>* display_buffer;
// The initial y coordinate of the top of the bottom text line
uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
// Keep track of the drawing x coordinate
uint16_t xPos = 0;
// The initial y coordinate of the top of the scrolling area
uint16_t yStart = TOP_FIXED_AREA_2;
// yArea must be a integral multiple of TEXT_HEIGHT
uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
// We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
// for a full width line, meanwhile the serial buffer may be filling... and overflowing
// We can speed up scrolling of short text lines by just blanking the character we drew
int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
//void initLVGL();
//void deinitLVGL();
//void joinWiFiGFX();
void tftDrawRedOnOffButton();
void tftDrawGreenOnOffButton();
void tftDrawGraphObjects(byte x_scale);
void tftDrawEapolColorKey();
void tftDrawColorKey();
void tftDrawXScaleButtons(byte x_scale);
void tftDrawYScaleButtons(byte y_scale);
void tftDrawChannelScaleButtons(int set_channel);
void tftDrawExitScaleButtons();
void buildBanner(String msg, int xpos);
void clearScreen();
void displayBuffer(bool do_clear = false);
void drawJpeg(const char *filename, int xpos, int ypos);
void setupDraw();
void drawStylus();
void getTouchWhileFunction(bool pressed);
void initScrollValues(bool tte = false);
void jpegInfo();
void jpegRender(int xpos, int ypos);
void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
void listFiles();
void main(uint8_t scan_mode);
void RunSetup();
void scrollAddress(uint16_t vsp);
int scroll_line(uint32_t color);
void setupScrollArea(uint16_t tfa, uint16_t bfa);
void showCenterText(String text, int y);
void touchToExit();
void twoPartDisplay(String center_text);
void updateBanner(String msg);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,207 +1,217 @@
#ifndef MenuFunctions_h
#define MenuFunctions_h
#define BATTERY_ANALOG_ON 0
#include "WiFiScan.h"
#include "Display.h"
#include "BatteryInterface.h"
#include "SDInterface.h"
#include "Web.h"
#include "esp_interface.h"
#include "a32u4_interface.h"
extern Display display_obj;
extern WiFiScan wifi_scan_obj;
extern Web web_obj;
extern SDInterface sd_obj;
extern BatteryInterface battery_obj;
extern EspInterface esp_obj;
extern A32u4Interface a32u4_obj;
// Keypad start position, key sizes and spacing
#define KEY_X 120 // Centre of key
#define KEY_Y 50
#define KEY_W 240 // Width and height
#define KEY_H 22
#define KEY_SPACING_X 0 // X and Y gap
#define KEY_SPACING_Y 1
#define KEY_TEXTSIZE 1 // Font size multiplier
#define ICON_W 22
#define ICON_H 22
#define BUTTON_PADDING 22
//#define BUTTON_ARRAY_LEN 5
#define FLASH_BUTTON 0
#if BATTERY_ANALOG_ON == 1
#define BATTERY_PIN 13
#define ANALOG_PIN 34
#define CHARGING_PIN 27
#endif
// Icon definitions
#define ATTACKS 0
#define BEACON_SNIFF 1
#define BLUETOOTH 2
#define BLUETOOTH_SNIFF 3
#define DEAUTH_SNIFF 4
#define DRAW 5
#define PACKET_MONITOR 6
#define PROBE_SNIFF 7
#define SCANNERS 8
#define CC_SKIMMERS 9
#define SNIFFERS 10
#define WIFI 11
#define BEACON_SPAM 12
#define RICK_ROLL 13
#define REBOOT 14
#define GENERAL_APPS 15
#define UPDATE 16
#define DEVICE 17
#define DEVICE_INFO 18
#define SD_UPDATE 19
#define WEB_UPDATE 20
#define EAPOL 21
#define STATUS_BAT 22
#define STATUS_SD 23
#define PWNAGOTCHI 24
#define ESPRESSIF 25
#define SHUTDOWN 26
#define BEACON_LIST 27
#define GENERATE 28
#define CLEAR_ICO 29
#define KEYBOARD_ICO 30
#define JOIN_WIFI 31
#define ESP_UPDATE_ICO 32
#define BAD_USB_ICO 33
#define TEST_BAD_USB_ICO 34
PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
PROGMEM static lv_disp_buf_t disp_buf;
PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
PROGMEM static void test_btn_cb(lv_obj_t * load_btn, lv_event_t event);
PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
// lvgl stuff
PROGMEM static lv_obj_t *kb;
PROGMEM static lv_obj_t * save_as_kb;
struct Menu;
// Individual Nodes of a menu
struct MenuNode {
String name;
uint16_t color;
int icon;
TFT_eSPI_Button* button;
std::function<void()> callable;
};
// Full Menus
struct Menu {
String name;
LinkedList<MenuNode>* list;
Menu * parentMenu;
//uint8_t selected;
};
class MenuFunctions
{
private:
String u_result = "";
uint32_t initTime = 0;
//Menu* current_menu;
// Main menu stuff
Menu mainMenu;
Menu wifiMenu;
Menu bluetoothMenu;
Menu badusbMenu;
Menu generalMenu;
Menu deviceMenu;
// Device menu stuff
Menu whichUpdateMenu;
Menu failedUpdateMenu;
Menu confirmMenu;
Menu espUpdateMenu;
Menu updateMenu;
Menu infoMenu;
// WiFi menu stuff
Menu wifiSnifferMenu;
Menu wifiAttackMenu;
Menu wifiGeneralMenu;
// Bluetooth menu stuff
Menu bluetoothSnifferMenu;
Menu bluetoothGeneralMenu;
// Settings things menus
Menu shutdownWiFiMenu;
Menu shutdownBLEMenu;
Menu generateSSIDsMenu;
Menu clearSSIDsMenu;
Menu clearAPsMenu;
static void lv_tick_handler();
// Menu icons
//TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
void drawStatusBar();
void updateStatusBar();
void battery(bool initial = false);
void battery2(bool initial = false);
void showMenuList(Menu* menu, int layer);
public:
MenuFunctions();
Menu* current_menu;
Ticker tick;
uint16_t x = -1, y = -1;
boolean pressed = false;
String loaded_file = "";
void initLVGL();
void deinitLVGL();
void joinWiFiGFX();
void addSSIDGFX();
void addAPGFX();
void writeBadUSB();
void buildButtons(Menu* menu);
void changeMenu(Menu* menu);
void displayCurrentMenu();
void main(uint32_t currentTime);
void RunSetup();
void orientDisplay();
};
#endif
#ifndef MenuFunctions_h
#define MenuFunctions_h
#define BATTERY_ANALOG_ON 0
#include "WiFiScan.h"
#include "Display.h"
#include "BatteryInterface.h"
#include "SDInterface.h"
#include "Web.h"
#include "esp_interface.h"
#include "a32u4_interface.h"
#include "settings.h"
extern Display display_obj;
extern WiFiScan wifi_scan_obj;
extern Web web_obj;
extern SDInterface sd_obj;
extern BatteryInterface battery_obj;
extern EspInterface esp_obj;
extern A32u4Interface a32u4_obj;
extern Settings settings_obj;
// Keypad start position, key sizes and spacing
#define KEY_X 120 // Centre of key
#define KEY_Y 50
#define KEY_W 240 // Width and height
#define KEY_H 22
#define KEY_SPACING_X 0 // X and Y gap
#define KEY_SPACING_Y 1
#define KEY_TEXTSIZE 1 // Font size multiplier
#define ICON_W 22
#define ICON_H 22
#define BUTTON_PADDING 22
//#define BUTTON_ARRAY_LEN 5
#define FLASH_BUTTON 0
#if BATTERY_ANALOG_ON == 1
#define BATTERY_PIN 13
#define ANALOG_PIN 34
#define CHARGING_PIN 27
#endif
// Icon definitions
#define ATTACKS 0
#define BEACON_SNIFF 1
#define BLUETOOTH 2
#define BLUETOOTH_SNIFF 3
#define DEAUTH_SNIFF 4
#define DRAW 5
#define PACKET_MONITOR 6
#define PROBE_SNIFF 7
#define SCANNERS 8
#define CC_SKIMMERS 9
#define SNIFFERS 10
#define WIFI 11
#define BEACON_SPAM 12
#define RICK_ROLL 13
#define REBOOT 14
#define GENERAL_APPS 15
#define UPDATE 16
#define DEVICE 17
#define DEVICE_INFO 18
#define SD_UPDATE 19
#define WEB_UPDATE 20
#define EAPOL 21
#define STATUS_BAT 22
#define STATUS_SD 23
#define PWNAGOTCHI 24
#define ESPRESSIF 25
#define SHUTDOWN 26
#define BEACON_LIST 27
#define GENERATE 28
#define CLEAR_ICO 29
#define KEYBOARD_ICO 30
#define JOIN_WIFI 31
#define ESP_UPDATE_ICO 32
#define BAD_USB_ICO 33
#define TEST_BAD_USB_ICO 34
PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
PROGMEM static lv_disp_buf_t disp_buf;
PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
PROGMEM static void test_btn_cb(lv_obj_t * load_btn, lv_event_t event);
PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event);
PROGMEM static void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
// lvgl stuff
PROGMEM static lv_obj_t *kb;
PROGMEM static lv_obj_t * save_as_kb;
struct Menu;
// Individual Nodes of a menu
struct MenuNode {
String name;
uint16_t color;
int icon;
TFT_eSPI_Button* button;
bool selected;
std::function<void()> callable;
};
// Full Menus
struct Menu {
String name;
LinkedList<MenuNode>* list;
Menu * parentMenu;
//uint8_t selected;
};
class MenuFunctions
{
private:
String u_result = "";
uint32_t initTime = 0;
//Menu* current_menu;
// Main menu stuff
Menu mainMenu;
Menu wifiMenu;
Menu bluetoothMenu;
Menu badusbMenu;
Menu generalMenu;
Menu deviceMenu;
// Device menu stuff
Menu whichUpdateMenu;
Menu failedUpdateMenu;
Menu confirmMenu;
Menu espUpdateMenu;
Menu updateMenu;
Menu settingsMenu;
Menu specSettingMenu;
Menu infoMenu;
// WiFi menu stuff
Menu wifiSnifferMenu;
Menu wifiAttackMenu;
Menu wifiGeneralMenu;
// Bluetooth menu stuff
Menu bluetoothSnifferMenu;
Menu bluetoothGeneralMenu;
// Settings things menus
Menu shutdownWiFiMenu;
Menu shutdownBLEMenu;
Menu generateSSIDsMenu;
Menu clearSSIDsMenu;
Menu clearAPsMenu;
static void lv_tick_handler();
// Menu icons
//TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false);
void drawStatusBar();
void updateStatusBar();
void battery(bool initial = false);
void battery2(bool initial = false);
void showMenuList(Menu* menu, int layer);
String callSetting(String key);
void runBoolSetting(String ley);
void displaySetting(String key, Menu* menu, int index);
public:
MenuFunctions();
Menu* current_menu;
Ticker tick;
uint16_t x = -1, y = -1;
boolean pressed = false;
String loaded_file = "";
void initLVGL();
void deinitLVGL();
void joinWiFiGFX();
void addSSIDGFX();
void addAPGFX();
void displaySettingsGFX();
void writeBadUSB();
void buildButtons(Menu* menu);
void changeMenu(Menu* menu);
void displayCurrentMenu();
void main(uint32_t currentTime);
void RunSetup();
void orientDisplay();
};
#endif

View File

@@ -2,6 +2,18 @@
bool SDInterface::initSD() {
String display_string = "";
#ifdef KIT
pinMode(SD_DET, INPUT);
if (digitalRead(SD_DET) == LOW) {
Serial.println(F("SD Card Detect Pin Detected"));
}
else {
Serial.println(F("SD Card Detect Pin Not Detected"));
this->supported = false;
return false;
}
#endif
if (!SD.begin(SD_CS)) {
Serial.println(F("Failed to mount SD Card"));
@@ -167,11 +179,28 @@ void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) {
}
}
bool SDInterface::checkDetectPin() {
#ifdef KIT
if (digitalRead(SD_DET) == LOW)
return true;
else
return false;
#endif
return false;
}
void SDInterface::main() {
if ((this->supported) && (this->do_save)) {
//Serial.println("Saving packet...");
buffer_obj.forceSave(&SD);
}
else if (!this->supported) {
if (checkDetectPin()) {
delay(100);
this->initSD();
}
}
}
//void SDInterface::savePacket(uint8_t* buf, uint32_t len) {

View File

@@ -11,9 +11,14 @@ extern Display display_obj;
#define SD_CS 12
#ifdef KIT
#define SD_DET 4
#endif
class SDInterface {
private:
bool checkDetectPin();
public:
uint8_t cardType;

View File

@@ -69,7 +69,7 @@ void Web::setupOTAupdate()
Serial.println(wifi_scan_obj.freeRAM());
Serial.println("Starting softAP...");
esp_wifi_set_mac(ESP_IF_WIFI_AP, &newMACAddress[0]);
esp_wifi_set_mac(WIFI_IF_AP, &newMACAddress[0]);
WiFi.softAP(ssid, password);
Serial.println("");

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,7 @@
// Testing NimBLE
#include <NimBLEDevice.h>
#include <NimBLEAdvertisedDevice.h>
//#include <NimBLEAdvertisedDevice.h>
#include <WiFi.h>
#include <math.h>
@@ -21,6 +21,7 @@
#include "Buffer.h"
#include "BatteryInterface.h"
#include "TemperatureInterface.h"
#include "settings.h"
#include "Assets.h"
//#include "MenuFunctions.h"
@@ -48,6 +49,8 @@
#define WIFI_SCAN_TARGET_AP 16
#define LV_SELECT_AP 17
#define WIFI_ATTACK_AUTH 18
#define WIFI_ATTACK_MIMIC 19
#define WIFI_ATTACK_DEAUTH 20
#define GRAPH_REFRESH 100
@@ -58,8 +61,10 @@ extern SDInterface sd_obj;
extern Buffer buffer_obj;
extern BatteryInterface battery_obj;
extern TemperatureInterface temp_obj;
extern Settings settings_obj;
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
//int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3);
struct ssid {
String essid;
@@ -76,6 +81,12 @@ struct AccessPoint {
class WiFiScan
{
private:
// Settings
int channel_hop_delay = 1;
bool force_pmkid = false;
bool force_probe = false;
bool save_pcap = false;
int x_pos; //position along the graph x axis
float y_pos_x; //current graph y axis position of X value
float y_pos_x_old = 120; //old y axis position of X value
@@ -89,16 +100,19 @@ class WiFiScan
bool do_break = false;
bool wsl_bypass_enabled = false;
//int num_beacon = 0; // GREEN
//int num_probe = 0; // BLUE
//int num_deauth = 0; // RED
uint32_t initTime = 0;
bool run_setup = true;
void initWiFi(uint8_t scan_mode);
int bluetoothScanTime = 5;
int packets_sent = 0;
const wifi_promiscuous_filter_t filt = {.filter_mask=WIFI_PROMIS_FILTER_MASK_MGMT | WIFI_PROMIS_FILTER_MASK_DATA};
BLEScan* pBLEScan;
NimBLEScan* pBLEScan;
//String connected_network = "";
String alfa = "1234567890qwertyuiopasdfghjkklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM_";
@@ -128,8 +142,8 @@ class WiFiScan
} __attribute__((packed)) WifiMgmtHdr;
typedef struct {
WifiMgmtHdr hdr;
uint8_t payload[0];
WifiMgmtHdr hdr;
} wifi_ieee80211_packet_t;
// barebones packet
@@ -181,6 +195,16 @@ class WiFiScan
/* SSID */
};
uint8_t deauth_frame_default[26] = {
0xc0, 0x00, 0x3a, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0xff, 0x02, 0x00
};
void startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string);
void packetMonitorMain(uint32_t currentTime);
void eapolMonitorMain(uint32_t currentTime);
void changeChannel();
@@ -191,14 +215,17 @@ class WiFiScan
void tftDrawColorKey();
void tftDrawGraphObjects();
void sendProbeAttack(uint32_t currentTime);
void sendDeauthAttack(uint32_t currentTime);
void broadcastRandomSSID(uint32_t currentTime);
void broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid);
void broadcastSetSSID(uint32_t current_time, char* ESSID);
void RunAPScan(uint8_t scan_mode, uint16_t color);
void RunRickRoll(uint8_t scan_mode, uint16_t color);
void RunBeaconSpam(uint8_t scan_mode, uint16_t color);
void RunProbeFlood(uint8_t scan_mode, uint16_t color);
void RunBeaconList(uint8_t scan_mode, uint16_t color);
//void RunRickRoll(uint8_t scan_mode, uint16_t color);
//void RunBeaconSpam(uint8_t scan_mode, uint16_t color);
//void RunProbeFlood(uint8_t scan_mode, uint16_t color);
//void RunDeauthFlood(uint8_t scan_mode, uint16_t color);
void RunMimicFlood(uint8_t scan_mode, uint16_t color);
//void RunBeaconList(uint8_t scan_mode, uint16_t color);
void RunEspressifScan(uint8_t scan_mode, uint16_t color);
void RunPwnScan(uint8_t scan_mode, uint16_t color);
void RunBeaconScan(uint8_t scan_mode, uint16_t color);
@@ -210,6 +237,8 @@ class WiFiScan
void RunLvJoinWiFi(uint8_t scan_mode, uint16_t color);
static void scanCompleteCB(BLEScanResults scanResults);
//int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3);
public:
WiFiScan();
@@ -231,8 +260,9 @@ class WiFiScan
//lv_obj_t * scr = lv_cont_create(NULL, NULL);
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
char* stringToChar(String string);
void RunSetup();
int clearSSIDs();
int clearAPs();

View File

@@ -28,6 +28,7 @@ https://www.online-utility.org/image/convert/to/XBM
#include "LedInterface.h"
#include "esp_interface.h"
#include "a32u4_interface.h"
#include "settings.h"
//#include "icons.h"
/*
@@ -52,6 +53,7 @@ TemperatureInterface temp_obj;
LedInterface led_obj;
EspInterface esp_obj;
A32u4Interface a32u4_obj;
Settings settings_obj;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);
@@ -74,6 +76,10 @@ void setup()
Serial.begin(115200);
//Serial.begin(115200);
Serial.println("\n\nHello, World!\n");
Serial.println("ESP-IDF version is: " + String(esp_get_idf_version()));
display_obj.RunSetup();
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -110,6 +116,14 @@ void setup()
//Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8));
settings_obj.begin();
Serial.println("This is a test Channel: " + (String)settings_obj.loadSetting<uint8_t>("Channel"));
if (settings_obj.loadSetting<bool>("Force PMKID"))
Serial.println("This is a test Force PMKID: true");
else
Serial.println("This is a test Force PMKID: false");
wifi_scan_obj.RunSetup();
Serial.println(wifi_scan_obj.freeRAM());
@@ -184,9 +198,9 @@ void setup()
digitalWrite(TFT_BL, HIGH);
*/
esp_obj.begin();
//esp_obj.begin();
a32u4_obj.begin(); // This goes last to make sure nothing is messed up when reading serial
//a32u4_obj.begin(); // This goes last to make sure nothing is messed up when reading serial
display_obj.tft.println(F("Starting..."));
@@ -214,8 +228,9 @@ void loop()
sd_obj.main();
battery_obj.main(currentTime);
temp_obj.main(currentTime);
esp_obj.main(currentTime);
a32u4_obj.main(currentTime);
settings_obj.main(currentTime);
//esp_obj.main(currentTime);
//a32u4_obj.main(currentTime);
//led_obj.main(currentTime);
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
if ((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) &&
@@ -233,7 +248,7 @@ void loop()
else if (wifi_scan_obj.currentScanMode == ESP_UPDATE) {
display_obj.main(wifi_scan_obj.currentScanMode);
menu_function_obj.main(currentTime);
esp_obj.program();
//esp_obj.program();
delay(1);
}
//else

Binary file not shown.

304
esp32_marauder/settings.cpp Normal file
View File

@@ -0,0 +1,304 @@
#include "settings.h"
String Settings::getSettingsString() {
return this->json_settings_string;
}
bool Settings::begin() {
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
Serial.println("Settings SPIFFS Mount Failed");
return false;
}
File settingsFile;
//SPIFFS.remove("/settings.json"); // NEED TO REMOVE THIS LINE
if (SPIFFS.exists("/settings.json")) {
settingsFile = SPIFFS.open("/settings.json", FILE_READ);
if (!settingsFile) {
settingsFile.close();
Serial.println(F("Could not find settings file"));
if (this->createDefaultSettings(SPIFFS))
return true;
else
return false;
}
}
else {
Serial.println("Settings file does not exist");
if (this->createDefaultSettings(SPIFFS))
return true;
else
return false;
}
String json_string;
DynamicJsonDocument jsonBuffer(1024);
DeserializationError error = deserializeJson(jsonBuffer, settingsFile);
serializeJson(jsonBuffer, json_string);
Serial.println("Settings: " + (String)json_string + "\n");
this->printJsonSettings(json_string);
this->json_settings_string = json_string;
return true;
}
template <typename T>
T Settings::loadSetting(String key) {}
// Get type int settings
template<>
int Settings::loadSetting<int>(String key) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key)
return json["Settings"][i]["value"];
}
return 0;
}
// Get type string settings
template<>
String Settings::loadSetting<String>(String key) {
//return this->json_settings_string;
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key)
return json["Settings"][i]["value"];
}
return "";
}
// Get type bool settings
template<>
bool Settings::loadSetting<bool>(String key) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key)
return json["Settings"][i]["value"];
}
return false;
}
//Get type uint8_t settings
template<>
uint8_t Settings::loadSetting<uint8_t>(String key) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key)
return json["Settings"][i]["value"];
}
return 0;
}
template <typename T>
T Settings::saveSetting(String key, bool value) {}
template<>
bool Settings::saveSetting<bool>(String key, bool value) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
String settings_string;
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key) {
json["Settings"][i]["value"] = value;
Serial.println("Saving setting...");
File settingsFile = SPIFFS.open("/settings.json", FILE_WRITE);
if (!settingsFile) {
Serial.println(F("Failed to create settings file"));
return false;
}
if (serializeJson(json, settingsFile) == 0) {
Serial.println(F("Failed to write to file"));
}
if (serializeJson(json, settings_string) == 0) {
Serial.println(F("Failed to write to string"));
}
// Close the file
settingsFile.close();
this->json_settings_string = settings_string;
this->printJsonSettings(settings_string);
return true;
}
}
}
bool Settings::toggleSetting(String key) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key) {
if (json["Settings"][i]["value"]) {
saveSetting<bool>(key, false);
Serial.println("Setting value to false");
return false;
}
else {
saveSetting<bool>(key, true);
Serial.println("Setting value to true");
return true;
}
return false;
}
}
}
String Settings::setting_index_to_name(int i) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
return json["Settings"][i]["name"];
}
int Settings::getNumberSettings() {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
return json["Settings"].size();
}
String Settings::getSettingType(String key) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, this->json_settings_string)) {
Serial.println("\nCould not parse json");
}
for (int i = 0; i < json["Settings"].size(); i++) {
if (json["Settings"][i]["name"].as<String>() == key)
return json["Settings"][i]["type"];
}
}
void Settings::printJsonSettings(String json_string) {
DynamicJsonDocument json(1024); // ArduinoJson v6
if (deserializeJson(json, json_string)) {
Serial.println("\nCould not parse json");
}
Serial.println("Settings\n----------------------------------------------");
for (int i = 0; i < json["Settings"].size(); i++) {
Serial.println("Name: " + json["Settings"][i]["name"].as<String>());
Serial.println("Type: " + json["Settings"][i]["type"].as<String>());
Serial.println("Value: " + json["Settings"][i]["value"].as<String>());
Serial.println("----------------------------------------------");
}
}
bool Settings::createDefaultSettings(fs::FS &fs) {
Serial.println(F("Creating default settings file: settings.json"));
File settingsFile = fs.open("/settings.json", FILE_WRITE);
if (!settingsFile) {
Serial.println(F("Failed to create settings file"));
return false;
}
DynamicJsonDocument jsonBuffer(1024);
String settings_string;
//jsonBuffer["Settings"][0]["name"] = "Channel";
//jsonBuffer["Settings"][0]["type"] = "uint8_t";
//jsonBuffer["Settings"][0]["value"] = 11;
//jsonBuffer["Settings"][0]["range"]["min"] = 1;
//jsonBuffer["Settings"][0]["range"]["max"] = 14;
//jsonBuffer["Settings"][1]["name"] = "Channel Hop Delay";
//jsonBuffer["Settings"][1]["type"] = "int";
//jsonBuffer["Settings"][1]["value"] = 1;
//jsonBuffer["Settings"][1]["range"]["min"] = 1;
//jsonBuffer["Settings"][1]["range"]["max"] = 10;
jsonBuffer["Settings"][0]["name"] = "Force PMKID";
jsonBuffer["Settings"][0]["type"] = "bool";
jsonBuffer["Settings"][0]["value"] = true;
jsonBuffer["Settings"][0]["range"]["min"] = false;
jsonBuffer["Settings"][0]["range"]["max"] = true;
jsonBuffer["Settings"][1]["name"] = "Force Probe";
jsonBuffer["Settings"][1]["type"] = "bool";
jsonBuffer["Settings"][1]["value"] = true;
jsonBuffer["Settings"][1]["range"]["min"] = false;
jsonBuffer["Settings"][1]["range"]["max"] = true;
jsonBuffer["Settings"][2]["name"] = "Save PCAP";
jsonBuffer["Settings"][2]["type"] = "bool";
jsonBuffer["Settings"][2]["value"] = true;
jsonBuffer["Settings"][2]["range"]["min"] = false;
jsonBuffer["Settings"][2]["range"]["max"] = true;
//jsonBuffer.printTo(settingsFile);
if (serializeJson(jsonBuffer, settingsFile) == 0) {
Serial.println(F("Failed to write to file"));
}
if (serializeJson(jsonBuffer, settings_string) == 0) {
Serial.println(F("Failed to write to string"));
}
// Close the file
settingsFile.close();
this->json_settings_string = settings_string;
this->printJsonSettings(settings_string);
return true;
}
void Settings::main(uint32_t currentTime) {
}

52
esp32_marauder/settings.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef Settings_h
#define Settings_h
#include "SPIFFS.h"
#include <FS.h>
#include <ArduinoJson.h>
#define FORMAT_SPIFFS_IF_FAILED true
#include "Display.h"
extern Display display_obj;
class Settings {
private:
String json_settings_string;
void printJsonSettings(String json_string);
bool createDefaultSettings(fs::FS &fs);
public:
bool begin();
template <typename T>
T loadSetting(String name);
template <typename T>
T saveSetting(String key, bool value);
bool toggleSetting(String key);
String getSettingType(String key);
String setting_index_to_name(int i);
int getNumberSettings();
//template<>
//int loadSetting<int>(String key);
//template<>
//String loadSetting<String>(String key);
//template<>
//bool loadSetting<bool>(String key);
//template<>
//uint8_t loadSetting<uint8_t>(String key);
String getSettingsString();
void main(uint32_t currentTime);
};
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB