From 8c54c14742540113d41dd8068361ecaa602c8996 Mon Sep 17 00:00:00 2001 From: RebornedBrain <138568282+RebornedBrain@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:11:27 +0300 Subject: [PATCH] [FL-3758] NFC: MFC Unlock with Dictionary (#3411) * New menu item "Unlock with Dictionary" added to classic menu * No retry also returns to dictionary attack if it was previously displayed * nfc app: format code --------- Co-authored-by: gornekich --- .../protocol_support/mf_classic/mf_classic.c | 36 ++++++++++++++++--- .../main/nfc/scenes/nfc_scene_retry_confirm.c | 7 ++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/applications/main/nfc/helpers/protocol_support/mf_classic/mf_classic.c b/applications/main/nfc/helpers/protocol_support/mf_classic/mf_classic.c index 8ac4a2c6a9b..1486011917d 100644 --- a/applications/main/nfc/helpers/protocol_support/mf_classic/mf_classic.c +++ b/applications/main/nfc/helpers/protocol_support/mf_classic/mf_classic.c @@ -14,6 +14,7 @@ enum { SubmenuIndexDetectReader = SubmenuIndexCommonMax, SubmenuIndexWrite, SubmenuIndexUpdate, + SubmenuIndexDictAttack }; static void nfc_scene_info_on_enter_mf_classic(NfcApp* instance) { @@ -120,6 +121,13 @@ static void nfc_scene_read_menu_on_enter_mf_classic(NfcApp* instance) { SubmenuIndexDetectReader, nfc_protocol_support_common_submenu_callback, instance); + + submenu_add_item( + submenu, + "Unlock with Dictionary", + SubmenuIndexDictAttack, + nfc_protocol_support_common_submenu_callback, + instance); } } @@ -151,6 +159,13 @@ static void nfc_scene_saved_menu_on_enter_mf_classic(NfcApp* instance) { SubmenuIndexDetectReader, nfc_protocol_support_common_submenu_callback, instance); + + submenu_add_item( + submenu, + "Unlock with Dictionary", + SubmenuIndexDictAttack, + nfc_protocol_support_common_submenu_callback, + instance); } submenu_add_item( submenu, @@ -158,6 +173,7 @@ static void nfc_scene_saved_menu_on_enter_mf_classic(NfcApp* instance) { SubmenuIndexWrite, nfc_protocol_support_common_submenu_callback, instance); + submenu_add_item( submenu, "Update from Initial Card", @@ -173,13 +189,20 @@ static void nfc_scene_emulate_on_enter_mf_classic(NfcApp* instance) { } static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) { - if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexDetectReader) { - scene_manager_next_scene(instance->scene_manager, NfcSceneSaveConfirm); - dolphin_deed(DolphinDeedNfcDetectReader); - return true; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == SubmenuIndexDetectReader) { + scene_manager_next_scene(instance->scene_manager, NfcSceneSaveConfirm); + dolphin_deed(DolphinDeedNfcDetectReader); + consumed = true; + } else if(event.event == SubmenuIndexDictAttack) { + scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDictAttack); + consumed = true; + } } - return false; + return consumed; } static bool nfc_scene_saved_menu_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) { @@ -195,6 +218,9 @@ static bool nfc_scene_saved_menu_on_event_mf_classic(NfcApp* instance, SceneMana } else if(event.event == SubmenuIndexUpdate) { scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicUpdateInitial); consumed = true; + } else if(event.event == SubmenuIndexDictAttack) { + scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDictAttack); + consumed = true; } } diff --git a/applications/main/nfc/scenes/nfc_scene_retry_confirm.c b/applications/main/nfc/scenes/nfc_scene_retry_confirm.c index 99acbb0b803..62299609468 100644 --- a/applications/main/nfc/scenes/nfc_scene_retry_confirm.c +++ b/applications/main/nfc/scenes/nfc_scene_retry_confirm.c @@ -28,8 +28,11 @@ bool nfc_scene_retry_confirm_on_event(void* context, SceneManagerEvent event) { if(event.event == DialogExResultRight) { consumed = scene_manager_previous_scene(nfc->scene_manager); } else if(event.event == DialogExResultLeft) { - if(scene_manager_has_previous_scene( - nfc->scene_manager, NfcSceneMfUltralightUnlockWarn)) { + if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicDictAttack)) { + consumed = scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneMfClassicDictAttack); + } else if(scene_manager_has_previous_scene( + nfc->scene_manager, NfcSceneMfUltralightUnlockWarn)) { consumed = scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneMfUltralightUnlockMenu); } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneDetect)) {