From b461e6e3675765f05d75b19c8a77a3025ad9ae03 Mon Sep 17 00:00:00 2001 From: LW Date: Tue, 17 Dec 2019 19:56:14 -0800 Subject: [PATCH] add tag nonce to error message --- armsrc/mifarecmd.c | 3 ++- client/cmdhfmf.c | 4 ++-- client/mifare/mifarehost.c | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 68bcc804..50dc2443 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -951,11 +951,12 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat target_ks[i] = ks1; ncount++; if (i == 1 && target_nt[1] == target_nt[0]) { // we need two different nonces - target_nt[i] = 0; + target_nt[1] = 0; if (MF_DBGLEVEL >= 3) Dbprintf("Nonce#2: dismissed (= nonce#1), ntdist=%d", j); if( ++target_nt_duplicate_count == 50 ) { // unable to get a 2nd nonce after 50 tries, probably a fixed nonce isOK = -4; + target_nt[1] = nt1; break; } diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 4062ff61..81b4816d 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -712,7 +712,7 @@ int CmdHF14AMfNested(const char *Cmd) case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break; case -2 : PrintAndLog("Button pressed. Aborted.\n"); break; case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break; - case -4 : PrintAndLog("Tag isn't vulnerable to Nested Attack (tag nonce is static).\n"); break; + case -4 : key64 = bytes_to_num(keyBlock, 4); PrintAndLog("Tag isn't vulnerable to Nested Attack (tag nonce:%08X is static).\n", key64); break; default : PrintAndLog("Unknown Error.\n"); } return 2; @@ -798,7 +798,7 @@ int CmdHF14AMfNested(const char *Cmd) case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break; case -2 : PrintAndLog("Button pressed. Aborted.\n"); break; case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break; - case -4 : PrintAndLog("Tag isn't vulnerable to Nested Attack (tag nonce is static).\n"); break; + case -4 : key64 = bytes_to_num(keyBlock, 4); PrintAndLog("Tag isn't vulnerable to Nested Attack (tag nonce:%08X is static).\n", key64); break; default : PrintAndLog("Unknown Error.\n"); } free(e_sector); diff --git a/client/mifare/mifarehost.c b/client/mifare/mifarehost.c index a91f67a5..33df6e04 100644 --- a/client/mifare/mifarehost.c +++ b/client/mifare/mifarehost.c @@ -344,6 +344,8 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, } if (resp.arg[0]) { + memcpy(&statelists[0].nt, (void *)(resp.d.asBytes + 4 + 1 * 8 + 0), 4); + num_to_bytes(statelists[0].nt, 4, resultKey); return resp.arg[0]; // error during nested }