hf mf ice - now use cliparser

This commit is contained in:
tcprst 2021-02-07 13:30:56 -05:00
commit eeb6200081
No known key found for this signature in database
GPG key ID: 9145EAF5121AED25
2 changed files with 35 additions and 48 deletions

View file

@ -42,18 +42,6 @@
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
static int usage_hf14_ice(void) {
PrintAndLogEx(NORMAL, "Usage: hf mf ice [l <limit>] [f <name>]");
PrintAndLogEx(NORMAL, " h this help");
PrintAndLogEx(NORMAL, " l <limit> nonces to be collected");
PrintAndLogEx(NORMAL, " f <name> save nonces to <name> instead of hf-mf-<UID>-nonces.bin");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ice"));
PrintAndLogEx(NORMAL, _YELLOW_(" hf mf ice f nonces.bin"));
return PM3_SUCCESS;
}
static int usage_hf14_dump(void) { static int usage_hf14_dump(void) {
PrintAndLogEx(NORMAL, "Usage: hf mf dump [card memory] [k <name>] [f <name>]"); PrintAndLogEx(NORMAL, "Usage: hf mf dump [card memory] [k <name>] [f <name>]");
PrintAndLogEx(NORMAL, " [card memory]: 0 = 320 bytes (MIFARE Mini), 1 = 1K (default), 2 = 2K, 4 = 4K"); PrintAndLogEx(NORMAL, " [card memory]: 0 = 320 bytes (MIFARE Mini), 1 = 1K (default), 2 = 2K, 4 = 4K");
@ -4709,44 +4697,30 @@ static int CmdHf14AMfNack(const char *Cmd) {
} }
static int CmdHF14AMfice(const char *Cmd) { static int CmdHF14AMfice(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf ice",
"Collect MIFARE Classic nonces to file",
"hf mf ice\n"
"hf mf ice -f nonces.bin");
uint8_t blockNo = 0; void *argtable[] = {
uint8_t keyType = 0; arg_param_begin,
uint8_t trgBlockNo = 0; arg_str0("f", "file", "<filename>", "filename of nonce dump"),
uint8_t trgKeyType = 1; arg_u64_0(NULL, "limit", "<dec>", "nonces to be collected"),
bool slow = false; arg_param_end
bool initialize = true; };
bool acquisition_completed = false; CLIExecWithReturn(ctx, Cmd, argtable, true);
uint8_t cmdp = 0;
uint32_t flags = 0;
uint32_t total_num_nonces = 0;
char ctmp;
char filename[FILE_PATH_SIZE], *fptr;
FILE *fnonces = NULL;
PacketResponseNG resp;
uint32_t part_limit = 3000; int fnlen = 0;
uint32_t limit = 50000; char filename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
while ((ctmp = param_getchar(Cmd, cmdp))) { uint32_t limit = arg_get_u32_def(ctx, 2, 50000);
switch (tolower(ctmp)) {
case 'h': CLIParserFree(ctx);
return usage_hf14_ice();
case 'f': // Validations
param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE); char *fptr;
cmdp++;
break;
case 'l':
limit = param_get32ex(Cmd, cmdp + 1, 50000, 10);
cmdp++;
break;
default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'\n", ctmp);
usage_hf14_ice();
return PM3_ESOFT;
}
cmdp++;
}
if (filename[0] == '\0') { if (filename[0] == '\0') {
fptr = GenerateFilename("hf-mf-", "-nonces.bin"); fptr = GenerateFilename("hf-mf-", "-nonces.bin");
@ -4756,6 +4730,20 @@ static int CmdHF14AMfice(const char *Cmd) {
free(fptr); free(fptr);
} }
uint8_t blockNo = 0;
uint8_t keyType = 0;
uint8_t trgBlockNo = 0;
uint8_t trgKeyType = 1;
bool slow = false;
bool initialize = true;
bool acquisition_completed = false;
uint32_t flags = 0;
uint32_t total_num_nonces = 0;
FILE *fnonces = NULL;
PacketResponseNG resp;
uint32_t part_limit = 3000;
PrintAndLogEx(NORMAL, "Collecting "_YELLOW_("%u")" nonces \n", limit); PrintAndLogEx(NORMAL, "Collecting "_YELLOW_("%u")" nonces \n", limit);
if ((fnonces = fopen(filename, "wb")) == NULL) { if ((fnonces = fopen(filename, "wb")) == NULL) {

View file

@ -92,7 +92,6 @@ hf mf cview
hf mf gen3uid hf mf gen3uid
hf mf gen3blk hf mf gen3blk
hf mf gen3freeze hf mf gen3freeze
hf mf ice
lf em 410x lf em 410x
lf em 4x05 lf em 4x05
lf em 4x50 lf em 4x50