mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
move hardnested tables to resources/
This commit is contained in:
parent
f227cebc3b
commit
2c853d94ea
362 changed files with 50 additions and 26 deletions
|
@ -1648,7 +1648,7 @@ static int CmdLoad(const char *Cmd) {
|
|||
memcpy(filename, Cmd, len);
|
||||
|
||||
char *path;
|
||||
if (searchFile(&path, TRACES_SUBDIR, filename, "") != PM3_SUCCESS) {
|
||||
if (searchFile(&path, TRACES_SUBDIR, filename, "", false) != PM3_SUCCESS) {
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2398,7 +2398,7 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
|
|||
}
|
||||
|
||||
char *dict_path;
|
||||
int res = searchFile(&dict_path, DICTIONARIES_SUBDIR, filename, ".dic");
|
||||
int res = searchFile(&dict_path, DICTIONARIES_SUBDIR, filename, ".dic", false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
free(keyBlock);
|
||||
return res;
|
||||
|
@ -2660,7 +2660,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
}
|
||||
|
||||
char *dict_path;
|
||||
int res = searchFile(&dict_path, DICTIONARIES_SUBDIR, filename, ".dic");
|
||||
int res = searchFile(&dict_path, DICTIONARIES_SUBDIR, filename, ".dic", false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
free(keyBlock);
|
||||
return PM3_EFILE;
|
||||
|
|
|
@ -36,13 +36,14 @@
|
|||
#include "hardnested/hardnested_bf_core.h"
|
||||
#include "hardnested/hardnested_bitarray_core.h"
|
||||
#include "zlib.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#define NUM_CHECK_BITFLIPS_THREADS (num_CPUs())
|
||||
#define NUM_REDUCTION_WORKING_THREADS (num_CPUs())
|
||||
|
||||
#define IGNORE_BITFLIP_THRESHOLD 0.99 // ignore bitflip arrays which have nearly only valid states
|
||||
|
||||
#define STATE_FILES_DIRECTORY "hardnested/tables/"
|
||||
#define STATE_FILES_DIRECTORY "hardnested_tables/"
|
||||
#define STATE_FILE_TEMPLATE "bitflip_%d_%03" PRIx16 "_states.bin.z"
|
||||
|
||||
#define DEBUG_KEY_ELIMINATION
|
||||
|
@ -248,10 +249,15 @@ static void init_bitflip_bitarrays(void) {
|
|||
bitflip_bitarrays[odd_even][bitflip] = NULL;
|
||||
count_bitflip_bitarrays[odd_even][bitflip] = 1 << 24;
|
||||
sprintf(state_file_name, STATE_FILE_TEMPLATE, odd_even, bitflip);
|
||||
strcpy(state_files_path, get_my_executable_directory());
|
||||
strcat(state_files_path, STATE_FILES_DIRECTORY);
|
||||
strcpy(state_files_path, STATE_FILES_DIRECTORY);
|
||||
strcat(state_files_path, state_file_name);
|
||||
FILE *statesfile = fopen(state_files_path, "rb");
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, state_files_path, "", true) != PM3_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FILE *statesfile = fopen(path, "rb");
|
||||
free(path);
|
||||
if (statesfile == NULL) {
|
||||
continue;
|
||||
} else {
|
||||
|
|
|
@ -67,7 +67,7 @@ static int CmdScriptRun(const char *Cmd) {
|
|||
sscanf(Cmd, "%127s%n %255[^\n\r]%n", preferredName, &name_len, arguments, &arg_len);
|
||||
|
||||
char *script_path;
|
||||
int res = searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua");
|
||||
int res = searchFile(&script_path, LUA_SCRIPTS_SUBDIR, preferredName, ".lua", false);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ static int smart_loadjson(const char *preferredName, json_t **root) {
|
|||
if (preferredName == NULL) return 1;
|
||||
|
||||
char *path;
|
||||
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, ".json");
|
||||
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, ".json", false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ static char *asn1_oid_description(const char *oid, bool with_group_desc) {
|
|||
memset(res, 0x00, sizeof(res));
|
||||
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "oids", ".json") != PM3_SUCCESS) {
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "oids", ".json", false) != PM3_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ struct emv_pk *emv_pk_get_ca_pk(const unsigned char *rid, unsigned char idx) {
|
|||
}
|
||||
*/
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "capk", ".txt") != PM3_SUCCESS) {
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "capk", ".txt", false) != PM3_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
pk = emv_pk_get_ca_pk_from_file(path, rid, idx);
|
||||
|
|
|
@ -306,7 +306,7 @@ bool ParamLoadFromJson(struct tlvdb *tlv) {
|
|||
}
|
||||
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "emv_defparams", ".json") != PM3_SUCCESS) {
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, "emv_defparams", ".json", false) != PM3_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
root = json_load_file(path, 0, &error);
|
||||
|
|
|
@ -405,7 +405,7 @@ out:
|
|||
int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, size_t *datalen) {
|
||||
|
||||
char *path;
|
||||
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, suffix);
|
||||
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, suffix, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, u
|
|||
|
||||
if (data == NULL) return PM3_ESOFT;
|
||||
char *path;
|
||||
if (searchFile(&path, DICTIONARIES_SUBDIR, preferredName, ".dic") != PM3_SUCCESS)
|
||||
if (searchFile(&path, DICTIONARIES_SUBDIR, preferredName, ".dic", false) != PM3_SUCCESS)
|
||||
return PM3_EFILE;
|
||||
|
||||
// t5577 == 4bytes
|
||||
|
@ -701,7 +701,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
int retval = PM3_SUCCESS;
|
||||
|
||||
char *path;
|
||||
if (searchFile(&path, DICTIONARIES_SUBDIR, preferredName, ".dic") != PM3_SUCCESS)
|
||||
if (searchFile(&path, DICTIONARIES_SUBDIR, preferredName, ".dic", false) != PM3_SUCCESS)
|
||||
return PM3_EFILE;
|
||||
|
||||
// t5577 == 4bytes
|
||||
|
@ -863,19 +863,22 @@ int searchAndList(const char *pm3dir, const char *ext) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int searchFinalFile(char **foundpath, const char *pm3dir, const char *searchname) {
|
||||
static int searchFinalFile(char **foundpath, const char *pm3dir, const char *searchname, bool silent) {
|
||||
if ((foundpath == NULL) || (pm3dir == NULL) || (searchname == NULL)) return PM3_ESOFT;
|
||||
// explicit absolute (/) or relative path (./) => try only to match it directly
|
||||
char *filename = calloc(strlen(searchname) + 1, sizeof(char));
|
||||
if (filename == NULL) return PM3_EMALLOC;
|
||||
strcpy(filename, searchname);
|
||||
if (g_debugMode == 2) {
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", filename);
|
||||
}
|
||||
if (((strlen(filename) > 1) && (filename[0] == '/')) ||
|
||||
((strlen(filename) > 2) && (filename[0] == '.') && (filename[1] == '/'))) {
|
||||
if (fileExists(filename)) {
|
||||
*foundpath = filename;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
goto out;
|
||||
|
@ -887,6 +890,9 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
{
|
||||
if (fileExists(filename)) {
|
||||
*foundpath = filename;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -903,12 +909,15 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
strcpy(path, exec_path);
|
||||
strcat(path, pm3dir);
|
||||
strcat(path, filename);
|
||||
if (g_debugMode == 2) {
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", path);
|
||||
}
|
||||
if (fileExists(path)) {
|
||||
free(filename);
|
||||
*foundpath = path;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
free(path);
|
||||
|
@ -925,12 +934,15 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
strcat(path, above);
|
||||
strcat(path, pm3dir);
|
||||
strcat(path, filename);
|
||||
if (g_debugMode == 2) {
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", path);
|
||||
}
|
||||
if (fileExists(path)) {
|
||||
free(filename);
|
||||
*foundpath = path;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
free(path);
|
||||
|
@ -946,12 +958,15 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
strcat(path, PM3_USER_DIRECTORY);
|
||||
strcat(path, pm3dir);
|
||||
strcat(path, filename);
|
||||
if (g_debugMode == 2) {
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", path);
|
||||
}
|
||||
if (fileExists(path)) {
|
||||
free(filename);
|
||||
*foundpath = path;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
free(path);
|
||||
|
@ -965,12 +980,15 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
strcpy(path, PM3_SHARE_PATH);
|
||||
strcat(path, pm3dir);
|
||||
strcat(path, filename);
|
||||
if (g_debugMode == 2) {
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Searching %s", path);
|
||||
}
|
||||
if (fileExists(path)) {
|
||||
free(filename);
|
||||
*foundpath = path;
|
||||
if ((g_debugMode == 2) && (!silent)) {
|
||||
PrintAndLogEx(INFO, "Found %s", *foundpath);
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
} else {
|
||||
free(path);
|
||||
|
@ -981,14 +999,14 @@ out:
|
|||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix) {
|
||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent) {
|
||||
if (foundpath == NULL)
|
||||
return PM3_EINVARG;
|
||||
char *filename = filenamemcopy(searchname, suffix);
|
||||
if (filename == NULL) return PM3_EMALLOC;
|
||||
int res = searchFinalFile(foundpath, pm3dir, filename);
|
||||
int res = searchFinalFile(foundpath, pm3dir, filename, silent);
|
||||
if (res != PM3_SUCCESS) {
|
||||
if (res == PM3_EFILE)
|
||||
if ((res == PM3_EFILE) && (!silent))
|
||||
PrintAndLogEx(FAILED, "Error - can't find %s", filename);
|
||||
free(filename);
|
||||
return res;
|
||||
|
|
|
@ -202,6 +202,6 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
int convertOldMfuDump(uint8_t **dump, size_t *dumplen);
|
||||
|
||||
int searchAndList(const char *pm3dir, const char *ext);
|
||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix);
|
||||
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);
|
||||
|
||||
#endif // FILEUTILS_H
|
||||
|
|
|
@ -367,7 +367,7 @@ static bool read_bench_data(statelist_t *test_candidates) {
|
|||
uint32_t states_read = 0;
|
||||
|
||||
char *path;
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, TEST_BENCH_FILENAME, "") != PM3_SUCCESS) {
|
||||
if (searchFile(&path, RESOURCES_SUBDIR, TEST_BENCH_FILENAME, "", false) != PM3_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue