From ccef511dece359aa427407bd427411901bc3c075 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 20 Mar 2025 20:01:04 +0100 Subject: [PATCH] updated trace list -t seos to also annotate ISO7816 --- CHANGELOG.md | 1 + client/src/cmdhflist.c | 21 +++++++++++++++++---- client/src/cmdhflist.h | 2 +- client/src/cmdtrace.c | 10 +++++----- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b486f83fc..90332f164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Changed `trace list -t seos` - now annotate ISO7816 (@iceman1001) - Updated aid and mad json files (@iceman1001) - Changed `hf 14a apdu` - now can be interrupted and dynamically adds time (@iceman1001) - Changed `trace list -t` - shortend the hitag types (@iceman1001) diff --git a/client/src/cmdhflist.c b/client/src/cmdhflist.c index 2753f2c79..c91153218 100644 --- a/client/src/cmdhflist.c +++ b/client/src/cmdhflist.c @@ -799,14 +799,20 @@ void annotateTopaz(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { } // iso 7816-3 -void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { +void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) { - if (cmdsize < 2) + if (cmdsize < 2) { return; + } + + if (is_response) { + return; + } // S-block - if ((cmd[0] & 0xC0) && (cmdsize == 3)) { - switch ((cmd[0] & 0x3f)) { + if ((cmd[0] & 0xC0) && ((cmdsize == 3) || (cmdsize == 4))) { + + switch ((cmd[0] & 0x3F)) { case 0x00 : snprintf(exp, size, "S-block RESYNCH req"); break; @@ -831,6 +837,9 @@ void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { case 0x23 : snprintf(exp, size, "S-block WTX resp"); break; + case 0x32: + snprintf(exp, size, "S-block WTX req"); + break; default : snprintf(exp, size, "S-block"); break; @@ -845,6 +854,7 @@ void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { } // I-block else { + int pos = 0; switch (cmd[0]) { case 2: @@ -858,6 +868,7 @@ void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { pos = 3; break; } + switch (cmd[pos]) { case ISO7816_READ_BINARY: snprintf(exp, size, "READ BIN"); @@ -1788,6 +1799,8 @@ void annotateSeos(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is // it's basically a ISO14443a tag, so try annotation from there if (applyIso14443a(exp, size, cmd, cmdsize, false) != PM3_SUCCESS) { + annotateIso7816(exp, size, cmd, cmdsize, isResponse); + int pos = 0; switch (cmd[0]) { case 0: diff --git a/client/src/cmdhflist.h b/client/src/cmdhflist.h index 98bf27318..0f8c526b3 100644 --- a/client/src/cmdhflist.h +++ b/client/src/cmdhflist.h @@ -55,7 +55,7 @@ void annotateIso15693(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); void annotateTopaz(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); void annotateLegic(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); -void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); +void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response); void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); void annotateIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response); void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize); diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index c217f3e80..a9c637149 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -840,7 +840,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr annotateTopaz(explanation, sizeof(explanation), frame, data_len); break; case ISO_7816_4: - annotateIso7816(explanation, sizeof(explanation), frame, data_len); + annotateIso7816(explanation, sizeof(explanation), frame, data_len, hdr->isResponse); break; case ISO_15693: annotateIso15693(explanation, sizeof(explanation), frame, data_len); @@ -1070,13 +1070,13 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr } if (use_us) { - PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |fdt (Frame Delay Time): " _YELLOW_("%.1f"), + PrintAndLogEx(NORMAL, " %10.1f | %10.1f | %s |Frame Delay Time " _CYAN_("%.1f"), (float)time1 / 13.56, (float)time2 / 13.56, " ", (float)(next_hdr->timestamp - end_of_transmission_timestamp) / 13.56); } else { - PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): " _YELLOW_("%d"), + PrintAndLogEx(NORMAL, " %10u | %10u | %s |Frame Delay Time " _CYAN_("%d"), time1, time2, " ", @@ -1317,7 +1317,7 @@ int CmdTraceList(const char *Cmd) { "trace list -t 14b -> interpret as " _YELLOW_("ISO14443-B") "\n" "trace list -t 15 -> interpret as " _YELLOW_("ISO15693") "\n" "trace list -t 7816 -> interpret as " _YELLOW_("ISO7816-4") "\n" - "trace list -t cryptorf -> interpret as " _YELLOW_("CryptoRF") "\n\n" + "trace list -t cryptorf -> interpret as " _YELLOW_("CryptoRF") "\n" "trace list -t des -> interpret as " _YELLOW_("MIFARE DESFire") "\n" "trace list -t felica -> interpret as " _YELLOW_("ISO18092 / FeliCa") "\n" "trace list -t ht1 -> interpret as " _YELLOW_("Hitag 1") "\n" @@ -1348,7 +1348,7 @@ int CmdTraceList(const char *Cmd) { arg_lit0("u", NULL, "display times in microseconds instead of clock cycles"), arg_lit0("x", NULL, "show hexdump to convert to pcap(ng)\n" " or to import into Wireshark using encapsulation type \"ISO 14443\""), - arg_str0("t", "type", NULL, "protocol to annotate the trace"), + arg_str0("t", "type", "", "protocol to annotate the trace"), arg_str0("f", "file", "", "filename of dictionary"), arg_param_end };