| 4861 | } |
| 4862 | |
| 4863 | void executeAudioTest(int testIndex, NimBLEAddress target) { |
| 4864 | AutoCleanup cleanup([]() { BLEStateManager::deinitBLE(true); }); |
| 4865 | |
| 4866 | String connectionMethod = ""; |
| 4867 | NimBLEClient *pClient = attemptConnectionWithStrategies(target, connectionMethod); |
| 4868 | if (!pClient) { |
| 4869 | showAttackResult(false, "Failed to connect"); |
| 4870 | return; |
| 4871 | } |
| 4872 | |
| 4873 | BLEStateManager::registerClient(pClient); |
| 4874 | |
| 4875 | AudioAttackService audioAttack; |
| 4876 | switch (testIndex) { |
| 4877 | case 0: |
| 4878 | showAttackProgress("Testing AVRCP service...", TFT_WHITE); |
| 4879 | if (pClient->discoverAttributes()) { |
| 4880 | NimBLERemoteService *pService = pClient->getService(NimBLEUUID((uint16_t)0x110E)); |
| 4881 | if (pService) { |
| 4882 | audioAttack.attackAVRCP(pService); |
| 4883 | showAttackResult(true, "AVRCP test completed"); |
| 4884 | } else showAttackResult(false, "No AVRCP service found"); |
| 4885 | } |
| 4886 | break; |
| 4887 | case 1: |
| 4888 | showAttackProgress("Testing Media Control...", TFT_WHITE); |
| 4889 | if (pClient->discoverAttributes()) { |
| 4890 | NimBLERemoteService *pService = pClient->getService(NimBLEUUID((uint16_t)0x1843)); |
| 4891 | if (pService) { |
| 4892 | audioAttack.attackAudioMedia(pService); |
| 4893 | showAttackResult(true, "Media control test completed"); |
| 4894 | } else showAttackResult(false, "No Media service found"); |
| 4895 | } |
| 4896 | break; |
| 4897 | case 2: |
| 4898 | showAttackProgress("Testing Telephony...", TFT_WHITE); |
| 4899 | if (pClient->discoverAttributes()) { |
| 4900 | NimBLERemoteService *pService = pClient->getService(NimBLEUUID((uint16_t)0x1124)); |
| 4901 | if (pService) { |
| 4902 | audioAttack.attackTelephony(pService); |
| 4903 | showAttackResult(true, "Telephony test completed"); |
| 4904 | } else showAttackResult(false, "No Telephony service found"); |
| 4905 | } |
| 4906 | break; |
| 4907 | case 3: |
| 4908 | showAttackProgress("Testing all audio services...", TFT_WHITE); |
| 4909 | audioAttack.executeAudioAttack(target); |
| 4910 | showAttackResult(true, "Complete audio test done"); |
| 4911 | break; |
| 4912 | } |
| 4913 | pClient->disconnect(); |
| 4914 | BLEStateManager::unregisterClient(pClient); |
| 4915 | NimBLEDevice::deleteClient(pClient); |
| 4916 | cleanup.disable(); |
| 4917 | } |
| 4918 | |
| 4919 | void runHFPHIDPivotAttack(NimBLEAddress target) { |
| 4920 | AutoCleanup cleanup([]() { BLEStateManager::deinitBLE(true); }); |
no test coverage detected