Skip to content

Commit

Permalink
refactor: move lf hitag sim --hts to lf hitag hts
Browse files Browse the repository at this point in the history
  • Loading branch information
douniwan5788 committed Sep 21, 2024
1 parent 9f3e94c commit 0614251
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
9 changes: 2 additions & 7 deletions client/src/cmdlfhitag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions client/src/cmdlfhitaghts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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}
};

Expand Down

0 comments on commit 0614251

Please sign in to comment.