mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-19 11:33:51 +08: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);
|
||||
saveFileEML(filename, "eml", data, 48, 4);
|
||||
saveFileJSON(filename, "json", jsfHitag, (uint8_t *)data, 48);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -377,7 +378,7 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CmdLFHitagWP(const char *Cmd) {
|
||||
int CmdLFHitagWriter(const char *Cmd) {
|
||||
UsbCommand c = { CMD_WR_HITAG_S };
|
||||
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
||||
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
@ -419,14 +420,14 @@ int CmdLFHitagWP(const char *Cmd) {
|
|||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"list", CmdLFHitagList, 1, "<outfile> List Hitag trace history"},
|
||||
{"reader", CmdLFHitagReader, 1, "Act like a Hitag Reader"},
|
||||
{"sim", CmdLFHitagSim, 1, "<infile> Simulate Hitag transponder"},
|
||||
{"simS", CmdLFHitagSimS, 1, "<hitagS.hts> Simulate HitagS transponder" },
|
||||
{"sniff", CmdLFHitagSniff, 1, "Eavesdrop Hitag communication"},
|
||||
{"writer", CmdLFHitagWP, 1, "Act like a Hitag Writer" },
|
||||
{"check_challenges", CmdLFHitagCheckChallenges, 1, "<challenges.cc> test all challenges" },
|
||||
{"help", CmdHelp, 1, "This help"},
|
||||
{"list", CmdLFHitagList, 1, "<outfile> List Hitag trace history"},
|
||||
{"reader", CmdLFHitagReader, 1, "Act like a Hitag Reader"},
|
||||
{"sim", CmdLFHitagSim, 1, "<infile> Simulate Hitag transponder"},
|
||||
{"simS", CmdLFHitagSimS, 1, "<hitagS.bin> Simulate HitagS transponder" },
|
||||
{"sniff", CmdLFHitagSniff, 1, "Eavesdrop Hitag communication"},
|
||||
{"writer", CmdLFHitagWriter, 1, "Act like a Hitag Writer" },
|
||||
{"check_challenges", CmdLFHitagCheckChallenges, 1, "<challenges.cc> test all challenges" },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ extern int CmdLFHitagReader(const char *Cmd);
|
|||
extern int CmdLFHitagSim(const char *Cmd);
|
||||
extern int CmdLFHitagSimS(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);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -155,11 +155,12 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
|||
json_t *root = json_object();
|
||||
JsonSaveStr(root, "Created", "proxmark3");
|
||||
switch (ftype) {
|
||||
case jsfRaw:
|
||||
case jsfRaw: {
|
||||
JsonSaveStr(root, "FileType", "raw");
|
||||
JsonSaveBufAsHexCompact(root, "raw", data, datalen);
|
||||
break;
|
||||
case jsfCardMemory:
|
||||
}
|
||||
case jsfCardMemory: {
|
||||
JsonSaveStr(root, "FileType", "mfcard");
|
||||
for (int i = 0; i < (datalen / 16); i++) {
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
|
@ -208,7 +209,8 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
|||
}
|
||||
}
|
||||
break;
|
||||
case jsfMfuMemory:
|
||||
}
|
||||
case jsfMfuMemory: {
|
||||
JsonSaveStr(root, "FileType", "mfu");
|
||||
|
||||
mfu_dump_t *tmp = (mfu_dump_t *)data;
|
||||
|
@ -230,12 +232,26 @@ int saveFileJSON(const char *preferredName, const char *suffix, JSONFileType fty
|
|||
size_t len = (datalen - DUMP_PREFIX_LENGTH) / 4;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
char path[PATH_MAX_LENGTH] = {0};
|
||||
sprintf(path, "$.blocks.%d", i);
|
||||
JsonSaveBufAsHexCompact(root, path, tmp->data + (i * 4), 4);
|
||||
}
|
||||
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));
|
||||
|
|
|
@ -55,6 +55,11 @@ typedef enum {
|
|||
jsfRaw,
|
||||
jsfCardMemory,
|
||||
jsfMfuMemory,
|
||||
jsfHitag,
|
||||
// jsf14b,
|
||||
// jsf15,
|
||||
// jsfLegic,
|
||||
// jsfT55xx,
|
||||
} JSONFileType;
|
||||
|
||||
int fileExists(const char *filename);
|
||||
|
|
Loading…
Add table
Reference in a new issue