From 64a44d1e8503f497172ee35ea65a8fb738822bdc Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 9 Oct 2020 20:19:36 +0200 Subject: [PATCH] adapt list command to allow for options --- client/src/cmdhf14a.c | 8 +++++--- client/src/cmdhf14b.c | 8 +++++--- client/src/cmdhf15.c | 8 +++++--- client/src/cmdhfcryptorf.c | 8 +++++--- client/src/cmdhffelica.c | 8 +++++--- client/src/cmdhffido.c | 34 ++++++++++++++++++++++------------ client/src/cmdhficlass.c | 8 +++++--- client/src/cmdhflegic.c | 8 +++++--- client/src/cmdhflto.c | 8 +++++--- client/src/cmdhfmf.c | 7 +++++-- client/src/cmdhfmfdes.c | 7 +++++-- client/src/cmdhfst.c | 8 +++++--- client/src/cmdhfthinfilm.c | 9 +++++---- client/src/cmdhftopaz.c | 8 +++++--- client/src/cmdlfhitag.c | 9 ++++++--- client/src/cmdsmartcard.c | 8 +++++--- 16 files changed, 98 insertions(+), 56 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index af5e378e6..2297b19f7 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -269,9 +269,11 @@ static int usage_hf_14a_reader(void) { } static int CmdHF14AList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("14a"); - return 0; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 14a"); + } + return CmdTraceList(args); } int hf14a_getconfig(hf14a_config *config) { diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 5989fe23c..b13e76887 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -116,9 +116,11 @@ static bool wait_cmd_14b(bool verbose, bool is_select) { } static int CmdHF14BList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("14b"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 14b"); + } + return CmdTraceList(args); } static int CmdHF14BSim(const char *Cmd) { diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index cbef47554..0b370f7bc 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -1342,9 +1342,11 @@ static int CmdHF15Dump(const char *Cmd) { } static int CmdHF15List(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("15"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 15"); + } + return CmdTraceList(args); } static int CmdHF15Raw(const char *Cmd) { diff --git a/client/src/cmdhfcryptorf.c b/client/src/cmdhfcryptorf.c index b473b2fa2..d2ee539db 100644 --- a/client/src/cmdhfcryptorf.c +++ b/client/src/cmdhfcryptorf.c @@ -115,9 +115,11 @@ static int switch_off_field_cryptorf(void) { } static int CmdHFCryptoRFList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("cryptorf"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t cryptorf"); + } + return CmdTraceList(args); } static int CmdHFCryptoRFSim(const char *Cmd) { diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c index 092677b42..ee926c550 100644 --- a/client/src/cmdhffelica.c +++ b/client/src/cmdhffelica.c @@ -407,9 +407,11 @@ static bool add_last_IDm(uint8_t position, uint8_t *data) { } static int CmdHFFelicaList(const char *Cmd) { - (void)Cmd; - CmdTraceList("felica"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t felica"); + } + return CmdTraceList(args); } static int CmdHFFelicaReader(const char *Cmd) { diff --git a/client/src/cmdhffido.c b/client/src/cmdhffido.c index ee2da7bfa..fc3d3540f 100644 --- a/client/src/cmdhffido.c +++ b/client/src/cmdhffido.c @@ -36,10 +36,19 @@ #include "emv/dump.h" #include "ui.h" #include "cmdhf14a.h" +#include "cmdtrace.h" static int CmdHelp(const char *Cmd); -static int CmdHFFidoInfo(const char *cmd) { +static int cmd_hf_fido_list(const char *Cmd) { + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 14a"); + } + return CmdTraceList(args); +} + +static int cmd_hf_fido_info(const char *cmd) { if (cmd && strlen(cmd) > 0) PrintAndLogEx(WARNING, "WARNING: command doesn't have any parameters.\n"); @@ -150,7 +159,7 @@ static json_t *OpenJson(CLIParserContext *ctx, int paramnum, char *fname, void * return root; } -static int CmdHFFidoRegister(const char *cmd) { +static int cmd_hf_fido_register(const char *cmd) { uint8_t data[64] = {0}; int chlen = 0; uint8_t cdata[250] = {0}; @@ -386,7 +395,7 @@ static int CmdHFFidoRegister(const char *cmd) { return PM3_SUCCESS; } -static int CmdHFFidoAuthenticate(const char *cmd) { +static int cmd_hf_fido_authenticate(const char *cmd) { uint8_t data[512] = {0}; uint8_t hdata[250] = {0}; bool public_key_loaded = false; @@ -652,7 +661,7 @@ static int GetExistsFileNameJson(const char *prefixDir, const char *reqestedFile return PM3_SUCCESS; } -static int CmdHFFido2MakeCredential(const char *cmd) { +static int cmd_hf_fido_2make_credential(const char *cmd) { json_error_t error; char fname[FILE_PATH_SIZE] = {0}; @@ -777,7 +786,7 @@ static int CmdHFFido2MakeCredential(const char *cmd) { return PM3_SUCCESS; } -static int CmdHFFido2GetAssertion(const char *cmd) { +static int cmd_hf_fido_2get_assertion(const char *cmd) { json_error_t error; char fname[FILE_PATH_SIZE] = {0}; @@ -903,13 +912,14 @@ static int CmdHFFido2GetAssertion(const char *cmd) { } static command_t CommandTable[] = { - {"help", CmdHelp, AlwaysAvailable, "This help."}, - {"info", CmdHFFidoInfo, IfPm3Iso14443a, "Info about FIDO tag."}, - {"reg", CmdHFFidoRegister, IfPm3Iso14443a, "FIDO U2F Registration Message."}, - {"auth", CmdHFFidoAuthenticate, IfPm3Iso14443a, "FIDO U2F Authentication Message."}, - {"make", CmdHFFido2MakeCredential, IfPm3Iso14443a, "FIDO2 MakeCredential command."}, - {"assert", CmdHFFido2GetAssertion, IfPm3Iso14443a, "FIDO2 GetAssertion command."}, - {NULL, NULL, 0, NULL} + {"help", CmdHelp, AlwaysAvailable, "This help."}, + {"info", cmd_hf_fido_list, IfPm3Iso14443a, "List ISO 14443A history"}, + {"info", cmd_hf_fido_info, IfPm3Iso14443a, "Info about FIDO tag."}, + {"reg", cmd_hf_fido_register, IfPm3Iso14443a, "FIDO U2F Registration Message."}, + {"auth", cmd_hf_fido_authenticate, IfPm3Iso14443a, "FIDO U2F Authentication Message."}, + {"make", cmd_hf_fido_2make_credential, IfPm3Iso14443a, "FIDO2 MakeCredential command."}, + {"assert", cmd_hf_fido_2get_assertion, IfPm3Iso14443a, "FIDO2 GetAssertion command."}, + {NULL, NULL, 0, NULL} }; int CmdHFFido(const char *Cmd) { diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 1ce21f5fe..87ce3e9cf 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -604,9 +604,11 @@ static void print_picopass_header(const picopass_hdr *hdr) { } static int CmdHFiClassList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("iclass"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t iclass"); + } + return CmdTraceList(args); } static int CmdHFiClassSniff(const char *Cmd) { diff --git a/client/src/cmdhflegic.c b/client/src/cmdhflegic.c index 5d9147896..6da888ff1 100644 --- a/client/src/cmdhflegic.c +++ b/client/src/cmdhflegic.c @@ -1401,9 +1401,11 @@ static int CmdLegicWipe(const char *Cmd) { } static int CmdLegicList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("legic"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t legic"); + } + return CmdTraceList(args); } static command_t CommandTable[] = { diff --git a/client/src/cmdhflto.c b/client/src/cmdhflto.c index 6623f9cd2..0e2df52e2 100644 --- a/client/src/cmdhflto.c +++ b/client/src/cmdhflto.c @@ -207,9 +207,11 @@ int infoLTO(bool verbose) { } static int CmdHfLTOList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("lto"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t lto"); + } + return CmdTraceList(args); } static int lto_rdbl(uint8_t blk, uint8_t *block_responce, uint8_t *block_cnt_responce, bool verbose) { diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index a86e11f38..e0c52de2f 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -5196,8 +5196,11 @@ static int CmdHFMFPersonalize(const char *cmd) { } static int CmdHF14AMfList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return CmdTraceList("mf"); + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t mf"); + } + return CmdTraceList(args); } static int CmdHf14AGen3UID(const char *Cmd) { diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index d43df03a4..4ad346f8f 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -4470,8 +4470,11 @@ static int CmdHF14aDesChk(const char *Cmd) { } static int CmdHF14ADesList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - return CmdTraceList("des"); + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t des"); + } + return CmdTraceList(args); } /* diff --git a/client/src/cmdhfst.c b/client/src/cmdhfst.c index de9588ee3..021e9059d 100644 --- a/client/src/cmdhfst.c +++ b/client/src/cmdhfst.c @@ -724,9 +724,11 @@ static int cmd_hf_st_pwd(const char *Cmd) { } static int cmd_hf_st_list(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("7816"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 7816"); + } + return CmdTraceList(args); } static command_t CommandTable[] = { diff --git a/client/src/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c index 0ef62411a..b8fbe3798 100644 --- a/client/src/cmdhfthinfilm.c +++ b/client/src/cmdhfthinfilm.c @@ -118,7 +118,6 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len, bool verbos return PM3_SUCCESS; } - static int CmdHfThinFilmInfo(const char *Cmd) { uint8_t cmdp = 0; @@ -226,9 +225,11 @@ static int CmdHfThinFilmSim(const char *Cmd) { } static int CmdHfThinFilmList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("thinfilm"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t thinfilm"); + } + return CmdTraceList(args); } static command_t CommandTable[] = { diff --git a/client/src/cmdhftopaz.c b/client/src/cmdhftopaz.c index 6410d67bc..8a99fea73 100644 --- a/client/src/cmdhftopaz.c +++ b/client/src/cmdhftopaz.c @@ -481,9 +481,11 @@ static int CmdHFTopazCmdRaw(const char *Cmd) { } static int CmdHFTopazList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("topaz"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t topaz"); + } + return CmdTraceList(args); } static int CmdHelp(const char *Cmd); diff --git a/client/src/cmdlfhitag.c b/client/src/cmdlfhitag.c index 17a71b8e4..957542a84 100644 --- a/client/src/cmdlfhitag.c +++ b/client/src/cmdlfhitag.c @@ -149,9 +149,12 @@ static int usage_hitag_checkchallenges(void) { } static int CmdLFHitagList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("hitag2"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t hitag2"); + } + return CmdTraceList(args); + /* uint8_t *got = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t)); diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c index 69539362f..cd6f02a32 100644 --- a/client/src/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -844,9 +844,11 @@ static int CmdSmartSetClock(const char *Cmd) { } static int CmdSmartList(const char *Cmd) { - (void)Cmd; // Cmd is not used so far - CmdTraceList("7816"); - return PM3_SUCCESS; + char args[128]; + if (strlen(Cmd) == 0) { + snprintf(args, sizeof(args), "-t 7816"); + } + return CmdTraceList(args); } static void smart_brute_prim(void) {