mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
refactored topaz commands. It still uses a global var with dynamic memory. Added rdbl, wrbl, view, dump commands to match rest of client
This commit is contained in:
parent
5a4b8c8224
commit
62980b5038
7 changed files with 567 additions and 139 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "util.h"
|
||||
#include "cmdhficlass.h" // pagemap
|
||||
#include "protocols.h" // iclass defines
|
||||
#include "cmdhftopaz.h" // TOPAZ defines
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "scandir.h"
|
||||
|
@ -632,6 +633,24 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
|
|||
(*callback)(root);
|
||||
break;
|
||||
}
|
||||
case jsfTopaz: {
|
||||
topaz_tag_t *tag = (topaz_tag_t *)(void *) data;
|
||||
JsonSaveStr(root, "FileType", "topaz");
|
||||
JsonSaveBufAsHexCompact(root, "$.Card.UID", tag->uid, sizeof(tag->uid));
|
||||
JsonSaveBufAsHexCompact(root, "$.Card.H0R1", tag->HR01, sizeof(tag->HR01));
|
||||
JsonSaveBufAsHexCompact(root, "$.Card.Size", (uint8_t *)&(tag->size), 2);
|
||||
for (size_t i = 0; i < TOPAZ_STATIC_MEMORY / 8; i++) {
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
snprintf(path, sizeof(path), "$.blocks.%zu", i);
|
||||
JsonSaveBufAsHexCompact(root, path, &tag->data_blocks[i][0], TOPAZ_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
// ICEMAN todo: add dynamic memory.
|
||||
// uint16_z Size
|
||||
// uint8_t *dynamic_memory;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1277,7 +1296,39 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz
|
|||
if (!strcmp(ctype, "legic")) {
|
||||
JsonLoadBufAsHex(root, "$.raw", udata, maxdatalen, datalen);
|
||||
}
|
||||
|
||||
if (!strcmp(ctype, "topaz")) {
|
||||
|
||||
topaz_tag_t *mem = (topaz_tag_t *)udata;
|
||||
JsonLoadBufAsHex(root, "$.Card.UID", mem->uid, sizeof(mem->uid), datalen);
|
||||
JsonLoadBufAsHex(root, "$.Card.HR01", mem->HR01, sizeof(mem->HR01), datalen);
|
||||
JsonLoadBufAsHex(root, "$.Card.Size", (uint8_t *)&(mem->size), 2, datalen);
|
||||
|
||||
size_t sptr = 0;
|
||||
for (int i = 0; i < (TOPAZ_STATIC_MEMORY / 8); i++) {
|
||||
|
||||
if (sptr + TOPAZ_BLOCK_SIZE > maxdatalen) {
|
||||
retval = PM3_EMALLOC;
|
||||
goto out;
|
||||
}
|
||||
|
||||
char blocks[30] = {0};
|
||||
snprintf(blocks, sizeof(blocks), "$.blocks.%d", i);
|
||||
|
||||
size_t len = 0;
|
||||
JsonLoadBufAsHex(root, blocks, &mem->data_blocks[sptr][0], TOPAZ_BLOCK_SIZE, &len);
|
||||
if (!len)
|
||||
break;
|
||||
|
||||
sptr += len;
|
||||
|
||||
// ICEMAN todo: add dynamic memory.
|
||||
// uint16_z Size
|
||||
// uint8_t *dynamic_memory;
|
||||
}
|
||||
|
||||
*datalen += sptr;
|
||||
}
|
||||
out:
|
||||
|
||||
if (callback != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue