X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/c8b6da2295a35cda0232f147993a0ed6ff68b207..ef9b8b2c2b55254a70127e3730fd8e964c5b8521:/client/loclass/elite_crack.c diff --git a/client/loclass/elite_crack.c b/client/loclass/elite_crack.c index a8ab869e..a282ec50 100644 --- a/client/loclass/elite_crack.c +++ b/client/loclass/elite_crack.c @@ -394,7 +394,7 @@ int bruteforceItem(dumpdata item, uint16_t keytable[]) //Diversify diversifyKey(item.csn, key_sel_p, div_key); //Calc mac - doMAC(item.cc_nr,12, div_key,calculated_MAC); + doMAC(item.cc_nr, div_key,calculated_MAC); if(memcmp(calculated_MAC, item.mac, 4) == 0) { @@ -522,8 +522,8 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) errors += bruteforceItem(*attack, keytable); } free(attack); - clock_t t2 = clock(); - float diff = (((float)t2 - (float)t1) / CLOCKS_PER_SEC ); + t1 = clock() - t1; + float diff = ((float)t1 / CLOCKS_PER_SEC ); prnlog("\nPerformed full crack in %f seconds",diff); // Pick out the first 16 bytes of the keytable. @@ -563,6 +563,12 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) long fsize = ftell(f); fseek(f, 0, SEEK_SET); + if (fsize < 0) { + prnlog("Error, when getting filesize"); + fclose(f); + return 1; + } + uint8_t *dump = malloc(fsize); size_t bytes_read = fread(dump, 1, fsize, f); @@ -571,7 +577,10 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) { prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize ); } - return bruteforceDump(dump,fsize,keytable); + + uint8_t res = bruteforceDump(dump,fsize,keytable); + free(dump); + return res; } /** *