Merge pull request #3798 from matrix/fix-mf-brute

hf mf brute: read the options right and report the transfer
This commit is contained in:
Iceman authored and GitHub committed 2026-11-12 11:15:43 +08:00
commit cfeb19b689
2 files changed
+22 -11

No files matched your search

+1
View File
@@ -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)
- Fixed `hf mf darkside` - with more candidates than fit one check, every candidate is tested and none is read past the list (@matrix)
- Fixed `hf mf nested` - tests every key candidate, follows cards whose nonce distance varies, single sector retries (@matrix)
- Fixed `hf mf chk`, `hf mf staticnested` and other key checks - a card that stops answering no longer locks the device (@matrix)
+21 -11
View File
@@ -4364,6 +4364,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"
@@ -4386,13 +4388,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);
@@ -4548,12 +4550,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");
}
}
@@ -4571,7 +4581,7 @@ out:
free(keyBlock);
free(e_sector);
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
return eml_res;
}
static int CmdHF14AMfChk(const char *Cmd) {