json is case sensitive

This commit is contained in:
iceman1001 2024-01-24 23:35:16 +01:00
commit 2972ff9694

View file

@ -523,26 +523,31 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
case jsf15_v4: { case jsf15_v4: {
JsonSaveStr(root, "FileType", "15693 v4"); JsonSaveStr(root, "FileType", "15693 v4");
iso15_tag_t *tag = (iso15_tag_t *)data; iso15_tag_t *tag = (iso15_tag_t *)data;
JsonSaveBufAsHexCompact(root, "$.Card.uid", tag->uid, 8); JsonSaveBufAsHexCompact(root, "$.Card.uid", tag->uid, sizeof(tag->uid));
JsonSaveBufAsHexCompact(root, "$.Card.dsfid", &tag->dsfid, 1); JsonSaveBufAsHexCompact(root, "$.Card.dsfid", &tag->dsfid, 1);
JsonSaveBufAsHexCompact(root, "$.Card.dsfidLock", (uint8_t *)&tag->dsfidLock, 1); JsonSaveBufAsHexCompact(root, "$.Card.dsfidlock", (uint8_t *)&tag->dsfidLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.afi", &tag->afi, 1); JsonSaveBufAsHexCompact(root, "$.Card.afi", &tag->afi, 1);
JsonSaveBufAsHexCompact(root, "$.Card.afiLock", (uint8_t *)&tag->afiLock, 1); JsonSaveBufAsHexCompact(root, "$.Card.afilock", (uint8_t *)&tag->afiLock, 1);
JsonSaveBufAsHexCompact(root, "$.Card.bytesPerPage", &tag->bytesPerPage, 1); JsonSaveBufAsHexCompact(root, "$.Card.bytesperpage", &tag->bytesPerPage, 1);
JsonSaveBufAsHexCompact(root, "$.Card.pagesCount", &tag->pagesCount, 1); JsonSaveBufAsHexCompact(root, "$.Card.pagescount", &tag->pagesCount, 1);
JsonSaveBufAsHexCompact(root, "$.Card.IC", &tag->ic, 1); JsonSaveBufAsHexCompact(root, "$.Card.ic", &tag->ic, 1);
JsonSaveBufAsHexCompact(root, "$.Card.locks", tag->locks, tag->pagesCount); JsonSaveBufAsHexCompact(root, "$.Card.locks", tag->locks, tag->pagesCount);
JsonSaveBufAsHexCompact(root, "$.Card.random", tag->random, 2); JsonSaveBufAsHexCompact(root, "$.Card.random", tag->random, 2);
JsonSaveBufAsHexCompact(root, "$.Card.privacyPasswd", tag->privacyPasswd, 4); JsonSaveBufAsHexCompact(root, "$.Card.privacypasswd", tag->privacyPasswd, sizeof(tag->privacyPasswd));
JsonSaveBufAsHexCompact(root, "$.Card.state", (uint8_t *)&tag->state, 1); JsonSaveBufAsHexCompact(root, "$.Card.state", (uint8_t *)&tag->state, 1);
for (size_t i = 0 ; i < tag->pagesCount ; i++) { for (uint8_t i = 0 ; i < tag->pagesCount ; i++) {
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE)
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) {
break; break;
snprintf(path, sizeof(path), "$.blocks.%zu", i); }
JsonSaveBufAsHexCompact(root, path,
&tag->data[i * tag->bytesPerPage], snprintf(path, sizeof(path), "$.blocks.%u", i);
tag->bytesPerPage); JsonSaveBufAsHexCompact(root
, path
, &tag->data[i * tag->bytesPerPage]
, tag->bytesPerPage
);
} }
break; break;
} }
@ -1683,8 +1688,17 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (!strcmp(ctype, "15693 v3")) { if (!strcmp(ctype, "15693 v3")) {
size_t sptr = 0; size_t sptr = 0;
for (int i = 0; i < (maxdatalen / 8); i++) { for (int i = 0; i < (maxdatalen / 8); i++) {
if (sptr + 8 > maxdatalen) { if (sptr + 8 > maxdatalen) {
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr); PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen"
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto out; goto out;
} }
@ -1703,23 +1717,32 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
if (!strcmp(ctype, "15693 v4")) { if (!strcmp(ctype, "15693 v4")) {
iso15_tag_t *tag = (iso15_tag_t *)udata.bytes; iso15_tag_t *tag = (iso15_tag_t *)udata.bytes;
JsonLoadBufAsHex(root, "$.Card.UID", tag->uid, 8, datalen); JsonLoadBufAsHex(root, "$.Card.uid", tag->uid, 8, datalen);
JsonLoadBufAsHex(root, "$.Card.dsfid", &tag->dsfid, 1, datalen); JsonLoadBufAsHex(root, "$.Card.dsfid", &tag->dsfid, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.dsfidLock", (uint8_t *)&tag->dsfidLock, 1, datalen); JsonLoadBufAsHex(root, "$.Card.dsfidlock", (uint8_t *)&tag->dsfidLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.afi", &tag->afi, 1, datalen); JsonLoadBufAsHex(root, "$.Card.afi", &tag->afi, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.afiLock", (uint8_t *)&tag->afiLock, 1, datalen); JsonLoadBufAsHex(root, "$.Card.afilock", (uint8_t *)&tag->afiLock, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.bytesPerPage", &tag->bytesPerPage, 1, datalen); JsonLoadBufAsHex(root, "$.Card.bytesperpage", &tag->bytesPerPage, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.pagesCount", &tag->pagesCount, 1, datalen); JsonLoadBufAsHex(root, "$.Card.pagescount", &tag->pagesCount, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.IC", &tag->ic, 1, datalen); JsonLoadBufAsHex(root, "$.Card.ic", &tag->ic, 1, datalen);
JsonLoadBufAsHex(root, "$.Card.locks", tag->locks, tag->pagesCount, datalen); JsonLoadBufAsHex(root, "$.Card.locks", tag->locks, tag->pagesCount, datalen);
JsonLoadBufAsHex(root, "$.Card.random", tag->random, 2, datalen); JsonLoadBufAsHex(root, "$.Card.random", tag->random, 2, datalen);
JsonLoadBufAsHex(root, "$.Card.privacyPasswd", tag->privacyPasswd, 4, datalen); JsonLoadBufAsHex(root, "$.Card.privacypasswd", tag->privacyPasswd, 4, datalen);
JsonLoadBufAsHex(root, "$.Card.state", (uint8_t *)&tag->state, 1, datalen); JsonLoadBufAsHex(root, "$.Card.state", (uint8_t *)&tag->state, 1, datalen);
size_t sptr = 0; size_t sptr = 0;
for (int i = 0; i < tag->pagesCount ; i++) { for (uint8_t i = 0; i < tag->pagesCount ; i++) {
if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) { if (((i + 1) * tag->bytesPerPage) > ISO15693_TAG_MAX_SIZE) {
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr); PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen"
, maxdatalen
, maxdatalen
, i
, i
, sptr
, sptr
);
retval = PM3_EMALLOC; retval = PM3_EMALLOC;
goto out; goto out;
} }