diff --git a/client/src/cmdhftopaz.c b/client/src/cmdhftopaz.c index a64071c97..ba150cb71 100644 --- a/client/src/cmdhftopaz.c +++ b/client/src/cmdhftopaz.c @@ -14,6 +14,7 @@ #include #include #include +#include "cliparser.h" #include "cmdparser.h" // command_t #include "comms.h" #include "cmdtrace.h" @@ -393,21 +394,42 @@ static int topaz_print_NDEF(uint8_t *data, size_t maxsize) { } static int CmdHFTopazReader(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf topaz reader", + "Read UID from Topaz tags", + "hf topaz reader"); - bool verbose = true; - char ctmp = tolower(param_getchar(Cmd, 0)); - if (ctmp == 's') verbose = false; + void *argtable[] = { + arg_param_begin, + arg_lit0("v", "verbose", "verbose output"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + + bool verbose = arg_get_lit(ctx, 1); + + CLIParserFree(ctx); return readTopazUid(verbose); } // read a Topaz tag and print some useful information static int CmdHFTopazInfo(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf topaz info", + "Get info from Topaz tags", + "hf topaz info"); - bool verbose = true; - char ctmp = tolower(param_getchar(Cmd, 0)); - if (ctmp == 's') verbose = false; + void *argtable[] = { + arg_param_begin, + arg_lit0("v", "verbose", "verbose output"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + bool verbose = arg_get_lit(ctx, 1); + + CLIParserFree(ctx); int status = readTopazUid(verbose); if (status != PM3_SUCCESS) @@ -469,13 +491,34 @@ static int CmdHFTopazInfo(const char *Cmd) { } static int CmdHFTopazSim(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf topaz sim", + "Simulate a Topaz tag", + "hf topaz sim <- Not yet implemented"); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); PrintAndLogEx(INFO, "not yet implemented"); return PM3_SUCCESS; } static int CmdHFTopazCmdRaw(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf topaz raw", + "Send raw hex data to Topaz tags", + "hf topaz raw <- Not yet implemented"); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + PrintAndLogEx(INFO, "not yet implemented. Use hf 14 raw with option -T."); return PM3_SUCCESS; } @@ -490,6 +533,25 @@ static int CmdHFTopazList(const char *Cmd) { return CmdTraceList(args); } +static int CmdHFTopazSniff(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf topaz sniff", + "Sniff Topaz reader-tag communication", + "hf topaz sniff"); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + + uint8_t param = 0; + SendCommandNG(CMD_HF_ISO14443A_SNIFF, (uint8_t *)¶m, sizeof(uint8_t)); + + return PM3_SUCCESS; +} + static int CmdHelp(const char *Cmd); static command_t CommandTable[] = { @@ -498,7 +560,7 @@ static command_t CommandTable[] = { {"info", CmdHFTopazInfo, IfPm3Iso14443a, "Tag information"}, {"reader", CmdHFTopazReader, IfPm3Iso14443a, "Act like a Topaz reader"}, {"sim", CmdHFTopazSim, IfPm3Iso14443a, " -- Simulate Topaz tag"}, - {"sniff", CmdHF14ASniff, IfPm3Iso14443a, "Sniff Topaz reader-tag communication"}, + {"sniff", CmdHFTopazSniff, IfPm3Iso14443a, "Sniff Topaz reader-tag communication"}, {"raw", CmdHFTopazCmdRaw, IfPm3Iso14443a, "Send raw hex data to tag"}, {NULL, NULL, 0, NULL} }; diff --git a/doc/cliparser_todo.txt b/doc/cliparser_todo.txt index 9eac6d12e..b2571f493 100644 --- a/doc/cliparser_todo.txt +++ b/doc/cliparser_todo.txt @@ -141,11 +141,6 @@ hf mfu otptear hf mfdes enum hf mfdes getuid hf mfdes info -hf topaz info -hf topaz reader -hf topaz sim -hf topaz sniff -hf topaz raw hw connect hw dbg hw detectreader