From b7e431842e8d3cde88d1d2c63c9af6e4f23a68cb Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 17 Oct 2020 01:18:45 +0200 Subject: [PATCH] em4x05_dump - also save as json --- client/src/cmdlfem4x05.c | 2 ++ client/src/fileutils.c | 27 +++++++++++++++++++++++++++ client/src/fileutils.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index 93b136981..82e069092 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -625,6 +625,8 @@ int CmdEM4x05Dump(const char *Cmd) { } PrintAndLogEx(NORMAL, ""); + saveFileJSON(filename, (card_type == EM_4X69) ? jsfEM4x69 : jsfEM4x05, (uint8_t *)data, 16 * sizeof(uint32_t), NULL); + saveFileEML(filename, (uint8_t *)data, 16 * sizeof(uint32_t), sizeof(uint32_t)); saveFile(filename, ".bin", data, sizeof(data)); } diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 9b6482a66..ab4a7d241 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -494,6 +494,33 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data, } break; } + case jsfEM4x05: { + JsonSaveStr(root, "FileType", "EM4205/EM4305"); + JsonSaveBufAsHexCompact(root, "$.Card.UID", data + (1 * 4), 4); + JsonSaveBufAsHexCompact(root, "$.Card.Config", data + (4 * 4), 4); + JsonSaveBufAsHexCompact(root, "$.Card.Protection1", data + (14 * 4), 4); + JsonSaveBufAsHexCompact(root, "$.Card.Protection2", data + (15 * 4), 4); + + for (size_t i = 0; i < (datalen / 4); i++) { + char path[PATH_MAX_LENGTH] = {0}; + sprintf(path, "$.blocks.%zu", i); + JsonSaveBufAsHexCompact(root, path, data + (i * 4), 4); + } + break; + } + case jsfEM4x69: { + JsonSaveStr(root, "FileType", "EM4469/EM4569"); + JsonSaveBufAsHexCompact(root, "$.Card.UID", data + (1 * 4), 4); + JsonSaveBufAsHexCompact(root, "$.Card.Protection", data + (3 * 4), 4); + JsonSaveBufAsHexCompact(root, "$.Card.Config", data + (4 * 4), 4); + + for (size_t i = 0; i < (datalen / 4); i++) { + char path[PATH_MAX_LENGTH] = {0}; + sprintf(path, "$.blocks.%zu", i); + JsonSaveBufAsHexCompact(root, path, data + (i * 4), 4); + } + break; + } case jsfMfPlusKeys: { JsonSaveStr(root, "FileType", "mfp"); JsonSaveBufAsHexCompact(root, "$.Card.UID", &data[0], 7); diff --git a/client/src/fileutils.h b/client/src/fileutils.h index d9bad1364..49992c998 100644 --- a/client/src/fileutils.h +++ b/client/src/fileutils.h @@ -64,6 +64,8 @@ typedef enum { jsfMfPlusKeys, jsfCustom, jsfMfDesfireKeys, + jsfEM4x05, + jsfEM4x69, } JSONFileType; typedef enum {