Merge pull request #986 from justcallmekoko/develop

Fix flock scan memory leak
This commit is contained in:
Just Call Me Koko
2025-11-22 17:05:00 -05:00
committed by GitHub
3 changed files with 60 additions and 8 deletions

View File

@@ -921,6 +921,8 @@ void MenuFunctions::main(uint32_t currentTime)
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG_MON) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLIPPER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE_TWO) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SOUR_APPLE) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SPAM_ALL) ||
@@ -1017,6 +1019,8 @@ void MenuFunctions::main(uint32_t currentTime)
(wifi_scan_obj.currentScanMode == BT_SCAN_AIRTAG_MON) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLIPPER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_FLOCK) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE_TWO) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SOUR_APPLE) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||
(wifi_scan_obj.currentScanMode == BT_ATTACK_SPAM_ALL) ||
@@ -3172,6 +3176,16 @@ void MenuFunctions::RunSetup()
this->drawStatusBar();
wifi_scan_obj.StartScan(BT_SCAN_FLOCK, TFT_ORANGE);
});
/*this->addNodes(&bluetoothSnifferMenu, "Simple Sniff", TFTWHITE, NULL, BLUETOOTH_SNIFF, [this]() {
display_obj.clearScreen();
this->drawStatusBar();
wifi_scan_obj.StartScan(BT_SCAN_SIMPLE, TFT_ORANGE);
});
this->addNodes(&bluetoothSnifferMenu, "Simple Sniff 2", TFTWHITE, NULL, BLUETOOTH_SNIFF, [this]() {
display_obj.clearScreen();
this->drawStatusBar();
wifi_scan_obj.StartScan(BT_SCAN_SIMPLE_TWO, TFT_ORANGE);
});*/
// Bluetooth Attack menu
bluetoothAttackMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent

View File

