mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 19:40:37 -07:00
fix json loading for lf em 4x05
This commit is contained in:
parent
d215f18fdb
commit
79d143c970
2 changed files with 47 additions and 9 deletions
|
@ -3,7 +3,9 @@ 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...
|
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]
|
## [unreleased][unreleased]
|
||||||
- Added `hf mf gdmparsecfg` command to decode the GDM/USCUID config block and made `hf mf gdmcfg` show the parsed config on read (@nvx)
|
- Fixed `lf em 4x05 view` - now loads JSON files properl (@iceman1001)
|
||||||
|
- Added `hf mf gdmparsecfg` command to decode the GDM/USCUID config block (@nvx)
|
||||||
|
- Changed `hf mf gdmcfg` show the parsed config on read (@nvx)
|
||||||
- Changed `hf mf gdmcfg/gdmsetcfg` commands to support Gen1a and GDM Alt magic wakeups (@nvx)
|
- Changed `hf mf gdmcfg/gdmsetcfg` commands to support Gen1a and GDM Alt magic wakeups (@nvx)
|
||||||
- Fixed `hf 15 writedsfid` - long wait after write and dont force -o flag (@iceman1001)
|
- Fixed `hf 15 writedsfid` - long wait after write and dont force -o flag (@iceman1001)
|
||||||
- Changed `hf 14a sniff -i` - now supports the interactive flag (@iceman1001)
|
- Changed `hf 14a sniff -i` - now supports the interactive flag (@iceman1001)
|
||||||
|
|
|
@ -1370,7 +1370,7 @@ int loadFileMCT_safe(const char *preferredName, void **pdata, size_t *datalen) {
|
||||||
static int load_file_sanity(char *s, uint32_t datalen, int i, size_t len) {
|
static int load_file_sanity(char *s, uint32_t datalen, int i, size_t len) {
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
PrintAndLogEx(DEBUG, "WARNING: json %s block %d has zero-length data", s, i);
|
PrintAndLogEx(DEBUG, "WARNING: json %s block %d has zero-length data", s, i);
|
||||||
PrintAndLogEx(INFO, "File parsing stopped");
|
PrintAndLogEx(DEBUG, "File parsing stopped");
|
||||||
return false;
|
return false;
|
||||||
} else if (len != datalen) {
|
} else if (len != datalen) {
|
||||||
PrintAndLogEx(WARNING, "WARNING: json %s block %d only has %zu bytes", s, i, len);
|
PrintAndLogEx(WARNING, "WARNING: json %s block %d only has %zu bytes", s, i, len);
|
||||||
|
@ -1391,7 +1391,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, ".json", false);
|
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, ".json", false);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
return PM3_EFILE;
|
return PM3_EFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,7 +1618,49 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
||||||
*datalen = sptr;
|
*datalen = sptr;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(ctype, "EM4205/EM4305")) {
|
||||||
|
size_t sptr = 0;
|
||||||
|
for (int i = 0; i < (maxdatalen / 4); i++) {
|
||||||
|
if (sptr + 4 > maxdatalen) {
|
||||||
|
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr);
|
||||||
|
retval = PM3_EMALLOC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(blocks, sizeof(blocks), "$.blocks.%d", i);
|
||||||
|
JsonLoadBufAsHex(root, blocks, &udata.bytes[sptr], 4, &len);
|
||||||
|
if (load_file_sanity(ctype, 4, i, len) == false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr += len;
|
||||||
|
}
|
||||||
|
*datalen = sptr;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(ctype, "EM4469/EM4569")) {
|
||||||
|
size_t sptr = 0;
|
||||||
|
for (int i = 0; i < (maxdatalen / 4); i++) {
|
||||||
|
if (sptr + 4 > maxdatalen) {
|
||||||
|
PrintAndLogEx(ERR, "loadFileJSONex: maxdatalen=%zu (%04zx) block (i)=%4d (%04x) sptr=%zu (%04zx) -- exceeded maxdatalen", maxdatalen, maxdatalen, i, i, sptr, sptr);
|
||||||
|
retval = PM3_EMALLOC;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(blocks, sizeof(blocks), "$.blocks.%d", i);
|
||||||
|
JsonLoadBufAsHex(root, blocks, &udata.bytes[sptr], 4, &len);
|
||||||
|
if (load_file_sanity(ctype, 4, i, len) == false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr += len;
|
||||||
|
}
|
||||||
|
*datalen = sptr;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(ctype, "EM4X50")) {
|
if (!strcmp(ctype, "EM4X50")) {
|
||||||
size_t sptr = 0;
|
size_t sptr = 0;
|
||||||
for (int i = 0; i < (maxdatalen / 4); i++) {
|
for (int i = 0; i < (maxdatalen / 4); i++) {
|
||||||
|
@ -2914,16 +2956,10 @@ int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumpl
|
||||||
switch (dftype) {
|
switch (dftype) {
|
||||||
case BIN: {
|
case BIN: {
|
||||||
res = loadFile_safe(fn, ".bin", pdump, dumplen);
|
res = loadFile_safe(fn, ".bin", pdump, dumplen);
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(WARNING, "File IO failed");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EML: {
|
case EML: {
|
||||||
res = loadFileEML_safe(fn, pdump, dumplen);
|
res = loadFileEML_safe(fn, pdump, dumplen);
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(WARNING, "File IO failed");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JSON: {
|
case JSON: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue