NFC: Display unread Mifare Classic bytes as ??

This commit is contained in:
TollyH 2024-01-18 21:47:38 +00:00
parent 027ea9ea36
commit 51f6dcffa4
No known key found for this signature in database
GPG Key ID: D44F46D2F84F54AC

View File

@ -22,9 +22,55 @@ void nfc_render_mf_classic_dump(const MfClassicData* data, FuriString* str) {
uint16_t total_blocks = mf_classic_get_total_block_num(data->type);
for(size_t i = 0; i < total_blocks; i++) {
for(size_t j = 0; j < sizeof(MfClassicBlock); j += 2) {
furi_string_cat_printf(
str, "%02X%02X ", data->block[i].data[j], data->block[i].data[j + 1]);
const uint8_t* block_data = data->block[i].data;
if(mf_classic_is_block_read(data, i)) {
if(mf_classic_is_sector_trailer(i)) {
uint8_t sector = mf_classic_get_sector_by_block(i);
// Key A
if(mf_classic_is_key_found(data, sector, MfClassicKeyTypeA)) {
furi_string_cat_printf(
str,
"%02X%02X %02X%02X %02X%02X ",
block_data[0],
block_data[1],
block_data[2],
block_data[3],
block_data[4],
block_data[5]);
} else {
furi_string_cat(str, "???? ???? ???? ");
}
// Access bits
furi_string_cat_printf(
str,
"%02X%02X %02X%02X ",
block_data[6],
block_data[7],
block_data[8],
block_data[9]);
// Key B
if(mf_classic_is_key_found(data, sector, MfClassicKeyTypeB)) {
furi_string_cat_printf(
str,
"%02X%02X %02X%02X %02X%02X ",
block_data[10],
block_data[11],
block_data[12],
block_data[13],
block_data[14],
block_data[15]);
} else {
furi_string_cat(str, "???? ???? ???? ");
}
} else {
for(size_t j = 0; j < sizeof(MfClassicBlock); j += 2) {
furi_string_cat_printf(str, "%02X%02X ", block_data[j], block_data[j + 1]);
}
}
} else {
for(size_t j = 0; j < sizeof(MfClassicBlock); j += 2) {
furi_string_cat(str, "???? ");
}
}
}
}