@@ -623,6 +623,12 @@ extern "C" {
// (struct FlockBattery { String mac; String name; String serial; int rssi; uint32_t last_seen; }; etc.)
}
}
else if (wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE) {
wifi_scan_obj.bt_frames++;
}
else if (wifi_scan_obj.currentScanMode == BT_SCAN_SIMPLE_TWO) {
wifi_scan_obj.bt_frames++;
}
return;
}
@@ -1223,7 +1229,9 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
(scan_mode == BT_SCAN_AIRTAG_MON) ||
(scan_mode == BT_SCAN_FLIPPER) ||
(scan_mode == BT_SCAN_FLOCK) ||
(scan_mode == BT_SCAN_ANALYZER)) {
(scan_mode == BT_SCAN_ANALYZER) ||
(scan_mode == BT_SCAN_SIMPLE) ||
(scan_mode == BT_SCAN_SIMPLE_TWO)) {
#ifdef HAS_BT
RunBluetoothScan(scan_mode, color);
#endif
@@ -1409,6 +1417,7 @@ bool WiFiScan::shutdownBLE() {
NimBLEDevice::deinit();
this->_analyzer_value = 0;
this->bt_frames = 0;
this->ble_initialized = false;
}
@@ -1553,7 +1562,9 @@ void WiFiScan::StopScan(uint8_t scan_mode)
(currentScanMode == BT_SCAN_WAR_DRIVE) ||
(currentScanMode == BT_SCAN_WAR_DRIVE_CONT) ||
(currentScanMode == BT_SCAN_SKIMMERS) ||
(currentScanMode == BT_SCAN_ANALYZER))
(currentScanMode == BT_SCAN_ANALYZER) ||
(currentScanMode == BT_SCAN_SIMPLE) ||
(currentScanMode == BT_SCAN_SIMPLE_TWO))
{
#ifdef HAS_BT
#ifdef HAS_SCREEN
@@ -4006,13 +4017,18 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
if (scan_mode == BT_SCAN_FLOCK)
NimBLEDevice::setScanDuplicateCacheSize(0);
if ((scan_mode == BT_SCAN_SIMPLE) || (scan_mode == BT_SCAN_SIMPLE_TWO))
NimBLEDevice::setScanDuplicateCacheSize(0);
NimBLEDevice::init("");
pBLEScan = NimBLEDevice::getScan(); //create new scan
if ((scan_mode == BT_SCAN_ALL) ||
(scan_mode == BT_SCAN_AIRTAG) ||
(scan_mode == BT_SCAN_AIRTAG_MON) ||
(scan_mode == BT_SCAN_FLIPPER) ||
(scan_mode == BT_SCAN_FLOCK))
(scan_mode == BT_SCAN_FLOCK) ||
(scan_mode == BT_SCAN_SIMPLE) ||
(scan_mode == BT_SCAN_SIMPLE_TWO))
{
#ifdef HAS_SCREEN
display_obj.TOP_FIXED_AREA_2 = 48;
@@ -4032,6 +4048,10 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
display_obj.tft.drawCentreString("Flipper Sniff", TFT_WIDTH / 2, 16, 2);
else if (scan_mode == BT_SCAN_FLOCK)
display_obj.tft.drawCentreString("Flock Sniff", TFT_WIDTH / 2, 16, 2);
else if (scan_mode == BT_SCAN_SIMPLE)
display_obj.tft.drawCentreString("Simple Sniff", TFT_WIDTH / 2, 16, 2);
else if (scan_mode == BT_SCAN_SIMPLE_TWO)
display_obj.tft.drawCentreString("Simple Sniff 2", TFT_WIDTH / 2, 16, 2);
#ifdef HAS_ILI9341
display_obj.touchToExit();
#endif
@@ -4052,6 +4072,12 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
else if (scan_mode == BT_SCAN_FLOCK) {
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), true);
}
else if (scan_mode == BT_SCAN_SIMPLE) {
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), true);
}
else if (scan_mode == BT_SCAN_SIMPLE_TWO) {
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), false);
}
}
else if ((scan_mode == BT_SCAN_WAR_DRIVE) || (scan_mode == BT_SCAN_WAR_DRIVE_CONT)) {
#ifdef HAS_GPS
@@ -4130,14 +4156,11 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
#endif
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), false);
}
if (scan_mode != BT_SCAN_FLOCK)
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
else
pBLEScan->setActiveScan(false);
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
pBLEScan->setMaxResults(0);
if ((scan_mode == BT_SCAN_WAR_DRIVE_CONT) || (scan_mode == BT_SCAN_ANALYZER) || (scan_mode == BT_SCAN_FLOCK))
if ((scan_mode == BT_SCAN_WAR_DRIVE_CONT) || (scan_mode == BT_SCAN_ANALYZER) || (scan_mode == BT_SCAN_FLOCK) || (scan_mode == BT_SCAN_SIMPLE) || (scan_mode == BT_SCAN_SIMPLE_TWO))
pBLEScan->setDuplicateFilter(false);
pBLEScan->start(0, scanCompleteCB, false);
Serial.println("Started BLE Scan");
@@ -9118,6 +9141,17 @@ void WiFiScan::main(uint32_t currentTime)
eapolMonitorMain(currentTime);
#endif
}
else if ((currentScanMode == BT_SCAN_SIMPLE) || (currentScanMode == BT_SCAN_SIMPLE_TWO)) {
if (currentTime - initTime >= 1000) {
initTime = millis();
String displayString = "BT Frames: ";
displayString.concat(this->bt_frames);
#ifdef HAS_SCREEN
display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
display_obj.showCenterText(displayString, TFT_HEIGHT / 2);
#endif
}
}
else if (currentScanMode == WIFI_ATTACK_AUTH) {
for (int i = 0; i < 55; i++)
this->sendProbeAttack(currentTime);

View File

@@ -139,6 +139,8 @@
#define BT_SCAN_AIRTAG_MON 70
#define WIFI_SCAN_CHAN_ACT 71
#define BT_SCAN_FLOCK 72
#define BT_SCAN_SIMPLE 73
#define BT_SCAN_SIMPLE_TWO 74
#define WIFI_ATTACK_FUNNY_BEACON 99
@@ -617,6 +619,8 @@ class WiFiScan
int8_t min_rssi = 0;
int8_t max_rssi = -128;
int bt_frames = 0;
bool force_pmkid = false;
bool force_probe = false;
bool save_pcap = false;