From e488ef306c4bf182032684d9d3b853d5eb82dbe3 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 11 Sep 2020 14:09:38 +0200 Subject: [PATCH] Fix MFC static nonce detection on some cards and do it before prng det --- armsrc/mifarecmd.c | 3 +++ client/src/cmdhf14a.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 0746921ca..a5cf56bf3 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -2383,6 +2383,9 @@ void MifareHasStaticNonce(void) { nt = bytes_to_num(rec, 4); + // some cards with static nonce need to be reset before next query + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + LEDsoff(); CHK_TIMEOUT(); } diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index f8fc02f8f..4ce99c69a 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1956,23 +1956,23 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { isMagic = detect_classic_magic(); if (isMifareClassic) { - int res = detect_classic_prng(); - if (res == 1) - PrintAndLogEx(SUCCESS, "Prng detection: " _GREEN_("weak")); - else if (res == 0) - PrintAndLogEx(SUCCESS, "Prng detection: " _YELLOW_("hard")); - else - PrintAndLogEx(FAILED, "Prng detection: " _RED_("fail")); - - if (do_nack_test) - detect_classic_nackbug(false); - - res = detect_classic_static_nonce(); + int res = detect_classic_static_nonce(); if (res == 1) PrintAndLogEx(SUCCESS, "Static nonce: " _YELLOW_("yes")); if (res == 2 && verbose) PrintAndLogEx(SUCCESS, "Static nonce: " _RED_("fail")); + if (res != 1) { // not static + res = detect_classic_prng(); + if (res == 1) + PrintAndLogEx(SUCCESS, "Prng detection: " _GREEN_("weak")); + else if (res == 0) + PrintAndLogEx(SUCCESS, "Prng detection: " _YELLOW_("hard")); + else + PrintAndLogEx(FAILED, "Prng detection: " _RED_("fail")); + if (do_nack_test) + detect_classic_nackbug(false); + } } }