From eae6f7dd9bf530b4e0f1f613992029f9faedbdcc Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 12 Nov 2026 02:54:16 +0100 Subject: [PATCH] hf mf brute: read the options right and report the transfer The options were read one position further on in the argument table: --1k selected a Mini, --emu a 4K with no transfer, --dump the transfer, and --1k with --emu was refused. With --emu the command ignored the results of the transfer and of FastDumpWithEcFill() and returned success. It now reads positions 1-6 and handles both results as hf mf fchk does. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdhfmf.c | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a64e1fa..b387ab741 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] +- Fixed `hf mf brute` - options read at their own positions (`--1k` ran a Mini), `--emu` reports keys and dumps not transferred to emulator memory (@matrix) - Update Amiibo database (@tpglitch) - Changed `lf pcf7931 write` - write is verified via the tag's read after write, retried up to 3 times, failures are reported (@GiacoBot) - Changed `lf pcf7931 reader` - prints blocks 0-7 in order and decodes PAC, password, write protection and selection; handles partial selections, new `--rfb` param (@GiacoBot) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index e8c1d6efa..17db1d266 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -4350,6 +4350,8 @@ out2: static int CmdHF14AMfSmartBrute(const char *Cmd) { CLIParserContext *ctx; + // the result of an emulator memory transfer the command was asked for + int eml_res = PM3_SUCCESS; CLIParserInit(&ctx, "hf mf brute", "This is a smart bruteforce, exploiting common patterns, bugs and bad designs in key generators.", "hf mf brute --mini --> Key recovery against MIFARE Mini\n" @@ -4372,13 +4374,13 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) { CLIExecWithReturn(ctx, Cmd, argtable, true); - bool m0 = arg_get_lit(ctx, 2); - bool m1 = arg_get_lit(ctx, 3); - bool m2 = arg_get_lit(ctx, 4); - bool m4 = arg_get_lit(ctx, 5); + bool m0 = arg_get_lit(ctx, 1); + bool m1 = arg_get_lit(ctx, 2); + bool m2 = arg_get_lit(ctx, 3); + bool m4 = arg_get_lit(ctx, 4); - bool transferToEml = arg_get_lit(ctx, 6); - bool createDumpFile = arg_get_lit(ctx, 7); + bool transferToEml = arg_get_lit(ctx, 5); + bool createDumpFile = arg_get_lit(ctx, 6); CLIParserFree(ctx); @@ -4534,12 +4536,20 @@ out: // Disable fast mode on last packet g_conn.block_after_ACK = false; } - mf_elm_set_mem(block, b, 1); + eml_res = mf_elm_set_mem(block, b, 1); + if (eml_res != PM3_SUCCESS) { + g_conn.block_after_ACK = false; + break; + } } - PrintAndLogEx(SUCCESS, "Found keys have been transferred to the emulator memory"); + if (eml_res == PM3_SUCCESS) { + PrintAndLogEx(SUCCESS, "Found keys have been transferred to the emulator memory"); - if (found_keys == (sectorsCnt << 1)) { - FastDumpWithEcFill(sectorsCnt); + if (found_keys == (sectorsCnt << 1)) { + eml_res = FastDumpWithEcFill(sectorsCnt); + } + } else { + PrintAndLogEx(FAILED, "Found keys have not been transferred to the emulator memory"); } } @@ -4557,7 +4567,7 @@ out: free(keyBlock); free(e_sector); PrintAndLogEx(NORMAL, ""); - return PM3_SUCCESS; + return eml_res; } static int CmdHF14AMfChk(const char *Cmd) {