1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 12:42:30 +04:00

big upgrade

This commit is contained in:
MX
2022-09-08 05:00:53 +03:00
parent 4588f38ae9
commit 18891ade89
12 changed files with 390 additions and 85 deletions

View File

@@ -6,5 +6,5 @@ App(
cdefines=["APP_FLIP_FRID"],
requires=["gui"],
stack_size=1 * 1024,
order=29,
order=13,
)

View File

@@ -1,4 +1,5 @@
#include "flipfrid_scene_run_attack.h"
#include <gui/elements.h>
uint8_t counter = 0;
#define TIME_BETWEEN_CARDS 5
@@ -182,7 +183,7 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
canvas_set_color(canvas, ColorBlack);
// Frame
canvas_draw_frame(canvas, 0, 0, 128, 64);
//canvas_draw_frame(canvas, 0, 0, 128, 64);
// Title
canvas_set_font(canvas, FontPrimary);
@@ -202,11 +203,12 @@ void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
canvas_draw_str_aligned(canvas, 64, 24, AlignCenter, AlignTop, uid);
canvas_set_font(canvas, FontSecondary);
char start_stop_msg[20];
//char start_stop_msg[20];
if(context->is_attacking) {
snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to stop ");
elements_button_center(canvas, "Stop");
//snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to stop ");
} else {
snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to start ");
elements_button_center(canvas, "Start");
}
canvas_draw_str_aligned(canvas, 64, 44, AlignCenter, AlignTop, start_stop_msg);
//canvas_draw_str_aligned(canvas, 64, 44, AlignCenter, AlignTop, start_stop_msg);
}

View File

@@ -104,7 +104,7 @@ void flipfrid_scene_select_field_on_draw(Canvas* canvas, FlipFridState* context)
canvas_set_color(canvas, ColorBlack);
// Frame
canvas_draw_frame(canvas, 0, 0, 128, 64);
//canvas_draw_frame(canvas, 0, 0, 128, 64);
// Title
canvas_set_font(canvas, FontPrimary);

View File

