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); +}