]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlft55xx.c
CHG: 'lf noralsy' Added tag allocation year in demod output.
[proxmark3-svn] / client / cmdlft55xx.c
index f8865c8da89898488265e90f382024de18f0d452..25b9ba279905d6944aa3391d292940ffe81f9769 100644 (file)
@@ -547,6 +547,11 @@ bool tryDetectModulation(){
                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
@@ -555,6 +560,11 @@ bool tryDetectModulation(){
                                ++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
@@ -1249,8 +1259,11 @@ int CmdT55xxDump(const char *Cmd){
 \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
@@ -1450,8 +1463,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
                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
@@ -1478,7 +1490,10 @@ int CmdT55xxBruteForce(const char *Cmd) {
                                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
@@ -1489,8 +1504,10 @@ int CmdT55xxBruteForce(const char *Cmd) {
                        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
@@ -1501,7 +1518,13 @@ int CmdT55xxBruteForce(const char *Cmd) {
                // 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
@@ -1513,8 +1536,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
                        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
@@ -1522,7 +1544,6 @@ int CmdT55xxBruteForce(const char *Cmd) {
                        }\r
                        \r
                        found = tryDetectModulation();\r
-\r
                        if ( found ) {\r
                                PrintAndLog("Found valid password: [%08X]", testpwd);\r
                                free(keyBlock);\r
@@ -1583,8 +1604,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
     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
@@ -1593,7 +1613,8 @@ int tryOnePassword(uint32_t password)
 \r
        if (tryDetectModulation())\r
                return 1;\r
-       else return 0;\r
+       else \r
+               return 0;\r
 }\r
 \r
 int CmdT55xxRecoverPW(const char *Cmd) {\r
Impressum, Datenschutz