Skip to content

Commit

Permalink
[FL-3758] NFC: MFC Unlock with Dictionary (#3411)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
RebornedBrain and gornekich authored Feb 6, 2024
1 parent e180266 commit 8c54c14
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum {
SubmenuIndexDetectReader = SubmenuIndexCommonMax,
SubmenuIndexWrite,
SubmenuIndexUpdate,
SubmenuIndexDictAttack
};

static void nfc_scene_info_on_enter_mf_classic(NfcApp* instance) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -151,13 +159,21 @@ 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,
"Write to Initial Card",
SubmenuIndexWrite,
nfc_protocol_support_common_submenu_callback,
instance);

submenu_add_item(
submenu,
"Update from Initial Card",
Expand All @@ -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) {
Expand All @@ -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;
}
}

Expand Down
7 changes: 5 additions & 2 deletions applications/main/nfc/scenes/nfc_scene_retry_confirm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 8c54c14

Please sign in to comment.