From f78890cb03ee5a398fe57d6ccf092f75a8cdd6eb Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 27 Aug 2026 14:25:40 +0200 Subject: [PATCH] no table when no AID found --- client/src/emv/cmdemv.c | 10 ++++++++++ client/src/emv/emvcore.c | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client/src/emv/cmdemv.c b/client/src/emv/cmdemv.c index 7309d30fe..36a7eec74 100644 --- a/client/src/emv/cmdemv.c +++ b/client/src/emv/cmdemv.c @@ -799,6 +799,16 @@ static int CmdEMVSearch(const char *Cmd) { struct tlvdb *t = tlvdb_fixed(1, strlen(al), (const unsigned char *)al); if (EMVSearch(channel, activateField, leaveSignalON, decodeTLV, t, false)) { + + PrintAndLogEx(FAILED, "Search failed, no answer from the card"); + + // Without activation the ARM never reads the ATR, so it does not know + // which protocols the card offers and cannot redirect a T=0 request to + // a T=1 only card. That used to end here without a word. + if ((channel == CC_CONTACT) && (activateField == false)) { + PrintAndLogEx(HINT, "Hint: the card is activated by `" _YELLOW_("-s") "`, try `" _YELLOW_("emv search -w -s") "`"); + } + tlvdb_free(t); SetAPDULogging(false); return PM3_ERFTRANS; diff --git a/client/src/emv/emvcore.c b/client/src/emv/emvcore.c index 985c3b769..24671a068 100644 --- a/client/src/emv/emvcore.c +++ b/client/src/emv/emvcore.c @@ -266,6 +266,11 @@ void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv) { ttmp = tlvdb_find_next(ttmp, 0x6f); } + if (n == 0) { + PrintAndLogEx(INFO, "No applications found"); + return; + } + size_t w_aid = strlen("AID"); size_t w_prio = strlen("Priority"); size_t w_name = strlen("Name"); @@ -289,10 +294,6 @@ void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv) { (int)w_aid, "AID", (int)w_prio, "Priority", (int)w_name, "Name"); PrintAndLogEx(INFO, "%s", rule); - if (n == 0) { - PrintAndLogEx(INFO, "| %-*s |", (int)(w_aid + w_prio + w_name + 6), "none"); - } - for (size_t i = 0; i < n; i++) { PrintAndLogEx(INFO, "| " _YELLOW_("%-*s") " | %-*s | " _CYAN_("%-*s") " |", (int)w_aid, rows[i].aid,