@@ -1,6 +1,6 @@
App(
appid="subbrute",
name="SubGhz Bruteforcer",
name="SubGHz Bruteforcer",
apptype=FlipperAppType.PLUGIN,
entry_point="subbrute_start",
cdefines=["APP_SUB_BRUTE"],

View File

@@ -163,7 +163,7 @@ void subbrute_scene_entrypoint_on_draw(Canvas* canvas, SubBruteState* context) {
// Title
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 64, 6, AlignCenter, AlignTop, "SubGhz Fuzzer");
canvas_draw_str_aligned(canvas, 64, 6, AlignCenter, AlignTop, "SubGHz Fuzzer");
if(context->menu_index > SubBruteAttackLoadFile) {
canvas_set_font(canvas, FontSecondary);

View File

@@ -1,6 +1,9 @@
#include "subbrute_scene_load_file.h"
#include "subbrute_scene_entrypoint.h"
#include "../subbrute_utils.h"
#include <lib/subghz/protocols/registry.h>
#define SUBGHZ_APP_PATH_FOLDER "/ext/subghz"
bool subbrute_load(SubBruteState* context, const char* file_path) {
bool result = false;
@@ -61,6 +64,16 @@ bool subbrute_load(SubBruteState* context, const char* file_path) {
break;
}
const SubGhzProtocol* registry =
subghz_protocol_registry_get_by_name(string_get_cstr(context->protocol));
if(registry && registry->type == SubGhzProtocolTypeDynamic) {
FURI_LOG_D(TAG, "Protocol is dynamic - not supported");
string_reset(context->notification_msg);
string_set_str(context->notification_msg, "Dynamic protocol unsupported");
break;
}
context->decoder_result = subghz_receiver_search_decoder_base_by_name(
context->receiver, string_get_cstr(context->protocol));
@@ -98,9 +111,9 @@ bool subbrute_load(SubBruteState* context, const char* file_path) {
// TE
if(!flipper_format_read_uint32(fff_data_file, "TE", &temp_data32, 1)) {
FURI_LOG_E(TAG, "Missing or incorrect TE");
string_reset(context->notification_msg);
string_set_str(context->notification_msg, "Missing or incorrect TE");
break;
//string_reset(context->notification_msg);
//string_set_str(context->notification_msg, "Missing or incorrect TE");
//break;
} else {
FURI_LOG_I(TAG, "TE: %d", temp_data32);
context->te = temp_data32;
@@ -119,6 +132,7 @@ bool subbrute_load(SubBruteState* context, const char* file_path) {
} while(0);
string_clear(temp_str);
flipper_format_file_close(fff_data_file);
flipper_format_free(fff_data_file);
if(result) {
FURI_LOG_I(TAG, "Loaded successfully");
@@ -156,7 +170,9 @@ void subbrute_scene_load_file_on_event(SubBruteEvent event, SubBruteState* conte
case InputKeyLeft:
case InputKeyRight:
case InputKeyOk:
break;
case InputKeyBack:
context->current_scene = SceneEntryPoint;
break;
}
}
@@ -169,30 +185,25 @@ void subbrute_scene_load_file_on_draw(Canvas* canvas, SubBruteState* context) {
canvas_set_color(canvas, ColorBlack);
// Frame
canvas_draw_frame(canvas, 0, 0, 128, 64);
//canvas_draw_frame(canvas, 0, 0, 128, 64);
// Title
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 64, 16, AlignCenter, AlignTop, "SubGhz Fuzzer");
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Press OK to choose file");
canvas_draw_str_aligned(canvas, 64, 16, AlignCenter, AlignTop, "SubGHz Fuzzer");
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignTop, "Error: Press back");
}
bool subbrute_load_protocol_from_file(SubBruteState* context) {
string_t file_path;
string_init(file_path);
string_set_str(file_path, SUBGHZ_APP_PATH_FOLDER);
// Input events and views are managed by file_select
bool res = dialog_file_browser_show(
context->dialogs,
context->file_path,
context->file_path,
SUBGHZ_APP_EXTENSION,
true,
&I_sub1_10px,
true);
context->dialogs, file_path, file_path, SUBGHZ_APP_EXTENSION, true, &I_sub1_10px, true);
if(res) {
res = subbrute_load(context, string_get_cstr(context->file_path));
res = subbrute_load(context, string_get_cstr(file_path));
}
string_clear(file_path);

View File

@@ -1,10 +1,11 @@
#include "subbrute_scene_run_attack.h"
#include <lib/subghz/transmitter.h>
#include <gui/elements.h>
uint64_t subbrute_counter = 0;
uint64_t max_value;
bool is_running = false;
bool locked = false;
bool toSave = false;
char subbrute_payload_byte[4];
#define SUBBRUTE_DELAY 1
@@ -31,11 +32,11 @@ FuriHalSubGhzPreset str_to_preset(string_t preset) {
}
void subbrute_emit(SubBruteState* context) {
FURI_LOG_I(TAG, string_get_cstr(context->flipper_format_string));
//FURI_LOG_D(TAG, string_get_cstr(context->flipper_format_string));
furi_hal_subghz_start_async_tx(subghz_transmitter_yield, context->transmitter);
while(!(furi_hal_subghz_is_async_tx_complete())) {
furi_delay_ms(50);
furi_delay_ms(5);
}
furi_hal_subghz_stop_async_tx();
@@ -43,31 +44,22 @@ void subbrute_emit(SubBruteState* context) {
}
void prepare_emit(SubBruteState* context) {
is_running = true;
furi_hal_subghz_init();
stream_clean(context->stream);
stream_write_string(context->stream, context->flipper_format_string);
context->transmitter =
subghz_transmitter_alloc_init(context->environment, string_get_cstr(context->protocol));
subghz_transmitter_deserialize(context->transmitter, context->flipper_format);
furi_hal_subghz_reset();
furi_hal_subghz_load_preset(str_to_preset(context->preset));
context->frequency = furi_hal_subghz_set_frequency_and_path(context->frequency);
furi_hal_subghz_set_frequency_and_path(context->frequency);
}
void clear_emit(SubBruteState* context) {
furi_hal_subghz_stop_async_tx();
furi_hal_subghz_sleep();
if(context->attack == SubBruteAttackLoadFile) {
subghz_transmitter_free(context->transmitter);
}
subghz_transmitter_free(context->transmitter);
is_running = false;
}
/*
void subbrute_send_raw_packet(SubBruteState* context) {
@@ -138,18 +130,43 @@ void subbrute_send_packet_parsed(SubBruteState* context) {
}
string_clear(buffer);
}
if(strcmp(string_get_cstr(context->protocol), "Princeton") == 0) {
string_init_printf(
context->flipper_format_string,
"Filetype: Flipper SubGhz Key File\n"
"Version: 1\n"
"Frequency: %u\n"
"Preset: %s\n"
"Protocol: %s\n"
"Bit: %d\n"
"Key: %s\n"
"TE: %d\n",
context->frequency,
string_get_cstr(context->preset),
string_get_cstr(context->protocol),
context->bit,
string_get_cstr(context->candidate),
context->te);
} else {
string_init_printf(
context->flipper_format_string,
"Filetype: Flipper SubGhz Key File\n"
"Version: 1\n"
"Frequency: %u\n"
"Preset: %s\n"
"Protocol: %s\n"
"Bit: %d\n"
"Key: %s\n",
context->frequency,
string_get_cstr(context->preset),
string_get_cstr(context->protocol),
context->bit,
string_get_cstr(context->candidate));
}
stream_clean(context->stream);
stream_write_string(context->stream, context->flipper_format_string);
subghz_transmitter_deserialize(context->transmitter, context->flipper_format);
subbrute_emit(context);
}
@@ -164,6 +181,7 @@ void subbrute_send_packet(SubBruteState* context) {
}
void subbrute_scene_run_attack_on_enter(SubBruteState* context) {
if(!toSave) {
if(context->attack == SubBruteAttackLoadFile) {
max_value = 0xFF;
} else {
@@ -180,16 +198,18 @@ void subbrute_scene_run_attack_on_enter(SubBruteState* context) {
context->flipper_format = flipper_format_string_alloc();
context->stream = flipper_format_get_raw_stream(context->flipper_format);
context->environment = subghz_environment_alloc();
context->transmitter =
subghz_transmitter_alloc_init(context->environment, string_get_cstr(context->protocol));
context->transmitter = subghz_transmitter_alloc_init(
context->environment, string_get_cstr(context->protocol));
prepare_emit(context);
} else {
toSave = false;
}
}
void subbrute_scene_run_attack_on_exit(SubBruteState* context) {
if(is_running) {
is_running = false;
}
if(!toSave) {
clear_emit(context);
}
}
void subbrute_scene_run_attack_on_tick(SubBruteState* context) {
@@ -223,6 +243,10 @@ void subbrute_scene_run_attack_on_event(SubBruteEvent event, SubBruteState* cont
if(event.input_type == InputTypeShort) {
switch(event.key) {
case InputKeyDown:
if(!context->is_attacking) {
toSave = true;
context->current_scene = SceneSaveName;
}
case InputKeyUp:
break;
case InputKeyLeft:
@@ -254,6 +278,8 @@ void subbrute_scene_run_attack_on_event(SubBruteEvent event, SubBruteState* cont
context->is_attacking = false;
string_reset(context->notification_msg);
context->payload = 0x00;
subbrute_counter = 0;
notification_message(context->notify, &sequence_blink_stop);
if(context->attack == SubBruteAttackLoadFile) {
context->current_scene = SceneSelectField;
} else {
@@ -270,7 +296,7 @@ void subbrute_scene_run_attack_on_draw(Canvas* canvas, SubBruteState* context) {
canvas_set_color(canvas, ColorBlack);
// Frame
canvas_draw_frame(canvas, 0, 0, 128, 64);
//canvas_draw_frame(canvas, 0, 0, 128, 64);
// Title
canvas_set_font(canvas, FontPrimary);
@@ -284,10 +310,11 @@ void subbrute_scene_run_attack_on_draw(Canvas* canvas, SubBruteState* context) {
canvas_set_font(canvas, FontSecondary);
char start_stop_msg[20];
snprintf(start_stop_msg, sizeof(start_stop_msg), " Press (V) to save ");
if(context->is_attacking) {
snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to stop ");
elements_button_center(canvas, "Stop");
} else {
snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to start ");
elements_button_center(canvas, "Start");
}
canvas_draw_str_aligned(canvas, 64, 44, AlignCenter, AlignTop, start_stop_msg);
canvas_draw_str_aligned(canvas, 64, 39, AlignCenter, AlignTop, start_stop_msg);
}

View File

@@ -0,0 +1,222 @@
#include "../subbrute.h"
#include "m-string.h"
#include "subghz/types.h"
#include <lib/toolbox/random_name.h>
#include <gui/modules/validators.h>
#include <lib/toolbox/path.h>
#define MAX_TEXT_INPUT_LEN 22
bool backpressed = false;
bool subbrute_path_is_file(string_t path) {
return string_end_with_str_p(path, ".sub");
}
// method modified from subghz_i.c
// https://github.com/flipperdevices/flipperzero-firmware/blob/b0daa601ad5b87427a45f9089c8b403a01f72c2a/applications/subghz/subghz_i.c#L417-L456
bool subbrute_save_protocol_to_file(Stream* flipper_format_stream, const char* dev_file_name) {
furi_assert(dev_file_name);
Storage* storage = furi_record_open(RECORD_STORAGE);
bool saved = false;
string_t file_dir;
string_init(file_dir);
path_extract_dirname(dev_file_name, file_dir);
do {
if(!storage_simply_mkdir(storage, string_get_cstr(file_dir))) {
FURI_LOG_E(TAG, "(save) Cannot mkdir");
break;
}
if(!storage_simply_remove(storage, dev_file_name)) {
FURI_LOG_E(TAG, "(save) Cannot remove");
break;
}
stream_seek(flipper_format_stream, 0, StreamOffsetFromStart);
stream_save_to_file(flipper_format_stream, storage, dev_file_name, FSOM_CREATE_ALWAYS);
saved = true;
FURI_LOG_D(TAG, "(save) OK Save");
} while(0);
string_clear(file_dir);
furi_record_close(RECORD_STORAGE);
return saved;
}
void custom_callback(SubBruteState* context) {
if(strcmp(context->file_name_tmp, "")) {
string_cat_printf(context->file_path, "/%s%s", context->file_name_tmp, ".sub");
if(subbrute_path_is_file(context->file_path_tmp)) {
context->current_scene = SceneAttack;
return; //false;
} else {
subbrute_save_protocol_to_file(context->stream, string_get_cstr(context->file_path));
}
string_set_str(context->file_path, EXT_PATH("subghz"));
string_reset(context->file_path_tmp);
//scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
context->current_scene = SceneAttack;
return; //true;
} else {
//error no file name
context->current_scene = SceneAttack;
return; //true;
}
}
void subbrute_scene_save_name_text_input_callback(void* context) {
furi_assert(context);
SubBruteState* statee = context;
custom_callback(statee);
}
void subbrute_scene_save_name_on_tick(SubBruteState* context) {
if(backpressed) {
void* validator_context = text_input_get_validator_callback_context(context->text_input);
text_input_set_validator(context->text_input, NULL, NULL);
validator_is_file_free(validator_context);
// Clear view
text_input_reset(context->text_input);
// TextInput
view_dispatcher_remove_view(context->view_dispatcher, 0);
text_input_free(context->text_input);
// Popup
view_dispatcher_remove_view(context->view_dispatcher, 1);
popup_free(context->popup);
context->current_scene = SceneAttack;
}
}
bool subbrute_back_event_callback(void* context) {
UNUSED(context);
backpressed = true;
return true;
}
void subbrute_scene_save_name_on_enter(SubBruteState* context) {
// Text Input
context->text_input = text_input_alloc();
view_dispatcher_add_view(
context->view_dispatcher, 0, text_input_get_view(context->text_input));
// Popup
context->popup = popup_alloc();
view_dispatcher_add_view(context->view_dispatcher, 1, popup_get_view(context->popup));
// Setup view
TextInput* text_input = context->text_input;
bool dev_name_empty = false;
string_t file_name;
string_t dir_name;
string_init(file_name);
string_init(dir_name);
if(!subbrute_path_is_file(context->file_path)) {
char file_name_buf[64] = {0};
set_random_name(file_name_buf, 64);
string_set_str(file_name, file_name_buf);
string_set_str(context->file_path, EXT_PATH("subghz"));
//highlighting the entire filename by default
dev_name_empty = true;
} else {
string_set(context->file_path_tmp, context->file_path);
path_extract_dirname(string_get_cstr(context->file_path), dir_name);
path_extract_filename(context->file_path, file_name, true);
string_set(context->file_path, dir_name);
}
strncpy(context->file_name_tmp, string_get_cstr(file_name), 64);
text_input_set_header_text(text_input, "Name signal");
text_input_set_result_callback(
text_input,
subbrute_scene_save_name_text_input_callback,
context,
context->file_name_tmp,
MAX_TEXT_INPUT_LEN, // buffer size
dev_name_empty);
ValidatorIsFile* validator_is_file =
validator_is_file_alloc_init(string_get_cstr(context->file_path), ".sub", "");
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
string_clear(file_name);
string_clear(dir_name);
view_dispatcher_set_navigation_event_callback(
context->view_dispatcher, subbrute_back_event_callback);
view_dispatcher_switch_to_view(context->view_dispatcher, 0);
}
void subbrute_scene_save_name_on_event(SubBruteEvent event, SubBruteState* context) {
UNUSED(context);
if(event.evt_type == EventTypeKey) {
if(event.input_type == InputTypeShort) {
switch(event.key) {
case InputKeyDown:
case InputKeyUp:
case InputKeyLeft:
case InputKeyRight:
case InputKeyOk:
break;
case InputKeyBack:
//context->current_scene = SceneAttack;
break;
}
}
}
}
void subbrute_scene_save_name_on_exit(SubBruteState* context) {
if(!backpressed) {
// Clear validator
void* validator_context = text_input_get_validator_callback_context(context->text_input);
text_input_set_validator(context->text_input, NULL, NULL);
validator_is_file_free(validator_context);
// Clear view
text_input_reset(context->text_input);
// Setup view
Popup* popup = context->popup;
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, context);
popup_set_callback(popup, NULL);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(context->view_dispatcher, 1);
furi_delay_ms(1050);
// Clear view
//Popup* popup = subghz->popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);
popup_set_callback(popup, NULL);
popup_set_context(popup, NULL);
popup_set_timeout(popup, 0);
popup_disable_timeout(popup);
// TextInput
view_dispatcher_remove_view(context->view_dispatcher, 0);
text_input_free(context->text_input);
// Popup
view_dispatcher_remove_view(context->view_dispatcher, 1);
popup_free(context->popup);
} else {
backpressed = false;
}
}

View File

@@ -0,0 +1,6 @@
#include "../subbrute.h"
void subbrute_scene_save_name_on_enter(SubBruteState* context);
void subbrute_scene_save_name_on_exit(SubBruteState* context);
void subbrute_scene_save_name_on_event(SubBruteEvent event, SubBruteState* context);
void subbrute_scene_save_name_on_tick(SubBruteState* context);

View File

@@ -61,15 +61,15 @@ void subbrute_scene_select_field_on_tick(SubBruteState* context) {
void subbrute_scene_select_field_on_event(SubBruteEvent event, SubBruteState* context) {
if(event.evt_type == EventTypeKey) {
if(event.input_type == InputTypeShort) {
const char* key_cstr = string_get_cstr(context->key);
//const char* key_cstr = string_get_cstr(context->key);
// don't look, it's ugly but I'm a python dev so...
uint8_t nb_bytes = 0;
/*uint8_t nb_bytes = 0;
for(uint8_t i = 0; i < strlen(key_cstr); i++) {
if(' ' == key_cstr[i]) {
nb_bytes++;
}
}
}*/
switch(event.key) {
case InputKeyDown:
@@ -77,12 +77,12 @@ void subbrute_scene_select_field_on_event(SubBruteEvent event, SubBruteState* co
break;
case InputKeyLeft:
if(context->key_index > 0) {
context->key_index = context->key_index - 1;
context->key_index--;
}
break;
case InputKeyRight:
if(context->key_index < nb_bytes) {
context->key_index = context->key_index + 1;
if(context->key_index < 7) {
context->key_index++;
}
break;
case InputKeyOk:
@@ -94,7 +94,7 @@ void subbrute_scene_select_field_on_event(SubBruteEvent event, SubBruteState* co
context->current_scene = SceneSelectFile;
break;
}
FURI_LOG_D(TAG, "Position: %d/%d", context->key_index, nb_bytes);
//FURI_LOG_D(TAG, "Position: %d/%d", context->key_index, nb_bytes);
}
}
}
@@ -104,7 +104,7 @@ void subbrute_scene_select_field_on_draw(Canvas* canvas, SubBruteState* context)
canvas_set_color(canvas, ColorBlack);
// Frame
canvas_draw_frame(canvas, 0, 0, 128, 64);
//canvas_draw_frame(canvas, 0, 0, 128, 64);
// Title
canvas_set_font(canvas, FontPrimary);

View File

@@ -4,6 +4,7 @@
#include "scene/subbrute_scene_select_field.h"
#include "scene/subbrute_scene_run_attack.h"
#include "scene/subbrute_scene_entrypoint.h"
#include "scene/subbrute_scene_save_name.h"
static void draw_callback(Canvas* const canvas, void* ctx) {
SubBruteState* subbrute_state = (SubBruteState*)acquire_mutex((ValueMutex*)ctx, 100);
@@ -27,6 +28,8 @@ static void draw_callback(Canvas* const canvas, void* ctx) {
case SceneEntryPoint:
subbrute_scene_entrypoint_on_draw(canvas, subbrute_state);
break;
case SceneSaveName:
break;
}
release_mutex((ValueMutex*)ctx, subbrute_state);
@@ -62,12 +65,16 @@ SubBruteState* subbrute_alloc() {
subbrute->current_scene = SceneSelectFile;
subbrute->is_running = true;
subbrute->is_attacking = false;
subbrute->key_index = 0;
subbrute->key_index = 7;
subbrute->notify = furi_record_open(RECORD_NOTIFICATION);
subbrute->view_dispatcher = view_dispatcher_alloc();
//Dialog
subbrute->dialogs = furi_record_open(RECORD_DIALOGS);
subbrute->preset_def = malloc(sizeof(SubGhzPresetDefinition));
subbrute->flipper_format = flipper_format_string_alloc();
subbrute->environment = subghz_environment_alloc();
subbrute->receiver = subghz_receiver_alloc_init(subbrute->environment);
@@ -84,6 +91,8 @@ void subbrute_free(SubBruteState* subbrute) {
furi_record_close(RECORD_NOTIFICATION);
view_dispatcher_free(subbrute->view_dispatcher);
string_clear(subbrute->preset);
string_clear(subbrute->candidate);
@@ -98,6 +107,8 @@ void subbrute_free(SubBruteState* subbrute) {
subghz_environment_free(subbrute->environment);
subghz_receiver_free(subbrute->receiver);
free(subbrute->preset_def);
// The rest
free(subbrute);
}
@@ -135,8 +146,11 @@ int32_t subbrute_start(void* p) {
// Register view port in GUI
FURI_LOG_I(TAG, "Initializing gui");
Gui* gui = (Gui*)furi_record_open(RECORD_GUI);
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
subbrute_state->gui = furi_record_open(RECORD_GUI);
gui_add_view_port(subbrute_state->gui, view_port, GuiLayerFullscreen);
view_dispatcher_attach_to_gui(
subbrute_state->view_dispatcher, subbrute_state->gui, ViewDispatcherTypeFullscreen);
subbrute_state->current_scene = SceneEntryPoint;
@@ -156,6 +170,9 @@ int32_t subbrute_start(void* p) {
case SceneSelectField:
subbrute_scene_select_field_on_event(event, subbrute_state);
break;
case SceneSaveName:
subbrute_scene_save_name_on_event(event, subbrute_state);
break;
case SceneAttack:
subbrute_scene_run_attack_on_event(event, subbrute_state);
break;
@@ -182,6 +199,9 @@ int32_t subbrute_start(void* p) {
case SceneEntryPoint:
subbrute_scene_entrypoint_on_exit(subbrute_state);
break;
case SceneSaveName:
subbrute_scene_save_name_on_exit(subbrute_state);
break;
case NoneScene:
break;
}
@@ -198,6 +218,9 @@ int32_t subbrute_start(void* p) {
case SceneAttack:
subbrute_scene_run_attack_on_enter(subbrute_state);
break;
case SceneSaveName:
subbrute_scene_save_name_on_enter(subbrute_state);
break;
case SceneEntryPoint:
subbrute_scene_entrypoint_on_enter(subbrute_state);
break;
@@ -220,6 +243,9 @@ int32_t subbrute_start(void* p) {
case SceneEntryPoint:
subbrute_scene_entrypoint_on_tick(subbrute_state);
break;
case SceneSaveName:
subbrute_scene_save_name_on_tick(subbrute_state);
break;
}
view_port_update(view_port);
}
@@ -233,7 +259,7 @@ int32_t subbrute_start(void* p) {
furi_hal_power_suppress_charge_exit();
FURI_LOG_I(TAG, "Cleaning up");
gui_remove_view_port(gui, view_port);
gui_remove_view_port(subbrute_state->gui, view_port);
view_port_free(view_port);
furi_message_queue_free(event_queue);
furi_record_close(RECORD_GUI);

View File

@@ -12,6 +12,9 @@
#include <dialogs/dialogs.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/text_input.h>
#include <gui/modules/popup.h>
#define TAG "SUBBRUTE"
@@ -20,7 +23,8 @@ typedef enum {
SceneSelectFile,
SceneSelectField,
SceneAttack,
SceneEntryPoint
SceneEntryPoint,
SceneSaveName
} SubBruteScene;
typedef enum {
@@ -38,6 +42,7 @@ typedef enum {
typedef enum {
EventTypeTick,
EventTypeKey,
EventTypeCustom,
} EventType;
typedef struct {
@@ -54,6 +59,10 @@ typedef struct {
SubBruteScene current_scene;
SubBruteScene previous_scene;
NotificationApp* notify;
Gui* gui;
ViewDispatcher* view_dispatcher;
TextInput* text_input;
Popup* popup;
// SubGhz Stuff
FlipperFormat* flipper_format;
@@ -61,6 +70,7 @@ typedef struct {
SubGhzTransmitter* transmitter;
SubGhzReceiver* receiver;
SubGhzProtocolDecoderBase* decoder_result;
SubGhzPresetDefinition* preset_def;
string_t preset;
Stream* stream;
string_t protocol;
@@ -72,6 +82,7 @@ typedef struct {
// Context Stuff
DialogsApp* dialogs;
char file_name_tmp[64];
string_t file_path;
string_t file_path_tmp;
string_t notification_msg;