diff --git a/client/src/cmdhfgallagher.c b/client/src/cmdhfgallagher.c index f9765f37f..5e653708b 100644 --- a/client/src/cmdhfgallagher.c +++ b/client/src/cmdhfgallagher.c @@ -771,7 +771,12 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q // Read & decode credentials GallagherCredentials_t creds = {0}; res = hfgal_read_creds_app(&dctx, current_aid, site_key, &creds, verbose); - HFGAL_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials"); + if (res != PM3_SUCCESS && res != HFGAL_AUTH_FAIL) + HFGAL_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials"); + if (res == HFGAL_AUTH_FAIL) { + PrintAndLogEx(WARNING, "Invalid site key for AID %06X", current_aid); + continue; + } PrintAndLogEx(SUCCESS, "GALLAGHER (AID %06X) - Region: " _GREEN_("%u") ", Facility: " _GREEN_("%u") ", Card No.: " _GREEN_("%u") ", Issue Level: " _GREEN_("%u"), current_aid, diff --git a/client/src/cmdhfgallagher.h b/client/src/cmdhfgallagher.h index c4ed31784..087ad9364 100644 --- a/client/src/cmdhfgallagher.h +++ b/client/src/cmdhfgallagher.h @@ -40,4 +40,8 @@ int hfgal_diversify_key(uint8_t *site_key, uint8_t *uid, uint8_t uid_len, #define HFGAL_RET_IF_ERR_WITH_MSG(res, ...) if (res != PM3_SUCCESS) { PrintAndLogEx(ERR, __VA_ARGS__); return res; } #define HFGAL_RET_IF_ERR_MAYBE_MSG(res, verbose, ...) if (res != PM3_SUCCESS) { if (verbose) PrintAndLogEx(ERR, __VA_ARGS__); return res; } +// The response code when an invalid key is used for authentication +// Returned in /client/src/mifare/desfirecore.c, line 1185 (if DesfireExchangeEx fails) +#define HFGAL_AUTH_FAIL 7 + #endif