Streamlined the naming conventen and types.

This commit is contained in:
Matthias Konrath 2019-08-28 10:45:45 +02:00
parent 7eb79732ff
commit e259b26d60
4 changed files with 14 additions and 10 deletions

View file

@ -1786,7 +1786,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
// Load the dictionary
if (strlen(filename) != 0) {
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 6, &key_cnt);
int res = loadFileDICTIONARY_safe(filename, (void**) &keyBlock, 6, &key_cnt);
if (res != PM3_SUCCESS || key_cnt <= 0 || keyBlock == NULL) {
PrintAndLogEx(FAILED, "An error occurred while loading the dictionary! (we will use the default keys now)");
if (keyBlock != NULL) free(keyBlock);
@ -1806,6 +1806,10 @@ useDefaultKeys:
key_cnt = ARRAYLEN(g_mifare_default_keys);
}
for (int k = 0; k < key_cnt; k++) {
PrintAndLogEx(SUCCESS, "ID: %d KEY: %s", k, sprint_hex((keyBlock + (6 * k)), sizeof(key)));
}
// Use the dictionary to find sector keys on the card
PrintAndLogEx(INFO, "Enter dictionary run...");

View file

@ -2128,7 +2128,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
if (use_pwd_file) {
uint16_t keycount = 0;
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 4, &keycount);
int res = loadFileDICTIONARY_safe(filename, (void**) &keyBlock, 4, &keycount);
if (res != PM3_SUCCESS || keycount <= 0 || keyBlock == NULL) {
PrintAndLogEx(WARNING, "No keys found in file");
if (keyBlock != NULL) free(keyBlock);

View file

@ -649,7 +649,7 @@ out:
return retval;
}
int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t keylen, uint16_t *keycnt) {
int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint16_t *keycnt) {
int block_size = 512;
int allocation_size = block_size;
@ -673,8 +673,8 @@ int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t k
char line[255];
// allocate some space for the dictionary
*data = (uint8_t*) calloc(keylen * allocation_size, sizeof(uint8_t));
if (*data == NULL) return PM3_EFILE;
*pdata = calloc(keylen * allocation_size, sizeof(uint8_t));
if (*pdata == NULL) return PM3_EFILE;
FILE *f = fopen(path, "r");
if (!f) {
@ -687,12 +687,12 @@ int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t k
// check if we have enough space (if not allocate more)
if ((*keycnt) >= allocation_size) {
allocation_size += block_size;
*data = (uint8_t*) realloc((void*) *data, keylen * allocation_size * sizeof(uint8_t));
if (*data == NULL) {
*pdata = realloc(*pdata, keylen * allocation_size * sizeof(uint8_t));
if (*pdata == NULL) {
return PM3_EFILE;
} else {
// zero the new memeory (safety first)
memset(*data + counter, 0, block_size);
memset(*pdata + counter, 0, block_size);
}
}
@ -714,7 +714,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t k
uint64_t key = strtoull(line, NULL, 16);
num_to_bytes(key, keylen >> 1, *data + counter);
num_to_bytes(key, keylen >> 1, *pdata + counter);
(*keycnt)++;
memset(line, 0, sizeof(line));
counter += (keylen >> 1);

View file

@ -171,7 +171,7 @@ int loadFileDICTIONARY(const char *preferredName, void *data, size_t *datalen, u
* @param keylen the number of bytes a key per row is
* @return 0 for ok, 1 for failz
*/
int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t keylen, uint16_t *keycnt);
int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint16_t *keycnt);
/**
* @brief Utility function to check and convert old mfu dump format to new