From 06142515552bc4f7594095443514d957f0487b2f Mon Sep 17 00:00:00 2001 From: douniwan5788 Date: Fri, 20 Sep 2024 23:51:07 +0800 Subject: [PATCH] refactor: move `lf hitag sim --hts` to `lf hitag hts` --- client/src/cmdlfhitag.c | 9 ++------- client/src/cmdlfhitaghts.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/client/src/cmdlfhitag.c b/client/src/cmdlfhitag.c index 5a853ae77..88648cfc5 100644 --- a/client/src/cmdlfhitag.c +++ b/client/src/cmdlfhitag.c @@ -1827,22 +1827,20 @@ static int CmdLFHitagSim(const char *Cmd) { arg_param_begin, arg_lit0("1", "ht1", "simulate Hitag 1"), arg_lit0("2", "ht2", "simulate Hitag 2"), - arg_lit0("s", "hts", "simulate Hitag S"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); bool use_ht1 = arg_get_lit(ctx, 1); bool use_ht2 = arg_get_lit(ctx, 2); - bool use_hts = arg_get_lit(ctx, 3); bool use_htm = false; // not implemented yet CLIParserFree(ctx); - if ((use_ht1 + use_ht2 + use_hts + use_htm) > 1) { + if ((use_ht1 + use_ht2 + use_htm) > 1) { PrintAndLogEx(ERR, "error, specify only one Hitag type"); return PM3_EINVARG; } - if ((use_ht1 + use_ht2 + use_hts + use_htm) == 0) { + if ((use_ht1 + use_ht2 + use_htm) == 0) { PrintAndLogEx(ERR, "error, specify one Hitag type"); return PM3_EINVARG; } @@ -1851,9 +1849,6 @@ static int CmdLFHitagSim(const char *Cmd) { // if (use_ht1) // cmd = CMD_LF_HITAG1_SIMULATE; - if (use_hts) - cmd = CMD_LF_HITAGS_SIMULATE; - clearCommandBuffer(); SendCommandMIX(cmd, 0, 0, 0, NULL, 0); return PM3_SUCCESS; diff --git a/client/src/cmdlfhitaghts.c b/client/src/cmdlfhitaghts.c index b53178e52..657866043 100644 --- a/client/src/cmdlfhitaghts.c +++ b/client/src/cmdlfhitaghts.c @@ -418,6 +418,28 @@ static int CmdLFHitagSReader(const char *Cmd) { return PM3_SUCCESS; } +static int CmdLFHitagSSim(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf hitag hts sim", + "Simulate Hitag S transponder\n" + "You need to `lf hitag hts eload` first", + "lf hitag hts sim\n" + "lf hitag hts sim --82xx"); + + void *argtable[] = { + arg_param_begin, + arg_lit0("8", "82xx", "simulate 8268/8310"), + arg_param_end}; + CLIExecWithReturn(ctx, Cmd, argtable, true); + + // bool use_82xx = arg_get_lit(ctx, 1); // not implemented yet + CLIParserFree(ctx); + + clearCommandBuffer(); + SendCommandNG(CMD_LF_HITAGS_SIMULATE, NULL, 0); + return PM3_SUCCESS; +} + static int CmdLFHitagSList(const char *Cmd) { return CmdTraceListAlias(Cmd, "lf hitag hts", "hitags"); } @@ -470,6 +492,7 @@ static command_t CommandTable[] = { {"reader", CmdLFHitagSReader, IfPm3Hitag, "Act like a Hitag S reader"}, {"rdbl", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"}, {"wrbl", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"}, + {"sim", CmdLFHitagSSim, IfPm3Hitag, "Simulate Hitag transponder"}, {NULL, NULL, 0, NULL} };