From 9842416f3047075355944bf118d74afb71764011 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 2 Aug 2024 23:37:14 +0200 Subject: [PATCH] fix hf mf nested output for extended auths --- client/src/mifare/mifarehost.c | 36 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c index 02496d806..c2e009278 100644 --- a/client/src/mifare/mifarehost.c +++ b/client/src/mifare/mifarehost.c @@ -603,11 +603,21 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, free(statelists[1].head.slhead); num_to_bytes(key64, 6, resultKey); - PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c -- found valid key [ " _GREEN_("%s") " ]", - package->block, - package->keytype ? 'B' : 'A', - sprint_hex_inrow(resultKey, 6) - ); + if (package->keytype < 2) { + PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c -- found valid key [ " _GREEN_("%s") " ]", + package->block, + package->keytype ? 'B' : 'A', + sprint_hex_inrow(resultKey, 6) + ); + } else { + PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %02x -- found valid key [ " _GREEN_("%s") " ]", + package->block, + MIFARE_AUTH_KEYA + package->keytype, + sprint_hex_inrow(resultKey, 6) + ); + } + + return PM3_SUCCESS; } @@ -616,11 +626,17 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, } out: - PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c", - package->block, - package->keytype ? 'B' : 'A' - ); - + if (package->keytype < 2) { + PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c", + package->block, + package->keytype ? 'B' : 'A' + ); + } else { + PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %02x", + package->block, + MIFARE_AUTH_KEYA + package->keytype + ); + } free(statelists[0].head.slhead); free(statelists[1].head.slhead); return PM3_ESOFT;