X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/463ca973e7cf1e866bb60d7cc33d38e473aa4d3d..d3499d369d191057fea1335c4e50e907c6a9369f:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index b7f336db..c28563e2 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -2003,7 +2003,7 @@ int CmdHF14AMfCSave(const char *Cmd) { int CmdHF14AMfSniff(const char *Cmd){ - // params + bool wantLogToFile = 0; bool wantDecrypt = 0; //bool wantSaveToEml = 0; TODO @@ -2020,7 +2020,6 @@ 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); @@ -2031,8 +2030,8 @@ int CmdHF14AMfSniff(const char *Cmd){ PrintAndLog(" l - save encrypted sequence to logfile `uid.log`"); PrintAndLog(" d - decrypt sequence and put it to log file `uid.log`"); PrintAndLog(" n/a e - decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory"); - PrintAndLog(" r - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`"); - PrintAndLog("Usage: hf mf sniff [l][d][e][r]"); + PrintAndLog(" f - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`"); + PrintAndLog("Usage: hf mf sniff [l][d][e][f]"); PrintAndLog(" sample: hf mf sniff l d e"); return 0; } @@ -2087,14 +2086,19 @@ int CmdHF14AMfSniff(const char *Cmd){ printf(">\n"); PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum); num = 0; - while (bufPtr - buf + 9 < blockLen) { - isTag = bufPtr[3] & 0x80 ? true:false; - bufPtr += 4; - parity = *((uint32_t *)(bufPtr)); - bufPtr += 4; - len = bufPtr[0]; - bufPtr++; - if ((len == 14) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff)) { + while (bufPtr - buf < blockLen) { + bufPtr += 6; + len = *((uint16_t *)bufPtr); + + if(len & 0x8000) { + isTag = true; + len &= 0x7fff; + } else { + isTag = false; + } + bufPtr += 2; + if ((len == 14) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[12] == 0xff) && (bufPtr[13] == 0xff)) { + memcpy(uid, bufPtr + 2, 7); memcpy(atqa, bufPtr + 2 + 7, 2); uid_len = (atqa[0] & 0xC0) == 0x40 ? 7 : 4; @@ -2116,9 +2120,10 @@ int CmdHF14AMfSniff(const char *Cmd){ if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len); if (wantDecrypt) - mfTraceDecode(bufPtr, len, parity, wantSaveToEmlFile); + mfTraceDecode(bufPtr, len, wantSaveToEmlFile); } bufPtr += len; + bufPtr += ((len-1)/8+1); // ignore parity num++; } } @@ -2220,9 +2225,6 @@ int GetCardSize() return -1; } - - - static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"},