mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
hf legic eload - now use cliparser
This commit is contained in:
parent
ef2dfc8b3b
commit
cd972adce5
3 changed files with 38 additions and 64 deletions
|
@ -530,7 +530,7 @@ local function main(args)
|
||||||
res = res .."\ncreated clone_dump from\n\t"..infile.." crc: "..oldcrc.."\ndump_file:"
|
res = res .."\ncreated clone_dump from\n\t"..infile.." crc: "..oldcrc.."\ndump_file:"
|
||||||
res = res .."\n\t"..outfile.." crc: "..string.sub(newcrc, -2)
|
res = res .."\n\t"..outfile.." crc: "..string.sub(newcrc, -2)
|
||||||
res = res .."\nyou may load the new file with:"
|
res = res .."\nyou may load the new file with:"
|
||||||
res = res ..ansicolors.yellow.."hf legic eload f "..outfile..ansicolors.reset
|
res = res ..ansicolors.yellow.."hf legic eload -f "..outfile..ansicolors.reset
|
||||||
res = res .."\n\nif you don't write to tag immediately ('-w' switch) you will need to recalculate each segmentCRC"
|
res = res .."\n\nif you don't write to tag immediately ('-w' switch) you will need to recalculate each segmentCRC"
|
||||||
res = res .."\nafter writing this dump to a tag!"
|
res = res .."\nafter writing this dump to a tag!"
|
||||||
res = res .."\n\na segmentCRC gets calculated over MCD,MSN0..3, Segment-Header0..3"
|
res = res .."\n\na segmentCRC gets calculated over MCD,MSN0..3, Segment-Header0..3"
|
||||||
|
|
|
@ -28,20 +28,6 @@ static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
#define MAX_LENGTH 1024
|
#define MAX_LENGTH 1024
|
||||||
|
|
||||||
static int usage_legic_eload(void) {
|
|
||||||
PrintAndLogEx(NORMAL, "It loads a binary dump into emulator memory\n");
|
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf legic eload [h] [card memory] [f <file name w/o `.bin`>]\n");
|
|
||||||
PrintAndLogEx(NORMAL, "Options:");
|
|
||||||
PrintAndLogEx(NORMAL, " h : this help");
|
|
||||||
PrintAndLogEx(NORMAL, " [card memory] : 0 = MIM22");
|
|
||||||
PrintAndLogEx(NORMAL, " : 1 = MIM256 (default)");
|
|
||||||
PrintAndLogEx(NORMAL, " : 2 = MIM1024");
|
|
||||||
PrintAndLogEx(NORMAL, " f <filename> : filename w/o .bin to load");
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
|
||||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic eload 2 f myfile"));
|
|
||||||
return PM3_SUCCESS;
|
|
||||||
}
|
|
||||||
static int usage_legic_esave(void) {
|
static int usage_legic_esave(void) {
|
||||||
PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n");
|
PrintAndLogEx(NORMAL, "It saves bin/eml/json dump file of emulator memory\n");
|
||||||
PrintAndLogEx(NORMAL, "Usage: hf legic esave [h] [card memory] f <file name w/o `.bin`>\n");
|
PrintAndLogEx(NORMAL, "Usage: hf legic esave [h] [card memory] f <file name w/o `.bin`>\n");
|
||||||
|
@ -978,58 +964,47 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdLegicELoad(const char *Cmd) {
|
static int CmdLegicELoad(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf legic eload",
|
||||||
|
"Loads a LEGIC binary dump into emulator memory",
|
||||||
|
"hf legic eload -f myfile -t 0 <- Simulate Type MIM22\n"
|
||||||
|
"hf legic eload -f myfile -t 1 <- Simulate Type MIM256 (default)\n"
|
||||||
|
"hf legic eload -f myfile -t 2 <- Simulate Type MIM1024");
|
||||||
|
|
||||||
size_t numofbytes = 256;
|
void *argtable[] = {
|
||||||
char filename[FILE_PATH_SIZE] = {0x00};
|
arg_param_begin,
|
||||||
bool errors = false, shall_obsfuscate = false, have_filename = false;
|
arg_str1("f", "file", "<filename>", "Specify a filename to restore"),
|
||||||
uint8_t cmdp = 0;
|
arg_int0("t", "type", "<dec>", "Tag type to simulate."),
|
||||||
|
arg_lit0(NULL, "obfuscate", "Obfuscate dump data (xor with MCC)"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
int fnlen = 0;
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
char filename[FILE_PATH_SIZE] = {0};
|
||||||
case 'h' : {
|
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
||||||
return usage_legic_eload();
|
|
||||||
}
|
size_t numofbytes = 0;
|
||||||
case 'f' : {
|
|
||||||
if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) {
|
switch (arg_get_int_def(ctx, 2, 1)) {
|
||||||
PrintAndLogEx(FAILED, "Filename too long");
|
case 0:
|
||||||
break;
|
|
||||||
}
|
|
||||||
have_filename = true;
|
|
||||||
cmdp += 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'x': {
|
|
||||||
shall_obsfuscate = true;
|
|
||||||
cmdp++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '0' : {
|
|
||||||
numofbytes = 22;
|
numofbytes = 22;
|
||||||
cmdp++;
|
|
||||||
break;
|
break;
|
||||||
}
|
case 1:
|
||||||
case '1' : {
|
|
||||||
numofbytes = 256;
|
numofbytes = 256;
|
||||||
cmdp++;
|
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
case '2' : {
|
|
||||||
numofbytes = 1024;
|
numofbytes = 1024;
|
||||||
cmdp++;
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
PrintAndLogEx(ERR, "Unknown tag type");
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
default : {
|
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
|
||||||
errors = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (have_filename == false)
|
|
||||||
errors = true;
|
|
||||||
|
|
||||||
//Validations
|
bool shall_obsfuscate = arg_get_lit(ctx, 3);
|
||||||
if (errors || strlen(Cmd) == 0) return usage_legic_eload();
|
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// set up buffer
|
// set up buffer
|
||||||
uint8_t *data = calloc(numofbytes, sizeof(uint8_t));
|
uint8_t *data = calloc(numofbytes, sizeof(uint8_t));
|
||||||
|
|
|
@ -74,7 +74,6 @@ hf felica resetmode
|
||||||
hf felica litesim
|
hf felica litesim
|
||||||
hf felica litedump
|
hf felica litedump
|
||||||
hf fido info
|
hf fido info
|
||||||
hf legic eload
|
|
||||||
hf legic esave
|
hf legic esave
|
||||||
hf mf darkside
|
hf mf darkside
|
||||||
hf mf nested
|
hf mf nested
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue