mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Added additional checks to the from load dictionary returned data points.
This commit is contained in:
parent
225b18d5fc
commit
9dc3c39a95
2 changed files with 5 additions and 12 deletions
|
@ -1585,7 +1585,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
uint64_t key64 = 0;
|
uint64_t key64 = 0;
|
||||||
bool calibrate = true;
|
bool calibrate = true;
|
||||||
// Attack key storage variables
|
// Attack key storage variables
|
||||||
uint8_t *keyBlock;
|
uint8_t *keyBlock = NULL;
|
||||||
uint16_t key_cnt = 0;
|
uint16_t key_cnt = 0;
|
||||||
sector_t *e_sector;
|
sector_t *e_sector;
|
||||||
uint8_t sectors_cnt = MIFARE_1K_MAXSECTOR;
|
uint8_t sectors_cnt = MIFARE_1K_MAXSECTOR;
|
||||||
|
@ -1787,9 +1787,9 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||||
// Load the dictionary
|
// Load the dictionary
|
||||||
if (strlen(filename) != 0) {
|
if (strlen(filename) != 0) {
|
||||||
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 6, &key_cnt);
|
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 6, &key_cnt);
|
||||||
if (res != PM3_SUCCESS || key_cnt <= 0) {
|
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)");
|
PrintAndLogEx(FAILED, "An error occurred while loading the dictionary! (we will use the default keys now)");
|
||||||
free(keyBlock); // free the memory, just in case an allocation happened
|
if (keyBlock != NULL) free(keyBlock);
|
||||||
goto useDefaultKeys;
|
goto useDefaultKeys;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2128,17 +2128,10 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
||||||
if (use_pwd_file) {
|
if (use_pwd_file) {
|
||||||
uint16_t keycount = 0;
|
uint16_t keycount = 0;
|
||||||
|
|
||||||
// TODO, a way of reallocating memory if file was larger
|
|
||||||
keyBlock = calloc(4 * 200, sizeof(uint8_t));
|
|
||||||
if (keyBlock == NULL) {
|
|
||||||
PrintAndLogEx(ERR, "error, cannot allocate memory ");
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 4, &keycount);
|
int res = loadFileDICTIONARY_safe(filename, &keyBlock, 4, &keycount);
|
||||||
if (res || keycount == 0) {
|
if (res || keycount == 0 || keyBlock == NULL) {
|
||||||
PrintAndLogEx(WARNING, "No keys found in file");
|
PrintAndLogEx(WARNING, "No keys found in file");
|
||||||
free(keyBlock);
|
if (keyBlock != NULL) free(keyBlock);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue