clk = GetAskClock("", FALSE, FALSE);\r
if (clk>0) {\r
tests[hits].ST = TRUE;\r
+ // "0 0 1 " == clock auto, invert false, maxError 1.\r
+ // false = no verbose\r
+ // false = no emSearch\r
+ // 1 = Ask/Man\r
+ // st = true\r
if ( ASKDemod_ext("0 0 1", FALSE, FALSE, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
tests[hits].modulation = DEMOD_ASK;\r
tests[hits].bitrate = bitRate;\r
++hits;\r
}\r
tests[hits].ST = TRUE;\r
+ // "0 0 1 " == clock auto, invert true, maxError 1.\r
+ // false = no verbose\r
+ // false = no emSearch\r
+ // 1 = Ask/Man\r
+ // st = true\r
if ( ASKDemod_ext("0 1 1", FALSE, FALSE, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
tests[hits].modulation = DEMOD_ASK;\r
tests[hits].bitrate = bitRate;\r
\r
int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password ){\r
// arg0 bitmodes:\r
- // bit0 = pwdmode\r
- // bit1 = page to read from\r
+ // bit0 = pwdmode\r
+ // bit1 = page to read from\r
+ // arg1: which block to read\r
+ // arg2: password\r
+ \r
uint8_t arg0 = (page<<1) | pwdmode;\r
UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}};\r
\r
if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
memcpy(filename, Cmd+2, len);\r
\r
- FILE * f = fopen( filename , "r");\r
- \r
+ FILE * f = fopen( filename , "r"); \r
if ( !f ) {\r
PrintAndLog("File: %s: not found or locked.", filename);\r
free(keyBlock);\r
if (!p) {\r
PrintAndLog("Cannot allocate memory for defaultKeys");\r
free(keyBlock);\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 2;\r
}\r
keyBlock = p;\r
keycnt++;\r
memset(buf, 0, sizeof(buf));\r
} \r
- fclose(f);\r
- \r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
if (keycnt == 0) {\r
PrintAndLog("No keys found in file");\r
free(keyBlock);\r
// loop\r
uint64_t testpwd = 0x00;\r
for (uint16_t c = 0; c < keycnt; ++c ) {\r
- \r
+\r
+ if ( offline ) {\r
+ printf("Device offline\n");\r
+ free(keyBlock);\r
+ return 2;\r
+ }\r
+ \r
if (ukbhit()) {\r
ch = getchar();\r
(void)ch;\r
testpwd = bytes_to_num(keyBlock + 4*c, 4);\r
\r
PrintAndLog("Testing %08X", testpwd);\r
- \r
- \r
+ \r
if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, testpwd)) {\r
PrintAndLog("Aquireing data from device failed. Quitting");\r
free(keyBlock);\r
}\r
\r
found = tryDetectModulation();\r
-\r
if ( found ) {\r
PrintAndLog("Found valid password: [%08X]", testpwd);\r
free(keyBlock);\r
return 0;\r
}\r
\r
-int tryOnePassword(uint32_t password)\r
-{\r
+int tryOnePassword(uint32_t password) {\r
PrintAndLog("Trying password %08x", password);\r
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, password)) {\r
PrintAndLog("Aquireing data from device failed. Quitting");\r
\r
if (tryDetectModulation())\r
return 1;\r
- else return 0;\r
+ else \r
+ return 0;\r
}\r
\r
int CmdT55xxRecoverPW(const char *Cmd) {\r