Save more flash space

This commit is contained in:
Just Call Me Koko
2025-11-26 00:26:03 -05:00
parent eab60701d5
commit d3ce284ea4
7 changed files with 214 additions and 290 deletions

View File

@@ -1323,12 +1323,14 @@ void CommandLine::runCommand(String input) {
} }
if (cmd_args.get(0) == ARP_SCAN_CMD) { if (cmd_args.get(0) == ARP_SCAN_CMD) {
Serial.println("Starting ARP Scan. Stop with " + (String)STOPSCAN_CMD); #ifndef HAS_DUAL_BAND
#ifdef HAS_SCREEN Serial.println("Starting ARP Scan. Stop with " + (String)STOPSCAN_CMD);
display_obj.clearScreen(); #ifdef HAS_SCREEN
menu_function_obj.drawStatusBar(); display_obj.clearScreen();
menu_function_obj.drawStatusBar();
#endif
wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN);
#endif #endif
wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN);
} }
// GPS POI // GPS POI

View File

@@ -2036,7 +2036,7 @@ void MenuFunctions::RunSetup()
settingsMenu.list = new LinkedList<MenuNode>(); settingsMenu.list = new LinkedList<MenuNode>();
specSettingMenu.list = new LinkedList<MenuNode>(); specSettingMenu.list = new LinkedList<MenuNode>();
infoMenu.list = new LinkedList<MenuNode>(); infoMenu.list = new LinkedList<MenuNode>();
languageMenu.list = new LinkedList<MenuNode>(); //languageMenu.list = new LinkedList<MenuNode>();
// WiFi menu stuff // WiFi menu stuff
wifiSnifferMenu.list = new LinkedList<MenuNode>(); wifiSnifferMenu.list = new LinkedList<MenuNode>();
@@ -2051,9 +2051,9 @@ void MenuFunctions::RunSetup()
apInfoMenu.list = new LinkedList<MenuNode>(); apInfoMenu.list = new LinkedList<MenuNode>();
setMacMenu.list = new LinkedList<MenuNode>(); setMacMenu.list = new LinkedList<MenuNode>();
genAPMacMenu.list = new LinkedList<MenuNode>(); genAPMacMenu.list = new LinkedList<MenuNode>();
#ifdef HAS_BT //#ifdef HAS_BT
airtagMenu.list = new LinkedList<MenuNode>(); // airtagMenu.list = new LinkedList<MenuNode>();
#endif //#endif
//#ifndef HAS_ILI9341 //#ifndef HAS_ILI9341
wifiStationMenu.list = new LinkedList<MenuNode>(); wifiStationMenu.list = new LinkedList<MenuNode>();
//#endif //#endif
@@ -2102,7 +2102,7 @@ void MenuFunctions::RunSetup()
//whichUpdateMenu.name = text_table1[12]; //whichUpdateMenu.name = text_table1[12];
confirmMenu.name = text_table1[13]; confirmMenu.name = text_table1[13];
updateMenu.name = text_table1[15]; updateMenu.name = text_table1[15];
languageMenu.name = text_table1[16]; //languageMenu.name = text_table1[16];
infoMenu.name = text_table1[17]; infoMenu.name = text_table1[17];
settingsMenu.name = text_table1[18]; settingsMenu.name = text_table1[18];
bluetoothMenu.name = text_table1[19]; bluetoothMenu.name = text_table1[19];
@@ -2123,14 +2123,14 @@ void MenuFunctions::RunSetup()
generateSSIDsMenu.name = text_table1[27]; generateSSIDsMenu.name = text_table1[27];
clearSSIDsMenu.name = text_table1[28]; clearSSIDsMenu.name = text_table1[28];
clearAPsMenu.name = text_table1[29]; clearAPsMenu.name = text_table1[29];
wifiAPMenu.name = "Access Points"; wifiAPMenu.name = "Select";
wifiIPMenu.name = "Active IPs"; wifiIPMenu.name = "Active IPs";
apInfoMenu.name = "AP Info"; apInfoMenu.name = "AP Info";
setMacMenu.name = "Set MACs"; setMacMenu.name = "Set MACs";
genAPMacMenu.name = "Generate AP MAC"; genAPMacMenu.name = "Generate AP MAC";
#ifdef HAS_BT //#ifdef HAS_BT
airtagMenu.name = "Select Airtag"; // airtagMenu.name = "Select Airtag";
#endif //#endif
//#ifndef HAS_ILI9341 //#ifndef HAS_ILI9341
wifiStationMenu.name = "Select Stations"; wifiStationMenu.name = "Select Stations";
//#endif //#endif
@@ -2209,11 +2209,13 @@ void MenuFunctions::RunSetup()
this->drawStatusBar(); this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_PING_SCAN, TFT_CYAN); wifi_scan_obj.StartScan(WIFI_PING_SCAN, TFT_CYAN);
}); });
this->addNodes(&wifiScannerMenu, "ARP Scan", TFTCYAN, NULL, SCANNERS, [this]() { #ifndef HAS_DUAL_BAND
display_obj.clearScreen(); this->addNodes(&wifiScannerMenu, "ARP Scan", TFTCYAN, NULL, SCANNERS, [this]() {
this->drawStatusBar(); display_obj.clearScreen();
wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN); this->drawStatusBar();
}); wifi_scan_obj.StartScan(WIFI_ARP_SCAN, TFT_CYAN);
});
#endif
this->addNodes(&wifiScannerMenu, "Port Scan All", TFTMAGENTA, NULL, BEACON_LIST, [this](){ this->addNodes(&wifiScannerMenu, "Port Scan All", TFTMAGENTA, NULL, BEACON_LIST, [this](){
// Add the back button // Add the back button
wifiIPMenu.list->clear(); wifiIPMenu.list->clear();
@@ -2357,32 +2359,26 @@ void MenuFunctions::RunSetup()
this->drawStatusBar(); this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_MULTISSID, TFT_ORANGE); wifi_scan_obj.StartScan(WIFI_SCAN_MULTISSID, TFT_ORANGE);
}); });
//#ifndef HAS_ILI9341 /*this->addNodes(&wifiSnifferMenu, text_table1[49], TFTMAGENTA, NULL, BEACON_SNIFF, [this]() {
this->addNodes(&wifiSnifferMenu, text_table1[49], TFTMAGENTA, NULL, BEACON_SNIFF, [this]() { display_obj.clearScreen();
display_obj.clearScreen(); this->drawStatusBar();
this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA);
wifi_scan_obj.StartScan(WIFI_SCAN_TARGET_AP, TFT_MAGENTA); });*/
});
//#endif
this->addNodes(&wifiSnifferMenu, "Scan All", TFTLIME, NULL, BEACON_SNIFF, [this]() { this->addNodes(&wifiSnifferMenu, "Scan All", TFTLIME, NULL, BEACON_SNIFF, [this]() {
display_obj.clearScreen(); display_obj.clearScreen();
this->drawStatusBar(); this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_AP_STA, 0x97e0); wifi_scan_obj.StartScan(WIFI_SCAN_AP_STA, 0x97e0);
}); });
//#ifndef HAS_ILI9341 /*this->addNodes(&wifiSnifferMenu, text_table1[59], TFTORANGE, NULL, PACKET_MONITOR, [this]() {
this->addNodes(&wifiSnifferMenu, text_table1[59], TFTORANGE, NULL, PACKET_MONITOR, [this]() { display_obj.clearScreen();
display_obj.clearScreen(); this->drawStatusBar();
this->drawStatusBar(); wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_WHITE);
wifi_scan_obj.StartScan(WIFI_SCAN_STATION, TFT_WHITE); });*/
});
//#endif
//#ifdef HAS_ILI9341
this->addNodes(&wifiSnifferMenu, "Signal Monitor", TFTCYAN, NULL, PACKET_MONITOR, [this]() { this->addNodes(&wifiSnifferMenu, "Signal Monitor", TFTCYAN, NULL, PACKET_MONITOR, [this]() {
display_obj.clearScreen(); display_obj.clearScreen();
this->drawStatusBar(); this->drawStatusBar();
wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_CYAN); wifi_scan_obj.StartScan(WIFI_SCAN_SIG_STREN, TFT_CYAN);
}); });
//#endif
// Build Wardriving menu // Build Wardriving menu
#ifdef HAS_GPS #ifdef HAS_GPS
@@ -2649,7 +2645,9 @@ void MenuFunctions::RunSetup()
#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) #if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
this->addNodes(&wifiGeneralMenu, text_table1[1], TFTNAVY, NULL, KEYBOARD_ICO, [this](){ this->addNodes(&wifiGeneralMenu, text_table1[1], TFTNAVY, NULL, KEYBOARD_ICO, [this](){
this->changeMenu(&miniKbMenu, true); this->changeMenu(&miniKbMenu, true);
this->miniKeyboard(&miniKbMenu); #ifndef HAS_MINI_KB
this->miniKeyboard(&miniKbMenu);
#endif
}); });
#endif #endif
this->addNodes(&wifiGeneralMenu, text_table1[28], TFTSILVER, NULL, CLEAR_ICO, [this]() { this->addNodes(&wifiGeneralMenu, text_table1[28], TFTSILVER, NULL, CLEAR_ICO, [this]() {
@@ -3244,9 +3242,9 @@ void MenuFunctions::RunSetup()
// Select Airtag on Mini // Select Airtag on Mini
this->addNodes(&bluetoothAttackMenu, "Spoof Airtag", TFTWHITE, NULL, ATTACKS, [this](){ this->addNodes(&bluetoothAttackMenu, "Spoof Airtag", TFTWHITE, NULL, ATTACKS, [this](){
// Clear nodes and add back button // Clear nodes and add back button
airtagMenu.list->clear(); wifiAPMenu.list->clear();
this->addNodes(&airtagMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() { this->addNodes(&wifiAPMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() {
this->changeMenu(airtagMenu.parentMenu, true); this->changeMenu(wifiAPMenu.parentMenu, true);
}); });
// Add buttons for all airtags // Add buttons for all airtags
@@ -3259,7 +3257,7 @@ void MenuFunctions::RunSetup()
// Create the menu nodes for all of the list items // Create the menu nodes for all of the list items
for (int i = 0; i < menu_limit; i++) { 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); AirTag new_at = airtags->get(i);
new_at.selected = true; new_at.selected = true;
@@ -3281,12 +3279,12 @@ void MenuFunctions::RunSetup()
}); });
} }
this->changeMenu(&airtagMenu, true); this->changeMenu(&wifiAPMenu, true);
}); });
airtagMenu.parentMenu = &bluetoothAttackMenu; wifiAPMenu.parentMenu = &bluetoothAttackMenu;
this->addNodes(&airtagMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { this->addNodes(&wifiAPMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
this->changeMenu(airtagMenu.parentMenu, true); this->changeMenu(wifiAPMenu.parentMenu, true);
}); });
#endif #endif
@@ -3320,35 +3318,17 @@ void MenuFunctions::RunSetup()
this->changeMenu(&sdDeleteMenu, true); 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 #endif
this->addNodes(&deviceMenu, "Save/Load Files", TFTCYAN, NULL, SD_UPDATE, [this]() { this->addNodes(&deviceMenu, "Save/Load Files", TFTCYAN, NULL, SD_UPDATE, [this]() {
this->changeMenu(&saveFileMenu, true); 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; wifi_scan_obj.currentScanMode = SHOW_INFO;
this->changeMenu(&languageMenu, true); this->changeMenu(&languageMenu, true);
}); });*/
this->addNodes(&deviceMenu, text_table1[17], TFTWHITE, NULL, DEVICE_INFO, [this]() { this->addNodes(&deviceMenu, text_table1[17], TFTWHITE, NULL, DEVICE_INFO, [this]() {
wifi_scan_obj.currentScanMode = SHOW_INFO; wifi_scan_obj.currentScanMode = SHOW_INFO;
this->changeMenu(&infoMenu, true); this->changeMenu(&infoMenu, true);
@@ -3567,11 +3547,11 @@ void MenuFunctions::RunSetup()
this->changeMenu(infoMenu.parentMenu, true); this->changeMenu(infoMenu.parentMenu, true);
}); });
//language info menu //language info menu
languageMenu.parentMenu = &deviceMenu; /*languageMenu.parentMenu = &deviceMenu;
this->addNodes(&languageMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() { this->addNodes(&languageMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF;
this->changeMenu(infoMenu.parentMenu, true); this->changeMenu(infoMenu.parentMenu, true);
}); });*/
// Set the current menu to the mainMenu // Set the current menu to the mainMenu
this->changeMenu(&mainMenu, true); this->changeMenu(&mainMenu, true);
@@ -3579,6 +3559,7 @@ void MenuFunctions::RunSetup()
} }
//#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
#ifdef HAS_MINI_KB
String MenuFunctions::miniKeyboard(Menu * targetMenu, bool do_pass) { String MenuFunctions::miniKeyboard(Menu * targetMenu, bool do_pass) {
// Prepare a char array and reset temp SSID string // Prepare a char array and reset temp SSID string
extern LinkedList<ssid>* ssids; extern LinkedList<ssid>* ssids;
@@ -3982,7 +3963,7 @@ void MenuFunctions::RunSetup()
//#endif //#endif
#endif #endif
} }
//#endif #endif
void MenuFunctions::setupSDFileList(bool update) { void MenuFunctions::setupSDFileList(bool update) {
sd_obj.sd_files->clear(); sd_obj.sd_files->clear();

View File

@@ -175,13 +175,13 @@ class MenuFunctions
Menu deviceMenu; Menu deviceMenu;
// Device menu stuff // Device menu stuff
Menu whichUpdateMenu; //Menu whichUpdateMenu;
Menu failedUpdateMenu; Menu failedUpdateMenu;
Menu confirmMenu; Menu confirmMenu;
Menu updateMenu; Menu updateMenu;
Menu settingsMenu; Menu settingsMenu;
Menu specSettingMenu; Menu specSettingMenu;
Menu languageMenu; //Menu languageMenu;
Menu sdDeleteMenu; Menu sdDeleteMenu;
// WiFi menu stuff // WiFi menu stuff
@@ -195,9 +195,9 @@ class MenuFunctions
Menu wifiAPMenu; Menu wifiAPMenu;
Menu wifiIPMenu; Menu wifiIPMenu;
Menu ssidsMenu; Menu ssidsMenu;
#ifdef HAS_BT //#ifdef HAS_BT
Menu airtagMenu; // Menu airtagMenu;
#endif //#endif
//#ifndef HAS_ILI9341 //#ifndef HAS_ILI9341
Menu wifiStationMenu; Menu wifiStationMenu;
//#endif //#endif
@@ -253,7 +253,9 @@ class MenuFunctions
void buttonSelected(int b, int x = -1); void buttonSelected(int b, int x = -1);
void buttonNotSelected(int b, int x = -1); void buttonNotSelected(int b, int x = -1);
//#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS)) //#if (!defined(HAS_ILI9341) && defined(HAS_BUTTONS))
#ifdef HAS_MINI_KB
String miniKeyboard(Menu * targetMenu, bool do_pass = false); String miniKeyboard(Menu * targetMenu, bool do_pass = false);
#endif
//#endif //#endif
#ifdef MARAUDER_CARDPUTER #ifdef MARAUDER_CARDPUTER

View File

@@ -1856,6 +1856,23 @@ int WiFiScan::generateSSIDs(int count) {
return num_gen; 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) bool WiFiScan::joinWiFi(String ssid, String password, bool gui)
{ {
static const char * btns[] ={text16, ""}; 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 lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner
#endif #endif
this->connected_network = ssid; this->connected_network = ssid;
this->ip_addr = WiFi.localIP(); this->setNetworkInfo();
this->gateway = WiFi.gatewayIP(); this->showNetworkInfo();
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());
#ifdef HAS_SCREEN #ifdef HAS_SCREEN
#ifdef HAS_MINI_KB #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 lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); //Align to the corner
#endif #endif
this->connected_network = ssid; this->connected_network = ssid;
this->ip_addr = WiFi.softAPIP(); this->setNetworkInfo();
this->gateway = WiFi.gatewayIP();
this->subnet = WiFi.subnetMask();
Serial.println(F("\nStarted AP")); this->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());
#ifdef HAS_SCREEN #ifdef HAS_SCREEN
#ifdef HAS_MINI_KB #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...")); Serial.println(F("Starting Ping Scan with..."));
else if (scan_mode == WIFI_ARP_SCAN) else if (scan_mode == WIFI_ARP_SCAN)
Serial.println(F("Starting ARP Scan with...")); Serial.println(F("Starting ARP Scan with..."));
Serial.print(F("IP address: ")); this->showNetworkInfo();
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());
if (scan_mode == WIFI_PING_SCAN) if (scan_mode == WIFI_PING_SCAN)
buffer_obj.append("Starting Ping Scan with..."); 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"); buffer_obj.append("\n");
this->scan_complete = false; this->scan_complete = false;
//if (scan_mode == WIFI_ARP_SCAN)
// this->fullARP();
initTime = millis(); initTime = millis();
} }
@@ -2936,14 +2922,7 @@ void WiFiScan::RunPortScanAll(uint8_t scan_mode, uint16_t color)
this->current_scan_ip = this->gateway; this->current_scan_ip = this->gateway;
Serial.println(F("Starting Port Scan with...")); Serial.println(F("Starting Port Scan with..."));
Serial.print(F("IP address: ")); this->showNetworkInfo();
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());
buffer_obj.append("Starting Port Scan with..."); buffer_obj.append("Starting Port Scan with...");
buffer_obj.append("\nSSID: " + (String)this->connected_network); 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); 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(" -> ");
display_string.concat(access_points->get(ap_index).essid); 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); 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(sta_addr);
display_string.concat(" -> "); display_string.concat(" -> ");
@@ -9756,96 +9737,124 @@ bool WiFiScan::checkHostPort(IPAddress ip, uint16_t port, uint16_t timeout) {
return false; return false;
} }
bool WiFiScan::readARP(IPAddress targ_ip) { #ifndef HAS_DUAL_BAND
// Convert IPAddress to ip4_addr_t using IP4_ADDR bool WiFiScan::readARP(IPAddress targ_ip) {
ip4_addr_t test_ip; // Convert IPAddress to ip4_addr_t using IP4_ADDR
IP4_ADDR(&test_ip, targ_ip[0], targ_ip[1], targ_ip[2], targ_ip[3]); 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 // Get the netif interface for STA mode
//void* netif = NULL; //void* netif = NULL;
//tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif); //tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, &netif);
//struct netif* netif_interface = (struct netif*)netif; //struct netif* netif_interface = (struct netif*)netif;
const ip4_addr_t* ipaddr_ret = NULL; const ip4_addr_t* ipaddr_ret = NULL;
struct eth_addr* eth_ret = NULL; struct eth_addr* eth_ret = NULL;
// Use actual interface instead of NULL // Use actual interface instead of NULL
if (etharp_find_addr(NULL, &test_ip, &eth_ret, &ipaddr_ret) >= 0) { if (etharp_find_addr(NULL, &test_ip, &eth_ret, &ipaddr_ret) >= 0) {
return true; 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_t lwip_ip;
IP4_ADDR(&lwip_ip, IP4_ADDR(&lwip_ip,
this->current_scan_ip[0], ip_addr[0],
this->current_scan_ip[1], ip_addr[1],
this->current_scan_ip[2], ip_addr[2],
this->current_scan_ip[3]); ip_addr[3]);
etharp_request(netif_interface, &lwip_ip); 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) { void WiFiScan::fullARP() {
delay(250); 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); IPAddress check_ip = getPrevIP(this->current_scan_ip, this->subnet, i);
display_string = ""; display_string = "";
output_line = ""; output_line = "";
@@ -9865,42 +9874,16 @@ void WiFiScan::fullARP() {
Serial.println(output_line); Serial.println(output_line);
} }
} }
} this->arp_count = 0;
} if (!this->scan_complete) {
this->scan_complete = true;
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(" ");
}
#ifdef HAS_SCREEN #ifdef HAS_SCREEN
display_obj.display_buffer->add(display_string); display_obj.display_buffer->add("Scan complete");
#endif #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) { void WiFiScan::pingScan(uint8_t scan_mode) {
String display_string = ""; 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) { void WiFiScan::portScan(uint8_t scan_mode, uint16_t targ_port) {
@@ -10116,7 +10055,9 @@ void WiFiScan::main(uint32_t currentTime)
this->pingScan(); this->pingScan();
} }
else if (currentScanMode == WIFI_ARP_SCAN) { else if (currentScanMode == WIFI_ARP_SCAN) {
this->fullARP(); #ifndef HAS_DUAL_BAND
this->fullARP();
#endif
} }
else if (currentScanMode == WIFI_PORT_SCAN_ALL) { else if (currentScanMode == WIFI_PORT_SCAN_ALL) {
this->portScan(WIFI_PORT_SCAN_ALL); this->portScan(WIFI_PORT_SCAN_ALL);

View File

@@ -28,12 +28,14 @@
#include "esp_wifi.h" #include "esp_wifi.h"
#include "esp_wifi_types.h" #include "esp_wifi_types.h"
#include <esp_timer.h> #include <esp_timer.h>
#include <lwip/etharp.h> #ifndef HAS_DUAL_BAND
#include <lwip/ip_addr.h> #include <lwip/etharp.h>
#include <lwip/ip_addr.h>
#endif
#ifdef HAS_DUAL_BAND #ifdef HAS_DUAL_BAND
#include "esp_system.h" #include "esp_system.h"
#endif #endif
#ifdef HAS_BT #if defined(HAS_BT) && !defined(HAS_DUAL_BAND)
#include "esp_bt.h" #include "esp_bt.h"
#endif #endif
#ifdef HAS_SCREEN #ifdef HAS_SCREEN
@@ -523,6 +525,8 @@ class WiFiScan
NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type); NimBLEAdvertisementData GetUniversalAdvertisementData(EBLEPayloadType type);
#endif #endif
void showNetworkInfo();
void setNetworkInfo();
void fullARP(); void fullARP();
bool readARP(IPAddress targ_ip); bool readARP(IPAddress targ_ip);
bool singleARP(IPAddress ip_addr); bool singleARP(IPAddress ip_addr);

View File

@@ -428,7 +428,7 @@
#define HAS_BATTERY #define HAS_BATTERY
#define HAS_BT #define HAS_BT
//#define HAS_BUTTONS //#define HAS_BUTTONS
#define HAS_NEOPIXEL_LED //#define HAS_NEOPIXEL_LED
//#define HAS_PWR_MGMT //#define HAS_PWR_MGMT
#define HAS_SCREEN #define HAS_SCREEN
#define HAS_FULL_SCREEN #define HAS_FULL_SCREEN

View File

@@ -8,7 +8,7 @@
#include "configs.h" #include "configs.h"
#include "esp_heap_caps.h" //#include "esp_heap_caps.h"
struct mac_addr { struct mac_addr {
unsigned char bytes[6]; unsigned char bytes[6];
@@ -27,7 +27,7 @@ struct ProbeReqSsid {
uint8_t requests; 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", "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", "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", "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 = { 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:09:5B", "00:0F:B5", "00:14:6C"
"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"
}; };
const char oneplus_ouis[][9] PROGMEM = { const char oneplus_ouis[][9] PROGMEM = {
@@ -154,7 +147,7 @@ const char tplink_ouis[][9] PROGMEM = {
const char xiaomi_ouis[][9] PROGMEM = { const char xiaomi_ouis[][9] PROGMEM = {
"04:CF:8C", "18:59:36", "38:1A:2D", "64:B4:73", "78:02:F8", "04:CF:8C", "18:59:36", "38:1A:2D", "64:B4:73", "78:02:F8",
"90:4E:91", "C4:0B:CB", "D0:DB:32" "90:4E:91", "C4:0B:CB", "D0:DB:32"
}; };*/
uint8_t getDRAMUsagePercent() { uint8_t getDRAMUsagePercent() {
//size_t total = heap_caps_get_total_size(MALLOC_CAP_8BIT); //size_t total = heap_caps_get_total_size(MALLOC_CAP_8BIT);
@@ -171,7 +164,7 @@ uint8_t getDRAMUsagePercent() {
#ifdef HAS_PSRAM #ifdef HAS_PSRAM
uint8_t getPSRAMUsagePercent() { 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 free = heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
size_t total = ESP.getPsramSize(); size_t total = ESP.getPsramSize();
@@ -181,7 +174,8 @@ uint8_t getDRAMUsagePercent() {
size_t used = total - free; size_t used = total - free;
uint8_t percent = (used * 100) / total; uint8_t percent = (used * 100) / total;
return percent; return percent;*/
return getDRAMUsagePercent();
} }
#endif #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 // 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 static char oui[9]; // Temporary buffer for extracted OUI
// Extract the first three bytes (OUI) from addr // 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++) { \ for (uint8_t i = 0; i < sizeof(list) / sizeof(list[0]); i++) { \
char storedOUI[9]; \ char storedOUI[9]; \
strcpy_P(storedOUI, list[i]); \ strcpy_P(storedOUI, list[i]); \
/* Convert the stored OUI to lowercase */ \ \
for (int j = 0; j < 8; j++) { \ for (int j = 0; j < 8; j++) { \
storedOUI[j] = tolower(storedOUI[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) // Construct the new address: manufacturer + the remaining MAC address (after the first 3 bytes)
return String(manufacturer) + mac_suffix; return String(manufacturer) + mac_suffix;
} }*/
IPAddress getNextIP(IPAddress currentIP, IPAddress subnetMask) { IPAddress getNextIP(IPAddress currentIP, IPAddress subnetMask) {
// Convert IPAddress to uint32_t // Convert IPAddress to uint32_t