Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1937,8 +1937,12 @@ static int CmdHFiClassELoad(const char *Cmd) {
}

if (verbose) {
print_picopass_header((picopass_hdr_t *) dump);
print_picopass_info((picopass_hdr_t *) dump);
if (bytes_read < sizeof(picopass_hdr_t)) {
PrintAndLogEx(FAILED, "Error, dump file is too small to be a valid iCLASS dump - bytes: %zu, expected at least: %zu", bytes_read, sizeof(picopass_hdr_t));
} else {
print_picopass_header((picopass_hdr_t *) dump);
print_picopass_info((picopass_hdr_t *) dump);
}
}

PrintAndLogEx(NORMAL, "");
Expand Down Expand Up @@ -2059,8 +2063,12 @@ static int CmdHFiClassEView(const char *Cmd) {
}

if (verbose) {
print_picopass_header((picopass_hdr_t *) dump);
print_picopass_info((picopass_hdr_t *) dump);
if (bytes < sizeof(picopass_hdr_t)) {
PrintAndLogEx(FAILED, "Error, only %u bytes downloaded, too small to be a valid iCLASS dump - expected at least: %zu", bytes, sizeof(picopass_hdr_t));
} else {
print_picopass_header((picopass_hdr_t *) dump);
print_picopass_info((picopass_hdr_t *) dump);
}
}

PrintAndLogEx(NORMAL, "");
Expand Down Expand Up @@ -2326,6 +2334,18 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
return res;
}

// Below (and in iclass_decode_credentials()) we unconditionally probe
// fixed offsets up through block 9 -- app_issuer_area (block 5), the
// aa1_encryption flag and block 7 in iclass_decode_credentials(), and
// the block 9 PACS/PIN check here -- regardless of what applimit or
// decryptedlen/8 say the "real" block count is. All 10 blocks (0-9)
// must actually be present in the loaded file before any of that runs.
if (decryptedlen < 10 * PICOPASS_BLOCK_SIZE) {
PrintAndLogEx(FAILED, "Error, dump file is too small - bytes: %zu, expected at least: %d", decryptedlen, 10 * PICOPASS_BLOCK_SIZE);
free(decrypted);
return PM3_EFILE;
}

have_file = true;
}

Expand Down
Loading