fix some SE / SIO ends with 0x05 , 0x00 only

This commit is contained in:
iceman1001 2022-07-23 18:08:33 +02:00
commit 3001e2edce

View file

@ -2476,13 +2476,17 @@ static int CmdHFiClass_loclass(const char *Cmd) {
static void detect_credential(uint8_t *data, bool *legacy, bool *se, bool *sr) { static void detect_credential(uint8_t *data, bool *legacy, bool *se, bool *sr) {
bool r1 = !memcmp(data + (5 * 8), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8); bool r1 = !memcmp(data + (5 * 8), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8);
uint8_t pattern[] = {0x05, 0x00, 0x05, 0x00};
bool r2 = byte_strstr(data + (11 * 8), 6 * 8, pattern, sizeof(pattern)) != -1; uint8_t pattern_se[] = {0x05, 0x00};
bool r2 = byte_strstr(data + (6 * 8), 6 * 8, pattern_se, sizeof(pattern_se)) != -1;
uint8_t pattern_sr[] = {0x05, 0x00, 0x05, 0x00};
bool r3 = byte_strstr(data + (11 * 8), 6 * 8, pattern_sr, sizeof(pattern_sr)) != -1;
*legacy = (r1) && (data[6 * 8] != 0x30); *legacy = (r1) && (data[6 * 8] != 0x30);
*se = (r2) && (data[6 * 8] == 0x30); *se = (r2) && (data[6 * 8] == 0x30);
*sr = (r2) && (data[10 * 8] == 0x30); *sr = (r3) && (data[10 * 8] == 0x30);
r1 = NULL, r2 = NULL; r1 = NULL, r2 = NULL, r3 = NULL;
} }
// print ASN1 decoded array in TLV view // print ASN1 decoded array in TLV view
@ -2491,22 +2495,29 @@ static void printIclassSIO(uint8_t *iclass_dump) {
bool isLegacy, isSE, isSR; bool isLegacy, isSE, isSR;
detect_credential(iclass_dump, &isLegacy, &isSE, &isSR); detect_credential(iclass_dump, &isLegacy, &isSE, &isSR);
int dlen = 0;
uint8_t *sio_start; uint8_t *sio_start;
if (isSE) { if (isSE) {
sio_start = iclass_dump + (6 * 8);
} else if (isSR) {
sio_start = iclass_dump + (10 * 8);
} else {
return;
}
uint8_t pattern[] = {0x05, 0x00, 0x05, 0x00}; sio_start = iclass_dump + (6 * 8);
int dlen = byte_strstr(sio_start, 8 * 8, pattern, sizeof(pattern)); uint8_t pattern_se[] = {0x05, 0x00};
dlen = byte_strstr(sio_start, 8 * 8, pattern_se, sizeof(pattern_se));
if (dlen == -1) { if (dlen == -1) {
return; return;
} }
dlen += sizeof(pattern_se);
} else if (isSR) {
dlen += sizeof(pattern); sio_start = iclass_dump + (10 * 8);
uint8_t pattern_sr[] = {0x05, 0x00, 0x05, 0x00};
dlen = byte_strstr(sio_start, 8 * 8, pattern_sr, sizeof(pattern_sr));
if (dlen == -1) {
return;
}
dlen += sizeof(pattern_sr);
} else {
return;
}
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "---------------------------- " _CYAN_("SIO - RAW") " ----------------------------"); PrintAndLogEx(INFO, "---------------------------- " _CYAN_("SIO - RAW") " ----------------------------");
@ -2515,7 +2526,6 @@ static void printIclassSIO(uint8_t *iclass_dump) {
PrintAndLogEx(INFO, "------------------------- " _CYAN_("SIO - ASN1 TLV") " --------------------------"); PrintAndLogEx(INFO, "------------------------- " _CYAN_("SIO - ASN1 TLV") " --------------------------");
asn1_print(sio_start, dlen, " "); asn1_print(sio_start, dlen, " ");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
} }
void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize, bool dense_output) { void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t endblock, size_t filesize, bool dense_output) {
@ -2686,7 +2696,8 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e
// in a repeating block, but the next block doesn't match anymore, or we're at the end block // in a repeating block, but the next block doesn't match anymore, or we're at the end block
in_repeated_block = false; in_repeated_block = false;
} }
if (!in_repeated_block) {
if (in_repeated_block == false) {
PrintAndLogEx(INFO, PrintAndLogEx(INFO,
"%3d/0x%02X | %s | %s | %s ", "%3d/0x%02X | %s | %s | %s ",
i, i,