diff --git a/applications/external/pacs_fuzzer/lib/worker/protocol.c b/applications/external/pacs_fuzzer/lib/worker/protocol.c index b9f9e6bf6..c295289ae 100644 --- a/applications/external/pacs_fuzzer/lib/worker/protocol.c +++ b/applications/external/pacs_fuzzer/lib/worker/protocol.c @@ -228,10 +228,18 @@ const FuzzerProtocol fuzzer_proto_items[] = { }; #endif -const char* fuzzer_attack_names[] = { - [FuzzerMainMenuIndexDefaultValues] = "Default Values", - [FuzzerMainMenuIndexLoadFile] = "Load File", - [FuzzerMainMenuIndexLoadFileCustomUids] = "Load UIDs from file", +typedef struct { + const char* menu_label; + FuzzerAttackId attack_id; +} FuzzerMenuItems; + +const FuzzerMenuItems fuzzer_menu_items[] = { + {"Default Values", FuzzerAttackIdDefaultValues}, +#ifdef RFID_125_PROTOCOL + {"BF Customer ID", FuzzerAttackIdBFCustomerID}, +#endif + {"Load File", FuzzerAttackIdLoadFile}, + {"Load UIDs from file", FuzzerAttackIdLoadFileCustomUids}, }; const char* fuzzer_proto_get_name(FuzzerProtocolsID index) { @@ -246,10 +254,14 @@ uint8_t fuzzer_proto_get_max_data_size() { return MAX_PAYLOAD_SIZE; } -const char* fuzzer_proto_get_menu_label(FuzzerMainMenuIndex index) { - return fuzzer_attack_names[index]; +const char* fuzzer_proto_get_menu_label(uint8_t index) { + return fuzzer_menu_items[index].menu_label; +} + +FuzzerAttackId fuzzer_proto_get_attack_id_by_index(uint8_t index) { + return fuzzer_menu_items[index].attack_id; } uint8_t fuzzer_proto_get_count_of_menu_items() { - return COUNT_OF(fuzzer_attack_names); -} \ No newline at end of file + return COUNT_OF(fuzzer_menu_items); +} diff --git a/applications/external/pacs_fuzzer/lib/worker/protocol.h b/applications/external/pacs_fuzzer/lib/worker/protocol.h index a2893123e..4c2c70e0c 100644 --- a/applications/external/pacs_fuzzer/lib/worker/protocol.h +++ b/applications/external/pacs_fuzzer/lib/worker/protocol.h @@ -20,10 +20,11 @@ typedef enum { } FuzzerProtocolsID; typedef enum { - FuzzerMainMenuIndexDefaultValues = 0, - FuzzerMainMenuIndexLoadFile, - FuzzerMainMenuIndexLoadFileCustomUids, -} FuzzerMainMenuIndex; + FuzzerAttackIdDefaultValues = 0, + FuzzerAttackIdLoadFile, + FuzzerAttackIdLoadFileCustomUids, + FuzzerAttackIdBFCustomerID, +} FuzzerAttackId; struct FuzzerPayload { uint8_t* data; @@ -54,7 +55,14 @@ uint8_t fuzzer_proto_get_count_of_protocols(); * @param index menu index * @return pointer to a string containing the menu label */ -const char* fuzzer_proto_get_menu_label(FuzzerMainMenuIndex index); +const char* fuzzer_proto_get_menu_label(uint8_t index); + +/** + * Get FuzzerAttackId based on its index + * @param index menu index + * @return FuzzerAttackId + */ +FuzzerAttackId fuzzer_proto_get_attack_id_by_index(uint8_t index); /** * Get number of menu items diff --git a/applications/external/pacs_fuzzer/scenes/fuzzer_scene_main.c b/applications/external/pacs_fuzzer/scenes/fuzzer_scene_main.c index 5ad37654a..699037430 100644 --- a/applications/external/pacs_fuzzer/scenes/fuzzer_scene_main.c +++ b/applications/external/pacs_fuzzer/scenes/fuzzer_scene_main.c @@ -77,9 +77,11 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) { // TODO error logic bool loading_ok = false; + uint8_t d_size = fuzzer_proto_get_max_data_size(); + uint8_t* uid; - switch(app->fuzzer_state.menu_index) { - case FuzzerMainMenuIndexDefaultValues: + switch(fuzzer_proto_get_attack_id_by_index(app->fuzzer_state.menu_index)) { + case FuzzerAttackIdDefaultValues: loading_ok = fuzzer_worker_init_attack_dict(app->worker, app->fuzzer_state.proto_index); @@ -88,8 +90,20 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) { // error } break; + case FuzzerAttackIdBFCustomerID: + uid = malloc(d_size); + memset(uid, 0x00, d_size); - case FuzzerMainMenuIndexLoadFile: + loading_ok = fuzzer_worker_init_attack_bf_byte( + app->worker, app->fuzzer_state.proto_index, uid, 0); + + free(uid); + if(!loading_ok) { + // error + } + break; + + case FuzzerAttackIdLoadFile: if(!fuzzer_scene_main_load_key(app)) { break; } else { @@ -105,7 +119,7 @@ bool fuzzer_scene_main_on_event(void* context, SceneManagerEvent event) { } break; - case FuzzerMainMenuIndexLoadFileCustomUids: + case FuzzerAttackIdLoadFileCustomUids: if(!fuzzer_scene_main_load_custom_dict(app)) { break; } else { diff --git a/applications/external/pacs_fuzzer/todo.md b/applications/external/pacs_fuzzer/todo.md index dd6f4fc69..7afd3fad8 100644 --- a/applications/external/pacs_fuzzer/todo.md +++ b/applications/external/pacs_fuzzer/todo.md @@ -13,7 +13,7 @@ #### App functionality -- [ ] Add `BFCustomerID` attack +- [x] Add `BFCustomerID` attack - [ ] Save key logic ## Code Improvement diff --git a/applications/external/pacs_fuzzer/views/main_menu.c b/applications/external/pacs_fuzzer/views/main_menu.c index 8c4c23603..49b0a0d9c 100644 --- a/applications/external/pacs_fuzzer/views/main_menu.c +++ b/applications/external/pacs_fuzzer/views/main_menu.c @@ -75,7 +75,7 @@ void fuzzer_view_main_draw(Canvas* canvas, FuzzerViewMainModel* model) { canvas_draw_str_aligned( canvas, 64, 36, AlignCenter, AlignTop, fuzzer_proto_get_menu_label(model->menu_index)); - if(model->menu_index < model->menu_max) { + if(model->menu_index < (model->menu_max - 1)) { canvas_set_font(canvas, FontSecondary); canvas_draw_str_aligned( canvas,