From efbeb549ee5dee537d13c2f8efca496cd296afd0 Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Thu, 22 Dec 2022 10:28:17 -0500 Subject: [PATCH] Select stations from CLI --- esp32_marauder/CommandLine.cpp | 49 ++++++++++++++++++++++++++++++++-- esp32_marauder/CommandLine.h | 3 +-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/esp32_marauder/CommandLine.cpp b/esp32_marauder/CommandLine.cpp index 9c8a1b1..47e2473 100644 --- a/esp32_marauder/CommandLine.cpp +++ b/esp32_marauder/CommandLine.cpp @@ -135,7 +135,6 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_LIST_AP_CMD_B); Serial.println(HELP_LIST_AP_CMD_C); Serial.println(HELP_SEL_CMD_A); - Serial.println(HELP_SEL_CMD_B); Serial.println(HELP_SSID_CMD_A); Serial.println(HELP_SSID_CMD_B); @@ -546,13 +545,14 @@ void CommandLine::runCommand(String input) { Serial.println("[" + (String)i + "] " + ssids->get(i).essid); } } + // List Stations else if (cl_sw != -1) { char sta_mac[] = "00:00:00:00:00:00"; for (int x = 0; x < access_points->size(); x++) { Serial.println("[" + (String)x + "] " + access_points->get(x).essid + " " + (String)access_points->get(x).rssi + ":"); for (int i = 0; i < access_points->get(x).stations->size(); i++) { wifi_scan_obj.getMAC(sta_mac, stations->get(access_points->get(x).stations->get(i)).mac, 0); - if (stations->get(i).selected) { + if (stations->get(access_points->get(x).stations->get(i)).selected) { Serial.print(" [" + (String)access_points->get(x).stations->get(i) + "] "); Serial.print(sta_mac); Serial.println(" (selected)"); @@ -574,6 +574,7 @@ void CommandLine::runCommand(String input) { // Get switches int ap_sw = this->argSearch(&cmd_args, "-a"); int ss_sw = this->argSearch(&cmd_args, "-s"); + int cl_sw = this->argSearch(&cmd_args, "-c"); // select Access points if (ap_sw != -1) { @@ -621,6 +622,50 @@ void CommandLine::runCommand(String input) { } } } + else if (cl_sw != -1) { + LinkedList sta_index = this->parseCommand(cmd_args.get(cl_sw + 1), ","); + + // Select all Stations + if (cmd_args.get(cl_sw + 1) == "all") { + for (int i = 0; i < stations->size(); i++) { + if (stations->get(i).selected) { + // Unselect "selected" ap + Station new_sta = stations->get(i); + new_sta.selected = false; + stations->set(i, new_sta); + } + else { + // Select "unselected" ap + Station new_sta = stations->get(i); + new_sta.selected = true; + stations->set(i, new_sta); + } + } + } + // Select specific Stations + else { + // Mark Stations as selected + for (int i = 0; i < sta_index.size(); i++) { + int index = sta_index.get(i).toInt(); + if (!this->inRange(stations->size(), index)) { + Serial.println("Index not in range: " + (String)index); + continue; + } + if (stations->get(index).selected) { + // Unselect "selected" ap + Station new_sta = stations->get(index); + new_sta.selected = false; + stations->set(index, new_sta); + } + else { + // Select "unselected" ap + Station new_sta = stations->get(index); + new_sta.selected = true; + stations->set(index, new_sta); + } + } + } + } // select ssids else if (ss_sw != -1) { // Get list of indices diff --git a/esp32_marauder/CommandLine.h b/esp32_marauder/CommandLine.h index 4e466dd..34f778e 100644 --- a/esp32_marauder/CommandLine.h +++ b/esp32_marauder/CommandLine.h @@ -97,8 +97,7 @@ const char PROGMEM HELP_ATTACK_CMD[] = "attack -t