Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add method to clear bonding

Geoab753e672375
diff --git a/src/Services/BluetoothService.cpp b/src/Services/BluetoothService.cpp
index 592eab02..0a69b9a9 100644
--- a/src/Services/BluetoothService.cpp
+++ b/src/Services/BluetoothService.cpp
@@ -251,6 +251,22 @@ bool BluetoothService::spoofMacAddress(const std::string& macStr) {
return err == ESP_OK;
}
+void BluetoothService::clearBondedDevices() {
+ int dev_num = esp_ble_get_bond_device_num();
+ if (dev_num == 0) return;
+
+ esp_ble_bond_dev_t* bonded = (esp_ble_bond_dev_t*)malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
+ if (!bonded) return;
+
+ if (esp_ble_get_bond_device_list(&dev_num, bonded) == ESP_OK) {
+ for (int i = 0; i < dev_num; ++i) {
+ esp_ble_remove_bond_device(bonded[i].bd_addr);
+ }
+ }
+
+ free(bonded);
+}
+
const uint8_t BluetoothService::HID_REPORT_MAP[] = {
// Mouse report
0x05, 0x01, // Usage Page (Generic Desktop)
diff --git a/src/Services/BluetoothService.h b/src/Services/BluetoothService.h
index 18af8647..a04f3d71 100644
--- a/src/Services/BluetoothService.h
+++ b/src/Services/BluetoothService.h
@@ -60,6 +60,7 @@ public:
bool spoofMacAddress(const std::string& macStr);
std::string getMacAddress();
BluetoothMode getMode();
+ void clearBondedDevices();
std::vector<ScannedDevice> scanDevices(int seconds = 10);
std::vector<std::string> connectTo(const std::string& addr);