]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
there was bug in `hf mf mifare`. and speed up this command.
authorMerlokbr@gmail.com <Merlokbr@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 8 Nov 2012 09:48:02 +0000 (09:48 +0000)
committerMerlokbr@gmail.com <Merlokbr@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 8 Nov 2012 09:48:02 +0000 (09:48 +0000)
armsrc/iso14443a.c
client/cmdhfmf.c
client/nonce2key/nonce2key.c
client/nonce2key/nonce2key.h

index af7b35457aa52c5d5cb921261dbe675b000ee39c..d2a54d8ce360b46b560fa879508efd29cdb324d8 100644 (file)
@@ -1850,11 +1850,12 @@ void ReaderMifare(uint32_t parameter)
 
        while(TRUE)
        {
-               LED_C_ON();
+               LED_C_OFF();
                FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
-               SpinDelay(200);
+               SpinDelay(10);
                FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);
-               LED_C_OFF();
+               LED_C_ON();
+               SpinDelay(2);
 
                // Test if the action was cancelled
                if(BUTTON_PRESS()) {
index f3f243c440f94ab60a9aa4efb226c8e2c0e9b08f..dff5db37e08e526687e816480e66880082ae2ca0 100644 (file)
@@ -71,17 +71,22 @@ start:
        if (isOK != 1) return 1;\r
        \r
        // execute original function from util nonce2key\r
-       if (nonce2key(uid, nt, par_list, ks_list, &r_key)) return 2;\r
-       printf("------------------------------------------------------------------\n");\r
-       PrintAndLog("Key found:%012llx \n", r_key);\r
+       if (nonce2key(uid, nt, 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
+       } else {\r
+               printf("------------------------------------------------------------------\n");\r
+               PrintAndLog("Key found:%012llx \n", r_key);\r
 \r
-       num_to_bytes(r_key, 6, keyBlock);\r
-       isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);\r
+               num_to_bytes(r_key, 6, keyBlock);\r
+               isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);\r
+       }\r
        if (!isOK) \r
                PrintAndLog("Found valid key:%012llx", r_key);\r
        else\r
        {\r
-               PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt); \r
+               if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt);  \r
                c.arg[0] = nt;\r
                goto start;\r
        }\r
index 1c7ee14c51ec59400b3f2c2998c0ba954ebacd74..032b15c4be11ad7f6635801d38e83b7caecfbff1 100644 (file)
@@ -14,7 +14,7 @@
 #include "ui.h"
 
 int nonce2key(uint32_t uid, uint32_t nt, uint64_t par_info, uint64_t ks_info, uint64_t * key) {
-  struct Crypto1State *state;
+  struct Crypto1State *state, *state_s;
   uint32_t pos, nr, rr, nr_diff;//, ks1, ks2;
   byte_t bt, i, ks3x[8], par[8][8];
   uint64_t key_recovered;
@@ -47,9 +47,17 @@ int nonce2key(uint32_t uid, uint32_t nt, uint64_t par_info, uint64_t ks_info, ui
   }
   
   state = lfsr_common_prefix(nr, rr, ks3x, par);
-  lfsr_rollback_word(state, uid^nt, 0);
-  crypto1_get_lfsr(state, &key_recovered);
-  crypto1_destroy(state);
+       state_s = 0;
+       for (i = 0; (state) && ((state + i)->odd != 0 || (state + i)->even != 0) && (i < 10); i++)
+       {
+    printf("%08x|%08x\n",(state+i)->odd, (state+i)->even);
+               state_s = state + i;
+       }
+  if (!state_s) return 1;
+       
+  lfsr_rollback_word(state_s, uid^nt, 0);
+  crypto1_get_lfsr(state_s, &key_recovered);
+  if (!state) free(state);
        
        *key = key_recovered;
   
index 0f577cf862e038d3cd67222c7ca7a784ebfd5acb..acde7c8885e98b847d582e0fae704aee510da529 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <inttypes.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "crapto1.h"
 #include "common.h"
 
Impressum, Datenschutz