mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
chg: 'lf hitag reader' - now support json format
This commit is contained in:
parent
b35ea2e352
commit
072e83bc49
4 changed files with 36 additions and 14 deletions
|
@ -303,6 +303,7 @@ int CmdLFHitagReader(const char *Cmd) {
|
||||||
|
|
||||||
saveFile(filename, "bin", data, 48);
|
saveFile(filename, "bin", data, 48);
|
||||||
saveFileEML(filename, "eml", data, 48, 4);
|
saveFileEML(filename, "eml", data, 48, 4);
|
||||||
|
saveFileJSON(filename, "json", jsfHitag, (uint8_t *)data, 48);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +378,7 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdLFHitagWP(const char *Cmd) {
|
int CmdLFHitagWriter(const char *Cmd) {
|
||||||
UsbCommand c = { CMD_WR_HITAG_S };
|
UsbCommand c = { CMD_WR_HITAG_S };
|
||||||
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
||||||
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
||||||
|
@ -423,9 +424,9 @@ static command_t CommandTable[] = {
|
||||||
{"list", CmdLFHitagList, 1, "<outfile> List Hitag trace history"},
|
{"list", CmdLFHitagList, 1, "<outfile> List Hitag trace history"},
|
||||||
{"reader", CmdLFHitagReader, 1, "Act like a Hitag Reader"},
|
{"reader", CmdLFHitagReader, 1, "Act like a Hitag Reader"},
|
||||||
{"sim", CmdLFHitagSim, 1, "<infile> Simulate Hitag transponder"},
|
{"sim", CmdLFHitagSim, 1, "<infile> Simulate Hitag transponder"},
|
||||||
{"simS", CmdLFHitagSimS, 1, "<hitagS.hts> Simulate HitagS transponder" },
|
{"simS", CmdLFHitagSimS, 1, "<hitagS.bin> Simulate HitagS transponder" },
|
||||||
{"sniff", CmdLFHitagSniff, 1, "Eavesdrop Hitag communication"},
|
{"sniff", CmdLFHitagSniff, 1, "Eavesdrop Hitag communication"},
|
||||||
{"writer", CmdLFHitagWP, 1, "Act like a Hitag Writer" },
|
{"writer", CmdLFHitagWriter, 1, "Act like a Hitag Writer" },
|
||||||
{"check_challenges", CmdLFHitagCheckChallenges, 1, "<challenges.cc> test all challenges" },
|
{"check_challenges", CmdLFHitagCheckChallenges, 1, "<challenges.cc> test all challenges" },
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ extern int CmdLFHitagReader(const char *Cmd);
|
||||||
extern int CmdLFHitagSim(const char *Cmd);
|
extern int CmdLFHitagSim(const char *Cmd);
|
||||||
extern int CmdLFHitagSimS(const char *Cmd);
|
extern int CmdLFHitagSimS(const char *Cmd);
|
||||||
extern int CmdLFHitagSniff(const char *Cmd);
|
extern int CmdLFHitagSniff(const char *Cmd);
|
||||||
extern int CmdLFHitagWP(const char *Cmd);
|
extern int CmdLFHitagWriter(const char *Cmd);
|
||||||
extern int CmdLFHitagCheckChallenges(const char *Cmd);
|
extern int CmdLFHitagCheckChallenges(const char *Cmd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -155,11 +155,12 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
||||||
json_t *root = json_object();
|
json_t *root = json_object();
|
||||||
JsonSaveStr(root, "Created", "proxmark3");
|
JsonSaveStr(root, "Created", "proxmark3");
|
||||||
switch (ftype) {
|
switch (ftype) {
|
||||||
case jsfRaw:
|
case jsfRaw: {
|
||||||
JsonSaveStr(root, "FileType", "raw");
|
JsonSaveStr(root, "FileType", "raw");
|
||||||
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
||||||
break;
|
break;
|
||||||
case jsfCardMemory:
|
}
|
||||||
|
case jsfCardMemory: {
|
||||||
JsonSaveStr(root, "FileType", "mfcard");
|
JsonSaveStr(root, "FileType", "mfcard");
|
||||||
for (int i = 0; i < (datalen / 16); i++) {
|
for (int i = 0; i < (datalen / 16); i++) {
|
||||||
char path[PATH_MAX_LENGTH] = {0};
|
char path[PATH_MAX_LENGTH] = {0};
|
||||||
|
@ -208,7 +209,8 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case jsfMfuMemory:
|
}
|
||||||
|
case jsfMfuMemory: {
|
||||||
JsonSaveStr(root, "FileType", "mfu");
|
JsonSaveStr(root, "FileType", "mfu");
|
||||||
|
|
||||||
mfu_dump_t *tmp = (mfu_dump_t *)data;
|
mfu_dump_t *tmp = (mfu_dump_t *)data;
|
||||||
|
@ -230,13 +232,27 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
||||||
size_t len = (datalen - DUMP_PREFIX_LENGTH) / 4;
|
size_t len = (datalen - DUMP_PREFIX_LENGTH) / 4;
|
||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
|
||||||
char path[PATH_MAX_LENGTH] = {0};
|
char path[PATH_MAX_LENGTH] = {0};
|
||||||
sprintf(path, "$.blocks.%d", i);
|
sprintf(path, "$.blocks.%d", i);
|
||||||
JsonSaveBufAsHexCompact(root, path, tmp->data + (i * 4), 4);
|
JsonSaveBufAsHexCompact(root, path, tmp->data + (i * 4), 4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case jsfHitag: {
|
||||||
|
JsonSaveStr(root, "FileType", "hitag");
|
||||||
|
uint8_t uid[4] = {0};
|
||||||
|
memcpy(uid, data, 4);
|
||||||
|
|
||||||
|
JsonSaveBufAsHexCompact(root, "$.Card.UID", uid, sizeof(uid));
|
||||||
|
|
||||||
|
for (int i = 0; i < (datalen / 4); i++) {
|
||||||
|
char path[PATH_MAX_LENGTH] = {0};
|
||||||
|
sprintf(path, "$.blocks.%d", i);
|
||||||
|
JsonSaveBufAsHexCompact(root, path, data + (i * 4), 4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int res = json_dump_file(root, fileName, JSON_INDENT(2));
|
int res = json_dump_file(root, fileName, JSON_INDENT(2));
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
@ -55,6 +55,11 @@ typedef enum {
|
||||||
jsfRaw,
|
jsfRaw,
|
||||||
jsfCardMemory,
|
jsfCardMemory,
|
||||||
jsfMfuMemory,
|
jsfMfuMemory,
|
||||||
|
jsfHitag,
|
||||||
|
// jsf14b,
|
||||||
|
// jsf15,
|
||||||
|
// jsfLegic,
|
||||||
|
// jsfT55xx,
|
||||||
} JSONFileType;
|
} JSONFileType;
|
||||||
|
|
||||||
int fileExists(const char *filename);
|
int fileExists(const char *filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue