[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 <n.gorbadey@gmail.com>
This commit is contained in:
RebornedBrain 2024-02-06 22:11:27 +03:00 committed by GitHub
parent e180266c1a
commit 8c54c14742
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 7 deletions

View File

@ -14,6 +14,7 @@ enum {
SubmenuIndexDetectReader = SubmenuIndexCommonMax, SubmenuIndexDetectReader = SubmenuIndexCommonMax,
SubmenuIndexWrite, SubmenuIndexWrite,
SubmenuIndexUpdate, SubmenuIndexUpdate,
SubmenuIndexDictAttack
}; };
static void nfc_scene_info_on_enter_mf_classic(NfcApp* instance) { 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, SubmenuIndexDetectReader,
nfc_protocol_support_common_submenu_callback, nfc_protocol_support_common_submenu_callback,
instance); 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, SubmenuIndexDetectReader,
nfc_protocol_support_common_submenu_callback, nfc_protocol_support_common_submenu_callback,
instance); instance);
submenu_add_item(
submenu,
"Unlock with Dictionary",
SubmenuIndexDictAttack,
nfc_protocol_support_common_submenu_callback,
instance);
} }
submenu_add_item( submenu_add_item(
submenu, submenu,
@ -158,6 +173,7 @@ static void nfc_scene_saved_menu_on_enter_mf_classic(NfcApp* instance) {
SubmenuIndexWrite, SubmenuIndexWrite,
nfc_protocol_support_common_submenu_callback, nfc_protocol_support_common_submenu_callback,
instance); instance);
submenu_add_item( submenu_add_item(
submenu, submenu,
"Update from Initial Card", "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) { static bool nfc_scene_read_menu_on_event_mf_classic(NfcApp* instance, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom && event.event == SubmenuIndexDetectReader) { bool consumed = false;
scene_manager_next_scene(instance->scene_manager, NfcSceneSaveConfirm);
dolphin_deed(DolphinDeedNfcDetectReader); if(event.type == SceneManagerEventTypeCustom) {
return true; 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) { 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) { } else if(event.event == SubmenuIndexUpdate) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicUpdateInitial); scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicUpdateInitial);
consumed = true; consumed = true;
} else if(event.event == SubmenuIndexDictAttack) {
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicDictAttack);
consumed = true;
} }
} }

View File

@ -28,8 +28,11 @@ bool nfc_scene_retry_confirm_on_event(void* context, SceneManagerEvent event) {
if(event.event == DialogExResultRight) { if(event.event == DialogExResultRight) {
consumed = scene_manager_previous_scene(nfc->scene_manager); consumed = scene_manager_previous_scene(nfc->scene_manager);
} else if(event.event == DialogExResultLeft) { } else if(event.event == DialogExResultLeft) {
if(scene_manager_has_previous_scene( if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneMfClassicDictAttack)) {
nfc->scene_manager, NfcSceneMfUltralightUnlockWarn)) { 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( consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMfUltralightUnlockMenu); nfc->scene_manager, NfcSceneMfUltralightUnlockMenu);
} else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneDetect)) { } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneDetect)) {