change 'hf 15 restore' now supports EML/JSON

This commit is contained in:
iceman1001 2021-04-15 18:27:24 +02:00
parent 097d24347f
commit 46bf529763
3 changed files with 37 additions and 3 deletions

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]
- Change `hf 15 restore` - now also support EML/JSON (@iceman1001)
- Change - all commands now use cliparser (@iceman1001)
- Change `lf t55xx restore` - now also support JSON (@iceman1001)
- Change `hf mf csetuid` - adapted to accept 7byte uids. ~untested~ (@iceman1001)
- Added `hf mf view/eload/cload` - now accepts bin/eml/json (@iceman1001)

View file

@ -1982,10 +1982,38 @@ static int CmdHF15Restore(const char *Cmd) {
}
PrintAndLogEx(INFO, "Using block size... %zu", blocksize);
// 4bytes * 256 blocks. Should be enough..
uint8_t *data = calloc(4 * 256, sizeof(uint8_t));
if (data == NULL) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
return PM3_EMALLOC;
}
size_t datalen = 0;
uint8_t *data = NULL;
if (loadFile_safe(filename, ".bin", (void **)&data, &datalen) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "could not find file " _YELLOW_("%s"), filename);
int res = PM3_SUCCESS;
DumpFileType_t dftype = getfiletype(filename);
switch (dftype) {
case BIN: {
res = loadFile_safe(filename, ".bin", (void **)&data, &datalen);
break;
}
case EML: {
res = loadFileEML_safe(filename, (void **)&data, &datalen);
break;
}
case JSON: {
res = loadFileJSON(filename, data, 256 * 4, &datalen, NULL);
break;
}
case DICTIONARY: {
PrintAndLogEx(ERR, "Error: Only BIN/JSON/EML formats allowed");
free(data);
return PM3_EINVARG;
}
}
if (res != PM3_SUCCESS) {
free(data);
return PM3_EFILE;
}

View file

@ -1210,6 +1210,10 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
*datalen = sptr;
}
if (!strcmp(ctype, "15693")) {
JsonLoadBufAsHex(root, "$.raw", udata, maxdatalen, datalen);
}
out:
if (callback != NULL) {