mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-25 08:35:56 +08:00
hf lto rdbl - now use cliparser
This commit is contained in:
parent
02637193f7
commit
5b526522c7
2 changed files with 17 additions and 47 deletions
|
@ -37,18 +37,6 @@
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static int usage_lto_rdbl(void) {
|
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf lto rdbl [h] s <start block> e <end block>");
|
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
|
||||||
PrintAndLogEx(NORMAL, " h this help");
|
|
||||||
PrintAndLogEx(NORMAL, " s start block in decimal >= 0");
|
|
||||||
PrintAndLogEx(NORMAL, " e end block in decimal <= 254");
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf lto rdbl s 0 e 254") " - Read data block from 0 to 254");
|
|
||||||
return PM3_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int usage_lto_wrbl(void) {
|
static int usage_lto_wrbl(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf lto wrbl [h] b <block> d <data>");
|
PrintAndLogEx(NORMAL, "Usage: hf lto wrbl [h] b <block> d <data>");
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
PrintAndLogEx(NORMAL, "Options:");
|
||||||
|
@ -265,48 +253,31 @@ int rdblLTO(uint8_t st_blk, uint8_t end_blk, bool verbose) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHfLTOReadBlock(const char *Cmd) {
|
static int CmdHfLTOReadBlock(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf lto rdbl",
|
||||||
|
"Reead blocks from LTO tag",
|
||||||
|
"hf lto rdbl --first 0 --last 254");
|
||||||
|
|
||||||
uint8_t cmdp = 0;
|
void *argtable[] = {
|
||||||
bool errors = false;
|
arg_param_begin,
|
||||||
uint8_t st_blk = 0;
|
arg_int0(NULL, "first", "<dec>", "The first block number to read as an integer"),
|
||||||
uint8_t end_blk = 254;
|
arg_int0(NULL, "last", "<dec>", "The last block number to read as an integer"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
int startblock = arg_get_int_def(ctx, 1, 0);
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
int endblock = arg_get_int_def(ctx, 2, 254);
|
||||||
case 'h':
|
|
||||||
return usage_lto_rdbl();
|
|
||||||
case 's':
|
|
||||||
st_blk = param_get8(Cmd, cmdp + 1);
|
|
||||||
if (end_blk < st_blk) {
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmdp += 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'e':
|
CLIParserFree(ctx);
|
||||||
end_blk = param_get8(Cmd, cmdp + 1);
|
|
||||||
if (end_blk < st_blk) {
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmdp += 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors) {
|
if (endblock < startblock) {
|
||||||
usage_lto_rdbl();
|
PrintAndLogEx(ERR, "First block must be less than last block");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rdblLTO(st_blk, end_blk, true);
|
return rdblLTO(startblock, endblock, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lto_wrbl(uint8_t blk, uint8_t *data, bool verbose) {
|
static int lto_wrbl(uint8_t blk, uint8_t *data, bool verbose) {
|
||||||
|
|
|
@ -101,7 +101,6 @@ hf legic crc
|
||||||
hf legic eload
|
hf legic eload
|
||||||
hf legic esave
|
hf legic esave
|
||||||
hf legic wipe
|
hf legic wipe
|
||||||
hf lto rdbl
|
|
||||||
hf lto wrbl
|
hf lto wrbl
|
||||||
hf lto list
|
hf lto list
|
||||||
hf mf list
|
hf mf list
|
||||||
|
|
Loading…
Reference in a new issue