From a9d6e4aac95e95fea7ed65943826ad9d41b6542f Mon Sep 17 00:00:00 2001 From: John Stockdale Date: Fri, 6 Dec 2024 22:24:36 -0800 Subject: [PATCH] improve console serial here's a much better version of the serial console let me know if you need any changes --- esp32_marauder/CommandLine.cpp | 1022 +++++++++++++++++--------------- esp32_marauder/CommandLine.h | 6 +- 2 files changed, 558 insertions(+), 470 deletions(-) diff --git a/esp32_marauder/CommandLine.cpp b/esp32_marauder/CommandLine.cpp index a2f16da7b..8d135931c 100644 --- a/esp32_marauder/CommandLine.cpp +++ b/esp32_marauder/CommandLine.cpp @@ -11,24 +11,106 @@ void CommandLine::RunSetup() { Serial.println(" " + version_number + "\n"); Serial.println(F(" By: justcallmekoko\n")); Serial.println(F("--------------------------------\n\n")); - + Serial.print("> "); } String CommandLine::getSerialInput() { - String input = ""; + int bytes_received = 0; + int bytes_available = 0; + String command_line = ""; + char command_buffer[255]; + + memset(command_buffer, '\0', 255); + + if (Serial.available() > 0 && serial_buffer_idx < 255) { + bytes_available = Serial.available(); + //Serial.println("Should have bytes available: " + bytes_available); + int bytes_to_read = bytes_available < (254 - serial_buffer_idx) ? bytes_available : (254 - serial_buffer_idx); + bytes_received = Serial.readBytes(&serial_buffer[serial_buffer_idx], bytes_to_read); + + // echo what we just got to the terminal + for (int i = serial_buffer_idx; i < serial_buffer_idx + bytes_received; i++) { + // support backspace + if (serial_buffer[i] == '\x7f') { + for (int j = i; j < 255; j++) { + if (j == 0) { + break; + } else if (j == 254 || j > serial_buffer_idx) { + serial_buffer[j] = '\0'; + } else { + serial_buffer[j-1] = serial_buffer[j]; + } + } + serial_buffer_idx--; + } + Serial.print(serial_buffer[i]); + } + + serial_buffer_idx += bytes_received; + if (serial_buffer_idx < 254) { + serial_buffer[serial_buffer_idx+1] = '\0'; + } else if (serial_buffer_idx >= 254) { + Serial.println("Serial buffer overrun?"); + } +// Serial.println("Received bytes over serial: " + String(bytes_received)); +// Serial.println("Buffer: " + String(serial_buffer)); +// Serial.println("Buffer idx: " + String(serial_buffer_idx)); + } + + int index_of_newline = -1; - if (Serial.available() > 0) - input = Serial.readStringUntil('\n'); + for (int i = 0; i < serial_buffer_idx; i++) { +// Serial.println("Checking character at: " + String(i) + " it appears to be: " + String(serial_buffer[i])); +// Serial.print("Hex value of character: "); +// Serial.print(serial_buffer[i], HEX); +// Serial.println(); + + // this is mind boggling but hey. why not. :D + if (serial_buffer[i] == '\n' || serial_buffer[i] == '\r') { + //Serial.println("Found \"newline\" at index: " + String(i)); + index_of_newline = i; + if (index_of_newline == 0) { + command_buffer[i] = index_of_newline == 0 ? '\n' : '\0'; + } + } else { + command_buffer[i] = serial_buffer[i]; + } + } + + command_line = command_buffer; - input.trim(); - return input; + if (index_of_newline > -1) { + serial_buffer_idx = 0; + if (serial_buffer[index_of_newline] == '\r' && serial_buffer[index_of_newline+1] == '\n') { + index_of_newline++; + } + + for (int i = index_of_newline + 1; i < 255; i++) { + if(serial_buffer[i] == '\0') { + break; + } else if (i > index_of_newline + 1 || i == 254) { + // Always zero extra bytes and null terminate no matter what + serial_buffer[i]='\0'; + } else { + // Copy any characters we have after the newline + // but before the null terminator. If they exist. + serial_buffer[i - (index_of_newline + 1)] = serial_buffer[i]; + } + } + + command_line.trim(); + return command_line; + } else { + return ""; + } } void CommandLine::main(uint32_t currentTime) { String input = this->getSerialInput(); - this->runCommand(input); + if (input != "\n") + this->runCommand(input); if (input != "") Serial.print("> "); @@ -86,7 +168,7 @@ int CommandLine::argSearch(LinkedList* cmd_args_list, String key) { bool CommandLine::checkValueExists(LinkedList* cmd_args_list, int index) { if (index < cmd_args_list->size() - 1) return true; - + return false; } @@ -115,10 +197,10 @@ bool CommandLine::hasSSIDs() { void CommandLine::showCounts(int selected, int unselected) { Serial.print((String) selected + " selected"); - - if (unselected != -1) + + if (unselected != -1) Serial.print(", " + (String) unselected + " unselected"); - + Serial.println(""); } @@ -195,14 +277,14 @@ void CommandLine::filterAccessPoints(String filter) { void CommandLine::runCommand(String input) { if (input == "") return; - if(wifi_scan_obj.scanning() && wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA){ - if(input != STOPSCAN_CMD) return; + if (wifi_scan_obj.scanning() && wifi_scan_obj.currentScanMode == WIFI_SCAN_GPS_NMEA) { + if (input != STOPSCAN_CMD) return; } else Serial.println("#" + input); LinkedList cmd_args = this->parseCommand(input, " "); - + //// Admin commands // Help if (cmd_args.get(0) == HELP_CMD) { @@ -217,7 +299,7 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_GPS_DATA_CMD); Serial.println(HELP_GPS_CMD); Serial.println(HELP_NMEA_CMD); - + // WiFi sniff/scan Serial.println(HELP_EVIL_PORTAL_CMD); Serial.println(HELP_SIGSTREN_CMD); @@ -231,13 +313,13 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_SNIFF_DEAUTH_CMD); Serial.println(HELP_SNIFF_PMKID_CMD); Serial.println(HELP_STOPSCAN_CMD); - #ifdef HAS_GPS - Serial.println(HELP_WARDRIVE_CMD); - #endif - +#ifdef HAS_GPS + Serial.println(HELP_WARDRIVE_CMD); +#endif + // WiFi attack Serial.println(HELP_ATTACK_CMD); - + // WiFi Aux Serial.println(HELP_LIST_AP_CMD_A); Serial.println(HELP_LIST_AP_CMD_B); @@ -248,20 +330,20 @@ void CommandLine::runCommand(String input) { Serial.println(HELP_SSID_CMD_B); Serial.println(HELP_SAVE_CMD); Serial.println(HELP_LOAD_CMD); - + // Bluetooth sniff/scan - #ifdef HAS_BT - Serial.println(HELP_BT_SNIFF_CMD); - Serial.println(HELP_BT_SPAM_CMD); - Serial.println(HELP_BT_SPOOFAT_CMD); - //Serial.println(HELP_BT_SWIFTPAIR_SPAM_CMD); - //Serial.println(HELP_BT_SAMSUNG_SPAM_CMD); - //Serial.println(HELP_BT_SPAM_ALL_CMD); - #ifdef HAS_GPS - Serial.println(HELP_BT_WARDRIVE_CMD); - #endif - Serial.println(HELP_BT_SKIM_CMD); - #endif +#ifdef HAS_BT + Serial.println(HELP_BT_SNIFF_CMD); + Serial.println(HELP_BT_SPAM_CMD); + Serial.println(HELP_BT_SPOOFAT_CMD); + //Serial.println(HELP_BT_SWIFTPAIR_SPAM_CMD); + //Serial.println(HELP_BT_SAMSUNG_SPAM_CMD); + //Serial.println(HELP_BT_SPAM_ALL_CMD); +#ifdef HAS_GPS + Serial.println(HELP_BT_WARDRIVE_CMD); +#endif + Serial.println(HELP_BT_SKIM_CMD); +#endif Serial.println(HELP_FOOT); return; } @@ -270,168 +352,168 @@ void CommandLine::runCommand(String input) { if (cmd_args.get(0) == STOPSCAN_CMD) { //if (wifi_scan_obj.currentScanMode == OTA_UPDATE) { // wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; - //#ifdef HAS_SCREEN - // menu_function_obj.changeMenu(menu_function_obj.updateMenu.parentMenu); - //#endif + //#ifdef HAS_SCREEN + // menu_function_obj.changeMenu(menu_function_obj.updateMenu.parentMenu); + //#endif // WiFi.softAPdisconnect(true); // web_obj.shutdownServer(); // return; //} - - uint8_t old_scan_mode=wifi_scan_obj.currentScanMode; + + uint8_t old_scan_mode = wifi_scan_obj.currentScanMode; wifi_scan_obj.StartScan(WIFI_SCAN_OFF); - if(old_scan_mode == WIFI_SCAN_GPS_NMEA) + if (old_scan_mode == WIFI_SCAN_GPS_NMEA) Serial.println("END OF NMEA STREAM"); - else if(old_scan_mode == WIFI_SCAN_GPS_DATA) + else if (old_scan_mode == WIFI_SCAN_GPS_DATA) Serial.println("Stopping GPS data updates"); else Serial.println("Stopping WiFi tran/recv"); // If we don't do this, the text and button coordinates will be off - #ifdef HAS_SCREEN - display_obj.tft.init(); - menu_function_obj.changeMenu(menu_function_obj.current_menu); - #endif +#ifdef HAS_SCREEN + display_obj.tft.init(); + menu_function_obj.changeMenu(menu_function_obj.current_menu); +#endif } else if (cmd_args.get(0) == GPS_DATA_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - Serial.println("Getting GPS Data. Stop with " + (String)STOPSCAN_CMD); - wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_DATA; - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_GPS_DATA, TFT_CYAN); - } - #endif +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + Serial.println("Getting GPS Data. Stop with " + (String)STOPSCAN_CMD); + wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_DATA; +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_GPS_DATA, TFT_CYAN); + } +#endif } else if (cmd_args.get(0) == GPS_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int get_arg = this->argSearch(&cmd_args, "-g"); - int nmea_arg = this->argSearch(&cmd_args, "-n"); - - if (get_arg != -1) { - String gps_info = cmd_args.get(get_arg + 1); - - if (gps_info == "fix") - Serial.println("Fix: " + gps_obj.getFixStatusAsString()); - else if (gps_info == "sat") - Serial.println("Sats: " + gps_obj.getNumSatsString()); - else if (gps_info == "lat") - Serial.println("Lat: " + gps_obj.getLat()); - else if (gps_info == "lon") - Serial.println("Lon: " + gps_obj.getLon()); - else if (gps_info == "alt") - Serial.println("Alt: " + (String)gps_obj.getAlt()); - else if (gps_info == "accuracy") - Serial.println("Accuracy: " + (String)gps_obj.getAccuracy()); - else if (gps_info == "date") - Serial.println("Date/Time: " + gps_obj.getDatetime()); - else if (gps_info == "text"){ - Serial.println(gps_obj.getText()); - } - else if (gps_info == "nmea"){ - int notparsed_arg = this->argSearch(&cmd_args, "-p"); - int notimp_arg = this->argSearch(&cmd_args, "-i"); - int recd_arg = this->argSearch(&cmd_args, "-r"); - if(notparsed_arg == -1 && notimp_arg == -1 && recd_arg == -1){ - gps_obj.sendSentence(Serial, gps_obj.generateGXgga().c_str()); - gps_obj.sendSentence(Serial, gps_obj.generateGXrmc().c_str()); - } - else if(notparsed_arg == -1 && notimp_arg == -1) - Serial.println(gps_obj.getNmea()); - else if(notparsed_arg == -1) - Serial.println(gps_obj.getNmeaNotimp()); - else - Serial.println(gps_obj.getNmeaNotparsed()); +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int get_arg = this->argSearch(&cmd_args, "-g"); + int nmea_arg = this->argSearch(&cmd_args, "-n"); + + if (get_arg != -1) { + String gps_info = cmd_args.get(get_arg + 1); + + if (gps_info == "fix") + Serial.println("Fix: " + gps_obj.getFixStatusAsString()); + else if (gps_info == "sat") + Serial.println("Sats: " + gps_obj.getNumSatsString()); + else if (gps_info == "lat") + Serial.println("Lat: " + gps_obj.getLat()); + else if (gps_info == "lon") + Serial.println("Lon: " + gps_obj.getLon()); + else if (gps_info == "alt") + Serial.println("Alt: " + (String)gps_obj.getAlt()); + else if (gps_info == "accuracy") + Serial.println("Accuracy: " + (String)gps_obj.getAccuracy()); + else if (gps_info == "date") + Serial.println("Date/Time: " + gps_obj.getDatetime()); + else if (gps_info == "text") { + Serial.println(gps_obj.getText()); + } + else if (gps_info == "nmea") { + int notparsed_arg = this->argSearch(&cmd_args, "-p"); + int notimp_arg = this->argSearch(&cmd_args, "-i"); + int recd_arg = this->argSearch(&cmd_args, "-r"); + if (notparsed_arg == -1 && notimp_arg == -1 && recd_arg == -1) { + gps_obj.sendSentence(Serial, gps_obj.generateGXgga().c_str()); + gps_obj.sendSentence(Serial, gps_obj.generateGXrmc().c_str()); } + else if (notparsed_arg == -1 && notimp_arg == -1) + Serial.println(gps_obj.getNmea()); + else if (notparsed_arg == -1) + Serial.println(gps_obj.getNmeaNotimp()); else - Serial.println("You did not provide a valid argument"); + Serial.println(gps_obj.getNmeaNotparsed()); } - else if(nmea_arg != -1){ - String nmea_type = cmd_args.get(nmea_arg + 1); - - if (nmea_type == "native" || nmea_type == "all" || nmea_type == "gps" || nmea_type == "glonass" - || nmea_type == "galileo" || nmea_type == "navic" || nmea_type == "qzss" || nmea_type == "beidou"){ - if(nmea_type == "beidou"){ - int beidou_bd_arg = this->argSearch(&cmd_args, "-b"); - if(beidou_bd_arg != -1) - nmea_type="beidou_bd"; - } - gps_obj.setType(nmea_type); - Serial.println("GPS Output Type Set To: " + nmea_type); + else + Serial.println("You did not provide a valid argument"); + } + else if (nmea_arg != -1) { + String nmea_type = cmd_args.get(nmea_arg + 1); + + if (nmea_type == "native" || nmea_type == "all" || nmea_type == "gps" || nmea_type == "glonass" + || nmea_type == "galileo" || nmea_type == "navic" || nmea_type == "qzss" || nmea_type == "beidou") { + if (nmea_type == "beidou") { + int beidou_bd_arg = this->argSearch(&cmd_args, "-b"); + if (beidou_bd_arg != -1) + nmea_type = "beidou_bd"; } - else - Serial.println("You did not provide a valid argument"); + gps_obj.setType(nmea_type); + Serial.println("GPS Output Type Set To: " + nmea_type); } - else if(cmd_args.size()>1) - Serial.println("You did not provide a valid flag"); else - Serial.println("You did not provide an argument"); + Serial.println("You did not provide a valid argument"); } - #endif + else if (cmd_args.size() > 1) + Serial.println("You did not provide a valid flag"); + else + Serial.println("You did not provide an argument"); + } +#endif } else if (cmd_args.get(0) == NMEA_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); - #endif - Serial.println("NMEA STREAM FOLLOWS"); - wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_NMEA; - wifi_scan_obj.StartScan(WIFI_SCAN_GPS_NMEA, TFT_CYAN); - } - #endif +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.gpsInfoMenu); +#endif + Serial.println("NMEA STREAM FOLLOWS"); + wifi_scan_obj.currentScanMode = WIFI_SCAN_GPS_NMEA; + wifi_scan_obj.StartScan(WIFI_SCAN_GPS_NMEA, TFT_CYAN); + } +#endif } // LED command else if (cmd_args.get(0) == LED_CMD) { int hex_arg = this->argSearch(&cmd_args, "-s"); int pat_arg = this->argSearch(&cmd_args, "-p"); - #ifdef PIN - if (hex_arg != -1) { - String hexstring = cmd_args.get(hex_arg + 1); - int number = (int)strtol(&hexstring[1], NULL, 16); - int r = number >> 16; - int g = number >> 8 & 0xFF; - int b = number & 0xFF; - //Serial.println(r); - //Serial.println(g); - //Serial.println(b); - led_obj.setColor(r, g, b); - led_obj.setMode(MODE_CUSTOM); - } - else if (pat_arg != -1) { - String pat_name = cmd_args.get(pat_arg + 1); - pat_name.toLowerCase(); - if (pat_name == "rainbow") { - led_obj.setMode(MODE_RAINBOW); - } +#ifdef PIN + if (hex_arg != -1) { + String hexstring = cmd_args.get(hex_arg + 1); + int number = (int)strtol(&hexstring[1], NULL, 16); + int r = number >> 16; + int g = number >> 8 & 0xFF; + int b = number & 0xFF; + //Serial.println(r); + //Serial.println(g); + //Serial.println(b); + led_obj.setColor(r, g, b); + led_obj.setMode(MODE_CUSTOM); + } + else if (pat_arg != -1) { + String pat_name = cmd_args.get(pat_arg + 1); + pat_name.toLowerCase(); + if (pat_name == "rainbow") { + led_obj.setMode(MODE_RAINBOW); } - #else - Serial.println("This hardware does not support neopixel"); - #endif + } +#else + Serial.println("This hardware does not support neopixel"); +#endif } // ls command else if (cmd_args.get(0) == LS_CMD) { - #ifdef HAS_SD - if (cmd_args.size() > 1) - sd_obj.listDir(cmd_args.get(1)); - else - Serial.println("You did not provide a dir to list"); - #else - Serial.println("SD support disabled, cannot use command"); - return; - #endif +#ifdef HAS_SD + if (cmd_args.size() > 1) + sd_obj.listDir(cmd_args.get(1)); + else + Serial.println("You did not provide a dir to list"); +#else + Serial.println("SD support disabled, cannot use command"); + return; +#endif } // Channel command else if (cmd_args.get(0) == CH_CMD) { // Search for channel set arg int ch_set = this->argSearch(&cmd_args, "-s"); - + if (cmd_args.size() == 1) { Serial.println("Current channel: " + (String)wifi_scan_obj.set_channel); } @@ -448,23 +530,23 @@ void CommandLine::runCommand(String input) { int cl_sw = this->argSearch(&cmd_args, "-c"); // Stations if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); +#endif wifi_scan_obj.RunClearAPs(); } if (ss_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearSSIDsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearSSIDsMenu); +#endif wifi_scan_obj.RunClearSSIDs(); } if (cl_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); - #endif +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.clearAPsMenu); +#endif wifi_scan_obj.RunClearStations(); } } @@ -515,39 +597,40 @@ void CommandLine::runCommand(String input) { // Signal strength scan if (cmd_args.get(0) == SIGSTREN_CMD) { Serial.println("Starting Signal Strength Scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_MAGENTA); } // Wardrive else if (cmd_args.get(0) == WARDRIVE_CMD) { - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int sta_sw = this->argSearch(&cmd_args, "-s"); - - if (sta_sw == -1) { - Serial.println("Starting Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN); - } - else {Serial.println("Starting Station Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_GREEN); - } +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int sta_sw = this->argSearch(&cmd_args, "-s"); + + if (sta_sw == -1) { + Serial.println("Starting Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_WAR_DRIVE, TFT_GREEN); } - else - Serial.println("GPS Module not detected"); - #else - Serial.println("GPS not supported"); - #endif + else { + Serial.println("Starting Station Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(WIFI_SCAN_STATION_WAR_DRIVE, TFT_GREEN); + } + } + else + Serial.println("GPS Module not detected"); +#else + Serial.println("GPS not supported"); +#endif } // AP Scan else if (cmd_args.get(0) == EVIL_PORTAL_CMD) { @@ -558,10 +641,10 @@ void CommandLine::runCommand(String input) { String et_command = cmd_args.get(cmd_sw + 1); if (et_command == "start") { Serial.println("Starting Evil Portal. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif if (html_sw != -1) { String target_html_name = cmd_args.get(html_sw + 1); evil_portal_obj.target_html_name = target_html_name; @@ -574,10 +657,10 @@ void CommandLine::runCommand(String input) { wifi_scan_obj.StartScan(WIFI_SCAN_EVIL_PORTAL, TFT_MAGENTA); } else if (et_command == "reset") { - + } else if (et_command == "ack") { - + } else if (et_command == "sethtml") { String target_html_name = cmd_args.get(cmd_sw + 2); @@ -595,10 +678,10 @@ void CommandLine::runCommand(String input) { } else if (cmd_args.get(0) == SCANAP_CMD) { int full_sw = -1; - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif if (full_sw == -1) { Serial.println("Starting AP scan. Stop with " + (String)STOPSCAN_CMD); @@ -612,67 +695,67 @@ void CommandLine::runCommand(String input) { // Raw sniff else if (cmd_args.get(0) == SNIFF_RAW_CMD) { Serial.println("Starting Raw sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_RAW_CAPTURE, TFT_WHITE); } // Scan stations - else if (cmd_args.get(0) == SCANSTA_CMD) { - if(access_points->size() < 1) - Serial.println("The AP list is empty. Scan APs first with " + (String)SCANAP_CMD); - - Serial.println("Starting Station scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif + else if (cmd_args.get(0) == SCANSTA_CMD) { + if (access_points->size() < 1) + Serial.println("The AP list is empty. Scan APs first with " + (String)SCANAP_CMD); + + Serial.println("Starting Station scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_ORANGE); } // Beacon sniff else if (cmd_args.get(0) == SNIFF_BEACON_CMD) { Serial.println("Starting Beacon sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_AP, TFT_MAGENTA); } // Probe sniff else if (cmd_args.get(0) == SNIFF_PROBE_CMD) { Serial.println("Starting Probe sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_PROBE, TFT_MAGENTA); } // Deauth sniff else if (cmd_args.get(0) == SNIFF_DEAUTH_CMD) { Serial.println("Starting Deauth sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_DEAUTH, TFT_RED); } // Pwn sniff else if (cmd_args.get(0) == SNIFF_PWN_CMD) { Serial.println("Starting Pwnagotchi sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_PWN, TFT_MAGENTA); } // Espressif sniff else if (cmd_args.get(0) == SNIFF_ESP_CMD) { Serial.println("Starting Espressif device sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_SCAN_ESPRESSIF, TFT_MAGENTA); } // PMKID sniff @@ -687,12 +770,12 @@ void CommandLine::runCommand(String input) { return; } } - + if (ch_sw != -1) { wifi_scan_obj.set_channel = cmd_args.get(ch_sw + 1).toInt(); wifi_scan_obj.changeChannel(); Serial.println("Set channel: " + (String)wifi_scan_obj.set_channel); - + } if (d_sw == -1) { @@ -707,7 +790,7 @@ void CommandLine::runCommand(String input) { Serial.println("Starting PMKID sniff with deauthentication on channel " + (String)wifi_scan_obj.set_channel + ". Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_SCAN_ACTIVE_EAPOL, TFT_VIOLET); } - } + } //// WiFi attack commands // attack @@ -719,14 +802,14 @@ void CommandLine::runCommand(String input) { int src_addr_sw = this->argSearch(&cmd_args, "-s"); int dst_addr_sw = this->argSearch(&cmd_args, "-d"); int targ_sw = this->argSearch(&cmd_args, "-c"); - + if (attack_type_switch == -1) { Serial.println("You must specify an attack type"); return; } else { String attack_type = cmd_args.get(attack_type_switch + 1); - + // Branch on attack type // Deauth if (attack_type == ATTACK_TYPE_DEAUTH) { @@ -750,10 +833,10 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any targets selected. Use " + (String)SEL_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Deauthentication attack. Stop with " + (String)STOPSCAN_CMD); // Station list not specified if (targ_sw == -1) @@ -765,15 +848,15 @@ void CommandLine::runCommand(String input) { // Source addr specified else { String src_mac_str = cmd_args.get(src_addr_sw + 1); - sscanf(src_mac_str.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", - &wifi_scan_obj.src_mac[0], &wifi_scan_obj.src_mac[1], &wifi_scan_obj.src_mac[2], &wifi_scan_obj.src_mac[3], &wifi_scan_obj.src_mac[4], &wifi_scan_obj.src_mac[5]); + sscanf(src_mac_str.c_str(), "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", + &wifi_scan_obj.src_mac[0], &wifi_scan_obj.src_mac[1], &wifi_scan_obj.src_mac[2], &wifi_scan_obj.src_mac[3], &wifi_scan_obj.src_mac[4], &wifi_scan_obj.src_mac[5]); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Manual Deauthentication attack. Stop with " + (String)STOPSCAN_CMD); - wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH_MANUAL, TFT_RED); + wifi_scan_obj.StartScan(WIFI_ATTACK_DEAUTH_MANUAL, TFT_RED); } } // Beacon @@ -784,19 +867,19 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any SSIDs in your list. Use " + (String)SSID_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Beacon list spam. Stop with " + (String)STOPSCAN_CMD); 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 +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting random Beacon spam. Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_ATTACK_BEACON_SPAM, TFT_ORANGE); } @@ -806,10 +889,10 @@ void CommandLine::runCommand(String input) { Serial.println("You don't have any targets selected. Use " + (String)SEL_CMD); return; } - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif Serial.println("Starting Targeted AP Beacon spam. Stop with " + (String)STOPSCAN_CMD); wifi_scan_obj.StartScan(WIFI_ATTACK_AP_SPAM, TFT_MAGENTA); } @@ -823,18 +906,18 @@ void CommandLine::runCommand(String input) { return; } Serial.println("Starting Probe spam. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_ATTACK_AUTH, TFT_RED); } else if (attack_type == ATTACK_TYPE_RR) { Serial.println("Starting Rick Roll Beacon spam. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif wifi_scan_obj.StartScan(WIFI_ATTACK_RICK_ROLL, TFT_YELLOW); } else { @@ -847,72 +930,72 @@ void CommandLine::runCommand(String input) { //// Bluetooth scan/attack commands // Bluetooth scan if (cmd_args.get(0) == BT_SNIFF_CMD) { - #ifdef HAS_BT - int bt_type_sw = this->argSearch(&cmd_args, "-t"); - - // Specifying type of bluetooth sniff - if (bt_type_sw != -1) { - String bt_type = cmd_args.get(bt_type_sw + 1); - - bt_type.toLowerCase(); - - // Airtag sniff - if (bt_type == "airtag") { - Serial.println("Starting Airtag sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_AIRTAG, TFT_WHITE); - } - else if (bt_type == "flipper") { - Serial.println("Starting Flipper sniff. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_FLIPPER, TFT_ORANGE); - } +#ifdef HAS_BT + int bt_type_sw = this->argSearch(&cmd_args, "-t"); + + // Specifying type of bluetooth sniff + if (bt_type_sw != -1) { + String bt_type = cmd_args.get(bt_type_sw + 1); + + bt_type.toLowerCase(); + + // Airtag sniff + if (bt_type == "airtag") { + Serial.println("Starting Airtag sniff. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_AIRTAG, TFT_WHITE); } - // General bluetooth sniff - else { - Serial.println("Starting Bluetooth scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN); + else if (bt_type == "flipper") { + Serial.println("Starting Flipper sniff. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_FLIPPER, TFT_ORANGE); } - #else - Serial.println("Bluetooth not supported"); - #endif + } + // General bluetooth sniff + else { + Serial.println("Starting Bluetooth scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_ALL, TFT_GREEN); + } +#else + Serial.println("Bluetooth not supported"); +#endif } else if (cmd_args.get(0) == BT_SPOOFAT_CMD) { int at_sw = this->argSearch(&cmd_args, "-t"); if (at_sw != -1) { - #ifdef HAS_BT - int target_mac = cmd_args.get(at_sw + 1).toInt(); - if (target_mac < airtags->size()) { - for (int i = 0; i < airtags->size(); i++) { - AirTag at = airtags->get(i); - if (i == target_mac) - at.selected = true; - else - at.selected = false; - airtags->set(i, at); - } - Serial.println("Spoofing Airtag: " + airtags->get(target_mac).mac); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SPOOF_AIRTAG, TFT_WHITE); - } - else { - Serial.println("Provided index is out of range: " + (String)target_mac); - return; +#ifdef HAS_BT + int target_mac = cmd_args.get(at_sw + 1).toInt(); + if (target_mac < airtags->size()) { + for (int i = 0; i < airtags->size(); i++) { + AirTag at = airtags->get(i); + if (i == target_mac) + at.selected = true; + else + at.selected = false; + airtags->set(i, at); } - #endif + Serial.println("Spoofing Airtag: " + airtags->get(target_mac).mac); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SPOOF_AIRTAG, TFT_WHITE); + } + else { + Serial.println("Provided index is out of range: " + (String)target_mac); + return; + } +#endif } } else if (cmd_args.get(0) == BT_SPAM_CMD) { @@ -921,76 +1004,76 @@ void CommandLine::runCommand(String input) { String bt_type = cmd_args.get(bt_type_sw + 1); if (bt_type == "apple") { - #ifdef HAS_BT - Serial.println("Starting Sour Apple attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SOUR_APPLE, TFT_GREEN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Sour Apple attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SOUR_APPLE, TFT_GREEN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "windows") { - #ifdef HAS_BT - Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SWIFTPAIR_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SWIFTPAIR_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "samsung") { - #ifdef HAS_BT - Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SAMSUNG_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SAMSUNG_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "google") { - #ifdef HAS_BT - Serial.println("Starting Google Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_GOOGLE_SPAM, TFT_CYAN); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Google Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_GOOGLE_SPAM, TFT_CYAN); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "flipper") { - #ifdef HAS_BT - Serial.println("Starting Flipper Spam attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_FLIPPER_SPAM, TFT_ORANGE); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Flipper Spam attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_FLIPPER_SPAM, TFT_ORANGE); +#else + Serial.println("Bluetooth not supported"); +#endif } else if (bt_type == "all") { - #ifdef HAS_BT - Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_ATTACK_SPAM_ALL, TFT_MAGENTA); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_ATTACK_SPAM_ALL, TFT_MAGENTA); +#else + Serial.println("Bluetooth not supported"); +#endif } else { Serial.println("You did not specify a correct spam type"); @@ -1008,8 +1091,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SWIFTPAIR_SPAM_CMD) { + } + else if (cmd_args.get(0) == BT_SWIFTPAIR_SPAM_CMD) { #ifdef HAS_BT Serial.println("Starting Swiftpair Spam attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1020,8 +1103,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SAMSUNG_SPAM_CMD) { + } + else if (cmd_args.get(0) == BT_SAMSUNG_SPAM_CMD) { #ifdef HAS_BT Serial.println("Starting Samsung Spam attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1032,8 +1115,8 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - } - else if (cmd_args.get(0) == BT_SPAM_ALL_CMD) { + } + else if (cmd_args.get(0) == BT_SPAM_ALL_CMD) { #ifdef HAS_BT Serial.println("Starting BT Spam All attack. Stop with " + (String)STOPSCAN_CMD); #ifdef HAS_SCREEN @@ -1044,52 +1127,53 @@ void CommandLine::runCommand(String input) { #else Serial.println("Bluetooth not supported"); #endif - }*/ + }*/ // Wardrive else if (cmd_args.get(0) == BT_WARDRIVE_CMD) { - #ifdef HAS_BT - #ifdef HAS_GPS - if (gps_obj.getGpsModuleStatus()) { - int cont_sw = this->argSearch(&cmd_args, "-c"); - - if (cont_sw == -1) { - Serial.println("Starting BT Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE, TFT_GREEN); - } - else {Serial.println("Starting Continuous BT Wardrive. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE_CONT, TFT_GREEN); - } - } - else - Serial.println("GPS Module not detected"); - #else - Serial.println("GPS not supported"); - #endif - #else - Serial.println("Bluetooth not supported"); - #endif - +#ifdef HAS_BT +#ifdef HAS_GPS + if (gps_obj.getGpsModuleStatus()) { + int cont_sw = this->argSearch(&cmd_args, "-c"); + + if (cont_sw == -1) { + Serial.println("Starting BT Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE, TFT_GREEN); + } + else { + Serial.println("Starting Continuous BT Wardrive. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_WAR_DRIVE_CONT, TFT_GREEN); + } + } + else + Serial.println("GPS Module not detected"); +#else + Serial.println("GPS not supported"); +#endif +#else + Serial.println("Bluetooth not supported"); +#endif + } // Bluetooth CC Skimmer scan else if (cmd_args.get(0) == BT_SKIM_CMD) { - #ifdef HAS_BT - Serial.println("Starting Bluetooth CC Skimmer scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); - #endif - wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA); - #else - Serial.println("Bluetooth not supported"); - #endif +#ifdef HAS_BT + Serial.println("Starting Bluetooth CC Skimmer scan. Stop with " + (String)STOPSCAN_CMD); +#ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); +#endif + wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA); +#else + Serial.println("Bluetooth not supported"); +#endif } // Update command @@ -1101,24 +1185,24 @@ void CommandLine::runCommand(String input) { //if (w_sw != -1) { // Serial.println("Starting Marauder OTA Update. Stop with " + (String)STOPSCAN_CMD); // wifi_scan_obj.currentScanMode = OTA_UPDATE; - //#ifdef HAS_SCREEN - // menu_function_obj.changeMenu(menu_function_obj.updateMenu); - //#endif + //#ifdef HAS_SCREEN + // menu_function_obj.changeMenu(menu_function_obj.updateMenu); + //#endif // web_obj.setupOTAupdate(); //} // Update via SD if (sd_sw != -1) { - #ifdef HAS_SD - if (!sd_obj.supported) { - Serial.println("SD card is not connected. Cannot perform SD Update"); - return; - } - wifi_scan_obj.currentScanMode = OTA_UPDATE; - sd_obj.runUpdate(); - #else - Serial.println("SD card support disabled. Cannot perform SD Update"); +#ifdef HAS_SD + if (!sd_obj.supported) { + Serial.println("SD card is not connected. Cannot perform SD Update"); return; - #endif + } + wifi_scan_obj.currentScanMode = OTA_UPDATE; + sd_obj.runUpdate(); +#else + Serial.println("SD card support disabled. Cannot perform SD Update"); + return; +#endif } } } @@ -1139,7 +1223,7 @@ void CommandLine::runCommand(String input) { if (access_points->get(i).selected) { Serial.println("[" + (String)i + "][CH:" + (String)access_points->get(i).channel + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi + " (selected)"); count_selected += 1; - } + } else Serial.println("[" + (String)i + "][CH:" + (String)access_points->get(i).channel + "] " + access_points->get(i).essid + " " + (String)access_points->get(i).rssi); } @@ -1151,7 +1235,7 @@ void CommandLine::runCommand(String input) { if (ssids->get(i).selected) { Serial.println("[" + (String)i + "] " + ssids->get(i).essid + " (selected)"); count_selected += 1; - } + } else Serial.println("[" + (String)i + "] " + ssids->get(i).essid); } @@ -1260,7 +1344,7 @@ 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++) { @@ -1347,15 +1431,15 @@ void CommandLine::runCommand(String input) { int st_sw = this->argSearch(&cmd_args, "-s"); if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.saveAPsMenu); - #endif +#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 +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.saveSSIDsMenu); +#endif wifi_scan_obj.RunSaveSSIDList(true); } } @@ -1364,15 +1448,15 @@ void CommandLine::runCommand(String input) { int st_sw = this->argSearch(&cmd_args, "-s"); if (ap_sw != -1) { - #ifdef HAS_SCREEN - menu_function_obj.changeMenu(&menu_function_obj.loadAPsMenu); - #endif +#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 +#ifdef HAS_SCREEN + menu_function_obj.changeMenu(&menu_function_obj.loadSSIDsMenu); +#endif wifi_scan_obj.RunLoadSSIDList(); } } @@ -1419,11 +1503,11 @@ void CommandLine::runCommand(String input) { int n_sw = this->argSearch(&cmd_args, "-n"); // name int a_sw = this->argSearch(&cmd_args, "-a"); // access point int s_sw = this->argSearch(&cmd_args, "-s"); // ssid - int p_sw = this->argSearch(&cmd_args, "-p"); - + int p_sw = this->argSearch(&cmd_args, "-p"); + String essid = ""; String pwx = ""; - + if (s_sw != -1) { int index = cmd_args.get(s_sw + 1).toInt(); if (!this->inRange(ssids->size(), index)) { @@ -1444,11 +1528,11 @@ void CommandLine::runCommand(String input) { Serial.println("You must specify an access point or ssid"); return; } - + if (p_sw != -1) { pwx = cmd_args.get(p_sw + 1); } Serial.println("Attempting to join WiFi with ssid " + (String)essid); wifi_scan_obj.joinWiFi(essid, pwx); - }*/ + }*/ } diff --git a/esp32_marauder/CommandLine.h b/esp32_marauder/CommandLine.h index 350ed601d..7749e6266 100644 --- a/esp32_marauder/CommandLine.h +++ b/esp32_marauder/CommandLine.h @@ -148,9 +148,10 @@ const char PROGMEM HELP_BT_WARDRIVE_CMD[] = "btwardrive [-c]"; const char PROGMEM HELP_BT_SKIM_CMD[] = "sniffskim"; const char PROGMEM HELP_FOOT[] = "=================================="; - class CommandLine { private: + static char serial_buffer[255]; + static int serial_buffer_idx; String getSerialInput(); LinkedList parseCommand(String input, char* delim); String toLowerCase(String str); @@ -197,4 +198,7 @@ class CommandLine { void main(uint32_t currentTime); }; +int CommandLine::serial_buffer_idx = 0; +char CommandLine::serial_buffer[255]; + #endif