Add BLE analyzer

This commit is contained in:
Just Call Me Koko
2025-03-24 11:32:30 -04:00
parent 5207b18aff
commit edbfd62e4c
4 changed files with 69 additions and 15 deletions

View File

@@ -650,7 +650,8 @@ void MenuFunctions::main(uint32_t currentTime)
this->updateStatusBar(); this->updateStatusBar();
// Do channel analyzer stuff // Do channel analyzer stuff
if (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) { if ((wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER)){
this->setGraphScale(this->graphScaleCheck(wifi_scan_obj._analyzer_values)); this->setGraphScale(this->graphScaleCheck(wifi_scan_obj._analyzer_values));
this->drawGraph(wifi_scan_obj._analyzer_values); this->drawGraph(wifi_scan_obj._analyzer_values);
@@ -818,7 +819,8 @@ void MenuFunctions::main(uint32_t currentTime)
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_EAPOL) || (wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_LIST_EAPOL) || (wifi_scan_obj.currentScanMode == WIFI_SCAN_ACTIVE_LIST_EAPOL) ||
(wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) || (wifi_scan_obj.currentScanMode == WIFI_PACKET_MONITOR) ||
(wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER)) (wifi_scan_obj.currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER))
{ {
wifi_scan_obj.StartScan(WIFI_SCAN_OFF); wifi_scan_obj.StartScan(WIFI_SCAN_OFF);
@@ -1587,7 +1589,7 @@ void MenuFunctions::RunSetup()
this->addNodes(&wifiSnifferMenu, "Channel Analyzer", TFTCYAN, NULL, PACKET_MONITOR, [this]() { this->addNodes(&wifiSnifferMenu, "Channel Analyzer", TFTCYAN, NULL, PACKET_MONITOR, [this]() {
display_obj.clearScreen(); display_obj.clearScreen();
this->drawStatusBar(); this->drawStatusBar();
this->renderGraphUI(); this->renderGraphUI(WIFI_SCAN_CHAN_ANALYZER);
wifi_scan_obj.StartScan(WIFI_SCAN_CHAN_ANALYZER, TFT_CYAN); wifi_scan_obj.StartScan(WIFI_SCAN_CHAN_ANALYZER, TFT_CYAN);
}); });
#endif #endif
@@ -2023,6 +2025,12 @@ void MenuFunctions::RunSetup()
this->drawStatusBar(); this->drawStatusBar();
wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA); wifi_scan_obj.StartScan(BT_SCAN_SKIMMERS, TFT_MAGENTA);
}); });
this->addNodes(&bluetoothSnifferMenu, "Bluetooth Analyzer", TFTCYAN, NULL, PACKET_MONITOR, [this]() {
display_obj.clearScreen();
this->drawStatusBar();
this->renderGraphUI(BT_SCAN_ANALYZER);
wifi_scan_obj.StartScan(BT_SCAN_ANALYZER, TFT_CYAN);
});
// Bluetooth Attack menu // Bluetooth Attack menu
bluetoothAttackMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent bluetoothAttackMenu.parentMenu = &bluetoothMenu; // Second Menu is third menu parent
@@ -2691,9 +2699,12 @@ void MenuFunctions::drawGraph(int16_t *values) {
this->drawMaxLine(total / TFT_WIDTH, TFT_ORANGE); // Draw average this->drawMaxLine(total / TFT_WIDTH, TFT_ORANGE); // Draw average
} }
void MenuFunctions::renderGraphUI() { void MenuFunctions::renderGraphUI(uint8_t scan_mode) {
display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK); display_obj.tft.setTextColor(TFT_WHITE, TFT_BLACK);
display_obj.tft.drawCentreString("Frames/" + (String)BANNER_TIME + "ms", TFT_WIDTH / 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), 1); if (scan_mode == WIFI_SCAN_CHAN_ANALYZER)
display_obj.tft.drawCentreString("Frames/" + (String)BANNER_TIME + "ms", TFT_WIDTH / 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), 1);
else if (scan_mode == BT_SCAN_ANALYZER)
display_obj.tft.drawCentreString("BLE Beacons/" + (String)BANNER_TIME + "ms", TFT_WIDTH / 2, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 2), 1);
display_obj.tft.drawLine(0, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WIDTH, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WHITE); display_obj.tft.drawLine(0, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WIDTH, TFT_HEIGHT - GRAPH_VERT_LIM - 1, TFT_WHITE);
display_obj.tft.setCursor(0, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 8)); display_obj.tft.setCursor(0, TFT_HEIGHT - GRAPH_VERT_LIM - (CHAR_WIDTH * 8));
display_obj.tft.setTextSize(1); display_obj.tft.setTextSize(1);
@@ -2702,7 +2713,8 @@ void MenuFunctions::renderGraphUI() {
display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK); display_obj.tft.setTextColor(TFT_ORANGE, TFT_BLACK);
display_obj.tft.println("Average"); display_obj.tft.println("Average");
display_obj.tft.setTextColor(TFT_RED, TFT_BLACK); display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
display_obj.tft.println("Channel Marker"); if (scan_mode != BT_SCAN_ANALYZER)
display_obj.tft.println("Channel Marker");
} }
uint16_t MenuFunctions::getColor(uint16_t color) { uint16_t MenuFunctions::getColor(uint16_t color) {

View File

@@ -197,7 +197,7 @@ class MenuFunctions
float calculateGraphScale(int16_t value); float calculateGraphScale(int16_t value);
float graphScaleCheck(const int16_t array[TFT_WIDTH]); float graphScaleCheck(const int16_t array[TFT_WIDTH]);
void drawGraph(int16_t *values); void drawGraph(int16_t *values);
void renderGraphUI(); void renderGraphUI(uint8_t scan_mode = 0);
//void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = ""); //void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
void addNodes(Menu* menu, String name, uint8_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = ""); void addNodes(Menu* menu, String name, uint8_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
void battery(bool initial = false); void battery(bool initial = false);

View File

@@ -440,6 +440,9 @@ extern "C" {
} }
#endif #endif
} }
else if (wifi_scan_obj.currentScanMode == BT_SCAN_ANALYZER) {
wifi_scan_obj._analyzer_value++;
}
} }
}; };
@@ -781,7 +784,7 @@ void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
this->startWiFiAttacks(scan_mode, color, text_table4[47]); this->startWiFiAttacks(scan_mode, color, text_table4[47]);
else if (scan_mode == WIFI_ATTACK_AP_SPAM) else if (scan_mode == WIFI_ATTACK_AP_SPAM)
this->startWiFiAttacks(scan_mode, color, " AP Beacon Spam "); this->startWiFiAttacks(scan_mode, color, " AP Beacon Spam ");
else if ((scan_mode == BT_SCAN_ALL) || (scan_mode == BT_SCAN_AIRTAG) || (scan_mode == BT_SCAN_FLIPPER)){ else if ((scan_mode == BT_SCAN_ALL) || (scan_mode == BT_SCAN_AIRTAG) || (scan_mode == BT_SCAN_FLIPPER) || (scan_mode == BT_SCAN_ANALYZER)){
#ifdef HAS_BT #ifdef HAS_BT
RunBluetoothScan(scan_mode, color); RunBluetoothScan(scan_mode, color);
#endif #endif
@@ -905,6 +908,8 @@ bool WiFiScan::shutdownWiFi() {
#else #else
led_obj.setMode(MODE_OFF); led_obj.setMode(MODE_OFF);
#endif #endif
this->_analyzer_value = 0;
this->wifi_initialized = false; this->wifi_initialized = false;
return true; return true;
@@ -923,6 +928,8 @@ bool WiFiScan::shutdownBLE() {
pBLEScan->clearResults(); pBLEScan->clearResults();
NimBLEDevice::deinit(); NimBLEDevice::deinit();
this->_analyzer_value = 0;
this->ble_initialized = false; this->ble_initialized = false;
} }
@@ -978,9 +985,11 @@ void WiFiScan::StopScan(uint8_t scan_mode)
{ {
this->shutdownWiFi(); this->shutdownWiFi();
for (int i = 0; i < TFT_WIDTH; i++) { #ifdef HAS_SCREEN
this->_analyzer_values[i] = 0; for (int i = 0; i < TFT_WIDTH; i++) {
} this->_analyzer_values[i] = 0;
}
#endif
} }
@@ -996,9 +1005,16 @@ void WiFiScan::StopScan(uint8_t scan_mode)
(currentScanMode == BT_SPOOF_AIRTAG) || (currentScanMode == BT_SPOOF_AIRTAG) ||
(currentScanMode == BT_SCAN_WAR_DRIVE) || (currentScanMode == BT_SCAN_WAR_DRIVE) ||
(currentScanMode == BT_SCAN_WAR_DRIVE_CONT) || (currentScanMode == BT_SCAN_WAR_DRIVE_CONT) ||
(currentScanMode == BT_SCAN_SKIMMERS)) (currentScanMode == BT_SCAN_SKIMMERS) ||
(currentScanMode == BT_SCAN_ANALYZER))
{ {
#ifdef HAS_BT #ifdef HAS_BT
#ifdef HAS_SCREEN
for (int i = 0; i < TFT_WIDTH; i++) {
this->_analyzer_values[i] = 0;
}
#endif
this->shutdownBLE(); this->shutdownBLE();
#endif #endif
} }
@@ -2800,6 +2816,9 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
NimBLEDevice::setScanFilterMode(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE); NimBLEDevice::setScanFilterMode(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE);
NimBLEDevice::setScanDuplicateCacheSize(200); NimBLEDevice::setScanDuplicateCacheSize(200);
} }
else if ((scan_mode == BT_SCAN_WAR_DRIVE_CONT) || (scan_mode == BT_SCAN_ANALYZER)) {
NimBLEDevice::setScanDuplicateCacheSize(0);
}
NimBLEDevice::init(""); NimBLEDevice::init("");
pBLEScan = NimBLEDevice::getScan(); //create new scan pBLEScan = NimBLEDevice::getScan(); //create new scan
if ((scan_mode == BT_SCAN_ALL) || (scan_mode == BT_SCAN_AIRTAG) || (scan_mode == BT_SCAN_FLIPPER)) if ((scan_mode == BT_SCAN_ALL) || (scan_mode == BT_SCAN_AIRTAG) || (scan_mode == BT_SCAN_FLIPPER))
@@ -2894,10 +2913,31 @@ void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
#endif #endif
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanSkimmersCallback(), false); pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanSkimmersCallback(), false);
} }
else if (scan_mode == BT_SCAN_ANALYZER) {
#ifdef HAS_SCREEN
display_obj.TOP_FIXED_AREA_2 = 48;
display_obj.tteBar = true;
display_obj.initScrollValues(true);
display_obj.tft.setTextWrap(false);
display_obj.tft.setTextColor(TFT_BLACK, color);
#ifdef HAS_FULL_SCREEN
display_obj.tft.fillRect(0,16,240,16, color);
display_obj.tft.drawCentreString("Bluetooth Analyzer", 120, 16, 2);
#ifdef HAS_ILI9341
display_obj.touchToExit();
#endif
#endif
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
#endif
pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), false);
}
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100); pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value pBLEScan->setWindow(99); // less or equal setInterval value
pBLEScan->setMaxResults(0); pBLEScan->setMaxResults(0);
if ((scan_mode == BT_SCAN_WAR_DRIVE_CONT) || (scan_mode == BT_SCAN_ANALYZER))
pBLEScan->setDuplicateFilter(false);
pBLEScan->start(0, scanCompleteCB, false); pBLEScan->start(0, scanCompleteCB, false);
Serial.println("Started BLE Scan"); Serial.println("Started BLE Scan");
this->ble_initialized = true; this->ble_initialized = true;
@@ -5330,7 +5370,8 @@ void WiFiScan::main(uint32_t currentTime)
channelHop(); channelHop();
} }
} }
else if ((currentScanMode == WIFI_SCAN_CHAN_ANALYZER)) { else if ((currentScanMode == WIFI_SCAN_CHAN_ANALYZER) ||
(currentScanMode == BT_SCAN_ANALYZER)) {
this->channelAnalyzerLoop(currentTime); this->channelAnalyzerLoop(currentTime);
} }
else if ((currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) || else if ((currentScanMode == BT_ATTACK_SWIFTPAIR_SPAM) ||

View File

@@ -99,6 +99,7 @@
#define BT_SPOOF_AIRTAG 44 #define BT_SPOOF_AIRTAG 44
#define BT_SCAN_FLIPPER 45 #define BT_SCAN_FLIPPER 45
#define WIFI_SCAN_CHAN_ANALYZER 46 #define WIFI_SCAN_CHAN_ANALYZER 46
#define BT_SCAN_ANALYZER 47
#define BASE_MULTIPLIER 4 #define BASE_MULTIPLIER 4
@@ -177,8 +178,6 @@ class WiFiScan
// Wardriver thanks to https://github.com/JosephHewitt // Wardriver thanks to https://github.com/JosephHewitt
struct mac_addr mac_history[mac_history_len]; struct mac_addr mac_history[mac_history_len];
int16_t _analyzer_value = 0;
// Settings // Settings
uint mac_history_cursor = 0; uint mac_history_cursor = 0;
uint8_t channel_hop_delay = 1; uint8_t channel_hop_delay = 1;
@@ -373,6 +372,8 @@ class WiFiScan
uint8_t old_channel = 0; uint8_t old_channel = 0;
int16_t _analyzer_value = 0;
bool orient_display = false; bool orient_display = false;
bool wifi_initialized = false; bool wifi_initialized = false;
bool ble_initialized = false; bool ble_initialized = false;