From 4f722a00c06c7eb4816840fbe4e10a857e8db3dc Mon Sep 17 00:00:00 2001 From: noproto Date: Fri, 4 Oct 2024 18:41:29 -0400 Subject: [PATCH] Avoid storage errors, clean up temporary files --- .../scenes/nfc_scene_mf_classic_dict_attack.c | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c index 4c0459e74..2691999b0 100644 --- a/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c +++ b/applications/main/nfc/scenes/nfc_scene_mf_classic_dict_attack.c @@ -171,20 +171,25 @@ static void nfc_scene_mf_classic_dict_attack_prepare_view(NfcApp* instance) { do { instance->nfc_dict_context.enhanced_dict = true; - // TODO: Check for errors - storage_common_remove(instance->storage, NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH); - storage_common_copy( - instance->storage, - NFC_APP_MF_CLASSIC_DICT_SYSTEM_PATH, - NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH); + if(keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH)) { + storage_common_remove( + instance->storage, NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH); + } + if(keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_SYSTEM_PATH)) { + storage_common_copy( + instance->storage, + NFC_APP_MF_CLASSIC_DICT_SYSTEM_PATH, + NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH); + } if(!keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_USER_PATH)) { state = DictAttackStateSystemDictInProgress; break; } - // TODO: Check for errors - storage_common_remove(instance->storage, NFC_APP_MF_CLASSIC_DICT_USER_NESTED_PATH); + if(keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_USER_NESTED_PATH)) { + storage_common_remove(instance->storage, NFC_APP_MF_CLASSIC_DICT_USER_NESTED_PATH); + } storage_common_copy( instance->storage, NFC_APP_MF_CLASSIC_DICT_USER_PATH, @@ -376,6 +381,14 @@ void nfc_scene_mf_classic_dict_attack_on_exit(void* context) { instance->nfc_dict_context.msb_count = 0; instance->nfc_dict_context.enhanced_dict = false; + // Clean up temporary files used for nested dictionary attack + if(keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_USER_NESTED_PATH)) { + storage_common_remove(instance->storage, NFC_APP_MF_CLASSIC_DICT_USER_NESTED_PATH); + } + if(keys_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH)) { + storage_common_remove(instance->storage, NFC_APP_MF_CLASSIC_DICT_SYSTEM_NESTED_PATH); + } + nfc_blink_stop(instance); notification_message(instance->notifications, &sequence_display_backlight_enforce_auto); }