move aidlist.json to resources/

This commit is contained in:
Philippe Teuwen 2019-08-30 01:23:50 +02:00
commit af65beb987
2 changed files with 17 additions and 14 deletions

View file

@ -22,6 +22,7 @@
#include "crypto/libpcrypto.h" // sha512hash #include "crypto/libpcrypto.h" // sha512hash
#include "emv/dump.h" #include "emv/dump.h"
#include "ui.h" #include "ui.h"
#include "fileutils.h"
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
@ -92,33 +93,35 @@ static int usage_sm_brute(void) {
return 0; return 0;
} }
static int smart_loadjson(const char *preferredName, const char *suffix, json_t **root) { static int smart_loadjson(const char *preferredName, json_t **root) {
json_error_t error; json_error_t error;
if (preferredName == NULL) return 1; if (preferredName == NULL) return 1;
if (suffix == NULL) return 1;
int retval = 0; char *path;
int size = sizeof(char) * (strlen(get_my_executable_directory()) + strlen(preferredName) + strlen(suffix) + 10); int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, ".json");
char *fileName = calloc(size, sizeof(char)); if (res != PM3_SUCCESS) {
sprintf(fileName, "%s%s.%s", get_my_executable_directory(), preferredName, suffix); return PM3_EFILE;
*root = json_load_file(fileName, 0, &error); }
int retval = PM3_SUCCESS;
*root = json_load_file(path, 0, &error);
if (!*root) { if (!*root) {
PrintAndLogEx(ERR, "json (%s) error on line %d: %s", fileName, error.line, error.text); PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text);
retval = 2; 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.", fileName); PrintAndLogEx(ERR, "Invalid json (%s) format. root must be an array.", path);
retval = 3; retval = PM3_ESOFT;
goto out; goto out;
} }
PrintAndLogEx(SUCCESS, "Loaded file (%s) OK.", fileName); PrintAndLogEx(SUCCESS, "Loaded file (%s) OK.", path);
out: out:
free(fileName); free(path);
return retval; return retval;
} }
@ -1035,7 +1038,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
PrintAndLogEx(INFO, "Importing AID list"); PrintAndLogEx(INFO, "Importing AID list");
json_t *root = NULL; json_t *root = NULL;
smart_loadjson("aidlist", "json", &root); smart_loadjson("aidlist", &root);
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t)); uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
if (!buf) if (!buf)