From 487524436c7131ff75ca9f481002af83bcf66c6e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Nov 2020 12:06:45 +0100 Subject: [PATCH] lf cliparser stuff --- client/src/cmdlfmotorola.c | 27 +++++++++++++++++++++++++-- client/src/cmdlfnedap.c | 17 ++++++++++++++--- client/src/cmdlfnexwatch.c | 15 +++++++++++++-- client/src/cmdlfnoralsy.c | 17 ++++++++++++++--- client/src/cmdlfpac.c | 15 +++++++++++++-- client/src/cmdlfparadox.c | 13 ++++++++++++- doc/cliparser_todo.txt | 7 ------- 7 files changed, 91 insertions(+), 20 deletions(-) diff --git a/client/src/cmdlfmotorola.c b/client/src/cmdlfmotorola.c index b9233fc0c..cf3f79137 100644 --- a/client/src/cmdlfmotorola.c +++ b/client/src/cmdlfmotorola.c @@ -116,9 +116,19 @@ int demodMotorola(bool verbose) { return PM3_SUCCESS; } -//see PSKDemod for what args are accepted static int CmdMotorolaDemod(const char *Cmd) { - (void)Cmd; + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf motorola demod", + "Try to find Motorola preamble, if found decode / descramble data", + "lf motorola demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodMotorola(true); } @@ -235,7 +245,20 @@ static int CmdMotorolaClone(const char *Cmd) { } static int CmdMotorolaSim(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf motorola sim", + "Enables simulation of Motorola card with specified card number.\n" + "Simulation runs until the button is pressed or another USB command is issued.", + "lf motorola sim" + ); + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); + // PSK sim. PrintAndLogEx(INFO, " PSK1 at 66 kHz... Interesting."); PrintAndLogEx(INFO, " To be implemented, feel free to contribute!"); diff --git a/client/src/cmdlfnedap.c b/client/src/cmdlfnedap.c index 06daf357e..1ee2923c1 100644 --- a/client/src/cmdlfnedap.c +++ b/client/src/cmdlfnedap.c @@ -11,10 +11,8 @@ #define _GNU_SOURCE #include - #include #include - #include "cmdparser.h" // command_t #include "comms.h" #include "crc16.h" @@ -24,6 +22,8 @@ #include "cmdlf.h" #include "lfdemod.h" #include "protocols.h" +#include "cliparser.h" +#include "cmdlfem4x05.h" // EM defines #define FIXED_71 0x71 #define FIXED_40 0x40 @@ -262,7 +262,18 @@ int demodNedap(bool verbose) { } static int CmdLFNedapDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf nedap demod", + "Try to find Nedap preamble, if found decode / descramble data", + "lf nedap demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodNedap(true); } /* Index map E E diff --git a/client/src/cmdlfnexwatch.c b/client/src/cmdlfnexwatch.c index 1b8064362..ea69535f3 100644 --- a/client/src/cmdlfnexwatch.c +++ b/client/src/cmdlfnexwatch.c @@ -217,14 +217,25 @@ int demodNexWatch(bool verbose) { } static int CmdNexWatchDemod(const char *Cmd) { - (void)Cmd; + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf nexwatch demod", + "Try to find Nexwatch preamble, if found decode / descramble data", + "lf nexwatch demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodNexWatch(true); } static int CmdNexWatchReader(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf nexwatch reader", - "read a nexwatch tag", + "read a Nexwatch tag", "lf nexwatch reader -@ -> continuous reader mode" ); diff --git a/client/src/cmdlfnoralsy.c b/client/src/cmdlfnoralsy.c index a49093ec8..73a027c33 100644 --- a/client/src/cmdlfnoralsy.c +++ b/client/src/cmdlfnoralsy.c @@ -103,14 +103,25 @@ int demodNoralsy(bool verbose) { } static int CmdNoralsyDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf noralsy demod", + "Try to find Noralsy preamble, if found decode / descramble data", + "lf noralsy demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodNoralsy(true); } static int CmdNoralsyReader(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf noralsy reader", - "read a noralsy tag", + "read a Noralsy tag", "lf noralsy reader -@ -> continuous reader mode" ); @@ -133,7 +144,7 @@ static int CmdNoralsyReader(const char *Cmd) { static int CmdNoralsyClone(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf noralsy clone", - "clone a noralsy tag to a T55x7, Q5/T5555 or EM4305/4469 tag.", + "clone a Noralsy tag to a T55x7, Q5/T5555 or EM4305/4469 tag.", "lf noralsy clone --cn 112233\n" "lf noralsy clone --cn 112233 --q5 -> encode for Q5/T5555 tag\n" "lf noralsy clone --cn 112233 --em -> encode for EM4305/4469" diff --git a/client/src/cmdlfpac.c b/client/src/cmdlfpac.c index f6eda612d..99495641f 100644 --- a/client/src/cmdlfpac.c +++ b/client/src/cmdlfpac.c @@ -157,7 +157,18 @@ int demodPac(bool verbose) { } static int CmdPacDemod(const char *Cmd) { - (void)Cmd; + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf pac demod", + "Try to find PAC/Stanley preamble, if found decode / descramble data", + "lf pac demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodPac(true); } @@ -165,7 +176,7 @@ static int CmdPacReader(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf pac reader", - "read a pac tag", + "read a PAC/Stanley tag", "lf pac reader -@ -> continuous reader mode" ); diff --git a/client/src/cmdlfparadox.c b/client/src/cmdlfparadox.c index 824ab2164..f740721e9 100644 --- a/client/src/cmdlfparadox.c +++ b/client/src/cmdlfparadox.c @@ -170,7 +170,18 @@ int demodParadox(bool verbose) { } static int CmdParadoxDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf paradox demod", + "Try to find Paradox preamble, if found decode / descramble data", + "lf paradox demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodParadox(true); } diff --git a/doc/cliparser_todo.txt b/doc/cliparser_todo.txt index e45b396fb..afde469a4 100644 --- a/doc/cliparser_todo.txt +++ b/doc/cliparser_todo.txt @@ -257,17 +257,10 @@ lf io sim lf io watch lf jablotron sim lf keri demod -lf motorola demod -lf motorola sim -lf nedap demod lf nedap generate lf nedap read lf nedap clone lf nedap sim -lf nexwatch demod -lf noralsy demod -lf pac demod -lf paradox demod lf pcf7931 read lf pcf7931 write lf pcf7931 config