From d3ce284ea461d3a4a10596b768ba01f0bf0e5c2d Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Wed, 26 Nov 2025 00:26:03 -0500 Subject: [PATCH] Save more flash space --- esp32_marauder/CommandLine.cpp | 12 +- esp32_marauder/MenuFunctions.cpp | 111 +++++------ esp32_marauder/MenuFunctions.h | 12 +- esp32_marauder/WiFiScan.cpp | 331 +++++++++++++------------------ esp32_marauder/WiFiScan.h | 10 +- esp32_marauder/configs.h | 2 +- esp32_marauder/utils.h | 26 +-- 7 files changed, 214 insertions(+), 290 deletions(-) diff --git a/esp32_marauder/CommandLine.cpp b/esp32_marauder/CommandLine.cpp index 0813361..d186eb6 100644 --- a/esp32_marauder/CommandLine.cpp +++ b/esp32_marauder/CommandLine.cpp @@ -1323,12 +1323,14 @@ void CommandLine::runCommand(String input) { } if (cmd_args.get(0) == ARP_SCAN_CMD) { - Serial.println("Starting ARP Scan. Stop with " + (String)STOPSCAN_CMD); - #ifdef HAS_SCREEN - display_obj.clearScreen(); - menu_function_obj.drawStatusBar(); + #ifndef HAS_DUAL_BAND + Serial.println("Starting ARP Scan. Stop with " + (String)STOPSCAN_CMD); + #ifdef HAS_SCREEN + display_obj.clearScreen(); + menu_function_obj.drawStatusBar(); + #endif + wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN); #endif - wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN); } // GPS POI diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index 6321116..fc67f07 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -2036,7 +2036,7 @@ void MenuFunctions::RunSetup() settingsMenu.list = new LinkedList(); specSettingMenu.list = new LinkedList(); infoMenu.list = new LinkedList(); - languageMenu.list = new LinkedList(); + //languageMenu.list = new LinkedList(); // WiFi menu stuff wifiSnifferMenu.list = new LinkedList(); @@ -2051,9 +2051,9 @@ void MenuFunctions::RunSetup() apInfoMenu.list = new LinkedList(); setMacMenu.list = new LinkedList(); genAPMacMenu.list = new LinkedList(); - #ifdef HAS_BT - airtagMenu.list = new LinkedList(); - #endif + //#ifdef HAS_BT + // airtagMenu.list = new LinkedList(); + //#endif //#ifndef HAS_ILI9341 wifiStationMenu.list = new LinkedList(); //#endif @@ -2102,7 +2102,7 @@ void MenuFunctions::RunSetup() //whichUpdateMenu.name = text_table1[12]; confirmMenu.name = text_table1[13]; updateMenu.name = text_table1[15]; - languageMenu.name = text_table1[16]; + //languageMenu.name = text_table1[16]; infoMenu.name = text_table1[17]; settingsMenu.name = text_table1[18]; bluetoothMenu.name = text_table1[19]; @@ -2123,14 +2123,14 @@ void MenuFunctions::RunSetup() generateSSIDsMenu.name = text_table1[27]; clearSSIDsMenu.name = text_table1[28]; clearAPsMenu.name = text_table1[29]; - wifiAPMenu.name = "Access Points"; + wifiAPMenu.name = "Select"; wifiIPMenu.name = "Active IPs"; apInfoMenu.name = "AP Info"; setMacMenu.name = "Set MACs"; genAPMacMenu.name = "Generate AP MAC"; - #ifdef HAS_BT - airtagMenu.name = "Select Airtag"; - #endif + //#ifdef HAS_BT + // airtagMenu.name = "Select Airtag"; + //#endif //#ifndef HAS_ILI9341 wifiStationMenu.name = "Select Stations"; //#endif @@ -2209,11 +2209,13 @@ void MenuFunctions::RunSetup() this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_PING_SCAN, TFT_CYAN); }); - this->addNodes(&wifiScannerMenu, "ARP Scan", TFTCYAN, NULL, SCANNERS, [this]() { - display_obj.clearScreen(); - this->drawStatusBar(); - wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN); - }); + #ifndef HAS_DUAL_BAND + this->addNodes(&wifiScannerMenu, "ARP Scan", TFTCYAN, NULL, SCANNERS, [this]() { + display_obj.clearScreen(); + this->drawStatusBar(); + wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN); + }); + #endif this->addNodes(&wifiScannerMenu, "Port Scan All", TFTMAGENTA, NULL, BEACON_LIST, [this](){ // Add the back button wifiIPMenu.list->clear(); @@ -2357,32 +2359,26 @@ void MenuFunctions::RunSetup() this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_MULTISSID, TFT_ORANGE); }); - //#ifndef HAS_ILI9341 - this->addNodes(&wifiSnifferMenu, text_table1[49], TFTMAGENTA, NULL, BEACON_SNIFF, [this]() { - display_obj.clearScreen(); - this->drawStatusBar(); - wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA); - }); - //#endif + /*this->addNodes(&wifiSnifferMenu, text_table1[49], TFTMAGENTA, NULL, BEACON_SNIFF, [this]() { + display_obj.clearScreen(); + this->drawStatusBar(); + wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA); + });*/ this->addNodes(&wifiSnifferMenu, "Scan All", TFTLIME, NULL, BEACON_SNIFF, [this]() { display_obj.clearScreen(); this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_AP_STA, 0x97e0); }); - //#ifndef HAS_ILI9341 - this->addNodes(&wifiSnifferMenu, text_table1[59], TFTORANGE, NULL, PACKET_MONITOR, [this]() { - display_obj.clearScreen(); - this->drawStatusBar(); - wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_WHITE); - }); - //#endif - //#ifdef HAS_ILI9341 + /*this->addNodes(&wifiSnifferMenu, text_table1[59], TFTORANGE, NULL, PACKET_MONITOR, [this]() { + display_obj.clearScreen(); + this->drawStatusBar(); + wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_WHITE); + });*/ this->addNodes(&wifiSnifferMenu, "Signal Monitor", TFTCYAN, NULL, PACKET_MONITOR, [this]() { display_obj.clearScreen(); this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_CYAN); }); - //#endif // Build Wardriving menu #ifdef HAS_GPS @@ -2649,7 +2645,9 @@ void MenuFunctions::RunSetup() #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) this->addNodes(&wifiGeneralMenu, text_table1[1], TFTNAVY, NULL, KEYBOARD_ICO, [this](){ this->changeMenu(&miniKbMenu, true); - this->miniKeyboard(&miniKbMenu); + #ifndef HAS_MINI_KB + this->miniKeyboard(&miniKbMenu); + #endif }); #endif this->addNodes(&wifiGeneralMenu, text_table1[28], TFTSILVER, NULL, CLEAR_ICO, [this]() { @@ -3244,9 +3242,9 @@ void MenuFunctions::RunSetup() // Select Airtag on Mini this->addNodes(&bluetoothAttackMenu, "Spoof Airtag", TFTWHITE, NULL, ATTACKS, [this](){ // Clear nodes and add back button - airtagMenu.list->clear(); - this->addNodes(&airtagMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { - this->changeMenu(airtagMenu.parentMenu, true); + wifiAPMenu.list->clear(); + this->addNodes(&wifiAPMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { + this->changeMenu(wifiAPMenu.parentMenu, true); }); // Add buttons for all airtags @@ -3259,7 +3257,7 @@ void MenuFunctions::RunSetup() // Create the menu nodes for all of the list items for (int i = 0; i < menu_limit; i++) { - this->addNodes(&airtagMenu, airtags->get(i).mac, TFTWHITE, NULL, BLUETOOTH, [this, i](){ + this->addNodes(&wifiAPMenu, airtags->get(i).mac, TFTWHITE, NULL, BLUETOOTH, [this, i](){ AirTag new_at = airtags->get(i); new_at.selected = true; @@ -3281,12 +3279,12 @@ void MenuFunctions::RunSetup() }); } - this->changeMenu(&airtagMenu, true); + this->changeMenu(&wifiAPMenu, true); }); - airtagMenu.parentMenu = &bluetoothAttackMenu; - this->addNodes(&airtagMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { - this->changeMenu(airtagMenu.parentMenu, true); + wifiAPMenu.parentMenu = &bluetoothAttackMenu; + this->addNodes(&wifiAPMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { + this->changeMenu(wifiAPMenu.parentMenu, true); }); #endif @@ -3320,35 +3318,17 @@ void MenuFunctions::RunSetup() this->changeMenu(&sdDeleteMenu, true); }); } - - /*if (sd_obj.supported) { - addNodes(&whichUpdateMenu, text_table1[40], TFTMAGENTA, NULL, SD_UPDATE, [this]() { - wifi_scan_obj.currentScanMode = OTA_UPDATE; - this->changeMenu(&confirmMenu, true); - }); - } - - // Confirm SD update menu - confirmMenu.parentMenu = &whichUpdateMenu; - this->addNodes(&confirmMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { - this->changeMenu(confirmMenu.parentMenu, true); - }); - this->addNodes(&confirmMenu, text14, TFTORANGE, NULL, UPDATE, [this]() { - wifi_scan_obj.currentScanMode = OTA_UPDATE; - this->changeMenu(&failedUpdateMenu, true); - sd_obj.runUpdate(); - });*/ #endif this->addNodes(&deviceMenu, "Save/Load Files", TFTCYAN, NULL, SD_UPDATE, [this]() { this->changeMenu(&saveFileMenu, true); }); - this->addNodes(&deviceMenu, text_table1[16], TFTGREEN, NULL, LANGUAGE, [this]() { + /*this->addNodes(&deviceMenu, text_table1[16], TFTGREEN, NULL, LANGUAGE, [this]() { wifi_scan_obj.currentScanMode = SHOW_INFO; this->changeMenu(&languageMenu, true); - }); + });*/ this->addNodes(&deviceMenu, text_table1[17], TFTWHITE, NULL, DEVICE_INFO, [this]() { wifi_scan_obj.currentScanMode = SHOW_INFO; this->changeMenu(&infoMenu, true); @@ -3567,11 +3547,11 @@ void MenuFunctions::RunSetup() this->changeMenu(infoMenu.parentMenu, true); }); //language info menu - languageMenu.parentMenu = &deviceMenu; - this->addNodes(&languageMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { - wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; - this->changeMenu(infoMenu.parentMenu, true); - }); + /*languageMenu.parentMenu = &deviceMenu; + this->addNodes(&languageMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { + wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; + this->changeMenu(infoMenu.parentMenu, true); + });*/ // Set the current menu to the mainMenu this->changeMenu(&mainMenu, true); @@ -3579,6 +3559,7 @@ void MenuFunctions::RunSetup() } //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) +#ifdef HAS_MINI_KB String MenuFunctions::miniKeyboard(Menu * targetMenu, bool do_pass) { // Prepare a char array and reset temp SSID string extern LinkedList* ssids; @@ -3982,7 +3963,7 @@ void MenuFunctions::RunSetup() //#endif #endif } -//#endif +#endif void MenuFunctions::setupSDFileList(bool update) { sd_obj.sd_files->clear(); diff --git a/esp32_marauder/MenuFunctions.h b/esp32_marauder/MenuFunctions.h index 036355a..133373e 100644 --- a/esp32_marauder/MenuFunctions.h +++ b/esp32_marauder/MenuFunctions.h @@ -175,13 +175,13 @@ class MenuFunctions Menu deviceMenu; // Device menu stuff - Menu whichUpdateMenu; + //Menu whichUpdateMenu; Menu failedUpdateMenu; Menu confirmMenu; Menu updateMenu; Menu settingsMenu; Menu specSettingMenu; - Menu languageMenu; + //Menu languageMenu; Menu sdDeleteMenu; // WiFi menu stuff @@ -195,9 +195,9 @@ class MenuFunctions Menu wifiAPMenu; Menu wifiIPMenu; Menu ssidsMenu; - #ifdef HAS_BT - Menu airtagMenu; - #endif + //#ifdef HAS_BT + // Menu airtagMenu; + //#endif //#ifndef HAS_ILI9341 Menu wifiStationMenu; //#endif @@ -253,7 +253,9 @@ class MenuFunctions void buttonSelected(int b, int x = -1); void buttonNotSelected(int b, int x = -1); //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) + #ifdef HAS_MINI_KB String miniKeyboard(Menu * targetMenu, bool do_pass = false); + #endif //#endif #ifdef MARAUDER_CARDPUTER diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index 1f55543..297033a 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -1856,6 +1856,23 @@ int WiFiScan::generateSSIDs(int count) { return num_gen; } +void WiFiScan::setNetworkInfo() { + this->ip_addr = WiFi.localIP(); + this->gateway = WiFi.gatewayIP(); + this->subnet = WiFi.subnetMask(); +} + +void WiFiScan::showNetworkInfo() { + Serial.print(F("IP address: ")); + Serial.println(this->ip_addr); + Serial.print(F("Gateway: ")); + Serial.println(this->gateway); + Serial.print(F("Netmask: ")); + Serial.println(this->subnet); + Serial.print(F("MAC: ")); + Serial.println(WiFi.macAddress()); +} + bool WiFiScan::joinWiFi(String ssid, String password, bool gui) { static const char * btns[] ={text16, ""}; @@ -1952,19 +1969,8 @@ bool WiFiScan::joinWiFi(String ssid, String password, bool gui) lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner #endif this->connected_network = ssid; - this->ip_addr = WiFi.localIP(); - this->gateway = WiFi.gatewayIP(); - this->subnet = WiFi.subnetMask(); - - Serial.println(F("\nConnected to the WiFi network")); - Serial.print(F("IP address: ")); - Serial.println(this->ip_addr); - Serial.print(F("Gateway: ")); - Serial.println(this->gateway); - Serial.print(F("Netmask: ")); - Serial.println(this->subnet); - Serial.print(F("MAC: ")); - Serial.println(WiFi.macAddress()); + this->setNetworkInfo(); + this->showNetworkInfo(); #ifdef HAS_SCREEN #ifdef HAS_MINI_KB @@ -2054,19 +2060,9 @@ bool WiFiScan::startWiFi(String ssid, String password, bool gui) lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner #endif this->connected_network = ssid; - this->ip_addr = WiFi.softAPIP(); - this->gateway = WiFi.gatewayIP(); - this->subnet = WiFi.subnetMask(); + this->setNetworkInfo(); - Serial.println(F("\nStarted AP")); - Serial.print(F("IP address: ")); - Serial.println(this->ip_addr); - Serial.print(F("Gateway: ")); - Serial.println(this->gateway); - Serial.print(F("Netmask: ")); - Serial.println(this->subnet); - Serial.print(F("MAC: ")); - Serial.println(WiFi.macAddress()); + this->showNetworkInfo(); #ifdef HAS_SCREEN #ifdef HAS_MINI_KB @@ -2831,14 +2827,7 @@ void WiFiScan::RunPingScan(uint8_t scan_mode, uint16_t color) Serial.println(F("Starting Ping Scan with...")); else if (scan_mode == WIFI_ARP_SCAN) Serial.println(F("Starting ARP Scan with...")); - Serial.print(F("IP address: ")); - Serial.println(this->ip_addr); - Serial.print(F("Gateway: ")); - Serial.println(this->gateway); - Serial.print(F("Netmask: ")); - Serial.println(this->subnet); - Serial.print(F("MAC: ")); - Serial.println(WiFi.macAddress()); + this->showNetworkInfo(); if (scan_mode == WIFI_PING_SCAN) buffer_obj.append("Starting Ping Scan with..."); @@ -2855,9 +2844,6 @@ void WiFiScan::RunPingScan(uint8_t scan_mode, uint16_t color) buffer_obj.append("\n"); this->scan_complete = false; - - //if (scan_mode == WIFI_ARP_SCAN) - // this->fullARP(); initTime = millis(); } @@ -2936,14 +2922,7 @@ void WiFiScan::RunPortScanAll(uint8_t scan_mode, uint16_t color) this->current_scan_ip = this->gateway; Serial.println(F("Starting Port Scan with...")); - Serial.print(F("IP address: ")); - Serial.println(this->ip_addr); - Serial.print(F("Gateway: ")); - Serial.println(this->gateway); - Serial.print(F("Netmask: ")); - Serial.println(this->subnet); - Serial.print(F("MAC: ")); - Serial.println(WiFi.macAddress()); + this->showNetworkInfo(); buffer_obj.append("Starting Port Scan with..."); buffer_obj.append("\nSSID: " + (String)this->connected_network); @@ -5701,7 +5680,8 @@ void WiFiScan::apSnifferCallbackFull(void* buf, wifi_promiscuous_pkt_type_t type Serial.println(ap_addr); } - display_string.concat(replaceOUIWithManufacturer(sta_addr)); + //display_string.concat(replaceOUIWithManufacturer(sta_addr)); + display_string.concat(sta_addr); display_string.concat(" -> "); display_string.concat(access_points->get(ap_index).essid); @@ -7286,7 +7266,8 @@ void WiFiScan::stationSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t typ Serial.println(ap_addr); } - display_string.concat(replaceOUIWithManufacturer(sta_addr)); + //display_string.concat(replaceOUIWithManufacturer(sta_addr)); + display_string.concat(sta_addr); //display_string.concat(sta_addr); display_string.concat(" -> "); @@ -9756,96 +9737,124 @@ bool WiFiScan::checkHostPort(IPAddress ip, uint16_t port, uint16_t timeout) { return false; } -bool WiFiScan::readARP(IPAddress targ_ip) { - // Convert IPAddress to ip4_addr_t using IP4_ADDR - ip4_addr_t test_ip; - IP4_ADDR(&test_ip, targ_ip[0], targ_ip[1], targ_ip[2], targ_ip[3]); +#ifndef HAS_DUAL_BAND + bool WiFiScan::readARP(IPAddress targ_ip) { + // Convert IPAddress to ip4_addr_t using IP4_ADDR + ip4_addr_t test_ip; + IP4_ADDR(&test_ip, targ_ip[0], targ_ip[1], targ_ip[2], targ_ip[3]); - // Get the netif interface for STA mode - //void* netif = NULL; - //tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); - //struct netif* netif_interface = (struct netif*)netif; + // Get the netif interface for STA mode + //void* netif = NULL; + //tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); + //struct netif* netif_interface = (struct netif*)netif; - const ip4_addr_t* ipaddr_ret = NULL; - struct eth_addr* eth_ret = NULL; + const ip4_addr_t* ipaddr_ret = NULL; + struct eth_addr* eth_ret = NULL; - // Use actual interface instead of NULL - if (etharp_find_addr(NULL, &test_ip, ð_ret, &ipaddr_ret) >= 0) { - return true; + // Use actual interface instead of NULL + if (etharp_find_addr(NULL, &test_ip, ð_ret, &ipaddr_ret) >= 0) { + return true; + } + + return false; } - return false; -} + bool WiFiScan::singleARP(IPAddress ip_addr) { -bool WiFiScan::singleARP(IPAddress ip_addr) { + #ifndef HAS_DUAL_BAND + void* netif = NULL; + tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); + struct netif* netif_interface = (struct netif*)netif; + #else + struct netif* netif_interface = (struct netif*)esp_netif_get_netif_impl(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); + //esp_netif_t* netif_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); + //struct netif* netif_interface = (struct netif*)netif; + //struct netif* netif_interface = esp_netif_get_netif_impl(*netif); + #endif - #ifndef HAS_DUAL_BAND - void* netif = NULL; - tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); - struct netif* netif_interface = (struct netif*)netif; - #else - struct netif* netif_interface = (struct netif*)esp_netif_get_netif_impl(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); - //esp_netif_t* netif_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); - //struct netif* netif_interface = (struct netif*)netif; - //struct netif* netif_interface = esp_netif_get_netif_impl(*netif); - #endif - - ip4_addr_t lwip_ip; - IP4_ADDR(&lwip_ip, - ip_addr[0], - ip_addr[1], - ip_addr[2], - ip_addr[3]); - - etharp_request(netif_interface, &lwip_ip); - - delay(250); - - if (this->readARP(ip_addr)) - return true; - - return false; -} - -void WiFiScan::fullARP() { - String display_string = ""; - String output_line = ""; - - #ifndef HAS_DUAL_BAND - void* netif = NULL; - tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); - struct netif* netif_interface = (struct netif*)netif; - #else - struct netif* netif_interface = (struct netif*)esp_netif_get_netif_impl(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); - //esp_netif_t* netif_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); - //struct netif* netif_interface = (struct netif*)netif; - //struct netif* netif_interface = esp_netif_get_netif_impl(*netif); - #endif - - //this->arp_count = 0; - - if (this->current_scan_ip != IPAddress(0, 0, 0, 0)) { ip4_addr_t lwip_ip; IP4_ADDR(&lwip_ip, - this->current_scan_ip[0], - this->current_scan_ip[1], - this->current_scan_ip[2], - this->current_scan_ip[3]); + ip_addr[0], + ip_addr[1], + ip_addr[2], + ip_addr[3]); etharp_request(netif_interface, &lwip_ip); - delay(100); + delay(250); - this->current_scan_ip = getNextIP(this->current_scan_ip, this->subnet); + if (this->readARP(ip_addr)) + return true; - this->arp_count++; + return false; + } - if (this->arp_count >= 10) { - delay(250); + void WiFiScan::fullARP() { + String display_string = ""; + String output_line = ""; - this->arp_count = 0; + #ifndef HAS_DUAL_BAND + void* netif = NULL; + tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); + struct netif* netif_interface = (struct netif*)netif; + #else + struct netif* netif_interface = (struct netif*)esp_netif_get_netif_impl(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); + //esp_netif_t* netif_interface = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"); + //struct netif* netif_interface = (struct netif*)netif; + //struct netif* netif_interface = esp_netif_get_netif_impl(*netif); + #endif + + //this->arp_count = 0; + + if (this->current_scan_ip != IPAddress(0, 0, 0, 0)) { + ip4_addr_t lwip_ip; + IP4_ADDR(&lwip_ip, + this->current_scan_ip[0], + this->current_scan_ip[1], + this->current_scan_ip[2], + this->current_scan_ip[3]); + + etharp_request(netif_interface, &lwip_ip); + + delay(100); + + this->current_scan_ip = getNextIP(this->current_scan_ip, this->subnet); + + this->arp_count++; + + if (this->arp_count >= 10) { + delay(250); + + this->arp_count = 0; + + for (int i = 10; i > 0; i--) { + IPAddress check_ip = getPrevIP(this->current_scan_ip, this->subnet, i); + display_string = ""; + output_line = ""; + if (this->readARP(check_ip)) { + ipList->add(check_ip); + output_line = check_ip.toString(); + display_string.concat(output_line); + uint8_t temp_len = display_string.length(); + for (uint8_t i = 0; i < 40 - temp_len; i++) + { + display_string.concat(" "); + } + #ifdef HAS_SCREEN + display_obj.display_buffer->add(display_string); + #endif + buffer_obj.append(output_line + "\n"); + Serial.println(output_line); + } + } + } + } + + if (this->current_scan_ip == IPAddress(0, 0, 0, 0)) { + + for (int i = this->arp_count; i > 0; i--) { + delay(250); - for (int i = 10; i > 0; i--) { IPAddress check_ip = getPrevIP(this->current_scan_ip, this->subnet, i); display_string = ""; output_line = ""; @@ -9865,42 +9874,16 @@ void WiFiScan::fullARP() { Serial.println(output_line); } } - } - } - - if (this->current_scan_ip == IPAddress(0, 0, 0, 0)) { - - for (int i = this->arp_count; i > 0; i--) { - delay(250); - - IPAddress check_ip = getPrevIP(this->current_scan_ip, this->subnet, i); - display_string = ""; - output_line = ""; - if (this->readARP(check_ip)) { - ipList->add(check_ip); - output_line = check_ip.toString(); - display_string.concat(output_line); - uint8_t temp_len = display_string.length(); - for (uint8_t i = 0; i < 40 - temp_len; i++) - { - display_string.concat(" "); - } + this->arp_count = 0; + if (!this->scan_complete) { + this->scan_complete = true; #ifdef HAS_SCREEN - display_obj.display_buffer->add(display_string); + display_obj.display_buffer->add("Scan complete"); #endif - buffer_obj.append(output_line + "\n"); - Serial.println(output_line); } } - this->arp_count = 0; - if (!this->scan_complete) { - this->scan_complete = true; - #ifdef HAS_SCREEN - display_obj.display_buffer->add("Scan complete"); - #endif - } } -} +#endif void WiFiScan::pingScan(uint8_t scan_mode) { String display_string = ""; @@ -9973,50 +9956,6 @@ void WiFiScan::pingScan(uint8_t scan_mode) { } } } - - /*else if (scan_mode == WIFI_SCAN_SSH) { - if (this->current_scan_ip != IPAddress(0, 0, 0, 0)) { - this->current_scan_ip = getNextIP(this->current_scan_ip, this->subnet); - #ifndef HAS_DUAL_BAND - if (this->singleARP(this->current_scan_ip)) { - #else - if (this->isHostAlive(this->current_scan_ip)) { - #endif - Serial.println(this->current_scan_ip); - this->portScan(scan_mode, 22); - } - } - else { - if (!this->scan_complete) { - this->scan_complete = true; - #ifdef HAS_SCREEN - display_obj.display_buffer->add("Scan complete"); - #endif - } - } - } - - else if (scan_mode == WIFI_SCAN_TELNET) { - if (this->current_scan_ip != IPAddress(0, 0, 0, 0)) { - this->current_scan_ip = getNextIP(this->current_scan_ip, this->subnet); - #ifndef HAS_DUAL_BAND - if (this->singleARP(this->current_scan_ip)) { - #else - if (this->isHostAlive(this->current_scan_ip)) { - #endif - Serial.println(this->current_scan_ip); - this->portScan(scan_mode, 23); - } - } - else { - if (!this->scan_complete) { - this->scan_complete = true; - #ifdef HAS_SCREEN - display_obj.display_buffer->add("Scan complete"); - #endif - } - } - }*/ } void WiFiScan::portScan(uint8_t scan_mode, uint16_t targ_port) { @@ -10116,7 +10055,9 @@ void WiFiScan::main(uint32_t currentTime) this->pingScan(); } else if (currentScanMode == WIFI_ARP_SCAN) { - this->fullARP(); + #ifndef HAS_DUAL_BAND + this->fullARP(); + #endif } else if (currentScanMode == WIFI_PORT_SCAN_ALL) { this->portScan(WIFI_PORT_SCAN_ALL); diff --git a/esp32_marauder/WiFiScan.h b/esp32_marauder/WiFiScan.h index e59408b..bdcf2bc 100644 --- a/esp32_marauder/WiFiScan.h +++ b/esp32_marauder/WiFiScan.h @@ -28,12 +28,14 @@ #include "esp_wifi.h" #include "esp_wifi_types.h" #include -#include -#include +#ifndef HAS_DUAL_BAND + #include + #include +#endif #ifdef HAS_DUAL_BAND #include "esp_system.h" #endif -#ifdef HAS_BT +#if defined(HAS_BT) && !defined(HAS_DUAL_BAND) #include "esp_bt.h" #endif #ifdef HAS_SCREEN @@ -523,6 +525,8 @@ class WiFiScan NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type); #endif + void showNetworkInfo(); + void setNetworkInfo(); void fullARP(); bool readARP(IPAddress targ_ip); bool singleARP(IPAddress ip_addr); diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 4cf68db..ef070c1 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -428,7 +428,7 @@ #define HAS_BATTERY #define HAS_BT //#define HAS_BUTTONS - #define HAS_NEOPIXEL_LED + //#define HAS_NEOPIXEL_LED //#define HAS_PWR_MGMT #define HAS_SCREEN #define HAS_FULL_SCREEN diff --git a/esp32_marauder/utils.h b/esp32_marauder/utils.h index cfa9ea0..d293e1a 100644 --- a/esp32_marauder/utils.h +++ b/esp32_marauder/utils.h @@ -8,7 +8,7 @@ #include "configs.h" -#include "esp_heap_caps.h" +//#include "esp_heap_caps.h" struct mac_addr { unsigned char bytes[6]; @@ -27,7 +27,7 @@ struct ProbeReqSsid { uint8_t requests; }; -const char apple_ouis[][9] PROGMEM = { +/*const char apple_ouis[][9] PROGMEM = { "00:17:F2", "00:1E:C2", "00:26:08", "F8:1E:DF", "BC:92:6B", "28:E0:2C", "3C:07:54", "7C:D1:C3", "DC:A9:04", "F0:D1:A9", "C0:2C:5C", "00:03:93", "00:03:94", "00:03:95", "00:03:96", @@ -114,14 +114,7 @@ const char linksys_ouis[][9] PROGMEM = { }; const char netgear_ouis[][9] PROGMEM = { - "00:09:5B", "00:0F:B5", "00:14:6C", "00:1B:2F", "00:1E:2A", "00:1F:33", "00:22:3F", "00:22:4B", "00:26:F2", - "00:8E:F2", "08:02:8E", "08:36:C9", "08:BD:43", "10:0C:6B", "10:0D:7F", "10:DA:43", "14:59:C0", "20:4E:7F", - "20:E5:2A", "28:80:88", "28:94:01", "28:C6:8E", "2C:30:33", "2C:B0:5D", "30:46:9A", "34:98:B5", "38:94:ED", - "3C:37:86", "40:5D:82", "44:A5:6E", "4C:60:DE", "50:4A:6E", "50:6A:03", "54:07:7D", "58:EF:68", "60:38:E0", - "6C:B0:CE", "6C:CD:D6", "74:44:01", "80:37:73", "84:1B:5E", "8C:3B:AD", "94:18:65", "9C:3D:CF", "9C:C9:EB", - "9C:D3:6D", "A0:04:60", "A0:21:B7", "A0:40:A0", "A4:2B:8C", "B0:39:56", "B0:7F:B9", "B0:B9:8A", "BC:A5:11", - "C0:3F:0E", "C0:FF:D4", "C4:04:15", "C4:3D:C7", "C8:9E:43", "CC:40:D0", "DC:EF:09", "E0:46:9A", "E0:46:EE", - "E0:91:F5", "E4:F4:C6", "E8:FC:AF", "F8:73:94" + "00:09:5B", "00:0F:B5", "00:14:6C" }; const char oneplus_ouis[][9] PROGMEM = { @@ -154,7 +147,7 @@ const char tplink_ouis[][9] PROGMEM = { const char xiaomi_ouis[][9] PROGMEM = { "04:CF:8C", "18:59:36", "38:1A:2D", "64:B4:73", "78:02:F8", "90:4E:91", "C4:0B:CB", "D0:DB:32" -}; +};*/ uint8_t getDRAMUsagePercent() { //size_t total = heap_caps_get_total_size(MALLOC_CAP_8BIT); @@ -171,7 +164,7 @@ uint8_t getDRAMUsagePercent() { #ifdef HAS_PSRAM uint8_t getPSRAMUsagePercent() { - //size_t total = heap_caps_get_total_size(MALLOC_CAP_SPIRAM); + /*//size_t total = heap_caps_get_total_size(MALLOC_CAP_SPIRAM); //size_t free = heap_caps_get_free_size(MALLOC_CAP_SPIRAM); size_t total = ESP.getPsramSize(); @@ -181,7 +174,8 @@ uint8_t getDRAMUsagePercent() { size_t used = total - free; uint8_t percent = (used * 100) / total; - return percent; + return percent;*/ + return getDRAMUsagePercent(); } #endif @@ -299,7 +293,7 @@ void convertMacStringToUint8(const String& macStr, uint8_t macAddr[6]) { } // Function to check if the given MAC address matches any known OUI -const char* getManufacturer(const char *addr) { +/*const char* getManufacturer(const char *addr) { static char oui[9]; // Temporary buffer for extracted OUI // Extract the first three bytes (OUI) from addr @@ -316,7 +310,7 @@ const char* getManufacturer(const char *addr) { for (uint8_t i = 0; i < sizeof(list) / sizeof(list[0]); i++) { \ char storedOUI[9]; \ strcpy_P(storedOUI, list[i]); \ - /* Convert the stored OUI to lowercase */ \ + \ for (int j = 0; j < 8; j++) { \ storedOUI[j] = tolower(storedOUI[j]); \ } \ @@ -355,7 +349,7 @@ String replaceOUIWithManufacturer(const char *sta_addr) { // Construct the new address: manufacturer + the remaining MAC address (after the first 3 bytes) return String(manufacturer) + mac_suffix; -} +}*/ IPAddress getNextIP(IPAddress currentIP, IPAddress subnetMask) { // Convert IPAddress to uint32_t