From 841215ebbbcd288fecc74820e0fa4aaf07e3a759 Mon Sep 17 00:00:00 2001 From: Tom Samstag Date: Tue, 27 Sep 2022 10:00:50 -0700 Subject: [PATCH] =?UTF-8?q?=D0=A4dd=20formatting=20to=20DESfire=20data=20d?= =?UTF-8?q?ump=20(#1784)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gornekich --- lib/nfc/protocols/mifare_desfire.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/nfc/protocols/mifare_desfire.c b/lib/nfc/protocols/mifare_desfire.c index 1822d5c1ab69..f969cdde6421 100644 --- a/lib/nfc/protocols/mifare_desfire.c +++ b/lib/nfc/protocols/mifare_desfire.c @@ -209,8 +209,24 @@ void mf_df_cat_file(MifareDesfireFile* file, string_t out) { uint8_t* data = file->contents; if(data) { for(int rec = 0; rec < num; rec++) { - for(int ch = 0; ch < size; ch++) { - string_cat_printf(out, "%02x", data[rec * size + ch]); + string_cat_printf(out, "record %d\n", rec); + for(int ch = 0; ch < size; ch += 4) { + string_cat_printf(out, "%03x|", ch); + for(int i = 0; i < 4; i++) { + if(ch + i < size) { + string_cat_printf(out, "%02x ", data[rec * size + ch + i]); + } else { + string_cat_printf(out, " "); + } + } + for(int i = 0; i < 4 && ch + i < size; i++) { + if(isprint(data[rec * size + ch + i])) { + string_cat_printf(out, "%c", data[rec * size + ch + i]); + } else { + string_cat_printf(out, "."); + } + } + string_cat_printf(out, "\n"); } string_cat_printf(out, " \n"); }