reworked the JSON format for 14a, 14b, 15, cryptorf, lto, NDEF.\nDeprecated EML format. Pm3 client do not save EML files any more.nPm3 client will continue to load EML files.

This commit is contained in:
iceman1001
2023-10-02 20:11:23 +02:00
parent bb5d61dca7
commit fb23d2047f
27 changed files with 617 additions and 319 deletions
+2
View File
@@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Changed the json file formats for mfc, 14b, 15, legic, cryptorf, ndef (@iceman1001)
- Depricated the EML file format when saving dump files. (@iceman1001)
- Added `sim014.bin` - new sim module firmware v4.42 with improved ISO7816 Protocol T0 support (@gentilkiwi)
- Added datasheet for sim module (@iceman1001)
- Changed `smart raw --timeout` - allows for a custom timeout (@iceman1001)
+1 -2
View File
@@ -379,8 +379,7 @@ static int CmdFlashMemDump(const char *Cmd) {
}
if (filename[0] != '\0') {
saveFile(filename, ".bin", dump, len);
saveFileEML(filename, dump, len, 16);
pm3_save_dump(filename, dump, len, jsfRaw);
}
free(dump);
+1 -12
View File
@@ -370,14 +370,13 @@ static int CmdFlashMemSpiFFSDump(const char *Cmd) {
"Dumps device SPIFFS file to a local file\n"
"Size is handled by first sending a STAT command against file to verify existence",
"mem spiffs dump -s tag.bin --> download binary file from device\n"
"mem spiffs dump -s tag.bin -d aaa -e --> download tag.bin, save as aaa.eml format"
"mem spiffs dump -s tag.bin -d a001 -e --> download tag.bin, save as `a001.bin`"
);
void *argtable[] = {
arg_param_begin,
arg_str1("s", "src", "<fn>", "SPIFFS file to save"),
arg_str0("d", "dest", "<fn>", "file name to save to <w/o .bin>"),
arg_lit0("e", "eml", "also save in EML format"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
@@ -390,7 +389,6 @@ static int CmdFlashMemSpiFFSDump(const char *Cmd) {
char dest[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)dest, FILE_PATH_SIZE, &dlen);
bool eml = arg_get_lit(ctx, 3);
CLIParserFree(ctx);
// get size from spiffs itself !
@@ -433,15 +431,6 @@ static int CmdFlashMemSpiFFSDump(const char *Cmd) {
else
saveFile(fn, ".bin", dump, len); // default
if (eml) {
uint8_t eml_len = 16;
if (strstr(fn, "class") != NULL)
eml_len = 8;
else if (strstr(fn, "mfu") != NULL)
eml_len = 4;
saveFileEML(fn, dump, len, eml_len);
}
free(dump);
return PM3_SUCCESS;
}
+17 -3
View File
@@ -2748,6 +2748,7 @@ int CmdHF14ANdefRead(const char *Cmd) {
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool verbose = arg_get_lit(ctx, 2);
bool verbose2 = arg_get_lit(ctx, 2) > 1;
CLIParserFree(ctx);
bool activate_field = true;
@@ -2934,11 +2935,24 @@ int CmdHF14ANdefRead(const char *Cmd) {
memcpy(ndef_file + (i - offset), response, segment_size);
}
if (fnlen != 0) {
saveFile(filename, ".bin", ndef_file, ndef_size);
}
if (verbose2) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("NDEF raw") " ----------------");
print_buffer(ndef_file, ndef_size, 1);
}
NDEFRecordsDecodeAndPrint(ndef_file, ndef_size, verbose);
pm3_save_dump(filename, ndef_file, ndef_size, jsfNDEF);
if (verbose == false) {
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf 14a ndefread -v`") " for more details");
} else {
if (verbose2 == false) {
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf 14a ndefread -vv`") " for more details");
}
}
free(ndef_file);
return PM3_SUCCESS;
}
+8 -4
View File
@@ -1546,7 +1546,7 @@ static int CmdHF14BDump(const char *Cmd) {
}
size_t datalen = (lastblock + 2) * ST25TB_SR_BLOCK_SIZE;
pm3_save_dump(filename, data, datalen, jsf14b, ST25TB_SR_BLOCK_SIZE);
pm3_save_dump(filename, data, datalen, jsf14b_v2);
}
}
@@ -2121,9 +2121,13 @@ int CmdHF14BNdefRead(const char *Cmd) {
goto out;
}
if (fnlen != 0) {
saveFile(filename, ".bin", response + 2, resplen - 4);
}
// get total NDEF length before save. If fails, we save it all
size_t n = 0;
if (NDEFGetTotalLength(response + 2, resplen - 4, &n) != PM3_SUCCESS)
n = resplen - 4;
pm3_save_dump(filename, response + 2, n, jsfNDEF);
res = NDEFRecordsDecodeAndPrint(response + 2, resplen - 4, verbose);
out:
+38 -16
View File
@@ -62,7 +62,7 @@
typedef struct {
uint8_t lock;
uint8_t block[4];
uint8_t block[8];
} t15memory_t;
// structure and database for uid -> tagtype lookups
@@ -1143,14 +1143,14 @@ static int CmdHF15ELoad(const char *Cmd) {
static int CmdHF15ESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf 15 esave",
"Save emulator memory into three files (BIN/EML/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_int0("b", "blocksize", "<dec>", "block size, defaults to 4"),
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
};
@@ -1176,13 +1176,18 @@ static int CmdHF15ESave(const char *Cmd) {
}
PrintAndLogEx(INFO, "Downloading %u bytes from emulator memory", bytes);
if (!GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false)) {
if (GetFromDevice(BIG_BUF_EML, dump, bytes, 0, NULL, 0, NULL, 2500, false) == false) {
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
free(dump);
return PM3_ETIMEOUT;
}
pm3_save_dump(filename, dump, bytes, jsf15, blocksize);
if (blocksize == 8) {
pm3_save_dump(filename, dump, bytes, jsf15_v3);
} else {
pm3_save_dump(filename, dump, bytes, jsf15_v2);
}
free(dump);
return PM3_SUCCESS;
}
@@ -1604,9 +1609,12 @@ static int CmdHF15Dump(const char *Cmd) {
// memory.
t15memory_t mem[256];
uint8_t data[256 * 4] = {0};
uint8_t data[256 * 8] = {0};
memset(data, 0, sizeof(data));
// keep track of which block length tag returned?
uint8_t blklen = 4;
for (int retry = 0; (retry < 5 && blocknum < 0x100); retry++) {
req[10] = blocknum;
@@ -1646,9 +1654,15 @@ static int CmdHF15Dump(const char *Cmd) {
break;
}
// lock byte value
mem[blocknum].lock = resp.data.asBytes[0];
memcpy(mem[blocknum].block, resp.data.asBytes + 1, 4);
memcpy(data + (blocknum * 4), resp.data.asBytes + 1, 4);
// is tag responding with 4 or 8 bytes?
if (resp.length == 11) {
blklen = 8;
}
memcpy(mem[blocknum].block, resp.data.asBytes + 1, blklen);
memcpy(data + (blocknum * 4), resp.data.asBytes + 1, blklen);
retry = 0;
blocknum++;
@@ -1659,6 +1673,10 @@ static int CmdHF15Dump(const char *Cmd) {
DropField();
if (blklen == 8) {
PrintAndLogEx(INFO, "8 byte block length detected");
}
PrintAndLogEx(NORMAL, "\n");
PrintAndLogEx(INFO, "block# | data |lck| ascii");
PrintAndLogEx(INFO, "---------+--------------+---+----------");
@@ -1672,9 +1690,9 @@ static int CmdHF15Dump(const char *Cmd) {
PrintAndLogEx(INFO, "%3d/0x%02X | %s | %s | %s"
, i
, i
, sprint_hex(mem[i].block, 4)
, sprint_hex(mem[i].block, blklen)
, lck
, sprint_ascii(mem[i].block, 4)
, sprint_ascii(mem[i].block, blklen)
);
}
PrintAndLogEx(NORMAL, "");
@@ -1687,8 +1705,11 @@ static int CmdHF15Dump(const char *Cmd) {
FillFileNameByUID(fptr, SwapEndian64(uid, sizeof(uid), 8), "-dump", sizeof(uid));
}
size_t datalen = blocknum * 4;
pm3_save_dump(filename, data, datalen, jsf15, 4);
if (blklen == 8) {
pm3_save_dump(filename, data, (blocknum * blklen), jsf15_v3);
} else {
pm3_save_dump(filename, data, (blocknum * blklen), jsf15_v2);
}
return PM3_SUCCESS;
}
@@ -2000,15 +2021,16 @@ static int CmdHF15Readblock(const char *Cmd) {
return PM3_EWRONGANSWER;
}
// print response
char lck[16] = {0};
if (data[1]) {
snprintf(lck, sizeof(lck), _RED_("%d"), data[1]);
snprintf(lck, sizeof(lck), _RED_("%02X"), data[1]);
} else {
snprintf(lck, sizeof(lck), "%d", data[1]);
snprintf(lck, sizeof(lck), "%02X", data[1]);
}
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, " #%3d |lck| ascii", block);
PrintAndLogEx(INFO, "#%3d |lck| ascii", block);
PrintAndLogEx(INFO, "------------+---+------");
PrintAndLogEx(INFO, "%s| %s | %s", sprint_hex(data + 2, resp.length - 4), lck, sprint_ascii(data + 2, resp.length - 4));
PrintAndLogEx(NORMAL, "");
@@ -2834,7 +2856,7 @@ static int CmdHF15View(const char *Cmd) {
);
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "filename of dump"),
// arg_lit0("z", "dense", "dense dump output style"),
arg_param_end
};
+5 -10
View File
@@ -414,9 +414,8 @@ static int CmdHFCryptoRFDump(const char *Cmd) {
FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen);
}
saveFileEML(filename, data, datalen, 4);
saveFile(filename, ".bin", data, datalen);
// json?
pm3_save_dump(filename, data, datalen, jsfCryptorf);
return switch_off_field_cryptorf();
}
@@ -486,14 +485,14 @@ static int CmdHFCryptoRFESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf cryptorf esave",
"Save emulator memory to bin/eml/json file\n"
"Save emulator memory to to two files (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 dumpfile"),
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
@@ -527,11 +526,7 @@ static int CmdHFCryptoRFESave(const char *Cmd) {
FillFileNameByUID(fptr, data, "-dump", 4);
}
saveFile(filename, ".bin", data, numofbytes);
//needs to change
saveFileEML(filename, data, numofbytes, 8);
//needs to change
saveFileJSON(filename, jsfRaw, data, numofbytes, NULL);
pm3_save_dump(filename, data, numofbytes, jsfCryptorf);
free(data);
return PM3_SUCCESS;
}
+1 -8
View File
@@ -339,14 +339,7 @@ static int CmdHFFudanDump(const char *Cmd) {
free(fptr);
}
saveFile(dataFilename, ".bin", (uint8_t *)carddata, sizeof(carddata));
saveFileEML(dataFilename, (uint8_t *)carddata, sizeof(carddata), MAX_FUDAN_BLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = (uint8_t *)carddata;
xdump.dumplen = sizeof(carddata);
saveFileJSON(dataFilename, jsfFudan, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_dump(dataFilename, (uint8_t *)carddata, sizeof(carddata), jsfFudan);
return PM3_SUCCESS;
}
+10 -10
View File
@@ -19,8 +19,8 @@
#include "cmdhficlass.h"
#include <ctype.h>
#include "cliparser.h"
#include "cmdparser.h" // command_t
#include "commonutil.h" // ARRAYLEN
#include "cmdparser.h" // command_t
#include "commonutil.h" // ARRAYLEN
#include "cmdtrace.h"
#include "util_posix.h"
#include "comms.h"
@@ -34,13 +34,13 @@
#include "cardhelper.h"
#include "wiegand_formats.h"
#include "wiegand_formatutils.h"
#include "cmdsmartcard.h" // smart select fct
#include "cmdsmartcard.h" // smart select fct
#include "proxendian.h"
#include "iclass_cmd.h"
#include "crypto/asn1utils.h" // ASN1 decoder
#include "crypto/asn1utils.h" // ASN1 decoder
#include "preferences.h"
#define PICOPASS_BLOCK_SIZE 8
#define NUM_CSNS 9
#define MAC_ITEM_SIZE 24 // csn(8) + epurse(8) + nr(4) + mac(4) = 24 bytes
#define ICLASS_KEYS_MAX 8
@@ -1016,7 +1016,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_lit0("m", "mem", "use RDV4 spiffs"),
arg_lit0("v", "verbose", "verbose output"),
arg_param_end
@@ -1149,7 +1149,7 @@ static int CmdHFiClassESave(const char *Cmd) {
FillFileNameByUID(fptr, dump, "-dump", 8);
}
pm3_save_dump(filename, dump, bytes, jsfIclass, PICOPASS_BLOCK_SIZE);
pm3_save_dump(filename, dump, bytes, jsfIclass);
free(dump);
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass view -f") "` to view dump file");
@@ -1497,7 +1497,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
strcat(fptr, "hf-iclass-");
FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn));
pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass, PICOPASS_BLOCK_SIZE);
pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass);
printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output);
@@ -2045,7 +2045,7 @@ write_dump:
// save the dump to .bin file
PrintAndLogEx(SUCCESS, "saving dump file - %u blocks read", bytes_got / 8);
pm3_save_dump(filename, tag_data, bytes_got, jsfIclass, PICOPASS_BLOCK_SIZE);
pm3_save_dump(filename, tag_data, bytes_got, jsfIclass);
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass decrypt -f") "` to decrypt dump file");
PrintAndLogEx(HINT, "Try `" _YELLOW_("hf iclass view -f") "` to view dump file");
@@ -3026,7 +3026,7 @@ static int CmdHFiClassView(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "filename of dump"),
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"),
+4 -4
View File
@@ -858,7 +858,7 @@ static int CmdLegicReader(const char *Cmd) {
static int CmdLegicDump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf legic dump",
"Read all memory from LEGIC Prime tags and saves to (bin/eml/json) dump file\n"
"Read all memory from LEGIC Prime tags and saves to (bin/json) dump file\n"
"It autodetects card type (MIM22, MIM256, MIM1024)",
"hf legic dump --> use UID as filename\n"
"hf legic dump -f myfile \n"
@@ -951,7 +951,7 @@ static int CmdLegicDump(const char *Cmd) {
FillFileNameByUID(filename, data, "-dump", 4);
}
pm3_save_dump(filename, data, readlen, jsfLegic, LEGIC_BLOCK_SIZE);
pm3_save_dump(filename, data, readlen, jsfLegic_v2);
free(data);
return PM3_SUCCESS;
}
@@ -1119,7 +1119,7 @@ static int CmdLegicELoad(const char *Cmd) {
static int CmdLegicESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf legic esave",
"Saves a (bin/eml/json) dump file of emulator memory",
"Saves a (bin/json) dump file of emulator memory",
"hf legic esave --> uses UID as filename\n"
"hf legic esave -f myfile --22\n"
"hf legic esave -f myfile --22 --de\n"
@@ -1188,7 +1188,7 @@ static int CmdLegicESave(const char *Cmd) {
legic_xor(data, numofbytes);
}
pm3_save_dump(filename, data, numofbytes, jsfLegic, LEGIC_BLOCK_SIZE);
pm3_save_dump(filename, data, numofbytes, jsfLegic_v2);
return PM3_SUCCESS;
}
+1 -2
View File
@@ -771,8 +771,7 @@ static int CmdHfLTODump(const char *Cmd) {
char *fptr = filename + snprintf(filename, sizeof(filename), "hf-lto-");
FillFileNameByUID(fptr, dump, "-dump", 5);
}
saveFile(filename, ".bin", dump, dump_len);
saveFileEML(filename, dump, dump_len, 32);
pm3_save_dump(filename, dump, dump_len, jsfLto);
free(dump);
return PM3_SUCCESS;
}
+19 -67
View File
@@ -472,7 +472,7 @@ void mf_print_sector_hdr(uint8_t sector) {
static bool mf_write_block(const uint8_t *key, uint8_t keytype, uint8_t blockno, uint8_t *block) {
uint8_t data[26];
memcpy(data, key, MFKEY_SIZE);
memcpy(data, key, MIFARE_KEY_SIZE);
memcpy(data + 10, block, MFBLOCK_SIZE);
clearCommandBuffer();
@@ -1230,14 +1230,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
free(fptr);
}
saveFile(dataFilename, ".bin", mem, bytes);
saveFileEML(dataFilename, mem, bytes, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = mem;
xdump.dumplen = bytes;
saveFileJSON(dataFilename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(dataFilename, mem, bytes, jsfCardMemory);
free(mem);
return PM3_SUCCESS;
}
@@ -3164,13 +3157,7 @@ all_found:
strncpy(filename, fptr, sizeof(filename) - 1);
free(fptr);
saveFile(filename, ".bin", dump, bytes);
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(filename, dump, bytes, jsfCardMemory);
// Generate and show statistics
t1 = msclock() - t1;
@@ -4452,7 +4439,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf esave",
"Save emulator memory into three files (BIN/EML/JSON) ",
"Save emulator memory into two files (bin//json) ",
"hf mf esave\n"
"hf mf esave --4k\n"
"hf mf esave --4k -f hf-mf-01020304.eml"
@@ -4522,30 +4509,7 @@ static int CmdHF14AMfESave(const char *Cmd) {
FillFileNameByUID(fptr, dump, "-dump", 4);
}
saveFile(filename, ".bin", dump, bytes);
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump = {0};
xdump.card_info.ats_len = 0;
// Check for 4 bytes uid: bcc corrected and single size uid bits in ATQA
if ((dump[0] ^ dump[1] ^ dump[2] ^ dump[3]) == dump[4] && (dump[6] & 0xc0) == 0) {
xdump.card_info.uidlen = 4;
memcpy(xdump.card_info.uid, dump, xdump.card_info.uidlen);
xdump.card_info.sak = dump[5];
memcpy(xdump.card_info.atqa, &dump[6], sizeof(xdump.card_info.atqa));
}
// Check for 7 bytes UID: double size uid bits in ATQA
else if ((dump[8] & 0xc0) == 0x40) {
xdump.card_info.uidlen = 7;
memcpy(xdump.card_info.uid, dump, xdump.card_info.uidlen);
xdump.card_info.sak = dump[7];
memcpy(xdump.card_info.atqa, &dump[8], sizeof(xdump.card_info.atqa));
} else {
PrintAndLogEx(WARNING, "Invalid dump. UID/SAK/ATQA not found");
}
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(filename, dump, bytes, jsfCardMemory);
free(dump);
return PM3_SUCCESS;
}
@@ -5217,7 +5181,7 @@ 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 three files (BIN/EML/JSON)"
"Save magic gen1a card memory into two files (bin/json)"
"or into emulator memory",
"hf mf csave\n"
"hf mf csave --4k"
@@ -5364,13 +5328,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen);
}
saveFile(filename, ".bin", dump, bytes);
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(filename, dump, bytes, jsfCardMemory);
free(dump);
return PM3_SUCCESS;
}
@@ -6176,16 +6134,19 @@ int CmdHFMFNDEFRead(const char *Cmd) {
print_buffer(data, datalen, 1);
}
if (fnlen != 0) {
saveFile(filename, ".bin", data, datalen);
}
res = NDEFDecodeAndPrint(data, datalen, verbose);
if (res != PM3_SUCCESS) {
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
}
// get total NDEF length before save. If fails, we save it all
size_t n = 0;
if (NDEFGetTotalLength(data, datalen, &n) != PM3_SUCCESS)
n = datalen;
pm3_save_dump(filename, data, n, jsfNDEF);
if (verbose == false) {
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -v`") " for more details");
} else {
@@ -6282,8 +6243,8 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
// init keys to default key
uint8_t keyA[MIFARE_4K_MAXSECTOR][MFKEY_SIZE];
uint8_t keyB[MIFARE_4K_MAXSECTOR][MFKEY_SIZE];
uint8_t keyA[MIFARE_4K_MAXSECTOR][MIFARE_KEY_SIZE];
uint8_t keyB[MIFARE_4K_MAXSECTOR][MIFARE_KEY_SIZE];
for (uint8_t i = 0; i < MIFARE_4K_MAXSECTOR; i++) {
memcpy(keyA[i], g_mifare_default_key, sizeof(g_mifare_default_key));
@@ -6314,7 +6275,6 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
DropField();
}
// load key file if exist
if (strlen(keyFilename)) {
//
@@ -7402,7 +7362,6 @@ static int CmdHF14AMfView(const char *Cmd) {
block_cnt = MIFARE_4K_MAXBLOCK;
if (verbose) {
PrintAndLogEx(INFO, "File: " _YELLOW_("%s"), filename);
PrintAndLogEx(INFO, "File size %zu bytes, file blocks %d (0x%x)", bytes_read, block_cnt, block_cnt);
}
@@ -7896,7 +7855,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mf gsave",
"Save `magic gen4 gtu` card memory into three files (BIN/EML/JSON)"
"Save `magic gen4 gtu` card memory into two files (bin/json)"
"or into emulator memory",
"hf mf gsave\n"
"hf mf gsave --4k\n"
@@ -7908,7 +7867,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
arg_lit0(NULL, "1k", "MIFARE Classic 1k / S50 (def)"),
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
arg_lit0(NULL, "4k", "MIFARE Classic 4k / S70"),
arg_str0("p", "pwd", "<hex>", "password 4bytes"),
arg_str0("p", "pwd", "<hex>", "password 4 bytes"),
arg_str0("f", "file", "<fn>", "filename of dump"),
arg_lit0(NULL, "emu", "to emulator memory"),
arg_param_end
@@ -8079,14 +8038,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen);
}
saveFile(filename, ".bin", dump, bytes);
saveFileEML(filename, dump, bytes, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = dump;
xdump.dumplen = bytes;
saveFileJSON(filename, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(filename, dump, bytes, jsfCardMemory);
free(dump);
return PM3_SUCCESS;
}
+3 -3
View File
@@ -1126,9 +1126,9 @@ static int CmdHF14aDesChk(const char *Cmd) {
CLIParserInit(&ctx, "hf mfdes chk",
"Checks keys with MIFARE DESFire card.",
"hf mfdes chk --aid 123456 -k 000102030405060708090a0b0c0d0e0f -> check key on aid 0x123456\n"
"hf mfdes chk -d mfdes_default_keys -> check keys from dictionary against all existing aid on card\n"
"hf mfdes chk -d mfdes_default_keys --aid 123456 -> check keys from dictionary against aid 0x123456\n"
"hf mfdes chk --aid 123456 --pattern1b -j keys -> check all 1-byte keys pattern on aid 0x123456 and save found keys to json\n"
"hf mfdes chk -d mfdes_default_keys -> check keys against all existing aid on card\n"
"hf mfdes chk -d mfdes_default_keys --aid 123456 -> check keys against aid 0x123456\n"
"hf mfdes chk --aid 123456 --pattern1b -j keys -> check all 1-byte keys pattern on aid 0x123456 and save found keys to `keys.json`\n"
"hf mfdes chk --aid 123456 --pattern2b --startp2b FA00 -> check all 2-byte keys pattern on aid 0x123456. Start from key FA00FA00...FA00");
void *argtable[] = {
+8 -12
View File
@@ -1448,14 +1448,7 @@ static int CmdHFMFPDump(const char *Cmd) {
free(fptr);
}
saveFile(data_fn, ".bin", mem, MIFARE_4K_MAX_BYTES);
saveFileEML(data_fn, mem, MIFARE_4K_MAX_BYTES, MFBLOCK_SIZE);
iso14a_mf_extdump_t xdump;
xdump.card_info = card;
xdump.dump = mem;
xdump.dumplen = MIFARE_4K_MAX_BYTES;
saveFileJSON(data_fn, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL);
pm3_save_mf_dump(filename, dump, MIFARE_4K_MAX_BYTES, jsfCardMemory);
*/
free(mem);
return PM3_SUCCESS;
@@ -1746,16 +1739,19 @@ int CmdHFMFPNDEFRead(const char *Cmd) {
print_buffer(data, datalen, 1);
}
if (fnlen != 0) {
saveFile(filename, ".bin", data, datalen);
}
res = NDEFDecodeAndPrint(data, datalen, verbose);
if (res != PM3_SUCCESS) {
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
}
// get total NDEF length before save. If fails, we save it all
size_t n = 0;
if (NDEFGetTotalLength(data, datalen, &n) != PM3_SUCCESS)
n = datalen;
pm3_save_dump(filename, data, n, jsfNDEF);
if (verbose == false) {
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndefread -v`") " for more details");
} else {
+15 -9
View File
@@ -2677,7 +2677,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
}
uint16_t datalen = pages * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH;
pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory, MFU_BLOCK_SIZE);
pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory);
if (is_partial) {
PrintAndLogEx(WARNING, "Partial dump created. (%d of %d blocks)", pages, card_mem_size);
@@ -2840,7 +2840,7 @@ int CmdHF14MfUTamper(const char *Cmd) {
static int CmdHF14AMfURestore(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mfu restore",
"Restore MIFARE Ultralight/NTAG dump file to tag.\n",
"Restore MIFARE Ultralight/NTAG dump file (bin/eml/json) to tag.\n",
"hf mfu restore -f myfile -s -> special write\n"
"hf mfu restore -f myfile -k AABBCCDD -s -> special write, use key\n"
"hf mfu restore -f myfile -k AABBCCDD -ser -> special write, use key, write dump pwd, ..."
@@ -2848,7 +2848,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "specify dump filename (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "specify dump filename"),
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-"),
@@ -4443,14 +4443,20 @@ int CmdHF14MfuNDEFRead(const char *Cmd) {
}
DropField();
if (fnlen != 0) {
saveFile(filename, ".bin", records, (size_t)maxsize);
}
status = NDEFRecordsDecodeAndPrint(records, (size_t)maxsize, verbose);
if (status != PM3_SUCCESS) {
status = NDEFDecodeAndPrint(records, (size_t)maxsize, verbose);
}
// get total NDEF length before save. If fails, we save it all
size_t n = 0;
if (NDEFGetTotalLength(records, maxsize, &n) != PM3_SUCCESS)
n = maxsize;
pm3_save_dump(filename, records, n, jsfNDEF);
char *jooki = strstr((char *)records, "s.jooki.rocks/s/?s=");
if (jooki) {
jooki += 17;
@@ -4557,12 +4563,12 @@ static int CmdHF14AMfuEView(const char *Cmd) {
static int CmdHF14AMfuESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "hf mfu esave",
"Saves emulator memory to a MIFARE Ultralight/NTAG dump file (bin/eml/json)\n"
"Saves emulator memory to a MIFARE Ultralight/NTAG dump file (bin/json)\n"
"By default number of pages saved depends on defined tag type.\n"
"You can override this with option --end.",
"hf mfu esave\n"
"hf mfu esave --end 255 -> saves whole memory\n"
"hf mfu esave -f hf-mfu-04010203040506-dump.json"
"hf mfu esave -f hf-mfu-04010203040506-dump"
);
void *argtable[] = {
@@ -4613,7 +4619,7 @@ static int CmdHF14AMfuESave(const char *Cmd) {
// save dump. Last block contains PACK + RFU
uint16_t datalen = (end + 1) * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH;
res = pm3_save_dump(filename, (uint8_t *)dump, datalen, jsfMfuMemory, MFU_BLOCK_SIZE);
res = pm3_save_dump(filename, (uint8_t *)dump, datalen, jsfMfuMemory);
free(dump);
return res;
+8 -3
View File
@@ -404,10 +404,15 @@ int CmdHFST25TANdefRead(const char *Cmd) {
return PM3_ESOFT;
}
if (fnlen != 0) {
saveFile(filename, ".bin", response + 2, resplen - 4);
}
NDEFRecordsDecodeAndPrint(response + 2, resplen - 4, verbose);
// get total NDEF length before save. If fails, we save it all
size_t n = 0;
if (NDEFGetTotalLength(response, resplen, &n) != PM3_SUCCESS)
n = resplen;
pm3_save_dump(filename, response + 2, n, jsfNDEF);
return PM3_SUCCESS;
}
+3 -3
View File
@@ -897,9 +897,9 @@ static int CmdHFTopazDump(const char *Cmd) {
}
if (topaz_tag.size)
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t) + topaz_tag.size, jsfTopaz, TOPAZ_BLOCK_SIZE);
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t) + topaz_tag.size, jsfTopaz);
else
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t), jsfTopaz, TOPAZ_BLOCK_SIZE);
pm3_save_dump(filename, (uint8_t *)&topaz_tag, sizeof(topaz_tag_t), jsfTopaz);
if (set_dynamic) {
free(topaz_tag.dynamic_memory);
@@ -916,7 +916,7 @@ static int CmdHFTopazView(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "filename of dump"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, false);
+1 -14
View File
@@ -611,9 +611,7 @@ static int CmdHFXeroxDump(const char *Cmd) {
int fnlen = 0;
char filename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
bool decrypt = arg_get_lit(ctx, 2);
CLIParserFree(ctx);
iso14b_raw_cmd_t *packet = (iso14b_raw_cmd_t *)calloc(1, sizeof(iso14b_raw_cmd_t) + 11);
@@ -682,7 +680,6 @@ static int CmdHFXeroxDump(const char *Cmd) {
PrintAndLogEx(NORMAL, "." NOLF);
fflush(stdout);
// PrintAndLogEx(INPLACE, "blk %3d", blocknum);
}
}
@@ -773,23 +770,13 @@ static int CmdHFXeroxDump(const char *Cmd) {
PrintAndLogEx(NORMAL, "");
if (0 == filename[0]) { // generate filename from uid
/*
PrintAndLogEx(INFO, "Using UID as filename");
sprintf(filename, "hf-xerox-%02X%02X%02X%02X%02X%02X%02X%02X-dump%s",
card.uid[7],card.uid[6],card.uid[5],card.uid[4],card.uid[3],card.uid[2],card.uid[1],card.uid[0],
decrypt ? "-dec" : "");
*/
char *fptr = filename;
PrintAndLogEx(INFO, "Using UID as filename");
fptr += snprintf(fptr, sizeof(filename), "hf-xerox-");
FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), decrypt ? "-dump-dec" : "-dump", card.uidlen);
}
size_t datalen = blocknum * 4;
saveFile(filename, ".bin", data, datalen);
saveFileEML(filename, data, datalen, 4);
// saveFileJSON(filename, jsf15, data, datalen, NULL);
pm3_save_dump(filename, data, blocknum * 4, jsf14b_v2);
return PM3_SUCCESS;
}
+2 -2
View File
@@ -709,9 +709,9 @@ int CmdEM4x05Dump(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "");
if (card_type == EM_4369 || card_type == EM_4469)
pm3_save_dump(filename, (uint8_t *)data, sizeof(data), jsfEM4x69, 4);
pm3_save_dump(filename, (uint8_t *)data, sizeof(data), jsfEM4x69);
else
pm3_save_dump(filename, (uint8_t *)data, sizeof(data), jsfEM4x05, 4);
pm3_save_dump(filename, (uint8_t *)data, sizeof(data), jsfEM4x05);
}
PrintAndLogEx(NORMAL, "");
return success;
+6 -6
View File
@@ -194,7 +194,7 @@ int CmdEM4x50ELoad(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str1("f", "file", "<fn>", "dump filename (bin/eml/json)"),
arg_str1("f", "file", "<fn>", "dump filename"),
arg_param_end
};
@@ -223,7 +223,7 @@ int CmdEM4x50ELoad(const char *Cmd) {
int CmdEM4x50ESave(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "lf em 4x50 esave",
"Saves bin/eml/json dump file of emulator memory.",
"Saves bin/json dump file of emulator memory.",
"lf em 4x50 esave -> use UID as filename\n"
"lf em 4x50 esave -f mydump\n"
);
@@ -264,7 +264,7 @@ int CmdEM4x50ESave(const char *Cmd) {
FillFileNameByUID(fptr, (uint8_t *)&data[4 * EM4X50_DEVICE_ID], "-dump", 4);
}
pm3_save_dump(filename, data, DUMP_FILESIZE, jsfEM4x50, 4);
pm3_save_dump(filename, data, DUMP_FILESIZE, jsfEM4x50);
return PM3_SUCCESS;
}
@@ -796,7 +796,7 @@ int CmdEM4x50Reader(const char *Cmd) {
int CmdEM4x50Dump(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "lf em 4x50 dump",
"Reads all blocks/words from EM4x50 tag and saves dump in bin/eml/json format",
"Reads all blocks/words from EM4x50 tag and saves dump in (bin/json) format",
"lf em 4x50 dump\n"
"lf em 4x50 dump -f mydump\n"
"lf em 4x50 dump -p 12345678\n"
@@ -805,7 +805,7 @@ int CmdEM4x50Dump(const char *Cmd) {
void *argtable[] = {
arg_param_begin,
arg_str0("f", "file", "<fn>", "specify dump filename (bin/eml/json)"),
arg_str0("f", "file", "<fn>", "specify dump filename"),
arg_str0("p", "pwd", "<hex>", "password, 4 hex bytes, lsb"),
arg_param_end
};
@@ -867,7 +867,7 @@ int CmdEM4x50Dump(const char *Cmd) {
memcpy(data + (i * 4), words[i].byte, 4);
}
pm3_save_dump(filename, data, sizeof(data), jsfEM4x50, 4);
pm3_save_dump(filename, data, sizeof(data), jsfEM4x50);
return PM3_SUCCESS;
}

Some files were not shown because too many files have changed in this diff Show More