fix 'hf mf darkside' - adapted solution from @pwpivi

This commit is contained in:
iceman1001 2018-02-05 20:46:14 +01:00
parent 09d8744b84
commit 3464fbe1df
2 changed files with 9 additions and 9 deletions

View file

@ -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);

View file

@ -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) {