X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/fa0e0b109fd576eb6f720168058e67463b1aa321..6b23be6b7ecd1660922d53c8c1c0522f69389dc6:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index af96543d..9b43f411 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -94,12 +94,14 @@ int usage_hf14_hardnested(void){ PrintAndLog(" w acquire nonces and write them to binary file nonces.bin"); PrintAndLog(" s slower acquisition (required by some non standard cards)"); PrintAndLog(" r read nonces.bin and start attack"); + PrintAndLog(" t tests?"); PrintAndLog(" "); PrintAndLog("samples:"); PrintAndLog(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A"); PrintAndLog(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A w"); PrintAndLog(" hf mf hardnested 0 A FFFFFFFFFFFF 4 A w s"); PrintAndLog(" hf mf hardnested r"); + PrintAndLog(" hf mf hardnested r a0a1a2a3a4a5"); PrintAndLog(" "); PrintAndLog("Add the known target key to check if it is present in the remaining key space:"); PrintAndLog(" sample5: hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF"); @@ -109,15 +111,18 @@ int usage_hf14_chk(void){ PrintAndLog("Usage: hf mf chk |<*card memory> [t|d] [] []"); PrintAndLog("options:"); PrintAndLog(" h this help"); - PrintAndLog(" * all sectors"); - PrintAndLog(" card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, - 1K"); + PrintAndLog(" * all sectors based on card memory, other values then below defaults to 1k"); + PrintAndLog(" 0 - MINI(320 bytes)"); + PrintAndLog(" 1 - 1K"); + PrintAndLog(" 2 - 2K"); + PrintAndLog(" 4 - 4K"); PrintAndLog(" d write keys to binary file"); PrintAndLog(" t write keys to emulator memory\n"); PrintAndLog(" "); PrintAndLog("samples:"); - PrintAndLog(" hf mf chk 0 A 1234567890ab keys.dic"); - PrintAndLog(" hf mf chk *1 ? t"); - PrintAndLog(" hf mf chk *1 ? d"); + PrintAndLog(" hf mf chk 0 A 1234567890ab keys.dic -- target block 0, Key A"); + PrintAndLog(" hf mf chk *1 ? t -- target all blocks, all keys, 1K, write to emul"); + PrintAndLog(" hf mf chk *1 ? d -- target all blocks, all keys, 1K, write to file"); return 0; } @@ -218,8 +223,7 @@ END: return 0; } -int CmdHF14AMfWrBl(const char *Cmd) -{ +int CmdHF14AMfWrBl(const char *Cmd) { uint8_t blockNo = 0; uint8_t keyType = 0; uint8_t key[6] = {0, 0, 0, 0, 0, 0}; @@ -268,8 +272,7 @@ int CmdHF14AMfWrBl(const char *Cmd) return 0; } -int CmdHF14AMfRdBl(const char *Cmd) -{ +int CmdHF14AMfRdBl(const char *Cmd) { uint8_t blockNo = 0; uint8_t keyType = 0; uint8_t key[6] = {0, 0, 0, 0, 0, 0}; @@ -317,8 +320,7 @@ int CmdHF14AMfRdBl(const char *Cmd) return 0; } -int CmdHF14AMfRdSc(const char *Cmd) -{ +int CmdHF14AMfRdSc(const char *Cmd) { int i; uint8_t sectorNo = 0; uint8_t keyType = 0; @@ -375,8 +377,7 @@ int CmdHF14AMfRdSc(const char *Cmd) return 0; } -uint8_t FirstBlockOfSector(uint8_t sectorNo) -{ +uint8_t FirstBlockOfSector(uint8_t sectorNo) { if (sectorNo < 32) { return sectorNo * 4; } else { @@ -384,8 +385,7 @@ uint8_t FirstBlockOfSector(uint8_t sectorNo) } } -uint8_t NumBlocksPerSector(uint8_t sectorNo) -{ +uint8_t NumBlocksPerSector(uint8_t sectorNo) { if (sectorNo < 32) { return 4; } else { @@ -942,7 +942,7 @@ int CmdHF14AMfNestedHard(const char *Cmd) { char ctmp; ctmp = param_getchar(Cmd, 0); - if (ctmp != 'H' && ctmp != 'h' ) return usage_hf14_hardnested(); + if (ctmp == 'H' || ctmp == 'h' ) return usage_hf14_hardnested(); if (ctmp != 'R' && ctmp != 'r' && ctmp != 'T' && ctmp != 't' && strlen(Cmd) < 20) return usage_hf14_hardnested(); bool know_target_key = false; @@ -1008,9 +1008,9 @@ int CmdHF14AMfNestedHard(const char *Cmd) { trgBlockNo, trgKeyType?'B':'A', trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5], - know_target_key?"":" (not set)", - nonce_file_write?"write":nonce_file_read?"read":"none", - slow?"Yes":"No", + know_target_key ? "" : " (not set)", + nonce_file_write ? "write": nonce_file_read ? "read" : "none", + slow ? "Yes" : "No", tests); int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key?trgkey:NULL, nonce_file_read, nonce_file_write, slow, tests); @@ -1204,6 +1204,8 @@ int CmdHF14AMfChk(const char *Cmd) { // time clock_t t1 = clock(); + time_t start, end; + time(&start); // check keys. for (trgKeyType = !keyType; trgKeyType < 2; (keyType==2) ? (++trgKeyType) : (trgKeyType=2) ) { @@ -1215,7 +1217,8 @@ int CmdHF14AMfChk(const char *Cmd) { if (e_sector[i].foundKey[trgKeyType]) continue; for (uint32_t c = 0; c < keycnt; c += max_keys) { - + printf("."); + fflush(stdout); uint32_t size = keycnt-c > max_keys ? max_keys : keycnt-c; res = mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6*c], &key64); @@ -1224,19 +1227,19 @@ int CmdHF14AMfChk(const char *Cmd) { e_sector[i].foundKey[trgKeyType] = TRUE; break; } - printf("."); - fflush(stdout); } b < 127 ? ( b +=4 ) : ( b += 16 ); } } t1 = clock() - t1; + time(&end); + unsigned long elapsed_time = difftime(end, start); if ( t1 > 0 ) - printf("\nTime in checkkeys: %.0f ticks\n", (float)t1); + PrintAndLog("\nTime in checkkeys: %.0f ticks %u seconds\n", (float)t1, elapsed_time); + // 20160116 If Sector A is found, but not Sector B, try just reading it of the tag? if ( keyType != 1 ) { - PrintAndLog("testing to read key B..."); for (i = 0; i < SectorsCnt; i++) { // KEY A but not KEY B