From 991f13f27db8ba53fea29f0df8a9ae606fc5a491 Mon Sep 17 00:00:00 2001 From: pwpiwi Date: Tue, 15 Jul 2014 08:39:56 +0200 Subject: [PATCH] minor bugfixes to hf mf sniff and hf 14a snoop - tracing was not always enabled when starting hf mf sniff or hf 14a snoop - ATQA was displayed in wrong byte order in hf mf sniff - 4 Byte UIDs were displayed as 7 Byte UIDs (padded with 0x000000) in hf mf sniff - same for logfile names. - assignment (=) had been used instead of == in comparisons (shouldn't have been relevant though) --- armsrc/iso14443a.c | 4 +++- client/cmdhfmf.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index fe284352..c5bcc8d4 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -507,6 +507,7 @@ void RAMFUNC SnoopIso14443a(uint8_t param) { LEDsoff(); // init trace buffer iso14a_clear_trace(); + iso14a_set_tracing(TRUE); // We won't start recording the frames that we acquire until we trigger; // a good trigger condition to get started is probably when we see a @@ -2623,7 +2624,8 @@ void RAMFUNC SniffMifare(uint8_t param) { // C(red) A(yellow) B(green) LEDsoff(); // init trace buffer - iso14a_clear_trace(); + iso14a_clear_trace(); + iso14a_set_tracing(TRUE); // The command (reader -> tag) that we're receiving. // The length of a received command will in most cases be no more than 18 bytes. diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index a2665256..d9fd8092 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -1848,7 +1848,8 @@ int CmdHF14AMfSniff(const char *Cmd){ int blockLen = 0; int num = 0; int pckNum = 0; - uint8_t uid[8]; + uint8_t uid[7]; + uint8_t uid_len; uint8_t atqa[2]; uint8_t sak; bool isTag; @@ -1926,14 +1927,19 @@ int CmdHF14AMfSniff(const char *Cmd){ bufPtr += 4; len = bufPtr[0]; bufPtr++; - if ((len == 14) && (bufPtr[0] = 0xff) && (bufPtr[1] = 0xff)) { + if ((len == 14) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff)) { memcpy(uid, bufPtr + 2, 7); memcpy(atqa, bufPtr + 2 + 7, 2); + uid_len = (atqa[0] & 0xC0) == 0x40 ? 7 : 4; sak = bufPtr[11]; - PrintAndLog("tag select uid:%s atqa:%02x %02x sak:0x%02x", sprint_hex(uid, 7), atqa[0], atqa[1], sak); + PrintAndLog("tag select uid:%s atqa:0x%02x%02x sak:0x%02x", + sprint_hex(uid + (7 - uid_len), uid_len), + atqa[1], + atqa[0], + sak); if (wantLogToFile || wantDecrypt) { - FillFileNameByUID(logHexFileName, uid, ".log", 7); + FillFileNameByUID(logHexFileName, uid + (7 - uid_len), ".log", uid_len); AddLogCurrentDT(logHexFileName); } if (wantDecrypt) mfTraceInit(uid, atqa, sak, wantSaveToEmlFile); -- 2.39.5