From a88cc901d98b7a92b5a74619a637e57dd1953fdf Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 6 Jul 2022 18:55:35 +0300 Subject: [PATCH] update sending parameters --- client/src/cmdhftexkom.c | 46 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/client/src/cmdhftexkom.c b/client/src/cmdhftexkom.c index 3dfba4c2c..41bf1efe3 100644 --- a/client/src/cmdhftexkom.c +++ b/client/src/cmdhftexkom.c @@ -568,15 +568,22 @@ static int CmdHFTexkomSim(const char *Cmd) { arg_lit0("t", "tk17", "Use TK-17 modulation (TK-13 by default)"), arg_str0(NULL, "raw", "", "Raw data for texkom card, 8 bytes. Manual modulation select."), arg_str0(NULL, "id", "", "Raw data for texkom card, 8 bytes. Manual modulation select."), + arg_int0(NULL, "timeout", "", "Simulation timeout in the ms. If not specified or 0 - infinite. Command can be skipped by pressing the button"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); + // + struct p { + uint8_t data[8]; + uint8_t modulation; + uint32_t timeout; + } PACKED payload = {}; + bool verbose = arg_get_lit(ctx, 1); - uint32_t cmdtimeout = 0; - uint8_t modulation = 0; // tk-13 + payload.modulation = 0; // tk-13 if (arg_get_lit(ctx, 2)) - modulation = 1; //tk-17 + payload.modulation = 1; //tk-17 uint8_t rawdata[250] = {0}; int rawdatalen = 0; @@ -586,6 +593,8 @@ static int CmdHFTexkomSim(const char *Cmd) { int iddatalen = 0; CLIGetHexWithReturn(ctx, 4, iddata, &iddatalen); + payload.timeout = arg_get_int_def(ctx, 5, 0); + CLIParserFree(ctx); if (rawdatalen == 0 && iddatalen == 0) { @@ -601,9 +610,9 @@ static int CmdHFTexkomSim(const char *Cmd) { if (iddatalen == 4) { rawdata[0] = 0xff; rawdata[1] = 0xff; - rawdata[2] = (modulation == 0) ? 0x63 : 0xCA; + rawdata[2] = (payload.modulation == 0) ? 0x63 : 0xCA; memcpy(&rawdata[3], iddata, 4); - rawdata[7] = (modulation == 0) ? TexcomTK13CRC(iddata) : TexcomTK17CRC(iddata); + rawdata[7] = (payload.modulation == 0) ? TexcomTK13CRC(iddata) : TexcomTK17CRC(iddata); rawdatalen = 8; } @@ -612,33 +621,12 @@ static int CmdHFTexkomSim(const char *Cmd) { return PM3_EINVARG; } - //iceman, use a struct - /* - struct p { - uint8_t modulation; - uint32_t timeout; - uint8_t data[8]; - } PACKED payload; - - payload.modulation = modulation; - payload.timeout = cmdtimeout; - memcpy(payload.data, rawdata, sizeof(payload.data)); + memcpy(payload.data, rawdata, 8); + clearCommandBuffer(); SendCommandNG(CMD_HF_TEXKOM_SIMULATE, (uint8_t*)&payload, sizeof(payload)); - // Iceman, cmdtimeout is always 0. You never set it - */ - - // - uint8_t data[13] = {0}; - memcpy(data, rawdata, 8); - - data[8] = modulation; - memcpy(&data[9], &cmdtimeout, 4); - clearCommandBuffer(); - SendCommandNG(CMD_HF_TEXKOM_SIMULATE, data, sizeof(data)); - - if (cmdtimeout > 0 && cmdtimeout < 2800) { + if (payload.timeout > 0 && payload.timeout < 2800) { PacketResponseNG resp; if (WaitForResponseTimeout(CMD_HF_TEXKOM_SIMULATE, &resp, 3000) == false) { if (verbose) {