From 2fb669cd21a09a521bc6a46409b12ed296d057e3 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Wed, 24 Apr 2024 09:51:08 -0400 Subject: [PATCH] Add load ssids --- esp32_marauder/MenuFunctions.cpp | 53 +++++++++++++++++++++++++++++--- esp32_marauder/MenuFunctions.h | 6 ++++ esp32_marauder/WiFiScan.cpp | 50 ++++++++++++++++++++++++++++++ esp32_marauder/WiFiScan.h | 3 ++ 4 files changed, 108 insertions(+), 4 deletions(-) diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index 7a96b40..27d46cc 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -1279,7 +1279,12 @@ void MenuFunctions::RunSetup() generateSSIDsMenu.list = new LinkedList(); clearSSIDsMenu.list = new LinkedList(); clearAPsMenu.list = new LinkedList(); + saveFileMenu.list = new LinkedList(); + saveSSIDsMenu.list = new LinkedList(); + loadSSIDsMenu.list = new LinkedList(); + saveAPsMenu.list = new LinkedList(); + loadAPsMenu.list = new LinkedList(); // Work menu names mainMenu.name = text_table1[6]; @@ -1296,7 +1301,11 @@ void MenuFunctions::RunSetup() wifiSnifferMenu.name = text_table1[20]; wifiAttackMenu.name = text_table1[21]; wifiGeneralMenu.name = text_table1[22]; + saveFileMenu.name = "Save Files"; saveSSIDsMenu.name = "Save SSIDs"; + loadSSIDsMenu.name = "Load SSIDs"; + saveAPsMenu.name = "Save APs"; + loadAPsMenu.name = "Load APs"; bluetoothSnifferMenu.name = text_table1[23]; bluetoothAttackMenu.name = "Bluetooth Attacks"; generateSSIDsMenu.name = text_table1[27]; @@ -1488,9 +1497,8 @@ void MenuFunctions::RunSetup() this->changeMenu(&generateSSIDsMenu); wifi_scan_obj.RunGenerateSSIDs(); }); - this->addNodes(&wifiGeneralMenu, "Save SSIDs", TFT_CYAN, NULL, SD_UPDATE, [this]() { - this->changeMenu(&saveSSIDsMenu); - wifi_scan_obj.RunSaveSSIDList(true); + this->addNodes(&wifiGeneralMenu, "Save Files", TFT_CYAN, NULL, SD_UPDATE, [this]() { + this->changeMenu(&saveFileMenu); }); #ifdef HAS_ILI9341 this->addNodes(&wifiGeneralMenu, text_table1[1], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ @@ -1591,11 +1599,48 @@ void MenuFunctions::RunSetup() this->changeMenu(htmlMenu.parentMenu); }); - saveSSIDsMenu.parentMenu = &wifiGeneralMenu; + // Save Files Menu + saveFileMenu.parentMenu = &wifiGeneralMenu; + this->addNodes(&saveFileMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(saveFileMenu.parentMenu); + }); + this->addNodes(&saveFileMenu, "Save SSIDs", TFT_CYAN, NULL, SD_UPDATE, [this]() { + this->changeMenu(&saveSSIDsMenu); + wifi_scan_obj.RunSaveSSIDList(true); + }); + this->addNodes(&saveFileMenu, "Load SSIDs", TFT_SKYBLUE, NULL, SD_UPDATE, [this]() { + this->changeMenu(&loadSSIDsMenu); + wifi_scan_obj.RunLoadSSIDList(); + }); + this->addNodes(&saveFileMenu, "Save APs", TFT_NAVY, NULL, SD_UPDATE, [this]() { + this->changeMenu(&saveAPsMenu); + //wifi_scan_obj.RunLoadSSIDList(); + }); + this->addNodes(&saveFileMenu, "Load APs", TFT_BLUE, NULL, SD_UPDATE, [this]() { + this->changeMenu(&loadAPsMenu); + //wifi_scan_obj.RunLoadSSIDList(); + }); + + saveSSIDsMenu.parentMenu = &saveFileMenu; this->addNodes(&saveSSIDsMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { this->changeMenu(saveSSIDsMenu.parentMenu); }); + loadSSIDsMenu.parentMenu = &saveFileMenu; + this->addNodes(&loadSSIDsMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(loadSSIDsMenu.parentMenu); + }); + + saveAPsMenu.parentMenu = &saveFileMenu; + this->addNodes(&saveAPsMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(saveAPsMenu.parentMenu); + }); + + loadAPsMenu.parentMenu = &saveFileMenu; + this->addNodes(&loadAPsMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(loadAPsMenu.parentMenu); + }); + // Select APs on Mini this->addNodes(&wifiGeneralMenu, text_table1[56], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){ wifiAPMenu.list->clear(); diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index 4437dca..33da7f0 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -152,7 +152,13 @@ class MenuFunctions // WiFi General Menu Menu htmlMenu; Menu miniKbMenu; + Menu saveFileMenu; + + // Save Files Menu Menu saveSSIDsMenu; + Menu loadSSIDsMenu; + Menu saveAPsMenu; + Menu loadAPsMenu; // Bluetooth menu stuff Menu bluetoothSnifferMenu; diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index 22e108e..ddbddd9 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -952,6 +952,56 @@ void WiFiScan::startLog(String file_name) { ); } +void WiFiScan::RunLoadAPList() { + #ifdef HAS_SD + + #endif +} + +void WiFiScan::RunSaveAPList(bool save_as) { + if (save_as) { + sd_obj.removeFile("/APs_0.log"); + + this->startLog("APs"); + } +} + +void WiFiScan::RunLoadSSIDList() { + #ifdef HAS_SD + File log_file = sd_obj.getFile("/SSIDs_0.log"); + if (!log_file) { + Serial.println("Could not open /SSIDs_0.log"); + #ifdef HAS_SCREEN + display_obj.tft.setTextWrap(false); + display_obj.tft.setFreeFont(NULL); + display_obj.tft.setCursor(0, 100); + display_obj.tft.setTextSize(1); + display_obj.tft.setTextColor(TFT_CYAN); + + display_obj.tft.println("Could not open /SSIDs_0.log"); + #endif + return; + } + while (log_file.available()) { + String line = log_file.readStringUntil('\n'); // Read until newline character + this->addSSID(line); + } + + #ifdef HAS_SCREEN + display_obj.tft.setTextWrap(false); + display_obj.tft.setFreeFont(NULL); + display_obj.tft.setCursor(0, 100); + display_obj.tft.setTextSize(1); + display_obj.tft.setTextColor(TFT_CYAN); + + display_obj.tft.print("Loaded SSIDs: "); + display_obj.tft.println((String)ssids->size()); + #endif + + log_file.close(); + #endif +} + void WiFiScan::RunSaveSSIDList(bool save_as) { if (save_as) { sd_obj.removeFile("/SSIDs_0.log"); diff --git a/esp32_marauder/WiFiScan.h b/esp32_marauder/WiFiScan.h index bc5aa69..46723b4 100644 --- a/esp32_marauder/WiFiScan.h +++ b/esp32_marauder/WiFiScan.h @@ -386,6 +386,9 @@ class WiFiScan void RunClearAPs(); void RunClearStations(); void RunSaveSSIDList(bool save_as = true); + void RunLoadSSIDList(); + void RunSaveAPList(bool save_as = true); + void RunLoadAPList(); void channelHop(); uint8_t currentScanMode = 0; void main(uint32_t currentTime);