From 5e093962bcb5b31ce7135a69d3f0fee958a3a8c0 Mon Sep 17 00:00:00 2001 From: kormax Date: Thu, 11 Aug 2022 19:25:35 +0300 Subject: [PATCH] improve ecp2 annotations to support varying length, append terminal type to annotation --- client/src/cmdhflist.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhflist.c b/client/src/cmdhflist.c index b33cd37bf..d667b981f 100644 --- a/client/src/cmdhflist.c +++ b/client/src/cmdhflist.c @@ -182,14 +182,29 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i } if (cmdsize >= 7 && cmd[0] == ECP_HEADER) { - // Second byte of ECP frame indicates its version - // Version 0x01 payload is 7 bytes long (including crc) - // Version 0x02 payload is 15 bytes long (including crc) + // Byte 0 is a header + // Byte 1 indicates format version + // Version 0x01 format is 7 bytes long (including crc) + // Version 0x02 format is at least 7 bytes long (including crc). First 4 bits of byte 2 define extra payload length if (cmd[1] == 0x01 && cmdsize == 7) { snprintf(exp, size, "ECP1"); return PM3_SUCCESS; - } else if (cmd[1] == 0x02 && cmdsize == 15) { - snprintf(exp, size, "ECP2"); + } else if (cmd[1] == 0x02 && cmdsize == (cmd[2] & 0x0f) + 7) { + // Byte 3 is the reader type + switch(cmd[3]) { + case 0x01: + snprintf(exp, size, "ECP2 (Transit)"); + break; + case 0x02: + snprintf(exp, size, "ECP2 (Access)"); + break; + case 0x03: + snprintf(exp, size, "ECP2 (Identity)"); + break; + default: + snprintf(exp, size, "ECP2"); + break; + } return PM3_SUCCESS; } }