This commit is contained in:
iceman1001 2023-10-02 20:59:01 +02:00
parent 1f50a76d90
commit 89db5d3875
16 changed files with 66 additions and 127 deletions

View file

@ -2168,7 +2168,7 @@ static int CmdHF14BView(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
};

View file

@ -1143,13 +1143,13 @@ static int CmdHF15ELoad(const char *Cmd) {
static int CmdHF15ESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 esave",
"Save emulator memory into two files (BIN/JSON) ",
"Save emulator memory into two files (bin/json) ",
"hf 15 esave -f hf-15-01020304"
"hf 15 esave -b 8 -c 42 -f hf-15-01020304"
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_int0(NULL, "bsize", "<dec>", "block size, defaults to 4"),
arg_int0("c", "count", "<dec>", "number of blocks to export, defaults to all"),
arg_param_end
@ -1542,7 +1542,7 @@ static int CmdHF15WriteDsfid(const char *Cmd) {
static int CmdHF15Dump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 dump",
"This command dumps the contents of a ISO-15693 tag and save it to file",
"This command dumps the contents of a ISO-15693 tag and save to file (bin/json)",
"hf 15 dump\n"
"hf 15 dump -*\n"
"hf 15 dump -u E011223344556677 -f hf-15-my-dump.bin"
@ -1550,7 +1550,7 @@ static int CmdHF15Dump(const char *Cmd) {
void *argtable[6 + 2] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
argtable[arglen++] = arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -2175,7 +2175,7 @@ static int CmdHF15Write(const char *Cmd) {
static int CmdHF15Restore(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 restore",
"This command restore the contents of a dump file onto a ISO-15693 tag",
"This command restore the contents of a dump file (bin/eml/json) onto a ISO-15693 tag",
"hf 15 restore\n"
"hf 15 restore -*\n"
"hf 15 restore -u E011223344556677 -f hf-15-my-dump.bin"
@ -2183,10 +2183,10 @@ static int CmdHF15Restore(const char *Cmd) {
void *argtable[6 + 5] = {};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "filename of dump"),
argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"),
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
argtable[arglen++] = arg_int0("r", "retry", "<dec>", "number of retries (def 3)"),
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -2856,7 +2856,7 @@ static int CmdHF15View(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
// arg_lit0("z", "dense", "dense dump output style"),
arg_param_end
};

View file

@ -423,13 +423,13 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf cryptorf eload",
"Loads CryptoRF tag dump into emulator memory on device",
"Loads CryptoRF tag dump (bin/eml/json) into emulator memory on device",
"hf cryptorf eload -f hf-cryptorf-0102030405-dump.bin\n"
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -485,14 +485,14 @@ static int CmdHFCryptoRFESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf cryptorf esave",
"Save emulator memory to to two files (bin/json)\n"
"Save emulator memory to file (bin/json)\n"
"if filename is not supplied, UID will be used.",
"hf cryptorf esave\n"
"hf cryptorf esave -f filename"
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);

View file

@ -235,14 +235,14 @@ static int CmdHFFudanReader(const char *Cmd) {
static int CmdHFFudanDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf fudan dump",
"Dump FUDAN tag to binary file\n"
"Dump FUDAN tag to file (bin/json)\n"
"If no <name> given, UID will be used as filename",
"hf fudan dump -f mydump --> dump using filename\n"
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -453,7 +453,7 @@ static int CmdHFFudanView(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);

View file

@ -1009,14 +1009,14 @@ static int CmdHFiClassReader(const char *Cmd) {
static int CmdHFiClassELoad(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf iclass eload",
"Load emulator memory with data from (bin/eml/json) iCLASS dump file",
"hf iclass eload -f hf-iclass-AA162D30F8FF12F1-dump.eml\n"
"Load emulator memory with data from (bin/json) iCLASS dump file",
"hf iclass eload -f hf-iclass-AA162D30F8FF12F1-dump.json\n"
"hf iclass eload -f hf-iclass-AA162D30F8FF12F1-dump.bin -m\n"
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("m", "mem", "use RDV4 spiffs"),
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
@ -1103,7 +1103,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
static int CmdHFiClassESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf iclass esave",
"Save emulator memory to file.\n"
"Save emulator memory to file (bin/json)\n"
"if filename is not supplied, CSN will be used.",
"hf iclass esave\n"
"hf iclass esave -f hf-iclass-dump\n"
@ -1111,7 +1111,7 @@ static int CmdHFiClassESave(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump file"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_int0("s", "size", "<256|2048>", "number of bytes to save (default 256)"),
arg_param_end
};
@ -1308,7 +1308,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
"which is defined by the configuration block.\n"
"\nOBS!\n"
"In order to use this function, the file `iclass_decryptionkey.bin` must reside\n"
"in the resources directory. The file should be 16 bytes binary data\n"
"in the resources directory. The file must be 16 bytes binary data\n"
"or...\n"
"make sure your cardhelper is placed in the sim module",
"hf iclass decrypt -f hf-iclass-AA162D30F8FF12F1-dump.bin\n"
@ -1317,7 +1317,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump file (bin/eml/json)"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_str0("d", "data", "<hex>", "3DES encrypted data"),
arg_str0("k", "key", "<hex>", "3DES transport key"),
arg_lit0("v", "verbose", "verbose output"),
@ -2328,7 +2328,7 @@ static int CmdHFiClassCreditEpurse(const char *Cmd) {
static int CmdHFiClassRestore(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf iclass restore",
"Restore data from dumpfile onto a iCLASS tag",
"Restore data from dumpfile (bin/eml/json) onto a iCLASS tag",
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0\n"
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 --ki 0 --elite\n"
"hf iclass restore -f hf-iclass-AA162D30F8FF12F1-dump.bin --first 6 --last 18 -k 1122334455667788 --elite\n"
@ -2336,7 +2336,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "specify a filename to restore (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "specify a filename to restore"),
arg_str0("k", "key", "<hex>", "Access key as 8 hex bytes"),
arg_int0(NULL, "ki", "<dec>", "Key index to select key from memory 'hf iclass managekeys'"),
arg_int1(NULL, "first", "<dec>", "The first block number to restore"),
@ -3026,7 +3026,7 @@ static int CmdHFiClassView(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_int0(NULL, "first", "<dec>", "Begin printing from this block (default first user block)"),
arg_int0(NULL, "last", "<dec>", "End printing at this block (default 0, ALL)"),
arg_lit0("v", "verbose", "verbose output"),

View file

@ -966,7 +966,7 @@ static int CmdLegicRestore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "Filename to restore"),
arg_str1("f", "file", "<fn>", "Specify a filename to restore"),
arg_lit0(NULL, "ob", "obfuscate dump data (xor with MCC)"),
arg_param_end
};
@ -1406,7 +1406,7 @@ static int CmdLegicView(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "Filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
};

View file

@ -1130,7 +1130,7 @@ static int FastDumpWithEcFill(uint8_t numsectors) {
static int CmdHF14AMfDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf dump",
"Dump MIFARE Classic tag to binary file\n"
"Dump MIFARE Classic tag to file (bin/json)\n"
"If no <name> given, UID will be used as filename",
"hf mf dump --mini --> MIFARE Mini\n"
"hf mf dump --1k --> MIFARE Classic 1k\n"
@ -1140,7 +1140,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_str0("k", "keys", "<fn>", "filename of keys"),
arg_lit0(NULL, "mini", "MIFARE Classic Mini / S20"),
arg_lit0(NULL, "1k", "MIFARE Classic 1k / S50 (def)"),
@ -1264,7 +1264,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
arg_lit0(NULL, "4k", "MIFARE Classic 4k / S70"),
arg_str0("u", "uid", "<hex>", "uid, (4|7|10 hex bytes)"),
arg_str0("f", "file", "<fn>", "specify dump filename (bin/eml/json)"),
arg_str0("f", "file", "<fn>", "specify a filename for dump file"),
arg_str0("k", "kfn", "<fn>", "key filename"),
arg_lit0(NULL, "ka", "use specified keyfile to authenticate"),
arg_lit0(NULL, "force", "override warnings"),
@ -4250,7 +4250,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "mini", "MIFARE Classic Mini / S20"),
arg_lit0(NULL, "1k", "MIFARE Classic 1k / S50 (def)"),
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
@ -4439,14 +4439,14 @@ static int CmdHF14AMfESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf esave",
"Save emulator memory into two files (bin//json) ",
"Save emulator memory to file (bin/json) ",
"hf mf esave\n"
"hf mf esave --4k\n"
"hf mf esave --4k -f hf-mf-01020304.eml"
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "mini", "MIFARE Classic Mini / S20"),
arg_lit0(NULL, "1k", "MIFARE Classic 1k / S50 (def)"),
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
@ -4952,7 +4952,7 @@ static int CmdHF14AMfCLoad(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "emu", "from emulator memory"),
arg_param_end
};
@ -5181,14 +5181,14 @@ static int CmdHF14AMfCGetSc(const char *Cmd) {
static int CmdHF14AMfCSave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf csave",
"Save magic gen1a card memory into two files (bin/json)"
"Save magic gen1a card memory to file (bin/json)"
"or into emulator memory",
"hf mf csave\n"
"hf mf csave --4k"
);
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "mini", "MIFARE Classic Mini / S20"),
arg_lit0(NULL, "1k", "MIFARE Classic 1k / S50 (def)"),
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
@ -7332,7 +7332,7 @@ static int CmdHF14AMfView(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("v", "verbose", "verbose output"),
arg_lit0(NULL, "sk", "Save extracted keys to file"),
arg_param_end
@ -7509,7 +7509,7 @@ static int CmdHF14AGen4Load(const char *cmd) {
arg_lit0(NULL, "4k", "MIFARE Classic 4k / S70"),
arg_str0("p", "pwd", "<hex>", "password 4bytes"),
arg_lit0("v", "verbose", "verbose output"),
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "emu", "from emulator memory"),
arg_int0(NULL, "start", "<dec>", "index of block to start writing (default 0)"),
arg_int0(NULL, "end", "<dec>", "index of block to end writing (default last block)"),
@ -7855,7 +7855,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf gsave",
"Save `magic gen4 gtu` card memory into two files (bin/json)"
"Save `magic gen4 gtu` card memory to file (bin/json)"
"or into emulator memory",
"hf mf gsave\n"
"hf mf gsave --4k\n"
@ -7868,7 +7868,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
arg_lit0(NULL, "4k", "MIFARE Classic 4k / S70"),
arg_str0("p", "pwd", "<hex>", "password 4 bytes"),
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "emu", "to emulator memory"),
arg_param_end
};

View file

@ -1384,15 +1384,15 @@ static int CmdHFMFPChk(const char *Cmd) {
static int CmdHFMFPDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mfp dump",
"Dump MIFARE Plus tag to binary file\n"
"Dump MIFARE Plus tag to file (bin/json)\n"
"If no <name> given, UID will be used as filename",
"hf mfp dump\n"
"hf mfp dump --keys hf-mf-066C8B78-key.bin --> MIFARE Plus with keys from specified file\n");
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("k", "keys", "<fn>", "filename of keys"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_str0("k", "keys", "<fn>", "Specify a filename for keys file"),
arg_lit0(NULL, "ns", "no save to file"),
arg_lit0("v", "verbose", "Verbose mode"),
arg_param_end

View file

@ -2434,7 +2434,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mfu dump",
"Dump MIFARE Ultralight/NTAG tag to binary/eml/json files.\n"
"Dump MIFARE Ultralight/NTAG tag to files (bin/json)\n"
"It autodetects card type."
"Supports:\n"
"Ultralight, Ultralight-C, Ultralight EV1\n"
@ -2848,7 +2848,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "specify dump filename"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_str0("k", "key", "<hex>", "key for authentication (UL-C 16 bytes, EV1/NTAG 4 bytes)"),
arg_lit0("l", NULL, "swap entered key's endianness"),
arg_lit0("s", NULL, "enable special write UID -MAGIC TAG ONLY-"),
@ -3065,7 +3065,7 @@ static int CmdHF14AMfUeLoad(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "Filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_int0("q", "qty", "<dec>", "Number of blocks to load from eml file"),
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
@ -4574,7 +4574,7 @@ static int CmdHF14AMfuESave(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_int0("e", "end", "<dec>", "index of last block"),
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
@ -4634,7 +4634,7 @@ static int CmdHF14AMfuView(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "Filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("v", "verbose", "Verbose output"),
arg_param_end
};

View file

@ -41,7 +41,7 @@ static int CmdHF_ntag424_view(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "Filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0("v", "verbose", "Verbose output"),
arg_param_end
};

View file

@ -838,13 +838,13 @@ static int CmdHFTopazDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf topaz dump",
"Dump TOPAZ tag to binary file\n"
"Dump TOPAZ tag to file (bin/json)\n"
"If no <name> given, UID will be used as filename",
"hf topaz dump\n");
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_lit0(NULL, "ns", "no save to file"),
arg_param_end
};
@ -916,7 +916,7 @@ static int CmdHFTopazView(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);

View file

@ -194,7 +194,7 @@ int CmdEM4x50ELoad(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "dump filename"),
arg_str1("f", "file", "<fn>", "Specify a filename for dump file"),
arg_param_end
};
@ -1113,7 +1113,7 @@ int CmdEM4x50Restore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("u", "uid", "<hex>", "uid, 4 hex bytes, msb"),
arg_str0("f", "file", "<fn>", "specify dump filename (bin/eml/json)"),
arg_str0("f", "file", "<fn>", "specify a filename for dump file"),
arg_str0("p", "pwd", "<hex>", "password, 4 hex bytes, lsb"),
arg_param_end
};

View file

@ -2336,7 +2336,7 @@ static int CmdT55xxRestore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "filename of dump file"),
arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
arg_str0("p", "pwd", "<hex>", "password if target card has password set (4 hex bytes)"),
arg_param_end
};

View file

@ -264,57 +264,6 @@ int saveFile(const char *preferredName, const char *suffix, const void *data, si
return PM3_SUCCESS;
}
// dump file
int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t blocksize) {
if (data == NULL || datalen == 0) {
return PM3_EINVARG;
}
char *fileName = newfilenamemcopyEx(preferredName, ".eml", spDump);
if (fileName == NULL) {
return PM3_EMALLOC;
}
int retval = PM3_SUCCESS;
int blocks = datalen / blocksize;
uint16_t currblock = 1;
// We should have a valid filename now, e.g. dumpdata-3.bin
// Opening file for writing in text mode
FILE *f = fopen(fileName, "w+");
if (!f) {
PrintAndLogEx(WARNING, "file not found or locked `" _YELLOW_("%s") "`", fileName);
retval = PM3_EFILE;
goto out;
}
for (size_t i = 0; i < datalen; i++) {
fprintf(f, "%02X", data[i]);
// no extra line in the end
if ((i + 1) % blocksize == 0 && currblock != blocks) {
fprintf(f, "\n");
currblock++;
}
}
// left overs
if (datalen % blocksize != 0) {
int index = blocks * blocksize;
for (size_t j = 0; j < datalen % blocksize; j++) {
fprintf(f, "%02X", data[index + j]);
}
}
fflush(f);
fclose(f);
PrintAndLogEx(SUCCESS, "saved " _YELLOW_("%" PRId32) " blocks to text file " _YELLOW_("%s"), blocks, fileName);
out:
free(fileName);
return retval;
}
// dump file (normally, we also got preference file, etc)
int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, size_t datalen, void (*callback)(json_t *)) {
return saveFileJSONex(preferredName, ftype, data, datalen, true, callback, spDump);
@ -1543,12 +1492,15 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (!strcmp(ctype, "ndef")) {
/*
// when we will read and return extra values from NDEF json
json_error_t up_error = {0};
int i1 = 0;
size_t ndefsize = 0;
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "Ndef.Size", &i1) == 0) {
ndefsize = i1;
}
*/
size_t sptr = 0;
for (int i = 0; i < (maxdatalen / 16); i++) {

View file

@ -100,19 +100,6 @@ char *newfilenamemcopyEx(const char *preferredName, const char *suffix, savePath
*/
int saveFile(const char *preferredName, const char *suffix, const void *data, size_t datalen);
/**
* @brief Utility function to save data to a textfile (EML). This method takes a preferred name, but if that
* file already exists, it tries with another name until it finds something suitable.
* E.g. dumpdata-15.txt
*
* @param preferredName
* @param data The binary data to write to the file
* @param datalen the length of the data
* @param blocksize the length of one row
* @return 0 for ok, 1 for failz
*/
int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t blocksize);
/** STUB
* @brief Utility function to save JSON data to a file. This method takes a preferred name, but if that
* file already exists, it tries with another name until it finds something suitable.

View file

@ -140,7 +140,7 @@ Decrypt iCLASS Block / file
```
Options
---
-f, --file <filename> filename of dumpfile
-f, --file <filename> Specify a filename for dump file
-d, --data <hex> 3DES encrypted data
-k, --key <hex> 3DES transport key
-v, --verbose verbose output
@ -153,7 +153,7 @@ Load iCLASS dump into memory for simulation
```
Options
---
-f, --file <filename> filename of dump
-f, --file <filename> Specify a filename for dump file
--json load JSON type dump
--eml load EML type dump
@ -261,8 +261,8 @@ Dump MIFARE Classic card contents
```
Options:
---
-f, --file <filename> filename of dump
-k, --keys <filename> filename of keys
-f, --file <filename> Specify a filename for dump file
-k, --keys <filename> Specify a filename for keys file
--mini MIFARE Classic Mini / S20
--1k MIFARE Classic 1k / S50 (default)
--2k MIFARE Classic/Plus 2k
@ -335,7 +335,7 @@ Accepts (BIN/EML/JSON)
```
Options
---
-f, --file <fn> filename of dump
-f, --file <fn> Specify a filename for dump file
--mini MIFARE Classic Mini / S20
--1k MIFARE Classic 1k / S50 (def)
--2k MIFARE Classic/Plus 2k