improved command hf mf sniff. Now it cant decode nested authentication and cant write emulator files

This commit is contained in:
Merlokbr@gmail.com 2012-07-16 14:49:51 +00:00
commit 55acbb2a39
8 changed files with 357 additions and 14 deletions

View file

@ -1542,6 +1542,13 @@ int CmdHF14AMfCSave(const char *Cmd) {
}
int CmdHF14AMfSniff(const char *Cmd){
// params
bool wantLogToFile = 0;
bool wantDecrypt = 0;
bool wantSaveToEml = 0;
bool wantSaveToEmlFile = 0;
//var
int res = 0;
int len = 0;
int blockLen = 0;
@ -1556,11 +1563,25 @@ int CmdHF14AMfSniff(const char *Cmd){
memset(buf, 0x00, 3000);
if (param_getchar(Cmd, 0) == 'h') {
PrintAndLog("Usage: hf mf sniff ");
PrintAndLog(" sample: hf mf sniff ");
PrintAndLog("It continuously get data from the field and saves it to: log, emulator, emulator file.");
PrintAndLog("You can specify:");
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(" n/a 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(" sample: hf mf sniff l d e");
return 0;
}
for (int i = 0; i < 4; i++) {
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 == 'f' || ctmp == 'F') wantSaveToEmlFile = true;
}
printf("-------------------------------------------------------------------------\n");
printf("Executing command. \n");
printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");
@ -1611,9 +1632,17 @@ int CmdHF14AMfSniff(const char *Cmd){
memcpy(uid, bufPtr + 2, 7);
memcpy(atqa, bufPtr + 2 + 7, 2);
sak = bufPtr[11];
PrintAndLog("tag select uid:%s atqa:%02x %02x sak:0x%02x", sprint_hex(uid, 7), atqa[0], atqa[1], sak);
if (wantLogToFile) {
FillFileNameByUID(logHexFileName, uid, ".log");
AddLogCurrentDT(logHexFileName);
}
if (wantDecrypt) mfTraceInit(uid, atqa, sak);
} 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);
}
bufPtr += len;
num++;