Skip to content

Commit

Permalink
Merge pull request #527 from justcallmekoko/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
justcallmekoko authored Apr 25, 2024
2 parents 6a5f95a + 59c6f55 commit cf103d6
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 1 deletion.
37 changes: 37 additions & 0 deletions esp32_marauder/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ void CommandLine::runCommand(String input) {
Serial.println(HELP_SEL_CMD_A);
Serial.println(HELP_SSID_CMD_A);
Serial.println(HELP_SSID_CMD_B);
Serial.println(HELP_SAVE_CMD);
Serial.println(HELP_LOAD_CMD);

// Bluetooth sniff/scan
#ifdef HAS_BT
Expand Down Expand Up @@ -1262,6 +1264,41 @@ void CommandLine::runCommand(String input) {
return;
}
}
else if (cmd_args.get(0) == SAVE_CMD) {
int ap_sw = this->argSearch(&cmd_args, "-a");
int st_sw = this->argSearch(&cmd_args, "-s");

if (ap_sw != -1) {
#ifdef HAS_SCREEN
menu_function_obj.changeMenu(&menu_function_obj.saveAPsMenu);
#endif
wifi_scan_obj.RunSaveAPList(true);
}
else if (st_sw != -1) {
#ifdef HAS_SCREEN
menu_function_obj.changeMenu(&menu_function_obj.saveSSIDsMenu);
#endif
wifi_scan_obj.RunSaveSSIDList(true);
}
}
else if (cmd_args.get(0) == LOAD_CMD) {
int ap_sw = this->argSearch(&cmd_args, "-a");
int st_sw = this->argSearch(&cmd_args, "-s");

if (ap_sw != -1) {
#ifdef HAS_SCREEN
menu_function_obj.changeMenu(&menu_function_obj.loadAPsMenu);
#endif
wifi_scan_obj.RunLoadAPList();
}
else if (st_sw != -1) {
#ifdef HAS_SCREEN
menu_function_obj.changeMenu(&menu_function_obj.loadSSIDsMenu);
#endif
wifi_scan_obj.RunLoadSSIDList();
}
}

// SSID stuff
else if (cmd_args.get(0) == SSID_CMD) {
int add_sw = this->argSearch(&cmd_args, "-a");
Expand Down
4 changes: 4 additions & 0 deletions esp32_marauder/CommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const char PROGMEM ATTACK_TYPE_RR[] = "rickroll";
const char PROGMEM LIST_AP_CMD[] = "list";
const char PROGMEM SEL_CMD[] = "select";
const char PROGMEM SSID_CMD[] = "ssid";
const char PROGMEM SAVE_CMD[] = "save";
const char PROGMEM LOAD_CMD[] = "load";

// Bluetooth sniff/scan
const char PROGMEM BT_SPAM_CMD[] = "blespam";
Expand Down Expand Up @@ -128,6 +130,8 @@ const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c";
const char PROGMEM HELP_SEL_CMD_A[] = "select -a/-s/-c <index (comma separated)>/-f \"equals <String> or contains <String>\"";
const char PROGMEM HELP_SSID_CMD_A[] = "ssid -a [-g <count>/-n <name>]";
const char PROGMEM HELP_SSID_CMD_B[] = "ssid -r <index>";
const char PROGMEM HELP_SAVE_CMD[] = "save -a/-s";
const char PROGMEM HELP_LOAD_CMD[] = "load -a/-s";

// Bluetooth sniff/scan
const char PROGMEM HELP_BT_SNIFF_CMD[] = "sniffbt";
Expand Down
55 changes: 55 additions & 0 deletions esp32_marauder/MenuFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,12 @@ void MenuFunctions::RunSetup()
generateSSIDsMenu.list = new LinkedList<MenuNode>();
clearSSIDsMenu.list = new LinkedList<MenuNode>();
clearAPsMenu.list = new LinkedList<MenuNode>();
saveFileMenu.list = new LinkedList<MenuNode>();

saveSSIDsMenu.list = new LinkedList<MenuNode>();
loadSSIDsMenu.list = new LinkedList<MenuNode>();
saveAPsMenu.list = new LinkedList<MenuNode>();
loadAPsMenu.list = new LinkedList<MenuNode>();

// Work menu names
mainMenu.name = text_table1[6];
Expand All @@ -1295,6 +1301,11 @@ void MenuFunctions::RunSetup()
wifiSnifferMenu.name = text_table1[20];
wifiAttackMenu.name = text_table1[21];
wifiGeneralMenu.name = text_table1[22];
saveFileMenu.name = "Save/Load 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];
Expand Down Expand Up @@ -1486,6 +1497,9 @@ void MenuFunctions::RunSetup()
this->changeMenu(&generateSSIDsMenu);
wifi_scan_obj.RunGenerateSSIDs();
});
this->addNodes(&wifiGeneralMenu, "Save/Load 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](){
display_obj.clearScreen();
Expand Down Expand Up @@ -1640,6 +1654,47 @@ void MenuFunctions::RunSetup()
this->changeMenu(clearAPsMenu.parentMenu);
});

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);
});

// 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.RunSaveAPList();
});
this->addNodes(&saveFileMenu, "Load APs", TFT_BLUE, NULL, SD_UPDATE, [this]() {
this->changeMenu(&loadAPsMenu);
wifi_scan_obj.RunLoadAPList();
});

