refactor: move lf hitag sim --hts to lf hitag hts

This commit is contained in:
douniwan5788 2024-09-20 23:51:07 +08:00
commit 0614251555
2 changed files with 25 additions and 7 deletions

View file

@ -1827,22 +1827,20 @@ static int CmdLFHitagSim(const char *Cmd) {
arg_param_begin, arg_param_begin,
arg_lit0("1", "ht1", "simulate Hitag 1"), arg_lit0("1", "ht1", "simulate Hitag 1"),
arg_lit0("2", "ht2", "simulate Hitag 2"), arg_lit0("2", "ht2", "simulate Hitag 2"),
arg_lit0("s", "hts", "simulate Hitag S"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
bool use_ht1 = arg_get_lit(ctx, 1); bool use_ht1 = arg_get_lit(ctx, 1);
bool use_ht2 = arg_get_lit(ctx, 2); bool use_ht2 = arg_get_lit(ctx, 2);
bool use_hts = arg_get_lit(ctx, 3);
bool use_htm = false; // not implemented yet bool use_htm = false; // not implemented yet
CLIParserFree(ctx); 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"); PrintAndLogEx(ERR, "error, specify only one Hitag type");
return PM3_EINVARG; 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"); PrintAndLogEx(ERR, "error, specify one Hitag type");
return PM3_EINVARG; return PM3_EINVARG;
} }
@ -1851,9 +1849,6 @@ static int CmdLFHitagSim(const char *Cmd) {
// if (use_ht1) // if (use_ht1)
// cmd = CMD_LF_HITAG1_SIMULATE; // cmd = CMD_LF_HITAG1_SIMULATE;
if (use_hts)
cmd = CMD_LF_HITAGS_SIMULATE;
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(cmd, 0, 0, 0, NULL, 0); SendCommandMIX(cmd, 0, 0, 0, NULL, 0);
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -418,6 +418,28 @@ static int CmdLFHitagSReader(const char *Cmd) {
return PM3_SUCCESS; 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) { static int CmdLFHitagSList(const char *Cmd) {
return CmdTraceListAlias(Cmd, "lf hitag hts", "hitags"); return CmdTraceListAlias(Cmd, "lf hitag hts", "hitags");
} }
@ -470,6 +492,7 @@ static command_t CommandTable[] = {
{"reader", CmdLFHitagSReader, IfPm3Hitag, "Act like a Hitag S reader"}, {"reader", CmdLFHitagSReader, IfPm3Hitag, "Act like a Hitag S reader"},
{"rdbl", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"}, {"rdbl", CmdLFHitagSRead, IfPm3Hitag, "Read Hitag S memory"},
{"wrbl", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"}, {"wrbl", CmdLFHitagSWrite, IfPm3Hitag, "Write Hitag S page"},
{"sim", CmdLFHitagSSim, IfPm3Hitag, "Simulate Hitag transponder"},
{NULL, NULL, 0, NULL} {NULL, NULL, 0, NULL}
}; };