From 846937a684447cf0d836c0b7df46e1495afd7896 Mon Sep 17 00:00:00 2001 From: Simone Spadino Date: Wed, 23 Oct 2024 00:24:07 +0200 Subject: [PATCH] Support for static nonces card with offset 0 --- armsrc/mifarecmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 96f615c64..6be8f230b 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1534,7 +1534,7 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, continue; }; - if (mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_NESTED, NULL, NULL)) { + if (mifare_classic_authex(pcs, cuid, blockNo, keyType, ui64Key, AUTH_NESTED, &nt2, NULL)) { continue; }; @@ -1544,6 +1544,12 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, }; nt3 = bytes_to_num(receivedAnswer, 4); + // fix for cards with distance 0 + if (nt1 == nt2) { + target_nt[0] = nt1; + target_nt[1] = nt1; + target_ks[0] = nt3 ^ target_nt[0]; + } target_ks[1] = nt3 ^ target_nt[1]; isOK = PM3_SUCCESS;