From 070211be1bc07c73d225ca6b03b1a974bcab8671 Mon Sep 17 00:00:00 2001 From: "Peter S. Hollander" Date: Tue, 17 Mar 2026 12:54:13 +0000 Subject: [PATCH 1/2] Add `--timeout` to `hf 15 sim` --- CHANGELOG.md | 1 + client/src/cmdhf15.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cad05b438..388072ad6 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] +- Added `-t` / `--timeout` option for `hf 15 sim` (@recursivenomad) ## [Permafrost][2026-02-25] - Added standalone mode `HF_DOEGOX_AUTH0`: UL-C / UL-AES unlocker (@doegox) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index 1bbdfb951..a5b73b93f 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1473,6 +1473,7 @@ static int CmdHF15Sim(const char *Cmd) { arg_param_begin, arg_str0("u", "uid", "", "UID, 8 hex bytes"), arg_int0("b", "blocksize", "", "block size (def 4)"), + arg_int0("t", "timeout", "", "timeout in ms (0 will run until button press - def 0)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1486,6 +1487,7 @@ static int CmdHF15Sim(const char *Cmd) { int uidlen = 0; CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); payload.block_size = arg_get_int_def(ctx, 2, 4); + size_t timeout = arg_get_int_def(ctx, 3, 0); CLIParserFree(ctx); // sanity checks @@ -1494,6 +1496,10 @@ static int CmdHF15Sim(const char *Cmd) { return PM3_EINVARG; } + if (timeout == 0) { + timeout = -1; + } + PacketResponseNG resp; // get UID from emulator for printing @@ -1525,7 +1531,10 @@ static int CmdHF15Sim(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_HF_ISO15693_SIMULATE, (uint8_t *)&payload, sizeof(payload)); - WaitForResponse(CMD_HF_ISO15693_SIMULATE, &resp); + WaitForResponseTimeout(CMD_HF_ISO15693_SIMULATE, &resp, timeout); + if (timeout != -1) { + SendCommandNG(CMD_BREAK_LOOP, NULL, 0); + } PrintAndLogEx(INFO, "Done!"); return PM3_SUCCESS; } From 422b3b747344ac32e759e2e9b0975d34acc57399 Mon Sep 17 00:00:00 2001 From: "Peter S. Hollander" Date: Tue, 24 Mar 2026 10:53:13 +0000 Subject: [PATCH 2/2] Preserve default flow --- client/src/cmdhf15.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index a5b73b93f..becd9f7fd 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1473,7 +1473,7 @@ static int CmdHF15Sim(const char *Cmd) { arg_param_begin, arg_str0("u", "uid", "", "UID, 8 hex bytes"), arg_int0("b", "blocksize", "", "block size (def 4)"), - arg_int0("t", "timeout", "", "timeout in ms (0 will run until button press - def 0)"), + arg_int0("t", "timeout", "", "timeout in ms (def -1, ie. until button press)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1487,7 +1487,7 @@ static int CmdHF15Sim(const char *Cmd) { int uidlen = 0; CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); payload.block_size = arg_get_int_def(ctx, 2, 4); - size_t timeout = arg_get_int_def(ctx, 3, 0); + size_t timeout = arg_get_int_def(ctx, 3, -1); CLIParserFree(ctx); // sanity checks @@ -1496,10 +1496,6 @@ static int CmdHF15Sim(const char *Cmd) { return PM3_EINVARG; } - if (timeout == 0) { - timeout = -1; - } - PacketResponseNG resp; // get UID from emulator for printing @@ -1532,7 +1528,7 @@ static int CmdHF15Sim(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_HF_ISO15693_SIMULATE, (uint8_t *)&payload, sizeof(payload)); WaitForResponseTimeout(CMD_HF_ISO15693_SIMULATE, &resp, timeout); - if (timeout != -1) { + if (timeout != (size_t) - 1) { SendCommandNG(CMD_BREAK_LOOP, NULL, 0); } PrintAndLogEx(INFO, "Done!");