mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 15:38:14 -08:00
Get ready for setting new MACs
This commit is contained in:
@@ -1456,6 +1456,7 @@ void MenuFunctions::RunSetup()
|
|||||||
wifiGeneralMenu.list = new LinkedList<MenuNode>();
|
wifiGeneralMenu.list = new LinkedList<MenuNode>();
|
||||||
wifiAPMenu.list = new LinkedList<MenuNode>();
|
wifiAPMenu.list = new LinkedList<MenuNode>();
|
||||||
apInfoMenu.list = new LinkedList<MenuNode>();
|
apInfoMenu.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
|
||||||
@@ -1523,6 +1524,7 @@ void MenuFunctions::RunSetup()
|
|||||||
clearAPsMenu.name = text_table1[29];
|
clearAPsMenu.name = text_table1[29];
|
||||||
wifiAPMenu.name = "Access Points";
|
wifiAPMenu.name = "Access Points";
|
||||||
apInfoMenu.name = "AP Info";
|
apInfoMenu.name = "AP Info";
|
||||||
|
genAPMacMenu.name = "Generate AP MAC";
|
||||||
#ifdef HAS_BT
|
#ifdef HAS_BT
|
||||||
airtagMenu.name = "Select Airtag";
|
airtagMenu.name = "Select Airtag";
|
||||||
#endif
|
#endif
|
||||||
@@ -1941,6 +1943,17 @@ void MenuFunctions::RunSetup()
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*this->addNodes(&wifiGeneralMenu, "Generate AP MAC", TFTLIGHTGREY, NULL, 0, [this]() {
|
||||||
|
this->changeMenu(genAPMacMenu.parentMenu);
|
||||||
|
wifi_scan_obj.RunGenerateRandomMac(true);
|
||||||
|
});*/
|
||||||
|
|
||||||
|
// Menu for generating and setting access point MAC
|
||||||
|
genAPMacMenu.parentMenu = &wifiGeneralMenu;
|
||||||
|
this->addNodes(&genAPMacMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
|
||||||
|
this->changeMenu(genAPMacMenu.parentMenu);
|
||||||
|
});
|
||||||
|
|
||||||
// Build generate ssids menu
|
// Build generate ssids menu
|
||||||
generateSSIDsMenu.parentMenu = &wifiGeneralMenu;
|
generateSSIDsMenu.parentMenu = &wifiGeneralMenu;
|
||||||
this->addNodes(&generateSSIDsMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
|
this->addNodes(&generateSSIDsMenu, text09, TFTLIGHTGREY, NULL, 0, [this]() {
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ class MenuFunctions
|
|||||||
Menu miniKbMenu;
|
Menu miniKbMenu;
|
||||||
Menu saveFileMenu;
|
Menu saveFileMenu;
|
||||||
Menu apInfoMenu;
|
Menu apInfoMenu;
|
||||||
|
Menu genAPMacMenu;
|
||||||
|
|
||||||
// Bluetooth menu stuff
|
// Bluetooth menu stuff
|
||||||
Menu bluetoothSnifferMenu;
|
Menu bluetoothSnifferMenu;
|
||||||
|
|||||||
@@ -1072,7 +1072,7 @@ String WiFiScan::getStaMAC()
|
|||||||
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
||||||
esp_wifi_set_mode(WIFI_MODE_NULL);
|
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||||
esp_wifi_start();
|
esp_wifi_start();
|
||||||
esp_err_t mac_status = esp_wifi_get_mac(WIFI_IF_AP, mac);
|
esp_err_t mac_status = esp_wifi_get_mac(WIFI_IF_STA, mac);
|
||||||
this->wifi_initialized = true;
|
this->wifi_initialized = true;
|
||||||
sprintf(macAddrChr,
|
sprintf(macAddrChr,
|
||||||
"%02X:%02X:%02X:%02X:%02X:%02X",
|
"%02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
@@ -1700,6 +1700,42 @@ void WiFiScan::RunClearSSIDs() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WiFiScan::RunGenerateRandomMac(bool ap) {
|
||||||
|
uint8_t custom_mac[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||||
|
generateRandomMac(custom_mac);
|
||||||
|
esp_err_t result;
|
||||||
|
|
||||||
|
String custom_mac_str = macToString(custom_mac);
|
||||||
|
|
||||||
|
Serial.println("Setting custom MAC: " + (String)custom_mac_str);
|
||||||
|
//esp_wifi_init(&cfg);
|
||||||
|
//esp_wifi_start();
|
||||||
|
//this->wifi_initialized = true;
|
||||||
|
|
||||||
|
if (ap) result = esp_wifi_set_mac(WIFI_IF_AP, custom_mac);
|
||||||
|
else result = esp_wifi_set_mac(WIFI_IF_STA, custom_mac);
|
||||||
|
|
||||||
|
//this->shutdownWiFi();
|
||||||
|
|
||||||
|
if (result == ESP_OK) {
|
||||||
|
Serial.printf("[SUCCESS] Changed MAC for %s to %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||||
|
(!ap) ? "STA" : "AP",
|
||||||
|
custom_mac[0], custom_mac[1], custom_mac[2], custom_mac[3], custom_mac[4], custom_mac[5]);
|
||||||
|
} else {
|
||||||
|
Serial.printf("[ERROR] Failed to change MAC for %s. Error code: 0x%X\n",
|
||||||
|
(!ap) ? "STA" : "AP", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DISPLAY
|
||||||
|
display_obj.tft.setTextWrap(false);
|
||||||
|
display_obj.tft.setFreeFont(NULL);
|
||||||
|
display_obj.tft.setCursor(0, 100);
|
||||||
|
display_obj.tft.setTextSize(1);
|
||||||
|
display_obj.tft.setTextColor(TFT_CYAN);
|
||||||
|
display_obj.tft.println("Set MAC: " + (String)custom_mac_str);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void WiFiScan::RunGenerateSSIDs(int count) {
|
void WiFiScan::RunGenerateSSIDs(int count) {
|
||||||
#ifdef HAS_SCREEN
|
#ifdef HAS_SCREEN
|
||||||
display_obj.tft.setTextWrap(false);
|
display_obj.tft.setTextWrap(false);
|
||||||
|
|||||||
@@ -464,6 +464,7 @@ class WiFiScan
|
|||||||
void RunAPInfo(uint16_t index, bool do_display = true);
|
void RunAPInfo(uint16_t index, bool do_display = true);
|
||||||
void RunInfo();
|
void RunInfo();
|
||||||
//void RunShutdownBLE();
|
//void RunShutdownBLE();
|
||||||
|
void RunGenerateRandomMac(bool ap = true);
|
||||||
void RunGenerateSSIDs(int count = 20);
|
void RunGenerateSSIDs(int count = 20);
|
||||||
void RunClearSSIDs();
|
void RunClearSSIDs();
|
||||||
void RunClearAPs();
|
void RunClearAPs();
|
||||||
|
|||||||
Reference in New Issue
Block a user