Fix wardrive memory leak

This commit is contained in:
Just Call Me Koko
2023-09-08 14:08:17 -04:00
parent c370dfa996
commit 32c118b0d5
3 changed files with 18 additions and 2 deletions

View File

@@ -264,9 +264,12 @@ void EvilPortal::addLog(String log, int len) {
#ifdef WRITE_PACKETS_SERIAL
buffer_obj.addPacket(logBuffer, logLength, true);
delete[] logBuffer;
#elif defined(HAS_SD)
sd_obj.addPacket(logBuffer, logLength, true);
delete[] logBuffer;
#else
delete[] logBuffer;
return;
#endif
}

View File

@@ -1296,6 +1296,11 @@ void WiFiScan::executeWarDrive() {
bool do_save;
String display_string;
while (WiFi.scanComplete() == WIFI_SCAN_RUNNING) {
Serial.println("Scan running...");
delay(500);
}
int n = WiFi.scanNetworks(false, true, false, 110, this->set_channel);
if (n > 0) {
@@ -1349,6 +1354,9 @@ void WiFiScan::executeWarDrive() {
}
}
this->channelHop();
// Free up that memory, you sexy devil
WiFi.scanDelete();
}
#endif
}
@@ -1416,13 +1424,17 @@ void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
}
else {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
this->startWardriverWiFi();
}
this->wifi_initialized = true;
initTime = millis();
}
void WiFiScan::startWardriverWiFi() {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
}
void WiFiScan::RunStationScan(uint8_t scan_mode, uint16_t color)
{
#ifdef WRITE_PACKETS_SERIAL

View File

@@ -246,6 +246,7 @@ class WiFiScan
void save_mac(unsigned char* mac);
void clearMacHistory();
void executeWarDrive();
void startWardriverWiFi();
void startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string);