From 290c6f6c3126efe50dc04cbf236a76a24e5afdf6 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 19 Nov 2019 12:01:04 +0100 Subject: [PATCH] chg: hf 14a sim x - device simulation loop exited when client exits --- client/cmdhf14a.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/cmdhf14a.c b/client/cmdhf14a.c index 2f8473d1c..777b7d25c 100644 --- a/client/cmdhf14a.c +++ b/client/cmdhf14a.c @@ -512,8 +512,9 @@ int CmdHF14ASim(const char *Cmd) { PacketResponseNG resp; PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation"); + bool keypress = kbd_enter_pressed(); + while (!keypress) { - while (!kbd_enter_pressed()) { if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) continue; if (resp.status != PM3_SUCCESS) break; @@ -521,7 +522,15 @@ int CmdHF14ASim(const char *Cmd) { nonces_t *data = (nonces_t *)resp.data.asBytes; readerAttack(data[0], setEmulatorMem, verbose); + + keypress = kbd_enter_pressed(); } + + if (keypress && (flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) { + // inform device to break the sim loop since client has exited + SendCommandNG(CMD_BREAK_LOOP, NULL, 0); + } + if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK)) showSectorTable();