mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-21 22:03:19 -07:00
added tlv tree navigation
This commit is contained in:
parent
af789d7f2d
commit
7fecd489cf
3 changed files with 34 additions and 4 deletions
|
@ -1173,7 +1173,7 @@ int JsonSaveHex(json_t *elm, char *path, uint64_t data, int datalen) {
|
||||||
int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveValue) {
|
int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveValue) {
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
|
|
||||||
if (strlen(path) < 1)
|
if (strlen(path) < 1 || !tlvelm)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (path[0] == '$') {
|
if (path[0] == '$') {
|
||||||
|
@ -1197,7 +1197,18 @@ int JsonSaveTLVElm(json_t *elm, char *path, struct tlv *tlvelm, bool saveValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
int JsonSaveTLVTreeElm(json_t *elm, char *path, struct tlvdb *tlvdbelm, bool saveValue) {
|
int JsonSaveTLVTreeElm(json_t *elm, char *path, struct tlvdb *tlvdbelm, bool saveValue) {
|
||||||
JsonSaveTLVElm(elm, path, (struct tlv *)tlvdb_get_tlv(tlvdbelm), saveValue);
|
return JsonSaveTLVElm(elm, path, (struct tlv *)tlvdb_get_tlv(tlvdbelm), saveValue);
|
||||||
|
}
|
||||||
|
int JsonSaveTLVTree(json_t *elm, char *path, struct tlvdb *tlvdbelm) {
|
||||||
|
struct tlvdb *tlvp = tlvdbelm;
|
||||||
|
while (tlvp) {
|
||||||
|
JsonSaveTLVTreeElm(elm, path, tlvp, true);
|
||||||
|
if (tlvdb_elm_get_children(tlvp)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tlvp = tlvdb_elm_get_next(tlvp);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1301,7 +1312,7 @@ int CmdHFEMVScan(const char *cmd) {
|
||||||
TLVPrintAIDlistFromSelectTLV(tlvSelect);
|
TLVPrintAIDlistFromSelectTLV(tlvSelect);
|
||||||
|
|
||||||
JsonSaveBufAsHex(root, "$.PPSE.AID", (uint8_t *)"2PAY.SYS.DDF01", 14);
|
JsonSaveBufAsHex(root, "$.PPSE.AID", (uint8_t *)"2PAY.SYS.DDF01", 14);
|
||||||
JsonSaveTLVTreeElm(root, "$.PPSE.FCITemplate", tlvdb_find(tlvSelect, 0x6f), true);
|
JsonSaveTLVTree(root, "$.PPSE.FCITemplate", tlvdb_find(tlvSelect, 0x6f));
|
||||||
// here save PSE result to JSON
|
// here save PSE result to JSON
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1343,7 +1354,7 @@ int CmdHFEMVScan(const char *cmd) {
|
||||||
if (decodeTLV)
|
if (decodeTLV)
|
||||||
TLVPrintFromBuffer(buf, len);
|
TLVPrintFromBuffer(buf, len);
|
||||||
|
|
||||||
// here save Select result to JSON
|
JsonSaveTLVTree(root, "$.Application.FCITemplate", tlvdb_parse_multi(buf, len));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -520,3 +520,18 @@ bool tlv_equal(const struct tlv *a, const struct tlv *b)
|
||||||
|
|
||||||
return a->tag == b->tag && a->len == b->len && !memcmp(a->value, b->value, a->len);
|
return a->tag == b->tag && a->len == b->len && !memcmp(a->value, b->value, a->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_next(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_children(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->children;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_parent(struct tlvdb *tlvdb)
|
||||||
|
{
|
||||||
|
return tlvdb->parent;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ struct tlvdb *tlvdb_parse(const unsigned char *buf, size_t len);
|
||||||
struct tlvdb *tlvdb_parse_multi(const unsigned char *buf, size_t len);
|
struct tlvdb *tlvdb_parse_multi(const unsigned char *buf, size_t len);
|
||||||
void tlvdb_free(struct tlvdb *tlvdb);
|
void tlvdb_free(struct tlvdb *tlvdb);
|
||||||
|
|
||||||
|
struct tlvdb *tlvdb_elm_get_next(struct tlvdb *tlvdb);
|
||||||
|
struct tlvdb *tlvdb_elm_get_children(struct tlvdb *tlvdb);
|
||||||
|
struct tlvdb *tlvdb_elm_get_parent(struct tlvdb *tlvdb);
|
||||||
|
|
||||||
struct tlvdb *tlvdb_find_full(struct tlvdb *tlvdb, tlv_tag_t tag); // search also in childrens
|
struct tlvdb *tlvdb_find_full(struct tlvdb *tlvdb, tlv_tag_t tag); // search also in childrens
|
||||||
struct tlvdb *tlvdb_find(struct tlvdb *tlvdb, tlv_tag_t tag);
|
struct tlvdb *tlvdb_find(struct tlvdb *tlvdb, tlv_tag_t tag);
|
||||||
struct tlvdb *tlvdb_find_next(struct tlvdb *tlvdb, tlv_tag_t tag);
|
struct tlvdb *tlvdb_find_next(struct tlvdb *tlvdb, tlv_tag_t tag);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue