BLE Spam add led indicator blink (v3.2)

This commit is contained in:
Willy-JL
2023-10-21 08:27:01 +01:00
parent c73c487cfe
commit f514efd951
4 changed files with 48 additions and 10 deletions

View File

@@ -8,7 +8,7 @@ App(
fap_category="Bluetooth", fap_category="Bluetooth",
fap_author="@Willy-JL @ECTO-1A @Spooks4576", fap_author="@Willy-JL @ECTO-1A @Spooks4576",
fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam", 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_description="Flood BLE advertisements to cause spammy and annoying popups/notifications",
fap_icon_assets="icons", fap_icon_assets="icons",
fap_icon_assets_symbol="ble_spam", fap_icon_assets_symbol="ble_spam",

View File

@@ -149,6 +149,27 @@ typedef struct {
int8_t index; int8_t index;
} State; } 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) { static int32_t adv_thread(void* _ctx) {
State* state = _ctx; State* state = _ctx;
uint8_t size; uint8_t size;
@@ -158,6 +179,7 @@ static int32_t adv_thread(void* _ctx) {
Payload* payload = &attacks[state->index].payload; Payload* payload = &attacks[state->index].payload;
const Protocol* protocol = attacks[state->index].protocol; const Protocol* protocol = attacks[state->index].protocol;
if(!payload->random_mac) furi_hal_random_fill_buf(mac, sizeof(mac)); if(!payload->random_mac) furi_hal_random_fill_buf(mac, sizeof(mac));
if(state->ctx.led_indicator) start_blink(state);
while(state->advertising) { while(state->advertising) {
if(protocol) { if(protocol) {
@@ -175,6 +197,7 @@ static int32_t adv_thread(void* _ctx) {
furi_hal_bt_custom_adv_stop(); furi_hal_bt_custom_adv_stop();
} }
if(state->ctx.led_indicator) stop_blink(state);
return 0; return 0;
} }
@@ -315,7 +338,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) {
"App+Spam: \e#WillyJL\e# XFW\n" "App+Spam: \e#WillyJL\e# XFW\n"
"Apple+Crash: \e#ECTO-1A\e#\n" "Apple+Crash: \e#ECTO-1A\e#\n"
"Android+Win: \e#Spooks4576\e#\n" "Android+Win: \e#Spooks4576\e#\n"
" Version \e#3.1\e#", " Version \e#3.2\e#",
false); false);
break; break;
default: { default: {
@@ -385,11 +408,13 @@ static bool input_callback(InputEvent* input, void* _ctx) {
case InputKeyUp: case InputKeyUp:
if(is_attack && state->delay < COUNT_OF(delays) - 1) { if(is_attack && state->delay < COUNT_OF(delays) - 1) {
state->delay++; state->delay++;
if(advertising) start_blink(state);
} }
break; break;
case InputKeyDown: case InputKeyDown:
if(is_attack && state->delay > 0) { if(is_attack && state->delay > 0) {
state->delay--; state->delay--;
if(advertising) start_blink(state);
} }
break; break;
case InputKeyLeft: case InputKeyLeft:
@@ -429,7 +454,9 @@ int32_t ble_spam(void* p) {
furi_thread_set_callback(state->thread, adv_thread); furi_thread_set_callback(state->thread, adv_thread);
furi_thread_set_context(state->thread, state); furi_thread_set_context(state->thread, state);
furi_thread_set_stack_size(state->thread, 4096); 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); Gui* gui = furi_record_open(RECORD_GUI);
state->ctx.view_dispatcher = view_dispatcher_alloc(); state->ctx.view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(state->ctx.view_dispatcher); 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); scene_manager_free(state->ctx.scene_manager);
view_dispatcher_free(state->ctx.view_dispatcher); view_dispatcher_free(state->ctx.view_dispatcher);
furi_record_close(RECORD_GUI); furi_record_close(RECORD_GUI);
furi_record_close(RECORD_NOTIFICATION);
furi_thread_free(state->thread); furi_thread_free(state->thread);
free(state); free(state);

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <notification/notification_messages.h>
#include <gui/view_dispatcher.h> #include <gui/view_dispatcher.h>
#include <gui/modules/byte_input.h> #include <gui/modules/byte_input.h>
#include <gui/modules/submenu.h> #include <gui/modules/submenu.h>
@@ -19,6 +20,7 @@ enum {
enum { enum {
ConfigRandomMac, ConfigRandomMac,
ConfigExtraStart = ConfigRandomMac, ConfigExtraStart = ConfigRandomMac,
ConfigLedIndicator,
}; };
typedef struct Attack Attack; typedef struct Attack Attack;
@@ -27,7 +29,9 @@ typedef struct {
Attack* attack; Attack* attack;
uint8_t byte_store[3]; uint8_t byte_store[3];
VariableItemListEnterCallback fallback_config_enter; VariableItemListEnterCallback fallback_config_enter;
bool led_indicator;
NotificationApp* notification;
ViewDispatcher* view_dispatcher; ViewDispatcher* view_dispatcher;
SceneManager* scene_manager; SceneManager* scene_manager;

View File

@@ -2,10 +2,15 @@
#include "protocols/_protocols.h" #include "protocols/_protocols.h"
static void random_mac_changed(VariableItem* item) { static void _config_bool(VariableItem* item) {
Ctx* ctx = variable_item_get_context(item); bool* value = variable_item_get_context(item);
ctx->attack->payload.random_mac = variable_item_get_current_value_index(item); *value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF"); 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) { static void config_callback(void* _ctx, uint32_t index) {
@@ -19,21 +24,20 @@ static void config_callback(void* _ctx, uint32_t index) {
switch(index) { switch(index) {
case ConfigRandomMac: case ConfigRandomMac:
break; break;
case ConfigLedIndicator:
break;
default: default:
break; break;
} }
} }
void scene_config_on_enter(void* _ctx) { void scene_config_on_enter(void* _ctx) {
Ctx* ctx = _ctx; Ctx* ctx = _ctx;
VariableItem* item;
VariableItemList* list = ctx->variable_item_list; VariableItemList* list = ctx->variable_item_list;
variable_item_list_reset(list); variable_item_list_reset(list);
variable_item_list_set_header(list, ctx->attack->title); variable_item_list_set_header(list, ctx->attack->title);
item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx); config_bool(list, "Random MAC", &ctx->attack->payload.random_mac);
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); variable_item_list_set_enter_callback(list, config_callback, ctx);
if(!ctx->attack->protocol) { if(!ctx->attack->protocol) {
@@ -43,6 +47,8 @@ void scene_config_on_enter(void* _ctx) {
ctx->attack->protocol->extra_config(ctx); ctx->attack->protocol->extra_config(ctx);
} }
config_bool(list, "LED Indicator", &ctx->led_indicator);
variable_item_list_set_selected_item( variable_item_list_set_selected_item(
list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig)); list, scene_manager_get_scene_state(ctx->scene_manager, SceneConfig));