diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 4e808a969..536fa2ce3 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -442,11 +442,12 @@ static bool get_14b_UID(uint8_t *d, iso14b_type_t *found_type) { memcpy(d, resp.data.asBytes, sizeof(iso14b_card_select_t)); iso14b_card_select_t *card = (iso14b_card_select_t*)d; - uint8_t empty[] = "\x00\0x00\x00\0x00\x00\0x00\x00\0x00"; + uint8_t empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; if (memcmp(card->uid, empty, card->uidlen)) { - *found_type = ISO14B_SR; - return true; + return false; } + *found_type = ISO14B_SR; + return true; } } @@ -918,6 +919,11 @@ static bool HF14B_ST_Info(bool verbose, bool do_aid_search) { if (status < 0) return false; + uint8_t empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + if ((card.uidlen < 8) || (memcmp(card.uid, empty, card.uidlen) == 0)) { + return false; + } + print_st_general_info(card.uid, card.uidlen); if (do_aid_search) { @@ -969,13 +975,14 @@ static bool HF14B_st_reader(bool verbose) { iso14b_card_select_t card; memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t)); - uint8_t empty[] = "\x00\0x00\x00\0x00\x00\0x00\x00\0x00"; + uint8_t empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + if ((card.uidlen < 8) || (memcmp(card.uid, empty, card.uidlen) == 0)) { + return false; + } + int status = resp.oldarg[0]; switch (status) { case 0: - if (memcmp(card.uid, empty, card.uidlen) == 0) { - return false; - } print_st_general_info(card.uid, card.uidlen); return true; case -1: @@ -1011,12 +1018,18 @@ static bool HF14B_std_reader(bool verbose) { } return false; } - int status = resp.oldarg[0]; + + iso14b_card_select_t card; + memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t)); + + uint8_t empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + if (memcmp(card.uid, empty, card.uidlen) == 0) { + return false; + } + switch (status) { case 0: { - iso14b_card_select_t card; - memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t)); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, " UID : " _GREEN_("%s"), sprint_hex(card.uid, card.uidlen)); PrintAndLogEx(SUCCESS, " ATQB : %s", sprint_hex(card.atqb, sizeof(card.atqb))); @@ -1111,13 +1124,13 @@ static bool HF14B_other_reader(bool verbose) { if (status == 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "unknown tag type answered to a 0x000b3f80 command ans:"); + PrintAndLogEx(SUCCESS, "unknown tag type answered to a " _YELLOW_("0x000b3f80") " command ans:"); switch_off_field_14b(); free(packet); return true; } else if (status > 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "unknown tag type answered to a 0x000b3f80 command ans:"); + PrintAndLogEx(SUCCESS, "unknown tag type answered to a " _YELLOW_("0x000b3f80") " command ans:"); PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.data.asBytes, status)); switch_off_field_14b(); free(packet); @@ -1141,13 +1154,13 @@ static bool HF14B_other_reader(bool verbose) { if (status == 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "Unknown tag type answered to a 0x0A command ans:"); + PrintAndLogEx(SUCCESS, "Unknown tag type answered to a " _YELLOW_("0x0A") " command ans:"); switch_off_field_14b(); free(packet); return true; } else if (status > 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "unknown tag type answered to a 0x0A command ans:"); + PrintAndLogEx(SUCCESS, "unknown tag type answered to a " _YELLOW_("0x0A") " command ans:"); PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.data.asBytes, status)); switch_off_field_14b(); free(packet); @@ -1170,12 +1183,12 @@ static bool HF14B_other_reader(bool verbose) { if (status == 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "Unknown tag type answered to a 0x0C command ans:"); + PrintAndLogEx(SUCCESS, "Unknown tag type answered to a " _YELLOW_("0x0C") " command ans:"); switch_off_field_14b(); return true; } else if (status > 0) { PrintAndLogEx(SUCCESS, "\n14443-3b tag found:"); - PrintAndLogEx(SUCCESS, "unknown tag type answered to a 0x0C command ans:"); + PrintAndLogEx(SUCCESS, "unknown tag type answered to a " _YELLOW_("0x0C") " command ans:"); PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.data.asBytes, status)); switch_off_field_14b(); return true;