X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/e0c635d19c58423d88ae698788a31c865e5554ab..e98300f2455f72b64df737b3a81c072b6b3761e3:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index c27ba56c..abb6f59f 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -71,17 +71,22 @@ start: if (isOK != 1) return 1; // execute original function from util nonce2key - if (nonce2key(uid, nt, par_list, ks_list, &r_key)) return 2; - printf("------------------------------------------------------------------\n"); - PrintAndLog("Key found:%012llx \n", r_key); + if (nonce2key(uid, nt, par_list, ks_list, &r_key)) + { + isOK = 2; + PrintAndLog("Key not found (lfsr_common_prefix list is null). Nt=%08x", nt); + } else { + printf("------------------------------------------------------------------\n"); + PrintAndLog("Key found:%012I64x \n", r_key); - num_to_bytes(r_key, 6, keyBlock); - isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key); + num_to_bytes(r_key, 6, keyBlock); + isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key); + } if (!isOK) - PrintAndLog("Found valid key:%012llx", r_key); + PrintAndLog("Found valid key:%012I64x", r_key); else { - PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt); + if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt); c.arg[0] = nt; goto start; } @@ -570,7 +575,7 @@ int CmdHF14AMfNested(const char *Cmd) if (res) res = mfCheckKeys(trgBlockNo, trgKeyType, 8, &keyBlock[6 * 8], &key64); if (!res) { - PrintAndLog("Found valid key:%012llx", key64); + PrintAndLog("Found valid key:%012I64x", key64); // transfer key to the emulator if (transferToEml) { @@ -630,7 +635,7 @@ int CmdHF14AMfNested(const char *Cmd) if (res) res = mfCheckKeys(trgBlockNo, trgKeyType, 8, &keyBlock[6 * 8], &key64); if (!res) { - PrintAndLog("Found valid key:%012llx", key64); + PrintAndLog("Found valid key:%012I64x", key64); e_sector[trgBlockNo / 4].foundKey[trgKeyType] = 1; e_sector[trgBlockNo / 4].Key[trgKeyType] = key64; } @@ -643,7 +648,7 @@ int CmdHF14AMfNested(const char *Cmd) PrintAndLog("|sec|key A |res|key B |res|"); PrintAndLog("|---|----------------|---|----------------|---|"); for (i = 0; i < SectorsCnt; i++) { - PrintAndLog("|%03d| %012llx | %d | %012llx | %d |", i, + PrintAndLog("|%03d| %012I64x | %d | %012I64x | %d |", i, e_sector[i].Key[0], e_sector[i].foundKey[0], e_sector[i].Key[1], e_sector[i].foundKey[1]); } PrintAndLog("|---|----------------|---|----------------|---|"); @@ -840,7 +845,7 @@ int CmdHF14AMfChk(const char *Cmd) } memset(keyBlock + 6 * keycnt, 0, 6); num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt); - PrintAndLog("chk custom key[%d] %012llx", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6)); + PrintAndLog("chk custom key[%d] %012I64x", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6)); keycnt++; } } else { @@ -870,7 +875,7 @@ int CmdHF14AMfChk(const char *Cmd) res = mfCheckKeys(b, t, size, keyBlock +6*c, &key64); if (res !=1) { if (!res) { - PrintAndLog("Found valid key:[%012llx]",key64); + PrintAndLog("Found valid key:[%012I64x]",key64); if (transferToEml) { uint8_t block[16]; mfEmlGetMem(block, get_trailer_block(b), 1); @@ -984,10 +989,6 @@ int CmdHF14AMfEGet(const char *Cmd) } blockNo = param_get8(Cmd, 0); - if (blockNo >= 32 * 4 + 8 * 16) { - PrintAndLog("Block number must be in [0..255] as in MIFARE classic."); - return 1; - } PrintAndLog(" "); if (!mfEmlGetMem(data, blockNo, 3)) { @@ -1028,10 +1029,6 @@ int CmdHF14AMfESet(const char *Cmd) } blockNo = param_get8(Cmd, 0); - if (blockNo >= 32 * 4 + 8 * 16) { - PrintAndLog("Block number must be in [0..255] as in MIFARE classic."); - return 1; - } if (param_gethex(Cmd, 1, memBlock, 32)) { PrintAndLog("block data must include 32 HEX symbols"); @@ -1210,7 +1207,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd) } keyA = bytes_to_num(data, 6); keyB = bytes_to_num(data + 10, 6); - PrintAndLog("|%03d| %012llx | %012llx |", i, keyA, keyB); + PrintAndLog("|%03d| %012I64x | %012I64x |", i, keyA, keyB); } PrintAndLog("|---|----------------|----------------|"); @@ -1269,10 +1266,6 @@ int CmdHF14AMfCSetBlk(const char *Cmd) } blockNo = param_get8(Cmd, 0); - if (blockNo >= 32 * 4 + 8 * 16) { - PrintAndLog("Block number must be in [0..255] as in MIFARE classic."); - return 1; - } if (param_gethex(Cmd, 1, memBlock, 32)) { PrintAndLog("block data must include 32 HEX symbols"); @@ -1400,10 +1393,6 @@ int CmdHF14AMfCGetBlk(const char *Cmd) { } blockNo = param_get8(Cmd, 0); - if (blockNo >= 32 * 4 + 8 * 16) { - PrintAndLog("Block number must be in [0..255] as in MIFARE classic."); - return 1; - } PrintAndLog("--block number:%02x ", blockNo); @@ -1543,9 +1532,9 @@ int CmdHF14AMfCSave(const char *Cmd) { int CmdHF14AMfSniff(const char *Cmd){ // params - bool wantLogToFile = 1; - bool wantDecrypt = 1; - bool wantSaveToEml = 0; + bool wantLogToFile = 0; + bool wantDecrypt = 0; + //bool wantSaveToEml = 0; TODO bool wantSaveToEmlFile = 0; //var @@ -1558,6 +1547,7 @@ int CmdHF14AMfSniff(const char *Cmd){ uint8_t atqa[2]; uint8_t sak; bool isTag; + uint32_t parity; uint8_t buf[3000]; uint8_t * bufPtr = buf; memset(buf, 0x00, 3000); @@ -1578,7 +1568,7 @@ int CmdHF14AMfSniff(const char *Cmd){ char ctmp = param_getchar(Cmd, i); if (ctmp == 'l' || ctmp == 'L') wantLogToFile = true; if (ctmp == 'd' || ctmp == 'D') wantDecrypt = true; - if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true; + //if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true; TODO if (ctmp == 'f' || ctmp == 'F') wantSaveToEmlFile = true; } @@ -1625,7 +1615,9 @@ int CmdHF14AMfSniff(const char *Cmd){ num = 0; while (bufPtr - buf + 9 < blockLen) { isTag = bufPtr[3] & 0x80 ? true:false; - bufPtr += 8; + bufPtr += 4; + parity = *((uint32_t *)(bufPtr)); + bufPtr += 4; len = bufPtr[0]; bufPtr++; if ((len == 14) && (bufPtr[0] = 0xff) && (bufPtr[1] = 0xff)) { @@ -1642,7 +1634,7 @@ int CmdHF14AMfSniff(const char *Cmd){ } else { PrintAndLog("%s(%d):%s", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len)); if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len); - if (wantDecrypt) mfTraceDecode(bufPtr, len, wantSaveToEmlFile); + if (wantDecrypt) mfTraceDecode(bufPtr, len, parity, wantSaveToEmlFile); } bufPtr += len; num++;