From 75d0601318066c87127d48087b9b8e1d0af7ff88 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 5 Dec 2023 12:08:09 +0100 Subject: [PATCH] fix decrypted output --- client/src/cmdtrace.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index 9182608ae..aa1724a03 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -912,22 +912,32 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr size_t mfDataLen = 0; if (DecodeMifareData(frame, data_len, parityBytes, hdr->isResponse, mfData, &mfDataLen, mfDicKeys, mfDicKeysCount)) { memset(explanation, 0x00, sizeof(explanation)); - annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen, hdr->isResponse); + + if (protocol == PROTO_MFPLUS) { + annotateMfPlus(explanation, sizeof(explanation), mfData, mfDataLen); + } else { + annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen, hdr->isResponse); + } uint8_t crcc = iso14443A_CRC_check(hdr->isResponse, mfData, mfDataLen); - //iceman: colorise crc bytes here will need a refactor of code from above. - if (hdr->isResponse) { - PrintAndLogEx(NORMAL, " | | * |%-*s | %-4s| %s", - str_padder, - sprint_hex_inrow_spaces(mfData, mfDataLen, 2), - (crcc == 0 ? _RED_(" !! ") : (crcc == 1 ? _GREEN_(" ok ") : " ")), - explanation); - } else { - PrintAndLogEx(NORMAL, " | | * |" _YELLOW_("%-*s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"), - str_padder, - sprint_hex_inrow_spaces(mfData, mfDataLen, 2), - (crcc == 0 ? _RED_(" !! ") : (crcc == 1 ? _GREEN_(" ok ") : " ")), - explanation); + // iceman: colorise crc bytes here will need a refactor of code from above. + for (int j = 0; j < mfDataLen; j += TRACE_MAX_HEX_BYTES) { + + int plen = MIN((mfDataLen - j), TRACE_MAX_HEX_BYTES); + + if (hdr->isResponse) { + PrintAndLogEx(NORMAL, " | | * |%-*s | %-4s| %s", + str_padder, + sprint_hex_inrow_spaces(mfData + j, plen, 2), + (crcc == 0 ? _RED_(" !! ") : (crcc == 1 ? _GREEN_(" ok ") : " ")), + explanation); + } else { + PrintAndLogEx(NORMAL, " | | * |" _YELLOW_("%-*s")" | " _YELLOW_("%s") "| " _YELLOW_("%s"), + str_padder, + sprint_hex_inrow_spaces(mfData + j, plen, 2), + (crcc == 0 ? _RED_(" !! ") : (crcc == 1 ? _GREEN_(" ok ") : " ")), + explanation); + } } } }