From f807ca717baaa36278b0ba53d3a414a627ac6827 Mon Sep 17 00:00:00 2001 From: Alexandros Andreou Date: Sun, 17 Mar 2024 19:36:30 +0200 Subject: [PATCH] added all and all-safe attack types to blespam --- .../external/blespam/ui_blespam.cpp | 57 +++++++++++++------ .../external/blespam/ui_blespam.hpp | 10 +++- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/firmware/application/external/blespam/ui_blespam.cpp b/firmware/application/external/blespam/ui_blespam.cpp index 7131ecd2b..7b7de6f8e 100644 --- a/firmware/application/external/blespam/ui_blespam.cpp +++ b/firmware/application/external/blespam/ui_blespam.cpp @@ -509,6 +509,44 @@ void BLESpamView::createFastPairPacket() { std::copy(res.begin(), res.end(), advertisementData); } +void BLESpamView::createAnyPacket(bool safe) { + ATK_TYPE type[] = { + ATK_ANDROID, + ATK_IOS, + ATK_WINDOWS, + ATK_SAMSUNG, + ATK_IOS_CRASH}; + ATK_TYPE attackType = type[rand() % (COUNT_OF(type) - (1 ? safe : 0))]; + createPacket(attackType); +} + +void BLESpamView::createPacket(ATK_TYPE attackType) { + switch (attackType) { + case ATK_IOS_CRASH: + createIosPacket(true); + break; + case ATK_IOS: + createIosPacket(false); + break; + case ATK_SAMSUNG: + createSamsungPacket(); + break; + case ATK_WINDOWS: + createWindowsPacket(); + break; + case ATK_ALL_SAFE: + createAnyPacket(true); + break; + case ATK_ALL: + createAnyPacket(false); + break; + default: + case ATK_ANDROID: + createFastPairPacket(); + break; + } +} + void BLESpamView::changePacket(bool forced = false) { counter++; // need to send it multiple times to be accepted if (counter >= 4 || forced) { @@ -517,24 +555,7 @@ void BLESpamView::changePacket(bool forced = false) { randomizeMac(); randomChn(); if (randomDev || forced) { - switch (attackType) { - case ATK_IOS_CRASH: - createIosPacket(true); - break; - case ATK_IOS: - createIosPacket(false); - break; - case ATK_SAMSUNG: - createSamsungPacket(); - break; - case ATK_WINDOWS: - createWindowsPacket(); - break; - default: - case ATK_ANDROID: - createFastPairPacket(); - break; - } + createPacket(attackType); } // rate limit console display #ifdef BLESPMUSECONSOLE diff --git a/firmware/application/external/blespam/ui_blespam.hpp b/firmware/application/external/blespam/ui_blespam.hpp index f1b4f93f8..73b6e86aa 100644 --- a/firmware/application/external/blespam/ui_blespam.hpp +++ b/firmware/application/external/blespam/ui_blespam.hpp @@ -49,7 +49,9 @@ enum ATK_TYPE { ATK_IOS, ATK_IOS_CRASH, ATK_WINDOWS, - ATK_SAMSUNG + ATK_SAMSUNG, + ATK_ALL_SAFE, + ATK_ALL }; enum PKT_TYPE { PKT_TYPE_INVALID_TYPE, @@ -124,7 +126,9 @@ class BLESpamView : public View { {"iOs", 1}, {"iOs crash", 2}, {"Windows", 3}, - {"Samsung", 4}}}; + {"Samsung", 4}, + {"All-Safe", 5}, + {"All", 6}}}; bool is_running{false}; @@ -148,6 +152,8 @@ class BLESpamView : public View { void createIosPacket(bool crash); void createSamsungPacket(); void createWindowsPacket(); + void createAnyPacket(bool safe); + void createPacket(ATK_TYPE attackType); void changePacket(bool forced); void on_tx_progress(const bool done);