|
@@ -39,8 +39,6 @@ LinkedList<String> CommandLine::parseCommand(String input, char* delim) {
|
|
|
|
|
|
|
|
if (input != "") {
|
|
if (input != "") {
|
|
|
|
|
|
|
|
- //char delim[] = " ";
|
|
|
|
|
-
|
|
|
|
|
char fancy[input.length() + 1] = {};
|
|
char fancy[input.length() + 1] = {};
|
|
|
input.toCharArray(fancy, input.length() + 1);
|
|
input.toCharArray(fancy, input.length() + 1);
|
|
|
|
|
|
|
@@ -51,13 +49,6 @@ LinkedList<String> CommandLine::parseCommand(String input, char* delim) {
|
|
|
|
|
|
|
|
ptr = strtok(NULL, delim);
|
|
ptr = strtok(NULL, delim);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //memset(fancy, 0, sizeof(fancy));
|
|
|
|
|
-
|
|
|
|
|
- // Display the segmented cmd
|
|
|
|
|
- //for (int i = 0; i < cmd_args.size(); i++) {
|
|
|
|
|
- // Serial.println(cmd_args.get(i));
|
|
|
|
|
- //}
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return cmd_args;
|
|
return cmd_args;
|
|
@@ -72,6 +63,20 @@ int CommandLine::argSearch(LinkedList<String>* cmd_args_list, String key) {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+bool CommandLine::checkValueExists(LinkedList<String>* cmd_args_list, int index) {
|
|
|
|
|
+ if (index < cmd_args_list->size() - 1)
|
|
|
|
|
+ return true;
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool CommandLine::inRange(int max, int index) {
|
|
|
|
|
+ if ((index >= 0) && (index < max))
|
|
|
|
|
+ return true;
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void CommandLine::runCommand(String input) {
|
|
void CommandLine::runCommand(String input) {
|
|
|
if (input != "")
|
|
if (input != "")
|
|
|
Serial.println("#" + input);
|
|
Serial.println("#" + input);
|
|
@@ -115,7 +120,7 @@ void CommandLine::runCommand(String input) {
|
|
|
ESP.restart();
|
|
ESP.restart();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //// WiFi Scan commands
|
|
|
|
|
|
|
+ //// WiFi Scan/Attack commands
|
|
|
if (!wifi_scan_obj.scanning()) {
|
|
if (!wifi_scan_obj.scanning()) {
|
|
|
|
|
|
|
|
// AP Scan
|
|
// AP Scan
|
|
@@ -151,6 +156,8 @@ void CommandLine::runCommand(String input) {
|
|
|
// attack
|
|
// attack
|
|
|
if (cmd_args.get(0) == ATTACK_CMD) {
|
|
if (cmd_args.get(0) == ATTACK_CMD) {
|
|
|
int attack_type_switch = this->argSearch(&cmd_args, "-t"); // Required
|
|
int attack_type_switch = this->argSearch(&cmd_args, "-t"); // Required
|
|
|
|
|
+ int list_beacon_sw = this->argSearch(&cmd_args, "-l");
|
|
|
|
|
+ int rand_beacon_sw = this->argSearch(&cmd_args, "-r");
|
|
|
|
|
|
|
|
if (attack_type_switch == -1) {
|
|
if (attack_type_switch == -1) {
|
|
|
Serial.println("You must specify an attack type");
|
|
Serial.println("You must specify an attack type");
|
|
@@ -160,6 +167,7 @@ void CommandLine::runCommand(String input) {
|
|
|
String attack_type = cmd_args.get(attack_type_switch + 1);
|
|
String attack_type = cmd_args.get(attack_type_switch + 1);
|
|
|
|
|
|
|
|
// Branch on attack type
|
|
// Branch on attack type
|
|
|
|
|
+ // Deauth
|
|
|
if (attack_type == ATTACK_TYPE_DEAUTH) {
|
|
if (attack_type == ATTACK_TYPE_DEAUTH) {
|
|
|
#ifdef HAS_SCREEN
|
|
#ifdef HAS_SCREEN
|
|
|
display_obj.clearScreen();
|
|
display_obj.clearScreen();
|
|
@@ -167,6 +175,28 @@ void CommandLine::runCommand(String input) {
|
|
|
#endif
|
|
#endif
|
|
|
wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH, TFT_RED);
|
|
wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH, TFT_RED);
|
|
|
}
|
|
}
|
|
|
|
|
+ // Beacon
|
|
|
|
|
+ else if (attack_type == ATTACK_TYPE_BEACON) {
|
|
|
|
|
+ // spam by list
|
|
|
|
|
+ if (list_beacon_sw != -1) {
|
|
|
|
|
+ #ifdef HAS_SCREEN
|
|
|
|
|
+ display_obj.clearScreen();
|
|
|
|
|
+ menu_function_obj.drawStatusBar();
|
|
|
|
|
+ #endif
|
|
|
|
|
+ wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_LIST, TFT_RED);
|
|
|
|
|
+ }
|
|
|
|
|
+ // spam with random
|
|
|
|
|
+ else if (rand_beacon_sw != -1) {
|
|
|
|
|
+ #ifdef HAS_SCREEN
|
|
|
|
|
+ display_obj.clearScreen();
|
|
|
|
|
+ menu_function_obj.drawStatusBar();
|
|
|
|
|
+ #endif
|
|
|
|
|
+ wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_SPAM, TFT_ORANGE);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ Serial.println("You did not specify a beacon attack type");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
else {
|
|
else {
|
|
|
Serial.println("Attack type not properly defined");
|
|
Serial.println("Attack type not properly defined");
|
|
|
return;
|
|
return;
|
|
@@ -177,23 +207,41 @@ void CommandLine::runCommand(String input) {
|
|
|
|
|
|
|
|
|
|
|
|
|
//// WiFi aux commands
|
|
//// WiFi aux commands
|
|
|
-
|
|
|
|
|
// List access points
|
|
// List access points
|
|
|
if (cmd_args.get(0) == LIST_AP_CMD) {
|
|
if (cmd_args.get(0) == LIST_AP_CMD) {
|
|
|
- for (int i = 0; i < access_points->size(); i++) {
|
|
|
|
|
- if (access_points->get(i).selected)
|
|
|
|
|
- Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " (selected)");
|
|
|
|
|
- else
|
|
|
|
|
- Serial.println("[" + (String)i + "] " + access_points->get(i).essid);
|
|
|
|
|
|
|
+ int ap_sw = this->argSearch(&cmd_args, "-a");
|
|
|
|
|
+ int ss_sw = this->argSearch(&cmd_args, "-s");
|
|
|
|
|
+
|
|
|
|
|
+ // List APs
|
|
|
|
|
+ if (ap_sw != -1) {
|
|
|
|
|
+ for (int i = 0; i < access_points->size(); i++) {
|
|
|
|
|
+ if (access_points->get(i).selected)
|
|
|
|
|
+ Serial.println("[" + (String)i + "] " + access_points->get(i).essid + " (selected)");
|
|
|
|
|
+ else
|
|
|
|
|
+ Serial.println("[" + (String)i + "] " + access_points->get(i).essid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // List SSIDs
|
|
|
|
|
+ else if (ss_sw != -1) {
|
|
|
|
|
+ for (int i = 0; i < ssids->size(); i++) {
|
|
|
|
|
+ if (ssids->get(i).selected)
|
|
|
|
|
+ Serial.println("[" + (String)i + "] " + ssids->get(i).essid + " (selected)");
|
|
|
|
|
+ else
|
|
|
|
|
+ Serial.println("[" + (String)i + "] " + ssids->get(i).essid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ Serial.println("You did not specify which list to show");
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// Select access points or stations
|
|
// Select access points or stations
|
|
|
else if (cmd_args.get(0) == SEL_CMD) {
|
|
else if (cmd_args.get(0) == SEL_CMD) {
|
|
|
// Get switches
|
|
// Get switches
|
|
|
int ap_sw = this->argSearch(&cmd_args, "-a");
|
|
int ap_sw = this->argSearch(&cmd_args, "-a");
|
|
|
- int st_sw = this->argSearch(&cmd_args, "-s");
|
|
|
|
|
|
|
+ int ss_sw = this->argSearch(&cmd_args, "-s");
|
|
|
|
|
|
|
|
- // Access points
|
|
|
|
|
|
|
+ // select Access points
|
|
|
if (ap_sw != -1) {
|
|
if (ap_sw != -1) {
|
|
|
// Get list of indices
|
|
// Get list of indices
|
|
|
LinkedList<String> ap_index = this->parseCommand(cmd_args.get(ap_sw + 1), ",");
|
|
LinkedList<String> ap_index = this->parseCommand(cmd_args.get(ap_sw + 1), ",");
|
|
@@ -201,6 +249,10 @@ void CommandLine::runCommand(String input) {
|
|
|
// Mark APs as selected
|
|
// Mark APs as selected
|
|
|
for (int i = 0; i < ap_index.size(); i++) {
|
|
for (int i = 0; i < ap_index.size(); i++) {
|
|
|
int index = ap_index.get(i).toInt();
|
|
int index = ap_index.get(i).toInt();
|
|
|
|
|
+ if (!this->inRange(access_points->size(), index)) {
|
|
|
|
|
+ Serial.println("Index not in range: " + (String)index);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
if (access_points->get(index).selected) {
|
|
if (access_points->get(index).selected) {
|
|
|
// Unselect "selected" ap
|
|
// Unselect "selected" ap
|
|
|
AccessPoint new_ap = access_points->get(index);
|
|
AccessPoint new_ap = access_points->get(index);
|
|
@@ -215,9 +267,72 @@ void CommandLine::runCommand(String input) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // Stations
|
|
|
|
|
- else if (st_sw != -1) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // select ssids
|
|
|
|
|
+ else if (ss_sw != -1) {
|
|
|
|
|
+ // Get list of indices
|
|
|
|
|
+ LinkedList<String> ss_index = this->parseCommand(cmd_args.get(ss_sw + 1), ",");
|
|
|
|
|
+
|
|
|
|
|
+ // Mark APs as selected
|
|
|
|
|
+ for (int i = 0; i < ss_index.size(); i++) {
|
|
|
|
|
+ int index = ss_index.get(i).toInt();
|
|
|
|
|
+ if (!this->inRange(ssids->size(), index)) {
|
|
|
|
|
+ Serial.println("Index not in range: " + (String)index);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ssids->get(index).selected) {
|
|
|
|
|
+ // Unselect "selected" ap
|
|
|
|
|
+ ssid new_ssid = ssids->get(index);
|
|
|
|
|
+ new_ssid.selected = false;
|
|
|
|
|
+ ssids->set(index, new_ssid);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ // Select "unselected" ap
|
|
|
|
|
+ ssid new_ssid = ssids->get(index);
|
|
|
|
|
+ new_ssid.selected = true;
|
|
|
|
|
+ ssids->set(index, new_ssid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ Serial.println("You did not specify which list to select from");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // SSID stuff
|
|
|
|
|
+ else if (cmd_args.get(0) == SSID_CMD) {
|
|
|
|
|
+ int add_sw = this->argSearch(&cmd_args, "-a");
|
|
|
|
|
+ int gen_sw = this->argSearch(&cmd_args, "-g");
|
|
|
|
|
+ int spc_sw = this->argSearch(&cmd_args, "-n");
|
|
|
|
|
+ int rem_sw = this->argSearch(&cmd_args, "-r");
|
|
|
|
|
+
|
|
|
|
|
+ // Add ssid
|
|
|
|
|
+ if (add_sw != -1) {
|
|
|
|
|
+ // Generate random
|
|
|
|
|
+ if (gen_sw != -1) {
|
|
|
|
|
+ int gen_count = cmd_args.get(gen_sw + 1).toInt();
|
|
|
|
|
+ wifi_scan_obj.generateSSIDs(gen_count);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Add specific
|
|
|
|
|
+ else if (spc_sw != -1) {
|
|
|
|
|
+ String essid = cmd_args.get(spc_sw + 1);
|
|
|
|
|
+ wifi_scan_obj.addSSID(essid);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ Serial.println("You did not specify how to add SSIDs");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // Remove SSID
|
|
|
|
|
+ else if (rem_sw != -1) {
|
|
|
|
|
+ int index = cmd_args.get(rem_sw + 1).toInt();
|
|
|
|
|
+ if (!this->inRange(ssids->size(), index)) {
|
|
|
|
|
+ Serial.println("Index not in range: " + (String)index);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ ssids->remove(index);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ Serial.println("You did not specify whether to add or remove SSIDs");
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|