CHG: 'lf hitag sim' - now loads from BIN/EML/JSON. Also merged it with 'lf hitag simS', which is removed.

This commit is contained in:
iceman1001 2019-03-13 20:16:11 +01:00
commit e3afad8758
3 changed files with 132 additions and 66 deletions

View file

@ -463,8 +463,29 @@ int loadFileJSON(const char *preferredName, const char *suffix, void *data, size
*datalen = sptr;
}
if (!strcmp(ctype, "hitag")) {
size_t sptr = 0;
for (int i = 0; i < (maxdatalen/4); i++) {
if (sptr + 4 > maxdatalen) {
retval = 5;
goto out;
}
PrintAndLog("loaded from JSON file " _YELLOW_("%s"), fileName);
char path[30] = {0};
sprintf(path, "$.blocks.%d", i);
size_t len = 0;
JsonLoadBufAsHex(root, path, &udata[sptr], 4, &len);
if (!len)
break;
sptr += len;
}
*datalen = sptr;
}
PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
out:
json_decref(root);
free(fileName);