mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
chg: trace list color in list
This commit is contained in:
parent
c1a5f93dab
commit
ffa27049b7
3 changed files with 80 additions and 61 deletions
|
@ -641,7 +641,7 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors) {
|
if (errors || strlen(Cmd) == 0) {
|
||||||
free(data);
|
free(data);
|
||||||
return usage_hitag_checkchallenges();
|
return usage_hitag_checkchallenges();
|
||||||
}
|
}
|
||||||
|
@ -734,43 +734,61 @@ static int CmdLFHitag2Dump(const char *Cmd) {
|
||||||
|
|
||||||
|
|
||||||
// Annotate HITAG protocol
|
// Annotate HITAG protocol
|
||||||
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) {
|
||||||
|
|
||||||
|
// iceman: live decrypt of trace?
|
||||||
|
if (is_response) {
|
||||||
|
|
||||||
uint8_t cmdbits = (cmd[0] & 0xC0) >> 6;
|
|
||||||
|
|
||||||
if (cmdsize == 1) {
|
uint8_t cmdbits = (cmd[0] & 0xC0) >> 6;
|
||||||
if (cmdbits == HITAG2_START_AUTH) {
|
|
||||||
snprintf(exp, size, "START AUTH");
|
if (cmdsize == 1) {
|
||||||
return;
|
if (cmdbits == HITAG2_START_AUTH) {
|
||||||
|
snprintf(exp, size, "START AUTH");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cmdbits == HITAG2_HALT) {
|
||||||
|
snprintf(exp, size, "HALT");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cmdbits == HITAG2_HALT) {
|
|
||||||
snprintf(exp, size, "HALT");
|
if (cmdsize == 3) {
|
||||||
return;
|
if (cmdbits == HITAG2_START_AUTH) {
|
||||||
|
// C 1 C 0
|
||||||
|
// 1100 0 00 1 1100 000
|
||||||
|
uint8_t page = (cmd[0] & 0x38) >> 3;
|
||||||
|
uint8_t inv_page = ((cmd[0] & 0x1) << 2) | ((cmd[1] & 0xC0) >> 6);
|
||||||
|
snprintf(exp, size, "READ page(%x) %x", page, inv_page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cmdbits == HITAG2_WRITE_PAGE) {
|
||||||
|
uint8_t page = (cmd[0] & 0x38) >> 3;
|
||||||
|
uint8_t inv_page = ((cmd[0] & 0x1) << 2) | ((cmd[1] & 0xC0) >> 6);
|
||||||
|
snprintf(exp, size, "WRITE page(%x) %x", page, inv_page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdsize == 9) {
|
||||||
|
snprintf(exp, size, "Nr Ar Is response");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (cmdsize == 9) {
|
||||||
|
snprintf(exp, size, "Nr Ar");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (cmdsize == 2) {
|
|
||||||
if (cmdbits == HITAG2_START_AUTH) {
|
|
||||||
// C 1 C 0
|
|
||||||
// 1100 0 00 1 1100 000
|
|
||||||
uint8_t page = (cmd[0] & 0x38) >> 3;
|
|
||||||
uint8_t inv_page = ((cmd[0] & 0x1) << 2) | ((cmd[1] & 0xC0) >> 6);
|
|
||||||
snprintf(exp, size, "READ page(%x) %x", page, inv_page);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (cmdbits == HITAG2_WRITE_PAGE) {
|
|
||||||
uint8_t page = (cmd[0] & 0x38) >> 3;
|
|
||||||
uint8_t inv_page = ((cmd[0] & 0x1) << 2) | ((cmd[1] & 0xC0) >> 6);
|
|
||||||
snprintf(exp, size, "WRITE page(%x) %x", page, inv_page);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void annotateHitagS(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
void annotateHitagS(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
int CmdLFHitag(const char *Cmd);
|
int CmdLFHitag(const char *Cmd);
|
||||||
|
|
||||||
int readHitagUid(void);
|
int readHitagUid(void);
|
||||||
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
|
void annotateHitag1(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader);
|
||||||
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
|
void annotateHitag2(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader);
|
||||||
void annotateHitagS(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
|
void annotateHitagS(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_reader);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,7 @@ static int usage_trace_list(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: trace list <protocol> [f][c| <0|1>");
|
PrintAndLogEx(NORMAL, "Usage: trace list <protocol> [f][c| <0|1>");
|
||||||
PrintAndLogEx(NORMAL, " f - show frame delay times as well");
|
PrintAndLogEx(NORMAL, " f - show frame delay times as well");
|
||||||
PrintAndLogEx(NORMAL, " c - mark CRC bytes");
|
PrintAndLogEx(NORMAL, " c - mark CRC bytes");
|
||||||
PrintAndLogEx(NORMAL, " r - show relative times (gap and duration)");
|
PrintAndLogEx(NORMAL, " r - show relative times (gap and duration)");
|
||||||
PrintAndLogEx(NORMAL, " u - display times in microseconds instead of clock cycles");
|
PrintAndLogEx(NORMAL, " u - display times in microseconds instead of clock cycles");
|
||||||
PrintAndLogEx(NORMAL, " x - show hexdump to convert to pcap(ng) or to import into Wireshark using encapsulation type \"ISO 14443\"");
|
PrintAndLogEx(NORMAL, " x - show hexdump to convert to pcap(ng) or to import into Wireshark using encapsulation type \"ISO 14443\"");
|
||||||
PrintAndLogEx(NORMAL, " syntax to use: `text2pcap -t \"%%S.\" -l 264 -n <input-text-file> <output-pcapng-file>`");
|
PrintAndLogEx(NORMAL, " syntax to use: `text2pcap -t \"%%S.\" -l 264 -n <input-text-file> <output-pcapng-file>`");
|
||||||
|
@ -211,7 +211,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
duration *= 32;
|
duration *= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t *frame = hdr->frame;
|
uint8_t *frame = hdr->frame;
|
||||||
uint8_t *parityBytes = hdr->frame + data_len;
|
uint8_t *parityBytes = hdr->frame + data_len;
|
||||||
|
|
||||||
|
@ -332,18 +332,18 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
const char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
|
||||||
|
|
||||||
|
|
||||||
uint32_t previous_end_of_transmission_timestamp = 0;
|
uint32_t previous_end_of_transmission_timestamp = 0;
|
||||||
if (prev_eot) {
|
if (prev_eot) {
|
||||||
if (*prev_eot) {
|
if (*prev_eot) {
|
||||||
previous_end_of_transmission_timestamp = *prev_eot;
|
previous_end_of_transmission_timestamp = *prev_eot;
|
||||||
} else {
|
} else {
|
||||||
previous_end_of_transmission_timestamp = hdr->timestamp;
|
previous_end_of_transmission_timestamp = hdr->timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end_of_transmission_timestamp = hdr->timestamp + duration;
|
end_of_transmission_timestamp = hdr->timestamp + duration;
|
||||||
|
|
||||||
if (prev_eot)
|
if (prev_eot)
|
||||||
*prev_eot = end_of_transmission_timestamp;
|
*prev_eot = end_of_transmission_timestamp;
|
||||||
|
|
||||||
// Always annotate LEGIC read/tag
|
// Always annotate LEGIC read/tag
|
||||||
|
@ -355,8 +355,18 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
|
|
||||||
if (protocol == FELICA)
|
if (protocol == FELICA)
|
||||||
annotateFelica(explanation, sizeof(explanation), frame, data_len);
|
annotateFelica(explanation, sizeof(explanation), frame, data_len);
|
||||||
|
|
||||||
|
if (protocol == PROTO_HITAG1) {
|
||||||
|
annotateHitag1(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||||
|
}
|
||||||
|
if (protocol == PROTO_HITAG2) {
|
||||||
|
annotateHitag2(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||||
|
}
|
||||||
|
if (protocol == PROTO_HITAGS) {
|
||||||
|
annotateHitagS(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
|
||||||
|
}
|
||||||
|
|
||||||
if (!hdr->isResponse) {
|
if (hdr->isResponse == false) {
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
case ICLASS:
|
case ICLASS:
|
||||||
annotateIclass(explanation, sizeof(explanation), frame, data_len);
|
annotateIclass(explanation, sizeof(explanation), frame, data_len);
|
||||||
|
@ -385,15 +395,6 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
case LTO:
|
case LTO:
|
||||||
annotateLTO(explanation, sizeof(explanation), frame, data_len);
|
annotateLTO(explanation, sizeof(explanation), frame, data_len);
|
||||||
break;
|
break;
|
||||||
case PROTO_HITAG1:
|
|
||||||
annotateHitag1(explanation, sizeof(explanation), frame, data_len);
|
|
||||||
break;
|
|
||||||
case PROTO_HITAG2:
|
|
||||||
annotateHitag2(explanation, sizeof(explanation), frame, data_len);
|
|
||||||
break;
|
|
||||||
case PROTO_HITAGS:
|
|
||||||
annotateHitagS(explanation, sizeof(explanation), frame, data_len);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -402,19 +403,19 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
int num_lines = MIN((data_len - 1) / 18 + 1, 18);
|
int num_lines = MIN((data_len - 1) / 18 + 1, 18);
|
||||||
for (int j = 0; j < num_lines ; j++) {
|
for (int j = 0; j < num_lines ; j++) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
|
|
||||||
uint32_t time1 = hdr->timestamp - first_hdr->timestamp;
|
uint32_t time1 = hdr->timestamp - first_hdr->timestamp;
|
||||||
uint32_t time2 = end_of_transmission_timestamp - first_hdr->timestamp;
|
uint32_t time2 = end_of_transmission_timestamp - first_hdr->timestamp;
|
||||||
if (prev_eot) {
|
if (prev_eot) {
|
||||||
time1 = hdr->timestamp - previous_end_of_transmission_timestamp;
|
time1 = hdr->timestamp - previous_end_of_transmission_timestamp;
|
||||||
time2 = duration;
|
time2 = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_us) {
|
if (use_us) {
|
||||||
PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |%-72s | %s| %s",
|
PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |%-72s | %s| %s",
|
||||||
(float)time1/13.56,
|
(float)time1/13.56,
|
||||||
(float)time2/13.56,
|
(float)time2/13.56,
|
||||||
(hdr->isResponse ? "Tag" : "Rdr"),
|
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||||
line[j],
|
line[j],
|
||||||
(j == num_lines - 1) ? crc : " ",
|
(j == num_lines - 1) ? crc : " ",
|
||||||
(j == num_lines - 1) ? explanation : ""
|
(j == num_lines - 1) ? explanation : ""
|
||||||
|
@ -423,12 +424,12 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-72s | %s| %s",
|
PrintAndLogEx(NORMAL, " %10u | %10u | %s |%-72s | %s| %s",
|
||||||
(hdr->timestamp - first_hdr->timestamp),
|
(hdr->timestamp - first_hdr->timestamp),
|
||||||
(end_of_transmission_timestamp - first_hdr->timestamp),
|
(end_of_transmission_timestamp - first_hdr->timestamp),
|
||||||
(hdr->isResponse ? "Tag" : "Rdr"),
|
(hdr->isResponse ? "Tag" : _YELLOW_("Rdr")),
|
||||||
line[j],
|
line[j],
|
||||||
(j == num_lines - 1) ? crc : " ",
|
(j == num_lines - 1) ? crc : " ",
|
||||||
(j == num_lines - 1) ? explanation : ""
|
(j == num_lines - 1) ? explanation : ""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, " | | |%-72s | %s| %s",
|
PrintAndLogEx(NORMAL, " | | |%-72s | %s| %s",
|
||||||
|
@ -442,7 +443,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
if (protocol == PROTO_MIFARE) {
|
if (protocol == PROTO_MIFARE) {
|
||||||
if (DecodeMifareData(frame, data_len, parityBytes, hdr->isResponse, mfData, &mfDataLen)) {
|
if (DecodeMifareData(frame, data_len, parityBytes, hdr->isResponse, mfData, &mfDataLen)) {
|
||||||
memset(explanation, 0x00, sizeof(explanation));
|
memset(explanation, 0x00, sizeof(explanation));
|
||||||
if (!hdr->isResponse) {
|
if (hdr->isResponse == false) {
|
||||||
annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen);
|
annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen);
|
||||||
}
|
}
|
||||||
uint8_t crcc = iso14443A_CRC_check(hdr->isResponse, mfData, mfDataLen);
|
uint8_t crcc = iso14443A_CRC_check(hdr->isResponse, mfData, mfDataLen);
|
||||||
|
@ -457,11 +458,11 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
|
||||||
return traceLen;
|
return traceLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showWaitCycles && !hdr->isResponse && next_record_is_response(tracepos, trace)) {
|
if (showWaitCycles && hdr->isResponse == false && next_record_is_response(tracepos, trace)) {
|
||||||
|
|
||||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
|
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): " _YELLOW_("%d"),
|
||||||
(end_of_transmission_timestamp - first_hdr->timestamp),
|
(end_of_transmission_timestamp - first_hdr->timestamp),
|
||||||
(next_hdr->timestamp - first_hdr->timestamp),
|
(next_hdr->timestamp - first_hdr->timestamp),
|
||||||
" ",
|
" ",
|
||||||
|
@ -534,10 +535,10 @@ static int SanityOfflineCheck( bool useTraceBuffer ){
|
||||||
|
|
||||||
static int CmdTraceLoad(const char *Cmd) {
|
static int CmdTraceLoad(const char *Cmd) {
|
||||||
|
|
||||||
char filename[FILE_PATH_SIZE];
|
|
||||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||||
if (strlen(Cmd) < 1 || (strlen(Cmd) == 1 && cmdp == 'h')) return usage_trace_load();
|
if (strlen(Cmd) < 1 || (strlen(Cmd) == 1 && cmdp == 'h')) return usage_trace_load();
|
||||||
|
|
||||||
|
char filename[FILE_PATH_SIZE];
|
||||||
param_getstr(Cmd, 0, filename, sizeof(filename));
|
param_getstr(Cmd, 0, filename, sizeof(filename));
|
||||||
|
|
||||||
if (g_trace)
|
if (g_trace)
|
||||||
|
@ -557,6 +558,9 @@ static int CmdTraceLoad(const char *Cmd) {
|
||||||
|
|
||||||
static int CmdTraceSave(const char *Cmd) {
|
static int CmdTraceSave(const char *Cmd) {
|
||||||
|
|
||||||
|
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||||
|
if (strlen(Cmd) < 1 || (strlen(Cmd) == 1 && cmdp == 'h')) return usage_trace_save();
|
||||||
|
|
||||||
if (g_traceLen == 0) {
|
if (g_traceLen == 0) {
|
||||||
download_trace();
|
download_trace();
|
||||||
}
|
}
|
||||||
|
@ -567,9 +571,6 @@ static int CmdTraceSave(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char filename[FILE_PATH_SIZE];
|
char filename[FILE_PATH_SIZE];
|
||||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
|
||||||
if (strlen(Cmd) < 1 || (strlen(Cmd) == 1 && cmdp == 'h')) return usage_trace_save();
|
|
||||||
|
|
||||||
param_getstr(Cmd, 0, filename, sizeof(filename));
|
param_getstr(Cmd, 0, filename, sizeof(filename));
|
||||||
saveFile(filename, ".trace", g_trace, g_traceLen);
|
saveFile(filename, ".trace", g_trace, g_traceLen);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -697,7 +698,7 @@ int CmdTraceList(const char *Cmd) {
|
||||||
|
|
||||||
if (protocol == THINFILM) {
|
if (protocol == THINFILM) {
|
||||||
if (use_us)
|
if (use_us)
|
||||||
PrintAndLogEx(INFO, _YELLOW_("Thinfilm") " - all times are in microseconds");
|
PrintAndLogEx(INFO, _YELLOW_("Thinfilm") " - all times are in microseconds");
|
||||||
else
|
else
|
||||||
PrintAndLogEx(INFO, _YELLOW_("Thinfilm") " - all times are in carrier periods (1/13.56MHz)");
|
PrintAndLogEx(INFO, _YELLOW_("Thinfilm") " - all times are in carrier periods (1/13.56MHz)");
|
||||||
}
|
}
|
||||||
|
@ -751,7 +752,7 @@ int CmdTraceList(const char *Cmd) {
|
||||||
if (use_relative) {
|
if (use_relative) {
|
||||||
prev_EOT = &previous_EOT;
|
prev_EOT = &previous_EOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tracepos < g_traceLen) {
|
while (tracepos < g_traceLen) {
|
||||||
tracepos = printTraceLine(tracepos, g_traceLen, g_trace, protocol, showWaitCycles, markCRCBytes, prev_EOT, use_us);
|
tracepos = printTraceLine(tracepos, g_traceLen, g_trace, protocol, showWaitCycles, markCRCBytes, prev_EOT, use_us);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue