From 1e3ffe26242f42625ffcff8c7d32fd6effb5d24b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 29 Nov 2020 12:13:54 +0100 Subject: [PATCH] lf hid, idteck, keri - demod , continuous mode --- client/src/cmdlfhid.c | 44 +++++++++++++++++++++++++++++++--------- client/src/cmdlfidteck.c | 42 +++++++++++++++++++++++++++++++------- client/src/cmdlfkeri.c | 13 +++++++++++- 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/client/src/cmdlfhid.c b/client/src/cmdlfhid.c index 178a75449..9b73dda19 100644 --- a/client/src/cmdlfhid.c +++ b/client/src/cmdlfhid.c @@ -19,13 +19,10 @@ //----------------------------------------------------------------------------- #include "cmdlfhid.h" - #include #include - #include #include - #include "cmdparser.h" // command_t #include "comms.h" #include "commonutil.h" // ARRAYLEN @@ -38,6 +35,7 @@ #include "lfdemod.h" #include "wiegand_formats.h" #include "wiegand_formatutils.h" +#include "cmdlfem4x05.h" // EM defines #ifndef BITS # define BITS 96 @@ -153,15 +151,44 @@ int demodHID(bool verbose) { } static int CmdHIDDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf hid demod", + "Try to find HID Prox preamble, if found decode / descramble data", + "lf hid demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodHID(true); } // this read is the "normal" read, which download lf signal and tries to demod here. static int CmdHIDRead(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - lf_read(false, 16000); - return demodHID(true); + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf hid reader", + "read a HID Prox tag", + "lf hid reader -@ -> continuous reader mode" + ); + + void *argtable[] = { + arg_param_begin, + arg_lit0("@", NULL, "optional - continuous reader mode"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + bool cm = arg_get_lit(ctx, 1); + CLIParserFree(ctx); + + do { + lf_read(false, 16000); + demodHID(!cm); + } while (cm && !kbd_enter_pressed()); + + return PM3_SUCCESS; } // this read loops on device side. @@ -212,7 +239,6 @@ static int CmdHIDSim(const char *Cmd) { arg_int0("i", NULL, "", "issue level"), arg_int0("o", "oem", "", "OEM code"), arg_strx0("r", "raw", "", "raw bytes"), -// arg_lit0("q", "Q5", "optional - specify writing to Q5/T5555 tag"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -231,8 +257,6 @@ static int CmdHIDSim(const char *Cmd) { int raw_len = 0; char raw[40] = {0}; CLIParamStrToBuf(arg_get_str(ctx, 6), (uint8_t *)raw, sizeof(raw), &raw_len); - - //bool q5 = arg_get_lit(ctx, 7); CLIParserFree(ctx); wiegand_message_t packed; diff --git a/client/src/cmdlfidteck.c b/client/src/cmdlfidteck.c index 1499aa7c9..3f61f0eb4 100644 --- a/client/src/cmdlfidteck.c +++ b/client/src/cmdlfidteck.c @@ -9,13 +9,10 @@ // PSK //----------------------------------------------------------------------------- #include "cmdlfidteck.h" - #include #include #include - #include "common.h" - #include "cmdparser.h" // command_t #include "comms.h" #include "ui.h" @@ -23,6 +20,8 @@ #include "cmdlf.h" #include "lfdemod.h" #include "commonutil.h" // num_to_bytes +#include "cliparser.h" +#include "cmdlfem4x05.h" // EM defines static int CmdHelp(const char *Cmd); @@ -87,14 +86,43 @@ int demodIdteck(bool verbose) { } static int CmdIdteckDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf idteck demod", + "Try to find Idteck preamble, if found decode / descramble data", + "lf idteck demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodIdteck(true); } static int CmdIdteckRead(const char *Cmd) { - (void)Cmd; - lf_read(false, 5000); - return demodIdteck(true); + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf idteck reader", + "read a Idteck tag", + "lf idteck reader -@ -> continuous reader mode" + ); + + void *argtable[] = { + arg_param_begin, + arg_lit0("@", NULL, "optional - continuous reader mode"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + bool cm = arg_get_lit(ctx, 1); + CLIParserFree(ctx); + + do { + lf_read(false, 5000); + demodIdteck(!cm); + } while (cm && !kbd_enter_pressed()); + + return PM3_SUCCESS; } static command_t CommandTable[] = { diff --git a/client/src/cmdlfkeri.c b/client/src/cmdlfkeri.c index 93e8a2521..dfd0153fd 100644 --- a/client/src/cmdlfkeri.c +++ b/client/src/cmdlfkeri.c @@ -175,7 +175,18 @@ int demodKeri(bool verbose) { } static int CmdKeriDemod(const char *Cmd) { - (void)Cmd; // Cmd is not used so far + CLIParserContext *ctx; + CLIParserInit(&ctx, "lf keri demod", + "Try to find KERI preamble, if found decode / descramble data", + "lf keri demod" + ); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); return demodKeri(true); }