// Build Bluetooth Menu
bluetoothMenu.parentMenu = &mainMenu; // Second Menu is third menu parent
Expand Down
7 changes: 7 additions & 0 deletions esp32_marauder/MenuFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class MenuFunctions
// WiFi General Menu
Menu htmlMenu;
Menu miniKbMenu;
Menu saveFileMenu;

// Bluetooth menu stuff
Menu bluetoothSnifferMenu;
Expand Down Expand Up @@ -187,6 +188,12 @@ class MenuFunctions
Menu* current_menu;
Menu clearSSIDsMenu;
Menu clearAPsMenu;

// Save Files Menu
Menu saveSSIDsMenu;
Menu loadSSIDsMenu;
Menu saveAPsMenu;
Menu loadAPsMenu;

#ifdef HAS_GPS
// GPS Menu
Expand Down
182 changes: 182 additions & 0 deletions esp32_marauder/WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,188 @@ void WiFiScan::startLog(String file_name) {
);
}

void WiFiScan::parseBSSID(const char* bssidStr, uint8_t* bssid) {
sscanf(bssidStr, "%02X:%02X:%02X:%02X:%02X:%02X",
&bssid[0], &bssid[1], &bssid[2],
&bssid[3], &bssid[4], &bssid[5]);
}

void WiFiScan::RunLoadAPList() {
#ifdef HAS_SD
File file = sd_obj.getFile("/APs_0.log");
if (!file) {
Serial.println("Could not open /APs_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 /APs_0.log");
#endif
return;
}

DynamicJsonDocument doc(10048);
DeserializationError error = deserializeJson(doc, file);
if (error) {
Serial.print("JSON deserialize error: ");
Serial.println(error.c_str());
file.close();
#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 deserialize JSON");
display_obj.tft.println(error.c_str());
#endif
return;
}

JsonArray array = doc.as<JsonArray>();
for (JsonObject obj : array) {
AccessPoint ap;
ap.essid = obj["essid"].as<String>();
ap.channel = obj["channel"];
ap.selected = false;
parseBSSID(obj["bssid"], ap.bssid);
ap.stations = new LinkedList<uint8_t>();
access_points->add(ap);
}

file.close();

//doc.clear();

#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 APs: ");
display_obj.tft.println((String)access_points->size());
#endif
Serial.print("Loaded APs:");
Serial.println((String)access_points->size());
#endif
}

void WiFiScan::RunSaveAPList(bool save_as) {
if (save_as) {
sd_obj.removeFile("/APs_0.log");

this->startLog("APs");

DynamicJsonDocument jsonDocument(2048);

JsonArray jsonArray = jsonDocument.to<JsonArray>();

for (int i = 0; i < access_points->size(); i++) {
const AccessPoint& ap = access_points->get(i);
JsonObject jsonAp = jsonArray.createNestedObject();
jsonAp["essid"] = ap.essid;
jsonAp["channel"] = ap.channel;

char bssidStr[18];
sprintf(bssidStr, "%02X:%02X:%02X:%02X:%02X:%02X",
ap.bssid[0], ap.bssid[1], ap.bssid[2],
ap.bssid[3], ap.bssid[4], ap.bssid[5]);
jsonAp["bssid"] = bssidStr;
}

String jsonString;
serializeJson(jsonArray, jsonString);

buffer_obj.append(jsonString);

#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("Saved APs: ");
display_obj.tft.println((String)access_points->size());
#endif
Serial.print("Saved APs:");
Serial.println((String)access_points->size());
}
}

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();

Serial.print("Loaded SSIDs: ");
Serial.println((String)ssids->size());
#endif
}

void WiFiScan::RunSaveSSIDList(bool save_as) {
if (save_as) {
sd_obj.removeFile("/SSIDs_0.log");

this->startLog("SSIDs");

for (int i = 0; i < ssids->size(); i++) {
if (i < ssids->size() - 1)
buffer_obj.append(ssids->get(i).essid + "\n");
else
buffer_obj.append(ssids->get(i).essid);
}

#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("Saved SSIDs: ");
display_obj.tft.println((String)ssids->size());
#endif
Serial.print("Saved SSIDs: ");
Serial.println((String)ssids->size());
}
}

void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color)
{
startLog("evil_portal");
Expand Down
5 changes: 5 additions & 0 deletions esp32_marauder/WiFiScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class WiFiScan
void RunLvJoinWiFi(uint8_t scan_mode, uint16_t color);
void RunEvilPortal(uint8_t scan_mode, uint16_t color);
bool checkMem();
void parseBSSID(const char* bssidStr, uint8_t* bssid);


public:
Expand Down Expand Up @@ -385,6 +386,10 @@ class WiFiScan
void RunClearSSIDs();
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);
Expand Down
2 changes: 1 addition & 1 deletion esp32_marauder/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//#define MARAUDER_REV_FEATHER
//// END BOARD TARGETS

#define MARAUDER_VERSION "v0.13.9"
#define MARAUDER_VERSION "v0.13.10"

//// HARDWARE NAMES
#ifdef MARAUDER_M5STICKC
Expand Down

0 comments on commit cf103d6

Please sign in to comment.