From 94b0bcc7580cc4523ba98e5d646a688f7d735345 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 26 Apr 2023 00:08:01 +0200 Subject: [PATCH] changed the key table output. In some cases it didnt print non found keys red --- client/src/cmdhfmf.c | 90 ++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 765342ec2..a647d90c2 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -2861,6 +2861,9 @@ tryNested: } case PM3_ESTATIC_NONCE: PrintAndLogEx(ERR, "Error: Static encrypted nonce detected. Aborted\n"); + + e_sector[current_sector_i].Key[current_key_type_i] = 0xffffffffffff;; + e_sector[current_sector_i].foundKey[current_key_type_i] = false; // Show the results to the user PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, _GREEN_("found keys:")); @@ -2907,6 +2910,10 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack } case PM3_ESTATIC_NONCE: { PrintAndLogEx(ERR, "\nError: Static encrypted nonce detected. Aborted\n"); + + e_sector[current_sector_i].Key[current_key_type_i] = 0xffffffffffff;; + e_sector[current_sector_i].foundKey[current_key_type_i] = false; + // Show the results to the user PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, _GREEN_("found keys:")); @@ -3899,57 +3906,48 @@ void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_secto PrintAndLogEx(SUCCESS, "-----+-----+--------------+---+--------------+----"); PrintAndLogEx(SUCCESS, " Sec | Blk | key A |res| key B |res"); PrintAndLogEx(SUCCESS, "-----+-----+--------------+---+--------------+----"); + + bool extended_legend = false; for (uint8_t i = 0; i < sectorscnt; i++) { - snprintf(strA, sizeof(strA), "------------"); - snprintf(strB, sizeof(strB), "------------"); - - if (e_sector[i].foundKey[0]) - snprintf(strA, sizeof(strA), "%012" PRIX64, e_sector[i].Key[0]); - - if (e_sector[i].foundKey[1]) - snprintf(strB, sizeof(strB), "%012" PRIX64, e_sector[i].Key[1]); - - if (e_sector[i].foundKey[0] > 1) { - PrintAndLogEx(SUCCESS, " "_YELLOW_("%03d")" | %03d | " _GREEN_("%s")" | " _BRIGHT_GREEN_("%c")" | " _GREEN_("%s")" | " _BRIGHT_GREEN_("%c") - , i - , mfSectorTrailerOfSector(i) - , strA, e_sector[i].foundKey[0] - , strB, e_sector[i].foundKey[1] - ); - } else { - - // keep track if we use start_sector or i... - uint8_t s = start_sector; - if (start_sector == 0) - s = i; - - if (e_sector[i].foundKey[0]) { - snprintf(strA, sizeof(strA), _GREEN_("%012" PRIX64), e_sector[i].Key[0]); - snprintf(resA, sizeof(resA), _BRIGHT_GREEN_("%d"), 1); - } else { - snprintf(strA, sizeof(strA), _RED_("%s"), "------------"); - snprintf(resA, sizeof(resA), _RED_("%d"), 0); - } - - if (e_sector[i].foundKey[1]) { - snprintf(strB, sizeof(strB), _GREEN_("%012" PRIX64), e_sector[i].Key[1]); - snprintf(resB, sizeof(resB), _BRIGHT_GREEN_("%d"), 1); - } else { - snprintf(strB, sizeof(strB), _RED_("%s"), "------------"); - snprintf(resB, sizeof(resB), _RED_("%d"), 0); - } - - PrintAndLogEx(SUCCESS, " " _YELLOW_("%03d") " | %03d | %s | %s | %s | %s" - , s - , mfSectorTrailerOfSector(s) - , strA, resA - , strB, resB - ); + if ((e_sector[i].foundKey[0] > 1) || (e_sector[i].foundKey[1] > 1)) { + extended_legend = true; } + + if (e_sector[i].foundKey[0]) { + snprintf(strA, sizeof(strA), _GREEN_("%012" PRIX64), e_sector[i].Key[0]); + snprintf(resA, sizeof(resA), _BRIGHT_GREEN_("%c"), e_sector[i].foundKey[0]); + } else { + snprintf(strA, sizeof(strA), _RED_("%s"), "------------"); + snprintf(resA, sizeof(resA), _RED_("%d"), 0); + } + + if (e_sector[i].foundKey[1]) { + snprintf(strB, sizeof(strB), _GREEN_("%012" PRIX64), e_sector[i].Key[1]); + snprintf(resB, sizeof(resB), _BRIGHT_GREEN_("%c"), e_sector[i].foundKey[1]); + } else { + snprintf(strB, sizeof(strB), _RED_("%s"), "------------"); + snprintf(resB, sizeof(resB), _RED_("%d"), 0); + } + + // keep track if we use start_sector or i + // show one sector or all. + uint8_t s = start_sector; + if (start_sector == 0) { + s = i; + } + + PrintAndLogEx(SUCCESS, " " _YELLOW_("%03d") " | %03d | %s | %s | %s | %s" + , s + , mfSectorTrailerOfSector(s) + , strA, resA + , strB, resB + ); } + PrintAndLogEx(SUCCESS, "-----+-----+--------------+---+--------------+----"); - if (e_sector[0].foundKey[0] > 1) { + + if (extended_legend) { PrintAndLogEx(INFO, "( " _YELLOW_("D") ":Dictionary / " _YELLOW_("S") ":darkSide / "