Select stations from CLI

This commit is contained in:
Just Call Me Koko
2022-12-22 10:28:17 -05:00
parent 52c44d69c2
commit efbeb549ee
2 changed files with 48 additions and 4 deletions

View File

@@ -135,7 +135,6 @@ void CommandLine::runCommand(String input) {
Serial.println(HELP_LIST_AP_CMD_B); Serial.println(HELP_LIST_AP_CMD_B);
Serial.println(HELP_LIST_AP_CMD_C); Serial.println(HELP_LIST_AP_CMD_C);
Serial.println(HELP_SEL_CMD_A); Serial.println(HELP_SEL_CMD_A);
Serial.println(HELP_SEL_CMD_B);
Serial.println(HELP_SSID_CMD_A); Serial.println(HELP_SSID_CMD_A);
Serial.println(HELP_SSID_CMD_B); Serial.println(HELP_SSID_CMD_B);
@@ -546,13 +545,14 @@ void CommandLine::runCommand(String input) {
Serial.println("[" + (String)i + "] " + ssids->get(i).essid); Serial.println("[" + (String)i + "] " + ssids->get(i).essid);
} }
} }
// List Stations
else if (cl_sw != -1) { else if (cl_sw != -1) {
char sta_mac[] = "00:00:00:00:00:00"; char sta_mac[] = "00:00:00:00:00:00";
for (int x = 0; x < access_points->size(); x++) { for (int x = 0; x < access_points->size(); x++) {
Serial.println("[" + (String)x + "] " + access_points->get(x).essid + " " + (String)access_points->get(x).rssi + ":"); 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++) { 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); 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(" [" + (String)access_points->get(x).stations->get(i) + "] ");
Serial.print(sta_mac); Serial.print(sta_mac);
Serial.println(" (selected)"); Serial.println(" (selected)");
@@ -574,6 +574,7 @@ void CommandLine::runCommand(String input) {
// Get switches // Get switches
int ap_sw = this->argSearch(&cmd_args, "-a"); int ap_sw = this->argSearch(&cmd_args, "-a");
int ss_sw = this->argSearch(&cmd_args, "-s"); int ss_sw = this->argSearch(&cmd_args, "-s");
int cl_sw = this->argSearch(&cmd_args, "-c");
// select Access points // select Access points
if (ap_sw != -1) { if (ap_sw != -1) {
@@ -621,6 +622,50 @@ void CommandLine::runCommand(String input) {
} }
} }
} }
else if (cl_sw != -1) {
LinkedList<String> 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 // select ssids
else if (ss_sw != -1) { else if (ss_sw != -1) {
// Get list of indices // Get list of indices

View File

@@ -97,8 +97,7 @@ const char PROGMEM HELP_ATTACK_CMD[] = "attack -t <beacon [-l/-r/-a]/deauth [-s
const char PROGMEM HELP_LIST_AP_CMD_A[] = "list -s"; const char PROGMEM HELP_LIST_AP_CMD_A[] = "list -s";
const char PROGMEM HELP_LIST_AP_CMD_B[] = "list -a"; const char PROGMEM HELP_LIST_AP_CMD_B[] = "list -a";
const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c"; const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c";
const char PROGMEM HELP_SEL_CMD_A[] = "select -a <index (comma separated)>"; const char PROGMEM HELP_SEL_CMD_A[] = "select -a/-s/-c <index (comma separated)>";
const char PROGMEM HELP_SEL_CMD_B[] = "select -s <index (comma separated)>";
const char PROGMEM HELP_SSID_CMD_A[] = "ssid -a [-g <count>/-n <name>]"; 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_SSID_CMD_B[] = "ssid -r <index>";