X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/dd0434a6ed45d2128bb687f4cacbed7ae00cd586..02a405967e79bf24c930382791eeb07dd48b6d89:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index a86dd423..b26973e6 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -1378,7 +1378,7 @@ int CmdT55xxBruteForce(const char *Cmd) { char filename[FILE_PATH_SIZE]={0}; int keycnt = 0; uint8_t stKeyBlock = 20; - uint8_t *keyBlock = NULL, *p; + uint8_t *keyBlock = NULL, *p = NULL; keyBlock = calloc(stKeyBlock, 6); if (keyBlock == NULL) return 1; @@ -1387,7 +1387,10 @@ int CmdT55xxBruteForce(const char *Cmd) { bool found = false; char cmdp = param_getchar(Cmd, 0); - if (cmdp == 'h' || cmdp == 'H') return usage_t55xx_bruteforce(); + if (cmdp == 'h' || cmdp == 'H') { + free(keyBlock); + return usage_t55xx_bruteforce(); + } if (cmdp == 'i' || cmdp == 'I') { @@ -1423,6 +1426,7 @@ int CmdT55xxBruteForce(const char *Cmd) { if (!p) { PrintAndLog("Cannot allocate memory for defaultKeys"); free(keyBlock); + fclose(f); return 2; } keyBlock = p; @@ -1437,6 +1441,7 @@ int CmdT55xxBruteForce(const char *Cmd) { if (keycnt == 0) { PrintAndLog("No keys found in file"); + free(keyBlock); return 1; } PrintAndLog("Loaded %d keys", keycnt); @@ -1448,6 +1453,7 @@ int CmdT55xxBruteForce(const char *Cmd) { if (ukbhit()) { getchar(); printf("\naborted via keyboard!\n"); + free(keyBlock); return 0; } @@ -1458,6 +1464,7 @@ int CmdT55xxBruteForce(const char *Cmd) { if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, testpwd)) { PrintAndLog("Aquireing data from device failed. Quitting"); + free(keyBlock); return 0; } @@ -1465,10 +1472,12 @@ int CmdT55xxBruteForce(const char *Cmd) { if ( found ) { PrintAndLog("Found valid password: [%08X]", testpwd); + free(keyBlock); return 0; } } PrintAndLog("Password NOT found."); + free(keyBlock); return 0; } @@ -1478,7 +1487,10 @@ int CmdT55xxBruteForce(const char *Cmd) { start_password = param_get32ex(Cmd, 0, 0, 16); end_password = param_get32ex(Cmd, 1, 0, 16); - if ( start_password >= end_password ) return usage_t55xx_bruteforce(); + if ( start_password >= end_password ) { + free(keyBlock); + return usage_t55xx_bruteforce(); + } PrintAndLog("Search password range [%08X -> %08X]", start_password, end_password); @@ -1491,11 +1503,13 @@ int CmdT55xxBruteForce(const char *Cmd) { if (ukbhit()) { getchar(); printf("\naborted via keyboard!\n"); + free(keyBlock); return 0; } if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, i)) { PrintAndLog("Aquireing data from device failed. Quitting"); + free(keyBlock); return 0; } found = tryDetectModulation(); @@ -1510,6 +1524,8 @@ int CmdT55xxBruteForce(const char *Cmd) { PrintAndLog("Found valid password: [%08x]", i); else PrintAndLog("Password NOT found. Last tried: [%08x]", --i); + + free(keyBlock); return 0; }