From aa55bfca0e115926b545b9356e765033a518176b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20V=C3=A1zquez=20Blanco?= Date: Wed, 21 Oct 2026 13:21:17 +0200 Subject: [PATCH] HF 14a: Only hint EMV when correct AID is found --- CHANGELOG.md | 1 + client/resources/aidlist.json | 4 ++-- client/src/aidsearch.c | 4 ++++ client/src/aidsearch.h | 1 + client/src/cmdhf14a.c | 12 ++++++++++-- client/src/cmdhf14a.h | 2 +- client/src/cmdhfseos.c | 2 +- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd05b94d..ecd958c9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `hf seos managekeys -p` - key table columns stay aligned for slots 10 and up (@antoniovazquezblanco) - Fixed `aidlist.json` - uppercased the SEOS, TeslaDAP and LA Tap AIDs (@antoniovazquezblanco) - Changed `hf seos` - a failed MAC check with an empty privacy key slot now says so (@antoniovazquezblanco) +- Fixed `hf 14a info -s` - only hints `emv reader` when an EMV application is found, not for any AID (@antoniovazquezblanco) - Improved PM5 nonce-acquisition throughput for mfc by replacing the fixed 68-pair cap with a 2900 ms target budget (@nip-was-here) - Fixed PM5 tick-count reads across RTC second rollovers to prevent false receive timeouts - Fixed iso14443a - reject incomplete encrypted nonce frames instead of delaying nested authentication on PM5 (@nip-was-here) diff --git a/client/resources/aidlist.json b/client/resources/aidlist.json index b4ecf0a6d..a7c98eebf 100644 --- a/client/resources/aidlist.json +++ b/client/resources/aidlist.json @@ -17,7 +17,7 @@ "Country": "United States", "Name": "EMV Payment System Environment - PSE (1PAY.SYS.DDF01)", "Description": "", - "Type": "" + "Type": "EMV" }, { "AID": "325041592E5359532E4444463031", @@ -25,7 +25,7 @@ "Country": "United States", "Name": "EMV Proximity Payment System Environment - PPSE (2PAY.SYS.DDF01)", "Description": "Visa payWave for Mobile", - "Type": "" + "Type": "EMV" }, { "AID": "44464D46412E44466172653234313031", diff --git a/client/src/aidsearch.c b/client/src/aidsearch.c index 60d2af202..ba78bba4f 100644 --- a/client/src/aidsearch.c +++ b/client/src/aidsearch.c @@ -125,6 +125,10 @@ bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) { return true; } +const char *AIDGetTypeFromElm(json_t *data) { + return jsonStrGet(data, "Type"); +} + bool AIDSeenBefore(json_t *root, const uint8_t *aid, size_t aidlen, size_t before_index) { if (root == NULL || aid == NULL || aidlen == 0) { return false; diff --git a/client/src/aidsearch.h b/client/src/aidsearch.h index ab09bbbf7..035cac3da 100644 --- a/client/src/aidsearch.h +++ b/client/src/aidsearch.h @@ -31,6 +31,7 @@ int PrintAIDDescriptionBuf(json_t *root, uint8_t *aid, size_t aidlen, bool verbo json_t *AIDSearchInit(bool verbose); json_t *AIDSearchGetElm(json_t *root, size_t elmindx); bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen); +const char *AIDGetTypeFromElm(json_t *data); bool AIDSeenBefore(json_t *root, const uint8_t *aid, size_t aidlen, size_t before_index); int AIDSearchFree(json_t *root); diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 2763e6de4..6df5b9daf 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -2935,7 +2935,8 @@ static void get_compact_tlv(uint8_t *d, uint8_t n) { } // selects every AID in aidlist.json, returns how many were found -int hf14a_aid_search(bool verbose) { +// emv_found (optional) is set when an EMV application answers +int hf14a_aid_search(bool verbose, bool *emv_found) { PrintAndLogEx(INFO, "-------------------- " _CYAN_("AID Search") " --------------------"); @@ -3024,6 +3025,11 @@ int hf14a_aid_search(bool verbose) { if (verbose) PrintAndLogEx(SUCCESS, "----------------------------------------------------"); found++; + + const char *type = AIDGetTypeFromElm(data); + if (emv_found && type && strcmp(type, "EMV") == 0) { + *emv_found = true; + } } } @@ -3517,7 +3523,9 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { } if (do_aid_search) { - if (hf14a_aid_search(verbose) > 0) { + bool emv_found = false; + hf14a_aid_search(verbose, &emv_found); + if (emv_found) { isEMV = true; } } diff --git a/client/src/cmdhf14a.h b/client/src/cmdhf14a.h index 6d2b8bd4f..9d9170bd5 100644 --- a/client/src/cmdhf14a.h +++ b/client/src/cmdhf14a.h @@ -88,7 +88,7 @@ int hf14a_getconfig(hf14a_config_t *config); int hf14a_setconfig(hf14a_config_t *config, bool verbose); int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search); int infoHF14A4Applications(bool verbose); -int hf14a_aid_search(bool verbose); +int hf14a_aid_search(bool verbose, bool *emv_found); const char *getTagInfo(uint8_t uid); int Hf14443_4aGetCardData(iso14a_card_select_t *card); int ExchangeAPDU14a(const uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen); diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 8b9b976f4..7aeae2980 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -1738,7 +1738,7 @@ static int seos_print_card(const uint8_t *custom_aid, int custom_aid_len) { } DropField(); - hf14a_aid_search(false); + hf14a_aid_search(false, NULL); return PM3_SUCCESS; }