From bcec294606b009ff94235441c5a60c67dceb8a19 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 8 Jun 2025 16:09:23 +0200 Subject: [PATCH] fix the visual bug with when viewing larger mifare class dumps, 2k, 4k, it would mark the signature sectors... for the rest of the dumps. --- CHANGELOG.md | 1 + client/src/cmdhfmf.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3652b7abd..44df875d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fix `hf mf eview` - now viewing 2k, 4k cards doesn't get wrong background color (@iceman1001) - Changed `hf mf info` - skip checking if it detects a MIFARE Ultralight family card (@iceman1001) - Changed `hf mf rdsc` - it now addeds the used key to the output in the sector trailer (@iceman1001) - Added the `PM3ULTIMATE` platform in the build / docs. *untested* (@iceman1001) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 588d219fc..795aa1f59 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -561,7 +561,7 @@ void mf_print_block_one(uint8_t blockno, uint8_t *d, bool verbose) { } } -static void mf_print_block(uint8_t blockno, uint8_t *d, bool verbose) { +static void mf_print_block(uint16_t maxblocks, uint8_t blockno, uint8_t *d, bool verbose) { uint8_t sectorno = mfSectorNum(blockno); char secstr[6] = " "; @@ -593,7 +593,7 @@ static void mf_print_block(uint8_t blockno, uint8_t *d, bool verbose) { char ascii[24] = {0}; ascii_to_buffer((uint8_t *)ascii, d, MFBLOCK_SIZE, sizeof(ascii) - 1, 1); - if (blockno >= MIFARE_1K_MAXBLOCK) { + if (maxblocks < 18 && blockno >= MIFARE_1K_MAXBLOCK) { PrintAndLogEx(INFO, _BACK_BLUE_("%s| %3d | " _YELLOW_("%s")) _BACK_BLUE_(_MAGENTA_("%s")) @@ -622,7 +622,7 @@ static void mf_print_block(uint8_t blockno, uint8_t *d, bool verbose) { } } else { - if (blockno >= MIFARE_1K_MAXBLOCK) { + if (maxblocks < 18 && blockno >= MIFARE_1K_MAXBLOCK) { // MFC Ev1 signature blocks. PrintAndLogEx(INFO, _BACK_BLUE_("%s| %3d | %s"), secstr, blockno, sprint_hex_ascii(d, MFBLOCK_SIZE)); } else { @@ -641,10 +641,12 @@ static void mf_print_blocks(uint16_t n, uint8_t *d, bool verbose) { PrintAndLogEx(INFO, "-----+-----+-------------------------------------------------+-----------------"); PrintAndLogEx(INFO, " sec | blk | data | ascii"); PrintAndLogEx(INFO, "-----+-----+-------------------------------------------------+-----------------"); + for (uint16_t i = 0; i < n; i++) { - mf_print_block(i, d + (i * MFBLOCK_SIZE), verbose); + mf_print_block(n, i, d + (i * MFBLOCK_SIZE), verbose); } PrintAndLogEx(INFO, "-----+-----+-------------------------------------------------+-----------------"); + if (verbose) { PrintAndLogEx(HINT, _CYAN_("cyan") " = value block with decoded value"); PrintAndLogEx(HINT, _CYAN_("background blue") " = MFC Ev1 signature blocks"); @@ -5307,7 +5309,7 @@ static int CmdHF14AMfEView(const char *Cmd) { } PrintAndLogEx(INFO, "downloading emulator memory"); - if (!GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false)) { + if (GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false) == false) { PrintAndLogEx(WARNING, "Fail, transfer from device time-out"); free(dump); return PM3_ETIMEOUT;