From 3464fbe1df32f7896b837e8e4cdca19ca621aa70 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 5 Feb 2018 20:46:14 +0100 Subject: [PATCH] fix 'hf mf darkside' - adapted solution from @pwpivi --- armsrc/iso14443a.c | 4 ++-- client/mifarehost.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index c5c33eff4..d3f70cfbf 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -2407,7 +2407,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) { // if we missed the sync time already, advance to the next nonce repeat while ( GetCountSspClk() > sync_time) { - elapsed_prng_sequences++; + ++elapsed_prng_sequences; sync_time = (sync_time & 0xfffffff8 ) + sync_cycles; } @@ -2430,7 +2430,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) { // we didn't calibrate our clock yet, // iceman: has to be calibrated every time. - if (first_try && previous_nt && !nt_attacked) { + if (previous_nt && !nt_attacked) { int nt_distance = dist_nt(previous_nt, nt); diff --git a/client/mifarehost.c b/client/mifarehost.c index 7d7e543aa..2a0b80406 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -83,11 +83,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) { } } - if (keycount > 1) { - PrintAndLog("[+] found %u candidate keys. Trying to verify with authentication...\n", keycount); - } else { - PrintAndLog("[+] found a candidate key. Trying to verify it with authentication...\n"); - } + PrintAndLog("[+] found %u candidate key%s Trying to verify with authentication...\n", keycount, (keycount > 1) ? "s." : "."); *key = -1; uint8_t keyBlock[USB_CMD_DATA_SIZE]; @@ -96,7 +92,9 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) { int size = keycount - i > max_keys ? max_keys : keycount - i; for (int j = 0; j < size; j++) { if (par_list == 0) { - num_to_bytes(last_keylist[i*max_keys + j], 6, keyBlock); + if ( last_keylist != NULL ){ + num_to_bytes(last_keylist[i*max_keys + j], 6, keyBlock); + } } else { num_to_bytes(keylist[i*max_keys + j], 6, keyBlock); } @@ -111,7 +109,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) { free(keylist); break; } else { - PrintAndLog("[-] test authentication failed. Restarting darkside attack"); + PrintAndLog("[-] all candidate keys failed authentication. Restarting darkside attack"); free(last_keylist); last_keylist = keylist; c.arg[0] = true; @@ -905,8 +903,10 @@ int detect_classic_nackbug(bool verbose){ // for nice animation bool term = !isatty(STDIN_FILENO); +#if defined(__linux__) char star[] = {'-', '\\', '|', '/'}; uint8_t staridx = 0; +#endif while (true) {