From b3781a7bbcd73d5c046e66690de8b5d2d93ae5c0 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Tue, 30 Jun 2026 23:41:44 +0300 Subject: [PATCH] Update ASK CTS general info output --- armsrc/iso14443b.c | 2 +- client/src/cmdhf14b.c | 38 ++++++++++++++++++++++++++++++++++---- include/protocols.h | 11 +++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index 579b06391..13562543e 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -1818,7 +1818,7 @@ static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) { } if (card) { - // pc. fc Product code, Facility code + // REQT response payload: Product code, FAB code card->pc = r[0]; card->fc = r[1]; } diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 70f70db30..5a16698ab 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -48,6 +48,9 @@ // for static arrays #define ST25TB_SR_BLOCK_SIZE 4 +#define CTS_BLOCK_SIZE 2 +#define CTS256_BLOCK_COUNT 16 +#define CTS512_BLOCK_COUNT 32 // SR memory sizes @@ -757,17 +760,44 @@ static void print_st_general_info(uint8_t *data, uint8_t len) { PrintAndLogEx(SUCCESS, "Chip: %02X, " _YELLOW_("%s"), chipid, get_st_chip_model(chipid)); } +typedef struct { + uint8_t product_code; + const char *name; + uint8_t block_count; +} cts_product_info_t; + +static const cts_product_info_t cts_products[] = { + {ASK_CTS_PRODUCT_CODE_CTS256B, "CTS256B", CTS256_BLOCK_COUNT}, + {ASK_CTS_PRODUCT_CODE_CTS512B, "CTS512B", CTS512_BLOCK_COUNT}, +}; + +static const cts_product_info_t cts_unknown_product = { + 0x00, + "unknown", + CTS256_BLOCK_COUNT, +}; + +static const cts_product_info_t *get_cts_product_info(uint8_t product_code) { + for (size_t i = 0; i < ARRAYLEN(cts_products); i++) { + if (cts_products[i].product_code == product_code) { + return &cts_products[i]; + } + } + return &cts_unknown_product; +} + // print UID info from ASK CT chips static void print_ct_general_info(void *vcard) { iso14b_cts_card_select_t card; memcpy(&card, (iso14b_cts_card_select_t *)vcard, sizeof(iso14b_cts_card_select_t)); uint32_t uid32 = MemLeToUint4byte(card.uid); + const cts_product_info_t *product_info = get_cts_product_info(card.pc); PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(SUCCESS, "ASK C-Ticket"); - PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s") " ( " _YELLOW_("%010u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32); - PrintAndLogEx(SUCCESS, " Product Code: %02X", card.pc); - PrintAndLogEx(SUCCESS, " Facility Code: %02X", card.fc); + PrintAndLogEx(INFO, "--- " _CYAN_("ASK CTS / C-ticket") " -----------------------"); + PrintAndLogEx(SUCCESS, " UID : " _GREEN_("%s") " ( " _YELLOW_("%010u") " )", sprint_hex(card.uid, sizeof(card.uid)), uid32); + PrintAndLogEx(SUCCESS, " Product Code : %02X ( " _YELLOW_("%s") " )", card.pc, product_info->name); + PrintAndLogEx(SUCCESS, " Fab Code : %02X", card.fc); PrintAndLogEx(NORMAL, ""); } diff --git a/include/protocols.h b/include/protocols.h index 37378d56e..d70176434 100644 --- a/include/protocols.h +++ b/include/protocols.h @@ -414,10 +414,13 @@ ISO 7816-4 Basic interindustry commands. For command APDU's. #define ASK_REQT 0x10 #define ASK_IDENTIFY 0x0F #define ASK_SELECT 0x9F -#define ASK_MULTREAD (0x1 << 4) // High nibble -#define ASK_UPDATE (0x3 << 4) // High nibble -#define ASK_WRITE (0x5 << 4) // High nibble -#define ASK_READ (0x6 << 4) // High nibble +#define ASK_CTS_PRODUCT_CODE_CTS256B 0x50 +#define ASK_CTS_PRODUCT_CODE_CTS512B 0x60 +#define ASK_BLOCK_ADDRESS_MASK 0x1F +#define ASK_MULTREAD (0x1 << 5) // 001 AAAAA +#define ASK_UPDATE (0x3 << 5) // 011 AAAAA +#define ASK_WRITE (0x5 << 5) // 101 AAAAA +#define ASK_READ (0x6 << 5) // 110 AAAAA #define ASK_DESACTIVATE 0xF0