lf hitag info, sniff - now uses cliparser

This commit is contained in:
iceman1001 2021-01-09 22:45:17 +01:00
commit 005079b91f

View file

@ -7,18 +7,16 @@
//-----------------------------------------------------------------------------
// Low frequency Hitag support
//-----------------------------------------------------------------------------
#include "cmdlfhitag.h"
#include <ctype.h>
#include "cmdparser.h" // command_t
#include "cmdparser.h" // command_t
#include "comms.h"
#include "cmdtrace.h"
#include "commonutil.h"
#include "hitag.h"
#include "fileutils.h" // savefile
#include "protocols.h" // defines
#include "fileutils.h" // savefile
#include "protocols.h" // defines
#include "cliparser.h"
static int CmdHelp(const char *Cmd);
@ -52,17 +50,7 @@ static size_t nbytes(size_t nbits) {
return (nbits / 8) + ((nbits % 8) > 0);
}
*/
static int usage_hitag_sniff(void) {
PrintAndLogEx(NORMAL, "Sniff traffic between Hitag reader and tag. Use " _YELLOW_("`lf hitag list`")" to view collected data.");
PrintAndLogEx(NORMAL, "Usage: lf hitag sniff [h] ");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
// PrintAndLogEx(NORMAL, " p <pwd> Password");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag sniff");
return PM3_SUCCESS;
}
static int usage_hitag_sim(void) {
PrintAndLogEx(NORMAL, "Simulate " _YELLOW_("Hitag2 / HitagS")" transponder");
PrintAndLogEx(NORMAL, "Usage: lf hitag sim [h] [2|s] e|j|b <filename w/o extension>");
@ -77,15 +65,6 @@ static int usage_hitag_sim(void) {
PrintAndLogEx(NORMAL, " lf hitag sim 2 b lf-hitag-dump");
return PM3_SUCCESS;
}
static int usage_hitag_info(void) {
PrintAndLogEx(NORMAL, "Usage: lf hitag info [h] p <pwd>");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
PrintAndLogEx(NORMAL, " p <pwd> password");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf hitag info");
return PM3_SUCCESS;
}
/*
static int usage_hitag_dump(void) {
PrintAndLogEx(NORMAL, "Usage: lf hitag dump [h] p <pwd> f <name>");
@ -287,12 +266,23 @@ static int CmdLFHitagList(const char *Cmd) {
}
static int CmdLFHitagSniff(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "lf hitag sniff",
"Sniff traffic between Hitag reader and tag.\n"
"Use " _YELLOW_("`lf hitag list`")" to view collected data.",
"lf hitag sniff"
);
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hitag_sniff();
void *argtable[] = {
arg_param_begin,
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
clearCommandBuffer();
SendCommandNG(CMD_LF_HITAG_SNIFF, NULL, 0);
PrintAndLogEx(HINT, "HINT: Try " _YELLOW_("`lf hitag list`")" to view collected data");
return PM3_SUCCESS;
}
@ -508,8 +498,18 @@ static bool getHitagUid(uint32_t *uid) {
}
static int CmdLFHitagInfo(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hitag_info();
CLIParserContext *ctx;
CLIParserInit(&ctx, "lf hitag info",
"Sniff traffic between Hitag reader and tag.",
"lf hitag info"
);
void *argtable[] = {
arg_param_begin,
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
// read UID
uint32_t uid = 0;