mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-21 14:47:23 +08:00
add iclass json dump format
This commit is contained in:
parent
ec174a7232
commit
f9d8d56317
2 changed files with 35 additions and 0 deletions
|
@ -281,6 +281,19 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
|
|||
}
|
||||
break;
|
||||
}
|
||||
case jsfIclass: {
|
||||
JsonSaveStr(root, "FileType", "iclass");
|
||||
uint8_t uid[8] = {0};
|
||||
memcpy(uid, data, 8);
|
||||
JsonSaveBufAsHexCompact(root, "$.Card.UID", uid, sizeof(uid));
|
||||
|
||||
for (size_t i = 0; i < (datalen / 8 ); i++) {
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
sprintf(path, "$blocks.%zu", i);
|
||||
JsonSaveBufAsHexCompact(root, path, data + (i * 8), 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int res = json_dump_file(root, fileName, JSON_INDENT(2));
|
||||
|
@ -512,6 +525,27 @@ int loadFileJSON(const char *preferredName, void *data, size_t maxdatalen, size_
|
|||
*datalen = sptr;
|
||||
}
|
||||
|
||||
if (!strcmp(ctype, "iclass")) {
|
||||
size_t sptr = 0;
|
||||
for (size_t i = 0; i < (maxdatalen / 8); i++) {
|
||||
if (sptr + 8 > maxdatalen) {
|
||||
retval = 5;
|
||||
goto out;
|
||||
}
|
||||
|
||||
char path[30] = {0};
|
||||
sprintf(path, "$.blocks.%zu", i);
|
||||
|
||||
size_t len = 0;
|
||||
JsonLoadBufAsHex(root, path, &udata[sptr], 8, &len);
|
||||
if (!len)
|
||||
break;
|
||||
|
||||
sptr += len;
|
||||
}
|
||||
*datalen = sptr;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "loaded from JSON file " _YELLOW_("%s"), fileName);
|
||||
out:
|
||||
json_decref(root);
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef enum {
|
|||
jsfCardMemory,
|
||||
jsfMfuMemory,
|
||||
jsfHitag,
|
||||
jsfIclass,
|
||||
// jsf14b,
|
||||
// jsf15,
|
||||
// jsfLegic,
|
||||
|
|
Loading…
Reference in a new issue