From 215ac24edbc4464bb49c95e5e0e3fec9a5f8b164 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:32:35 +0200 Subject: [PATCH] Allow to detect which exact app implements AID via matching response data --- client/src/cmdhf14a.c | 43 +++++++++++++++++++++++++++++-------------- client/src/cmdhf14a.h | 2 ++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 2e12ce15e..a584fdbaf 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -233,17 +233,17 @@ const char *getTagInfo(uint8_t uid) { } static const hintAIDList_t hintAIDList[] = { - // AID, AID len, name, hint - how to use - { "\xA0\x00\x00\x06\x47\x2F\x00\x01", 8, "FIDO", "hf fido" }, - { "\xA0\x00\x00\x03\x08\x00\x00\x10\x00\x01\x00", 11, "PIV", "" }, - { "\xD2\x76\x00\x01\x24\x01", 8, "OpenPGP", "" }, - { "\x31\x50\x41\x59\x2E\x53\x59\x53\x2E\x44\x44\x46\x30\x31", 14, "EMV (pse)", "emv" }, - { "\x32\x50\x41\x59\x2E\x53\x59\x53\x2E\x44\x44\x46\x30\x31", 14, "EMV (ppse)", "emv" }, - { "\x41\x44\x20\x46\x31", 5, "CIPURSE", "hf cipurse" }, - { "\xA0\x00\x00\x09\x09\xAC\xCE\x55\x01", 9, "Aliro", "hf aliro" }, - { "\xd2\x76\x00\x00\x85\x01\x00", 7, "desfire", "hf mfdes" }, - { "\x4F\x53\x45\x2E\x56\x41\x53\x2E\x30\x31", 10, "OSE.VAS", "hf vas"}, - { "\xA0\x00\x00\x04\x76\xD0\x00\x01\x11", 9, "Google Smart Tap v2", "hf gst" }, + { "\xA0\x00\x00\x06\x47\x2F\x00\x01", 8, "", 0, "FIDO", "hf fido" }, + { "\xA0\x00\x00\x03\x08\x00\x00\x10\x00\x01\x00", 11, "", 0, "PIV", "" }, + { "\xD2\x76\x00\x01\x24\x01", 8, "", 0, "OpenPGP", "" }, + { "\x31\x50\x41\x59\x2E\x53\x59\x53\x2E\x44\x44\x46\x30\x31", 14, "", 0, "EMV (pse)", "emv" }, + { "\x32\x50\x41\x59\x2E\x53\x59\x53\x2E\x44\x44\x46\x30\x31", 14, "", 0, "EMV (ppse)", "emv" }, + { "\x41\x44\x20\x46\x31", 5, "", 0, "CIPURSE", "hf cipurse" }, + { "\xA0\x00\x00\x09\x09\xAC\xCE\x55\x01", 9, "", 0, "Aliro", "hf aliro" }, + { "\xd2\x76\x00\x00\x85\x01\x00", 7, "", 0, "desfire", "hf mfdes" }, + { "\x4F\x53\x45\x2E\x56\x41\x53\x2E\x30\x31", 10, "ApplePay", 8, "OSE.VAS (Apple Wallet)", "hf vas" }, + { "\x4F\x53\x45\x2E\x56\x41\x53\x2E\x30\x31", 10, "AndroidPay", 10, "OSE.VAS (Google Wallet)", "hf gst" }, + { "\xA0\x00\x00\x04\x76\xD0\x00\x01\x11", 9, "", 0, "Google Smart Tap v2", "hf gst" }, }; // iso14a apdu input frame length @@ -3407,6 +3407,18 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { return select_status; } +static bool hint_aid_match_select_response(const hintAIDList_t *entry, const uint8_t *select_response, size_t select_response_len) { + if (entry->select_response_match_length == 0) { + return true; + } + + if ((entry->select_response_match == NULL) || (select_response == NULL) || (select_response_len < entry->select_response_match_length)) { + return false; + } + + return byte_strstr(select_response, select_response_len, (const uint8_t *)entry->select_response_match, entry->select_response_match_length) != -1; +} + int infoHF14A4Applications(bool verbose) { bool cardFound[ARRAYLEN(hintAIDList)] = {0}; bool ActivateField = true; @@ -3421,6 +3433,10 @@ int infoHF14A4Applications(bool verbose) { break; if (sw == ISO7816_OK || sw == ISO7816_INVALID_DF || sw == ISO7816_FILE_TERMINATED) { + if (!hint_aid_match_select_response(&hintAIDList[i], result, resultlen)) { + continue; + } + if (!found) { if (verbose) PrintAndLogEx(INFO, "----------------- " _CYAN_("Short AID search") " -----------------"); @@ -3431,9 +3447,8 @@ int infoHF14A4Applications(bool verbose) { if (verbose) PrintAndLogEx(SUCCESS, "Application " _CYAN_("%s") " ( " _GREEN_("ok") " )", hintAIDList[i].desc); cardFound[i] = true; - } else { - if (verbose) - PrintAndLogEx(WARNING, "Application " _CYAN_("%s") " ( " _RED_("blocked") " )", hintAIDList[i].desc); + } else if (verbose) { + PrintAndLogEx(WARNING, "Application " _CYAN_("%s") " ( " _RED_("blocked") " )", hintAIDList[i].desc); } } } diff --git a/client/src/cmdhf14a.h b/client/src/cmdhf14a.h index 2e438a2d6..74e8a6685 100644 --- a/client/src/cmdhf14a.h +++ b/client/src/cmdhf14a.h @@ -32,6 +32,8 @@ typedef struct { typedef struct { const char *aid; const uint8_t aid_length; + const char *select_response_match; + const uint8_t select_response_match_length; const char *desc; const char *hint; } hintAIDList_t;