changed "mf eload" / "iclass eload" to be able to transfer a file from SPIFFS to EMULATOR memory. Original idea from @natesales
This commit is contained in:
1 parent
aff29b9d3b
commit
ba225905d3
5 files changed
+105
-18
No files matched your search
@@ -990,13 +990,14 @@ 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.bin\n"
|
||||
"hf iclass eload -f hf-iclass-AA162D30F8FF12F1-dump.eml\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 (bin/eml/json)"),
|
||||
arg_lit0("m", "mem", "use RDV4 spiffs"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
@@ -1011,8 +1012,39 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
bool use_spiffs = arg_get_lit(ctx, 2);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
// use RDV4 spiffs
|
||||
if (use_spiffs && IfPm3Flash() == false) {
|
||||
PrintAndLogEx(WARNING, "Device not compiled to support spiffs");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (use_spiffs) {
|
||||
|
||||
if (fnlen > 32) {
|
||||
PrintAndLogEx(WARNING, "filename too long for spiffs, expected 32, got %u", fnlen);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SPIFFS_ELOAD, (uint8_t *)filename, fnlen);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_SPIFFS_ELOAD, &resp, 2000) == false) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Loading file from spiffs to emulatore memory failed");
|
||||
return PM3_EFLASH;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "File transfered from spiffs to device emulator memory");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// read dump file
|
||||
uint8_t *dump = NULL;
|
||||
size_t bytes_read = 2048;
|
||||
|
||||
+34
-2
@@ -3890,6 +3890,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
arg_lit0(NULL, "2k", "MIFARE Classic/Plus 2k"),
|
||||
arg_lit0(NULL, "4k", "MIFARE Classic 4k / S70"),
|
||||
arg_lit0(NULL, "ul", "MIFARE Ultralight family"),
|
||||
arg_lit0("m", "mem", "use RDV4 spiffs"),
|
||||
arg_int0("q", "qty", "<dec>", "manually set number of blocks (overrides)"),
|
||||
arg_param_end
|
||||
};
|
||||
@@ -3905,7 +3906,8 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
bool m4 = arg_get_lit(ctx, 5);
|
||||
bool mu = arg_get_lit(ctx, 6);
|
||||
|
||||
int numblks = arg_get_int_def(ctx, 7, -1);
|
||||
bool use_spiffs = arg_get_lit(ctx, 7);
|
||||
int numblks = arg_get_int_def(ctx, 8, -1);
|
||||
|
||||
CLIParserFree(ctx);
|
||||
|
||||
@@ -3945,6 +3947,36 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
||||
PrintAndLogEx(INFO, "overriding number of blocks, will use %d blocks ( %u bytes )", block_cnt, block_cnt * block_width);
|
||||
}
|
||||
|
||||
// use RDV4 spiffs
|
||||
if (use_spiffs && IfPm3Flash() == false) {
|
||||
PrintAndLogEx(WARNING, "Device not compiled to support spiffs");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (use_spiffs) {
|
||||
|
||||
if (fnlen > 32) {
|
||||
PrintAndLogEx(WARNING, "filename too long for spiffs, expected 32, got %u", fnlen);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SPIFFS_ELOAD, (uint8_t *)filename, fnlen);
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_SPIFFS_ELOAD, &resp, 2000) == false) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
PrintAndLogEx(FAILED, "Loading file from spiffs to emulatore memory failed");
|
||||
return PM3_EFLASH;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "File transfered from spiffs to device emulator memory");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t *data = NULL;
|
||||
size_t bytes_read = 0;
|
||||
int res = pm3_load_dump(filename, (void **)&data, &bytes_read, (block_width * block_cnt + hdr_len));
|
||||
@@ -4204,7 +4236,7 @@ static int CmdHF14AMfECFill(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf mf ecfill",
|
||||
"Dump card and transfer the data to emulator memory.\n"
|
||||
"Keys must be laid in the emulator memory",
|
||||
"Keys must be in the emulator memory",
|
||||
"hf mf ecfill --> use key type A\n"
|
||||
"hf mf ecfill --4k -b --> target 4K card with key type B"
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user