]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
(no commit message)
[proxmark3-svn] / client / cmdhfmf.c
index c98b25dac543e3ee2ffdb93fe12c8371b4ab1591..96eb800782a3fc1110eca30191d1efc741a06a05 100644 (file)
@@ -15,18 +15,20 @@ static int CmdHelp(const char *Cmd);
 int CmdHF14AMifare(const char *Cmd)\r
 {\r
        uint32_t uid = 0;\r
-       uint32_t nt = 0;\r
+       uint32_t nt = 0, nr = 0;\r
        uint64_t par_list = 0, ks_list = 0, r_key = 0;\r
        uint8_t isOK = 0;\r
        uint8_t keyBlock[8] = {0};\r
 \r
-       if (param_getchar(Cmd, 0) && param_gethex(Cmd, 0, keyBlock, 8)) {\r
-               PrintAndLog("Nt must include 8 HEX symbols");\r
-               return 1;\r
-       }\r
+       UsbCommand c = {CMD_READER_MIFARE, {true, 0, 0}};\r
+\r
+       // message\r
+       printf("-------------------------------------------------------------------------\n");\r
+       printf("Executing command. Expected execution time: 25sec on average  :-)\n");\r
+       printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");\r
+       printf("-------------------------------------------------------------------------\n");\r
 \r
        \r
-       UsbCommand c = {CMD_READER_MIFARE, {(uint32_t)bytes_to_num(keyBlock, 4), 0, 0}};\r
 start:\r
     clearCommandBuffer();\r
     SendCommand(&c);\r
@@ -34,15 +36,10 @@ start:
        //flush queue\r
        while (ukbhit())        getchar();\r
 \r
-       // message\r
-       printf("-------------------------------------------------------------------------\n");\r
-       printf("Executing command. It may take up to 30 min.\n");\r
-       printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");\r
-       printf("-------------------------------------------------------------------------\n");\r
        \r
        // wait cycle\r
        while (true) {\r
-        //printf(".");\r
+        printf(".");\r
                fflush(stdout);\r
                if (ukbhit()) {\r
                        getchar();\r
@@ -51,27 +48,26 @@ start:
                }\r
                \r
                UsbCommand resp;\r
-               if (WaitForResponseTimeout(CMD_ACK,&resp,2000)) {\r
+               if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {\r
                        isOK  = resp.arg[0] & 0xff;\r
-       \r
                        uid = (uint32_t)bytes_to_num(resp.d.asBytes +  0, 4);\r
                        nt =  (uint32_t)bytes_to_num(resp.d.asBytes +  4, 4);\r
                        par_list = bytes_to_num(resp.d.asBytes +  8, 8);\r
                        ks_list = bytes_to_num(resp.d.asBytes +  16, 8);\r
-       \r
+                       nr = bytes_to_num(resp.d.asBytes + 24, 4);\r
                        printf("\n\n");\r
-                       PrintAndLog("isOk:%02x", isOK);\r
                        if (!isOK) PrintAndLog("Proxmark can't get statistic info. Execution aborted.\n");\r
                        break;\r
                }\r
        }       \r
+\r
        printf("\n");\r
        \r
        // error\r
        if (isOK != 1) return 1;\r
        \r
        // execute original function from util nonce2key\r
-       if (nonce2key(uid, nt, par_list, ks_list, &r_key))\r
+       if (nonce2key(uid, nt, nr, par_list, ks_list, &r_key))\r
        {\r
                isOK = 2;\r
                PrintAndLog("Key not found (lfsr_common_prefix list is null). Nt=%08x", nt);    \r
@@ -86,8 +82,9 @@ start:
                PrintAndLog("Found valid key:%012"llx, r_key);\r
        else\r
        {\r
-               if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt);  \r
-               c.arg[0] = nt;\r
+               if (isOK != 2) PrintAndLog("Found invalid key. ");      \r
+               PrintAndLog("Failing is expected to happen in 25%% of all cases. Trying again with a different reader nonce...");\r
+               c.arg[0] = false;\r
                goto start;\r
        }\r
        \r
Impressum, Datenschutz