\r
for (i=0 ; i<16 ; i++) {\r
if (fread(keyA[i], 1, 6, fkeys) == 0) {\r
- PrintAndLog("File reading error.");\r
+ PrintAndLog("File reading error.");\r
return 2;\r
}\r
}\r
for (i=0 ; i<16 ; i++) {\r
if (fread(keyB[i], 1, 6, fkeys) == 0) {\r
- PrintAndLog("File reading error.");\r
+ PrintAndLog("File reading error.");\r
return 2;\r
}\r
}\r
memcpy(c.d.asBytes, key, 6);\r
\r
if (fread(bldata, 1, 16, fdump) == 0) {\r
- PrintAndLog("File reading error.");\r
- return 2;\r
+ PrintAndLog("File reading error.");\r
+ return 2;\r
}\r
\r
if (j == 3) {\r
SendCommand(&c);\r
\r
UsbCommand resp;\r
- if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {\r
+ if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {\r
uint8_t isOK = resp.arg[0] & 0xff;\r
PrintAndLog("isOk:%02x", isOK);\r
} else {\r
int CmdHF14AMfELoad(const char *Cmd)\r
{\r
FILE * f;\r
- char filename[20];\r
+ char filename[255];\r
char * fnameptr = filename;\r
char buf[64];\r
uint8_t buf8[64];\r
int i, len, blockNum;\r
+ bool 4kcard = 0;\r
\r
memset(filename, 0, sizeof(filename));\r
memset(buf, 0, sizeof(buf));\r
\r
if (param_getchar(Cmd, 0) == 'h' || param_getchar(Cmd, 0)== 0x00) {\r
PrintAndLog("It loads emul dump from the file `filename.eml`");\r
- PrintAndLog("Usage: hf mf eload <file name w/o `.eml`>");\r
- PrintAndLog(" sample: hf mf eload filename");\r
+ PrintAndLog("Usage: hf mf eload <file name w/o `.eml`> <4 - 4kcard>");\r
+ PrintAndLog(" sample: hf mf eload filename [4]");\r
return 0;\r
} \r
\r
+ size = param_getchar(Cmd, 1);\r
+ if (size == '4') 4kcard = 1;\r
+\r
len = strlen(Cmd);\r
- if (len > 14) len = 14;\r
+ if (len > 254) len = 254;\r
\r
memcpy(filename, Cmd, len);\r
fnameptr += len;\r
}\r
fclose(f);\r
\r
- if (blockNum != 16 * 4 && blockNum != 32 * 4 + 8 * 16){\r
- PrintAndLog("File content error. There must be 64 blocks");\r
- return 4;\r
+ if(4kcard){\r
+ if (blockNum != 32 * 4 + 8 * 16){\r
+ PrintAndLog("File content error. There must be 64 blocks");\r
+ return 4;\r
+ }\r
+ }else{\r
+ if (blockNum != 16 * 4 && blockNum != 32 * 4 + 8 * 16){\r
+ PrintAndLog("File content error. There must be 64 blocks");\r
+ return 4;\r
+ }\r
}\r
PrintAndLog("Loaded %d blocks from file: %s", blockNum, filename);\r
return 0;\r
int CmdHF14AMfESave(const char *Cmd)\r
{\r
FILE * f;\r
- char filename[20];\r
+ char filename[255];\r
char * fnameptr = filename;\r
uint8_t buf[64];\r
int i, j, len;\r
} \r
\r
len = strlen(Cmd);\r
- if (len > 14) len = 14;\r
+ if (len > 254) len = 254;\r
\r
if (len < 1) {\r
// get filename\r
static command_t CommandTable[] =\r
{\r
{"help", CmdHelp, 1, "This help"},\r
- {"dbg", CmdHF14AMfDbg, 0, "Set default debug mode"},\r
+ {"dbg", CmdHF14AMfDbg, 0, "Set default debug mode"},\r
{"rdbl", CmdHF14AMfRdBl, 0, "Read MIFARE classic block"},\r
{"rdsc", CmdHF14AMfRdSc, 0, "Read MIFARE classic sector"},\r
{"dump", CmdHF14AMfDump, 0, "Dump MIFARE classic tag to binary file"},\r
- {"restore", CmdHF14AMfRestore, 0, "Restore MIFARE classic binary file to BLANK tag"},\r
+ {"restore", CmdHF14AMfRestore, 0, "Restore MIFARE classic binary file to BLANK tag"},\r
{"wrbl", CmdHF14AMfWrBl, 0, "Write MIFARE classic block"},\r
- {"chk", CmdHF14AMfChk, 0, "Test block keys"},\r
- {"mifare", CmdHF14AMifare, 0, "Read parity error messages."},\r
- {"nested", CmdHF14AMfNested, 0, "Test nested authentication"},\r
+ {"chk", CmdHF14AMfChk, 0, "Test block keys"},\r
+ {"mifare", CmdHF14AMifare, 0, "Read parity error messages."},\r
+ {"nested", CmdHF14AMfNested, 0, "Test nested authentication"},\r
{"sniff", CmdHF14AMfSniff, 0, "Sniff card-reader communication"},\r
- {"sim", CmdHF14AMf1kSim, 0, "Simulate MIFARE card"},\r
+ {"sim", CmdHF14AMf1kSim, 0, "Simulate MIFARE card"},\r
{"eclr", CmdHF14AMfEClear, 0, "Clear simulator memory block"},\r
{"eget", CmdHF14AMfEGet, 0, "Get simulator memory block"},\r
{"eset", CmdHF14AMfESet, 0, "Set simulator memory block"},\r
{"eload", CmdHF14AMfELoad, 0, "Load from file emul dump"},\r
{"esave", CmdHF14AMfESave, 0, "Save to file emul dump"},\r
- {"ecfill", CmdHF14AMfECFill, 0, "Fill simulator memory with help of keys from simulator"},\r
- {"ekeyprn", CmdHF14AMfEKeyPrn, 0, "Print keys from simulator memory"},\r
- {"csetuid", CmdHF14AMfCSetUID, 0, "Set UID for magic Chinese card"},\r
- {"csetblk", CmdHF14AMfCSetBlk, 0, "Write block into magic Chinese card"},\r
- {"cgetblk", CmdHF14AMfCGetBlk, 0, "Read block from magic Chinese card"},\r
- {"cgetsc", CmdHF14AMfCGetSc, 0, "Read sector from magic Chinese card"},\r
+ {"ecfill", CmdHF14AMfECFill, 0, "Fill simulator memory with help of keys from simulator"},\r
+ {"ekeyprn", CmdHF14AMfEKeyPrn, 0, "Print keys from simulator memory"},\r
+ {"csetuid", CmdHF14AMfCSetUID, 0, "Set UID for magic Chinese card"},\r
+ {"csetblk", CmdHF14AMfCSetBlk, 0, "Write block into magic Chinese card"},\r
+ {"cgetblk", CmdHF14AMfCGetBlk, 0, "Read block from magic Chinese card"},\r
+ {"cgetsc", CmdHF14AMfCGetSc, 0, "Read sector from magic Chinese card"},\r
{"cload", CmdHF14AMfCLoad, 0, "Load dump into magic Chinese card"},\r
{"csave", CmdHF14AMfCSave, 0, "Save dump from magic Chinese card into file or emulator"},\r
{NULL, NULL, 0, NULL}\r