Skip to content

Commit e38c736

Browse files
committed
upd blespam
1 parent aca6de0 commit e38c736

File tree

2 files changed

+56
-44
lines changed

2 files changed

+56
-44
lines changed

base_pack/ble_spam/application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ App(
88
fap_category="Bluetooth",
99
fap_author="@Willy-JL @ECTO-1A @Spooks4576",
1010
fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam",
11-
fap_version="5.0",
11+
fap_version="5.1",
1212
fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications",
1313
fap_icon_assets="icons",
1414
fap_icon_assets_symbol="ble_spam",

base_pack/ble_spam/ble_spam.c

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ typedef struct {
148148
uint8_t lock_count;
149149
FuriTimer* lock_timer;
150150

151-
// bool resume;
152151
bool advertising;
153152
uint8_t delay;
154153
GapExtraBeaconConfig config;
@@ -186,38 +185,52 @@ static void stop_blink(State* state) {
186185
notification_message_block(state->ctx.notification, &sequence_blink_stop);
187186
}
188187

189-
static int32_t adv_thread(void* _ctx) {
190-
State* state = _ctx;
188+
static void randomize_mac(State* state) {
189+
furi_hal_random_fill_buf(state->config.address, sizeof(state->config.address));
190+
}
191+
192+
static void start_extra_beacon(State* state) {
191193
uint8_t size;
192-
uint16_t delay;
193194
uint8_t* packet;
195+
uint16_t delay = delays[state->delay];
194196
GapExtraBeaconConfig* config = &state->config;
195197
Payload* payload = &attacks[state->index].payload;
196198
const Protocol* protocol = attacks[state->index].protocol;
197-
if(!payload->random_mac) furi_hal_random_fill_buf(config->address, sizeof(config->address));
199+
200+
config->min_adv_interval_ms = delay;
201+
config->max_adv_interval_ms = delay * 1.5;
202+
if(payload->random_mac) randomize_mac(state);
203+
furi_check(furi_hal_bt_extra_beacon_set_config(config));
204+
205+
if(protocol) {
206+
protocol->make_packet(&size, &packet, payload);
207+
} else {
208+
protocols[rand() % protocols_count]->make_packet(&size, &packet, NULL);
209+
}
210+
furi_check(furi_hal_bt_extra_beacon_set_data(packet, size));
211+
free(packet);
212+
213+
furi_check(furi_hal_bt_extra_beacon_start());
214+
}
215+
216+
static int32_t adv_thread(void* _ctx) {
217+
State* state = _ctx;
218+
Payload* payload = &attacks[state->index].payload;
219+
const Protocol* protocol = attacks[state->index].protocol;
220+
if(!payload->random_mac) randomize_mac(state);
198221
if(state->ctx.led_indicator) start_blink(state);
199222

200223
while(state->advertising) {
201-
if(protocol) {
202-
if(payload->mode == PayloadModeBruteforce && payload->bruteforce.counter++ >= 10) {
203-
payload->bruteforce.counter = 0;
204-
payload->bruteforce.value =
205-
(payload->bruteforce.value + 1) % (1 << (payload->bruteforce.size * 8));
206-
}
207-
protocol->make_packet(&size, &packet, payload);
208-
} else {
209-
protocols[rand() % protocols_count]->make_packet(&size, &packet, NULL);
224+
if(protocol && payload->mode == PayloadModeBruteforce &&
225+
payload->bruteforce.counter++ >= 10) {
226+
payload->bruteforce.counter = 0;
227+
payload->bruteforce.value =
228+
(payload->bruteforce.value + 1) % (1 << (payload->bruteforce.size * 8));
210229
}
211230

212-
delay = delays[state->delay];
213-
config->min_adv_interval_ms = config->max_adv_interval_ms = delay;
214-
if(payload->random_mac) furi_hal_random_fill_buf(config->address, sizeof(config->address));
215-
furi_check(furi_hal_bt_extra_beacon_set_config(config));
216-
furi_check(furi_hal_bt_extra_beacon_set_data(packet, size));
217-
free(packet);
231+
start_extra_beacon(state);
218232

219-
furi_check(furi_hal_bt_extra_beacon_start());
220-
furi_thread_flags_wait(true, FuriFlagWaitAny, delay);
233+
furi_thread_flags_wait(true, FuriFlagWaitAny, delays[state->delay]);
221234
furi_hal_bt_extra_beacon_stop();
222235
}
223236

@@ -230,11 +243,8 @@ static void toggle_adv(State* state) {
230243
state->advertising = false;
231244
furi_thread_flags_set(furi_thread_get_id(state->thread), true);
232245
furi_thread_join(state->thread);
233-
// if(state->resume) furi_hal_bt_start_advertising();
234246
} else {
235247
state->advertising = true;
236-
// state->resume = furi_hal_bt_is_active();
237-
// furi_hal_bt_stop_advertising();
238248
furi_thread_start(state->thread);
239249
}
240250
}
@@ -380,7 +390,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) {
380390
"App+Spam: \e#WillyJL\e# XFW\n"
381391
"Apple+Crash: \e#ECTO-1A\e#\n"
382392
"Android+Win: \e#Spooks4576\e#\n"
383-
" Version \e#5.0\e#",
393+
" Version \e#5.1\e#",
384394
false);
385395
break;
386396
default: {
@@ -539,33 +549,18 @@ static bool input_callback(InputEvent* input, void* _ctx) {
539549
}
540550
} else {
541551
if(!advertising) {
542-
// bool resume = furi_hal_bt_is_active();
543-
// furi_hal_bt_stop_advertising();
544-
GapExtraBeaconConfig* config = &state->config;
545552
Payload* payload = &attacks[state->index].payload;
546-
const Protocol* protocol = attacks[state->index].protocol;
547-
548-
uint8_t size;
549-
uint8_t* packet;
550-
protocol->make_packet(&size, &packet, payload);
553+
if(input->type == InputTypeLong && !payload->random_mac) randomize_mac(state);
551554

552-
uint16_t delay = delays[state->delay];
553-
config->min_adv_interval_ms = config->max_adv_interval_ms = delay;
554-
if(payload->random_mac || input->type == InputTypeLong)
555-
furi_hal_random_fill_buf(config->address, sizeof(config->address));
556-
furi_check(furi_hal_bt_extra_beacon_set_config(config));
557-
furi_check(furi_hal_bt_extra_beacon_set_data(packet, size));
558-
free(packet);
555+
start_extra_beacon(state);
559556

560-
furi_check(furi_hal_bt_extra_beacon_start());
561557
if(state->ctx.led_indicator)
562558
notification_message(state->ctx.notification, &solid_message);
563559
furi_delay_ms(10);
564560
furi_hal_bt_extra_beacon_stop();
565561

566562
if(state->ctx.led_indicator)
567563
notification_message_block(state->ctx.notification, &sequence_reset_rgb);
568-
// if(resume) furi_hal_bt_start_advertising();
569564
}
570565
}
571566
break;
@@ -625,6 +620,15 @@ static bool back_event_callback(void* _ctx) {
625620

626621
int32_t ble_spam(void* p) {
627622
UNUSED(p);
623+
GapExtraBeaconConfig prev_cfg;
624+
const GapExtraBeaconConfig* prev_cfg_ptr = furi_hal_bt_extra_beacon_get_config();
625+
if(prev_cfg_ptr) {
626+
memcpy(&prev_cfg, prev_cfg_ptr, sizeof(prev_cfg));
627+
}
628+
uint8_t prev_data[EXTRA_BEACON_MAX_DATA_SIZE];
629+
uint8_t prev_data_len = furi_hal_bt_extra_beacon_get_data(prev_data);
630+
bool prev_active = furi_hal_bt_extra_beacon_is_active();
631+
628632
State* state = malloc(sizeof(State));
629633
state->config.adv_channel_map = GapAdvChannelMapAll;
630634
state->config.adv_power_level = GapAdvPowerLevel_6dBm;
@@ -699,5 +703,13 @@ int32_t ble_spam(void* p) {
699703
furi_timer_free(state->lock_timer);
700704
furi_thread_free(state->thread);
701705
free(state);
706+
707+
if(prev_cfg_ptr) {
708+
furi_check(furi_hal_bt_extra_beacon_set_config(&prev_cfg));
709+
}
710+
furi_check(furi_hal_bt_extra_beacon_set_data(prev_data, prev_data_len));
711+
if(prev_active) {
712+
furi_check(furi_hal_bt_extra_beacon_start());
713+
}
702714
return 0;
703715
}

0 commit comments

Comments
 (0)