mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 18:57:12 +08:00
aidsearch works
This commit is contained in:
parent
c861f68a87
commit
0b5cc59bcd
2 changed files with 20 additions and 16 deletions
|
@ -16,7 +16,7 @@
|
||||||
#include "pm3_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
|
|
||||||
int openAIDFile(json_t *root) {
|
int openAIDFile(json_t **root) {
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -26,14 +26,14 @@ int openAIDFile(json_t *root) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int retval = PM3_SUCCESS;
|
int retval = PM3_SUCCESS;
|
||||||
root = json_load_file(path, 0, &error);
|
*root = json_load_file(path, 0, &error);
|
||||||
if (!root) {
|
if (!*root) {
|
||||||
PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text);
|
PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text);
|
||||||
retval = PM3_ESOFT;
|
retval = PM3_ESOFT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!json_is_array(root)) {
|
if (!json_is_array(*root)) {
|
||||||
PrintAndLogEx(ERR, "Invalid json (%s) format. root must be an array.", path);
|
PrintAndLogEx(ERR, "Invalid json (%s) format. root must be an array.", path);
|
||||||
retval = PM3_ESOFT;
|
retval = PM3_ESOFT;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -51,12 +51,13 @@ int closeAIDFile(json_t *root) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_t *AIDSearchInit(json_t *root) {
|
json_t *AIDSearchInit() {
|
||||||
int res = openAIDFile(root);
|
json_t *root = NULL;
|
||||||
|
int res = openAIDFile(&root);
|
||||||
if (res != PM3_SUCCESS)
|
if (res != PM3_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return AIDSearchGetElm(root, 0);
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_t *AIDSearchGetElm(json_t *root, int elmindx) {
|
json_t *AIDSearchGetElm(json_t *root, int elmindx) {
|
||||||
|
@ -77,6 +78,8 @@ const char * jsonStrGet(json_t *data, char *name) {
|
||||||
json_t *jstr;
|
json_t *jstr;
|
||||||
|
|
||||||
jstr = json_object_get(data, name);
|
jstr = json_object_get(data, name);
|
||||||
|
if (jstr == NULL)
|
||||||
|
return NULL;
|
||||||
if (!json_is_string(jstr)) {
|
if (!json_is_string(jstr)) {
|
||||||
PrintAndLogEx(ERR, "`%s` is not a string", name);
|
PrintAndLogEx(ERR, "`%s` is not a string", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -100,11 +103,11 @@ bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrintAIDDescription(char *aid, bool verbose) {
|
int PrintAIDDescription(char *aid, bool verbose) {
|
||||||
json_t *root = NULL;
|
|
||||||
int retval = PM3_SUCCESS;
|
int retval = PM3_SUCCESS;
|
||||||
|
|
||||||
int elmindx = 0;
|
int elmindx = 0;
|
||||||
json_t *data = AIDSearchInit(root);
|
json_t *root = AIDSearchInit();
|
||||||
|
json_t *data = AIDSearchGetElm(root, elmindx);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -129,18 +132,19 @@ int PrintAIDDescription(char *aid, bool verbose) {
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "AID %s | %s | %s", vaid, vendor, name);
|
PrintAndLogEx(SUCCESS, "AID %s | %s | %s", vaid, vendor, name);
|
||||||
} else {
|
} else {
|
||||||
|
PrintAndLogEx(NORMAL, "----------------------------------------");
|
||||||
if (aid)
|
if (aid)
|
||||||
PrintAndLogEx(SUCCESS, "AID: %s\n", vaid);
|
PrintAndLogEx(SUCCESS, "Found AID: %s", vaid);
|
||||||
if (vendor)
|
if (vendor)
|
||||||
PrintAndLogEx(SUCCESS, "Vendor: %s\n", vendor);
|
PrintAndLogEx(SUCCESS, "Vendor: %s", vendor);
|
||||||
if (type)
|
if (type)
|
||||||
PrintAndLogEx(SUCCESS, "Type: %s\n", type);
|
PrintAndLogEx(SUCCESS, "Type: %s", type);
|
||||||
if (name)
|
if (name)
|
||||||
PrintAndLogEx(SUCCESS, "Name: %s\n", name);
|
PrintAndLogEx(SUCCESS, "Name: %s", name);
|
||||||
if (country)
|
if (country)
|
||||||
PrintAndLogEx(SUCCESS, "Country: %s\n", country);
|
PrintAndLogEx(SUCCESS, "Country: %s", country);
|
||||||
if (description)
|
if (description)
|
||||||
PrintAndLogEx(SUCCESS, "Description: %s\n", description);
|
PrintAndLogEx(SUCCESS, "Description: %s", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
int PrintAIDDescription(char *aid, bool verbose);
|
int PrintAIDDescription(char *aid, bool verbose);
|
||||||
json_t *AIDSearchInit(json_t *root);
|
json_t *AIDSearchInit();
|
||||||
json_t *AIDSearchGetElm(json_t *root, int elmindx);
|
json_t *AIDSearchGetElm(json_t *root, int elmindx);
|
||||||
int AIDSearchFree();
|
int AIDSearchFree();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue