X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/7e735c1398b9c3643d292614db10c7e58c58db85..5215a874429bf41ec24c83d6d5f631233faf3d76:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 6b944df3..04998e18 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -24,19 +24,20 @@ int usage_hf14_mifare(void){ return 0; } int usage_hf14_mf1ksim(void){ - PrintAndLog("Usage: hf mf sim [h] u n i x"); + PrintAndLog("Usage: hf mf sim [h] u n [i] [x] [e] [v]"); PrintAndLog("options:"); PrintAndLog(" h this help"); PrintAndLog(" u (Optional) UID 4,7 or 10bytes. If not specified, the UID 4b from emulator memory will be used"); PrintAndLog(" n (Optional) Automatically exit simulation after blocks have been read by reader. 0 = infinite"); PrintAndLog(" i (Optional) Interactive, means that console will not be returned until simulation finishes or is aborted"); - PrintAndLog(" x (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)"); - PrintAndLog(" e (Optional) Fill simulator keys from what we crack"); - PrintAndLog(" v (Optional) Show maths used for cracking reader. Useful for debugging."); + PrintAndLog(" x (Optional) Crack, performs the 'reader attack', nr/ar attack against a reader"); + PrintAndLog(" e (Optional) Fill simulator keys from found keys"); + PrintAndLog(" v (Optional) Verbose"); PrintAndLog("samples:"); PrintAndLog(" hf mf sim u 0a0a0a0a"); PrintAndLog(" hf mf sim u 11223344556677"); PrintAndLog(" hf mf sim u 112233445566778899AA"); + PrintAndLog(" hf mf sim u 11223344 i x"); return 0; } int usage_hf14_dbg(void){ @@ -225,7 +226,7 @@ start: c.arg[0] = false; goto start; } else { - PrintAndLog("Found valid key: %012"llx" \n", r_key); + PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key); goto END; } } @@ -245,10 +246,10 @@ start: uint64_t key64 = 0; int res = mfCheckKeys(blockNo, keytype - 0x60 , false, 1, keyblock, &key64); if ( res > 0 ) { - PrintAndLog("Candidate Key found (%012"llx") - Test authentication failed. [%d] Restarting darkside attack", r_key, res); + PrintAndLog("Candidate Key found (%012" PRIx64 ") - Test authentication failed. [%d] Restarting darkside attack", r_key, res); goto start; } - PrintAndLog("Found valid key: %012"llx" \n", r_key); + PrintAndLog("Found valid key: %012" PRIx64 " \n", r_key); } END: t1 = clock() - t1; @@ -312,9 +313,7 @@ int CmdHF14AMfRdBl(const char *Cmd) { uint8_t blockNo = 0; uint8_t keyType = 0; uint8_t key[6] = {0, 0, 0, 0, 0, 0}; - - char cmdp = 0x00; - + char cmdp = 0x00; if (strlen(Cmd)<3) { PrintAndLog("Usage: hf mf rdbl "); @@ -471,10 +470,9 @@ int CmdHF14AMfDump(const char *Cmd) { size_t bytes_read; for (sectorNo=0; sectorNo bufsize) { + if (traceLen > bufsize || buf == NULL) { uint8_t *p; if (buf == NULL) // not yet allocated p = malloc(traceLen); @@ -1737,7 +1699,7 @@ int CmdHF14AMfKeyBrute(const char *Cmd) { time(&start); if (mfKeyBrute( blockNo, keytype, key, &foundkey)) - PrintAndLog("Found valid key: %012"llx" \n", foundkey); + PrintAndLog("Found valid key: %012" PRIx64 " \n", foundkey); else PrintAndLog("Key not found"); @@ -1755,7 +1717,7 @@ void printKeyTable( uint8_t sectorscnt, sector *e_sector ){ PrintAndLog("|sec|key A |res|key B |res|"); PrintAndLog("|---|----------------|---|----------------|---|"); for (uint8_t i = 0; i < sectorscnt; ++i) { - PrintAndLog("|%03d| %012"llx" | %d | %012"llx" | %d |", i, + PrintAndLog("|%03d| %012" PRIx64 " | %d | %012" PRIx64 " | %d |", i, e_sector[i].Key[0], e_sector[i].foundKey[0], e_sector[i].Key[1], e_sector[i].foundKey[1] ); @@ -1804,7 +1766,6 @@ int CmdHF14AMfESet(const char *Cmd) { uint8_t memBlock[16]; uint8_t blockNo = 0; - memset(memBlock, 0x00, sizeof(memBlock)); if (strlen(Cmd) < 3 || param_getchar(Cmd, 0) == 'h') { @@ -2086,7 +2047,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd) } keyA = bytes_to_num(data, 6); keyB = bytes_to_num(data + 10, 6); - PrintAndLog("|%03d| %012"llx" | %012"llx" |", i, keyA, keyB); + PrintAndLog("|%03d| %012" PRIx64 " | %012" PRIx64 " |", i, keyA, keyB); } PrintAndLog("|---|----------------|----------------|");