]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge remote-tracking branch 'upstream/master'
authorGabriele Gristina <gabriele.gristina@gmail.com>
Sat, 29 Oct 2016 13:19:55 +0000 (15:19 +0200)
committerGabriele Gristina <gabriele.gristina@gmail.com>
Sat, 29 Oct 2016 13:19:55 +0000 (15:19 +0200)
armsrc/iso14443a.c
armsrc/mifarecmd.c
armsrc/mifareutil.c
client/cmdhf14a.c
client/cmdhfmf.c
client/cmdhfmf.h
client/cmdhfmfhard.c
client/cmdlf.c
client/nonce2key/nonce2key.c
client/nonce2key/nonce2key.h
tools/mfkey/.gitignore [new file with mode: 0644]

index 570f028cb4f5cea47b1bc581e76216b275fdbdc3..4bd55fb3b75d77681120a6d4c4b3150731aa63c6 100644 (file)
@@ -2145,29 +2145,24 @@ int32_t dist_nt(uint32_t nt1, uint32_t nt2) {
        uint32_t nttmp1 = nt1;
        uint32_t nttmp2 = nt2;
 
-       for (uint16_t i = 1; i < 32768/8; ++i) {
+       // 0xFFFF -- Half up and half down to find distance between nonces
+       for (uint16_t i = 1; i < 32768/8; i += 8) {
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -i;
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+1;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+1);
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+2;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+2);
-
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+3;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+3);
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+4;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+4);
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+5;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+5);
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+6;
-               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+6);
-               
                nttmp1 = prng_successor(nttmp1, 1);     if (nttmp1 == nt2) return i+7;
+               
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -i;
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+1);
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+2);
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+3);
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+4);
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+5);
+               nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+6);
                nttmp2 = prng_successor(nttmp2, 1);     if (nttmp2 == nt1) return -(i+7);               
        }
        // either nt1 or nt2 are invalid nonces 
index 49730af98cae3f30edebcea8bafbb88168a6b34d..46478735167a8044d21ce06a8f56650a6969bdde 100644 (file)
@@ -1217,10 +1217,9 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain){
                        if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) {\r
                                if (MF_DBGLEVEL >= MF_DBG_ERROR)        Dbprintf("Can't select card");\r
                                errormsg = MAGIC_UID;\r
-                               // break;\r
                        }\r
-                       \r
-                       if ( mifare_classic_halt_ex(NULL) ) break;\r
+                       mifare_classic_halt_ex(NULL);\r
+                       break;\r
                }\r
        \r
                // wipe tag, fill it with zeros\r
@@ -1239,7 +1238,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain){
                                break;\r
                        }\r
 \r
-                       if ( mifare_classic_halt_ex(NULL) ) break;\r
+                       mifare_classic_halt_ex(NULL);\r
                }       \r
 \r
                // write block\r
@@ -1276,7 +1275,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain){
                }       \r
        \r
                if (workFlags & MAGIC_OFF) \r
-                       if ( mifare_classic_halt_ex(NULL) ) break;\r
+                       mifare_classic_halt_ex(NULL);\r
                \r
                isOK = true;\r
                break;\r
index 3d6dce41d5e0884722145ba2aacd8a69567f9271..9c6adcce72074872a0efd16c9804e74c15c62833 100644 (file)
@@ -474,7 +474,10 @@ int mifare_classic_halt_ex(struct Crypto1State *pcs) {
        uint8_t receivedAnswer[4] = {0x00, 0x00, 0x00, 0x00};\r
        len = mifare_sendcmd_short(pcs, (pcs == NULL) ? CRYPT_NONE : CRYPT_ALL, 0x50, 0x00, receivedAnswer, NULL, NULL);\r
        if (len != 0) {\r
-               if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("halt error. response len: %x", len);  \r
+               if (MF_DBGLEVEL >= MF_DBG_ERROR) \r
+                       Dbprintf("halt error. response len: %x data:%02X %02X %02X %02X", len, receivedAnswer[0],receivedAnswer[1],receivedAnswer[2],receivedAnswer[3]);  \r
+               if (len == 1 && receivedAnswer[0] == 0x04)\r
+                       return 4;\r
                return 1;\r
        }\r
        return 0;\r
index b404d4490f8769347a6cc022853bd4b2867ab246..abb786f4d15cc880345572f41d5df0c98c88217d 100644 (file)
@@ -143,6 +143,7 @@ int usage_hf_14a_sim(void) {
 //     PrintAndLog("    u     : 4, 7 or 10 byte UID");
        PrintAndLog("    u     : 4, 7 byte UID");
        PrintAndLog("    x     : (Optional) performs the 'reader attack', nr/ar attack against a legitimate reader");
+       PrintAndLog("    v     : (Optional) show maths used for cracking reader. Useful for debugging.");
        PrintAndLog("\n   sample : hf 14a sim t 1 u 11223344 x");
        PrintAndLog("          : hf 14a sim t 1 u 11223344");
        PrintAndLog("          : hf 14a sim t 1 u 11223344556677");
@@ -447,6 +448,7 @@ int CmdHF14ASim(const char *Cmd) {
        uint8_t uid[10] = {0,0,0,0,0,0,0,0,0,0};
        int uidlen = 0;
        bool useUIDfromEML = TRUE;
+       bool verbose = false;
 
        while(param_getchar(Cmd, cmdp) != 0x00) {
                switch(param_getchar(Cmd, cmdp)) {
@@ -477,6 +479,11 @@ int CmdHF14ASim(const char *Cmd) {
                                }
                                cmdp += 2;
                                break;
+                       case 'v':
+                       case 'V':
+                               verbose = true;
+                               cmdp++;
+                               break;
                        case 'x':
                        case 'X':
                                flags |= FLAG_NR_AR_ATTACK;
@@ -513,7 +520,7 @@ int CmdHF14ASim(const char *Cmd) {
                if ( (resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD ) break;
                        
                memcpy( data, resp.d.asBytes, sizeof(data) );
-               readerAttack(data, TRUE);
+               readerAttack(data, TRUE, verbose);
        }
        return 0;
 }
index 99a91ced7a8418e95665ffdc6eae7dc218cffae7..a840969e20c5e0af8d9e36985bf2ae6f455e5d7b 100644 (file)
@@ -32,6 +32,7 @@ int usage_hf14_mf1ksim(void){
        PrintAndLog("      i    (Optional) Interactive, means that console will not be returned until simulation finishes or is aborted");\r
        PrintAndLog("      x    (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)");\r
        PrintAndLog("      e    (Optional) Fill simulator keys from what we crack");\r
+       PrintAndLog("      v    (Optional) Show maths used for cracking reader. Useful for debugging.");\r
        PrintAndLog("samples:");\r
        PrintAndLog("           hf mf sim u 0a0a0a0a");\r
        PrintAndLog("           hf mf sim u 11223344556677");\r
@@ -1364,7 +1365,7 @@ int CmdHF14AMfChk(const char *Cmd) {
 #define ATTACK_KEY_COUNT 8\r
 sector *k_sector = NULL;\r
 uint8_t k_sectorsCount = 16;\r
-void readerAttack(nonces_t data[], bool setEmulatorMem) {\r
+void readerAttack(nonces_t data[], bool setEmulatorMem, bool verbose) {\r
 \r
        // initialize storage for found keys\r
        if (k_sector == NULL)\r
@@ -1388,7 +1389,7 @@ void readerAttack(nonces_t data[], bool setEmulatorMem) {
 \r
                        // We can probably skip this, mfkey32v2 is more reliable.\r
 #ifdef HFMF_TRYMFK32\r
-                       if (tryMfk32(data[i], &key)) {\r
+                       if (tryMfk32(data[i], &key, verbose)) {\r
                                PrintAndLog("Found Key%s for sector %02d: [%012"llx"]"\r
                                        , (data[i].keytype) ? "B" : "A"\r
                                        , data[i].sector\r
@@ -1413,7 +1414,7 @@ void readerAttack(nonces_t data[], bool setEmulatorMem) {
                        }\r
 #endif\r
                        //moebius attack                        \r
-                       if (tryMfk32_moebius(data[i+ATTACK_KEY_COUNT], &key)) {\r
+                       if (tryMfk32_moebius(data[i+ATTACK_KEY_COUNT], &key, verbose)) {\r
                                uint8_t sectorNum = data[i+ATTACK_KEY_COUNT].sector;\r
                                uint8_t keyType = data[i+ATTACK_KEY_COUNT].keytype;\r
 \r
@@ -1449,11 +1450,14 @@ int CmdHF14AMf1kSim(const char *Cmd) {
        uint8_t uid[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\r
        uint8_t exitAfterNReads = 0;\r
        uint8_t flags = (FLAG_UID_IN_EMUL | FLAG_4B_UID_IN_DATA);\r
-       int uidlen = 0; \r
+       int uidlen = 0;\r
        bool setEmulatorMem = false;\r
        uint8_t cmdp = 0;\r
        bool errors = false;\r
 \r
+       // If set to true, we should show our workings when doing NR_AR_ATTACK.\r
+       bool verbose = false;\r
+\r
        while(param_getchar(Cmd, cmdp) != 0x00) {\r
                switch(param_getchar(Cmd, cmdp)) {\r
                case 'e':\r
@@ -1485,6 +1489,11 @@ int CmdHF14AMf1kSim(const char *Cmd) {
                        }\r
                        cmdp +=2;\r
                        break;\r
+               case 'v':\r
+               case 'V':\r
+                       verbose = true;\r
+                       cmdp++;\r
+                       break;\r
                case 'x':\r
                case 'X':\r
                        flags |= FLAG_NR_AR_ATTACK;\r
@@ -1524,7 +1533,7 @@ int CmdHF14AMf1kSim(const char *Cmd) {
                        if ( (resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD ) break;\r
 \r
                        memcpy( data, resp.d.asBytes, sizeof(data) );                   \r
-                       readerAttack(data, setEmulatorMem);\r
+                       readerAttack(data, setEmulatorMem, verbose);\r
                }\r
                \r
                if (k_sector != NULL) {\r
index 738b343251e390e9e5d408dff2a3703a9b288fd5..d9964261a3507a3840893f4e0cd076a22c843561 100644 (file)
 #include "nonce2key/nonce2key.h"\r
 \r
 int CmdHFMF(const char *Cmd);\r
-
-int CmdHF14AMfDbg(const char* cmd);
-int CmdHF14AMfRdBl(const char* cmd);
-int CmdHF14AMfURdBl(const char* cmd);
-int CmdHF14AMfRdSc(const char* cmd);
-int CmdHF14SMfURdCard(const char* cmd);
-int CmdHF14AMfDump(const char* cmd);
-int CmdHF14AMfRestore(const char* cmd);
-int CmdHF14AMfWrBl(const char* cmd);
-int CmdHF14AMfUWrBl(const char* cmd);
-int CmdHF14AMfChk(const char* cmd);
-int CmdHF14AMifare(const char* cmd);
-int CmdHF14AMfNested(const char* cmd);
+\r
+int CmdHF14AMfDbg(const char* cmd);\r
+int CmdHF14AMfRdBl(const char* cmd);\r
+int CmdHF14AMfURdBl(const char* cmd);\r
+int CmdHF14AMfRdSc(const char* cmd);\r
+int CmdHF14SMfURdCard(const char* cmd);\r
+int CmdHF14AMfDump(const char* cmd);\r
+int CmdHF14AMfRestore(const char* cmd);\r
+int CmdHF14AMfWrBl(const char* cmd);\r
+int CmdHF14AMfUWrBl(const char* cmd);\r
+int CmdHF14AMfChk(const char* cmd);\r
+int CmdHF14AMifare(const char* cmd);\r
+int CmdHF14AMfNested(const char* cmd);\r
 int CmdHF14AMfNestedHard(const char *Cmd);\r
 int CmdHF14AMfSniff(const char* cmd);\r
 int CmdHF14AMf1kSim(const char* cmd);\r
@@ -60,6 +60,6 @@ int CmdHF14AMfCLoad(const char* cmd);
 int CmdHF14AMfCSave(const char* cmd);\r
 int CmdHf14MfDecryptBytes(const char *Cmd);\r
 \r
-void readerAttack(nonces_t data[], bool setEmulatorMem);\r
+void readerAttack(nonces_t data[], bool setEmulatorMem, bool verbose);\r
 void printKeyTable( uint8_t sectorscnt, sector *e_sector );\r
 #endif\r
index ea46469f9f7290755bca0a1f3f5b56f404768f93..fb576441bc5271b8ffa093915a684fcab7ac7e37 100644 (file)
@@ -261,7 +261,10 @@ static double p_hypergeometric(uint16_t N, uint16_t K, uint16_t n, uint16_t k)
                for (int16_t i = N; i >= N-n+1; i--) {
                        log_result -= log(i);
                }
-               return exp(log_result);
+               if ( log_result > 0 )
+                       return exp(log_result);
+               else 
+                       return 0.0;
        } else {
                if (n-k == N-K) {       // special case. The published recursion below would fail with a divide by zero exception
                        double log_result = 0.0;
@@ -1312,7 +1315,7 @@ static bool generate_candidates(uint16_t sum_a0, uint16_t sum_a8)
 
        if (maximum_states == 0) return false; // prevent keyspace reduction error (2^-inf)
 
-       printf("Number of possible keys with Sum(a0) = %d: %"PRIu64" (2^%1.1f)\n", sum_a0, maximum_states, log(maximum_states)/log(2.0));
+       printf("Number of possible keys with Sum(a0) = %d: %"PRIu64" (2^%1.1f)\n", sum_a0, maximum_states, log(maximum_states)/log(2));
        
        init_statelist_cache();
        
@@ -1329,9 +1332,9 @@ static bool generate_candidates(uint16_t sum_a0, uint16_t sum_a8)
                                                        // and eliminate the need to calculate the other part
                                                        if (MIN(partial_statelist[p].len[ODD_STATE], partial_statelist[r].len[ODD_STATE]) 
                                                                        < MIN(partial_statelist[q].len[EVEN_STATE], partial_statelist[s].len[EVEN_STATE])) { 
-                                                       add_matching_states(current_candidates, p, r, ODD_STATE);
+                                                               add_matching_states(current_candidates, p, r, ODD_STATE);
                                                                if(current_candidates->len[ODD_STATE]) {
-                                                       add_matching_states(current_candidates, q, s, EVEN_STATE);
+                                                                       add_matching_states(current_candidates, q, s, EVEN_STATE);
                                                                } else {
                                                                        current_candidates->len[EVEN_STATE] = 0;
                                                                        uint32_t *p = current_candidates->states[EVEN_STATE] = malloc(sizeof(uint32_t));
@@ -1363,7 +1366,7 @@ static bool generate_candidates(uint16_t sum_a0, uint16_t sum_a8)
 
        if (maximum_states == 0) return false; // prevent keyspace reduction error (2^-inf)
 
-       float kcalc = log(maximum_states)/log(2.0);
+       float kcalc = log(maximum_states)/log(2);
        printf("Number of remaining possible keys: %"PRIu64" (2^%1.1f)\n", maximum_states, kcalc);
        if (write_stats) {
                if (maximum_states != 0) {
@@ -1703,7 +1706,7 @@ static bool brute_force(void)
                crypto1_bs_init();
 
                PrintAndLog("Using %u-bit bitslices", MAX_BITSLICES);
-               PrintAndLog("Bitslicing best_first_byte^uid[3] (rollback byte): %02x...", best_first_bytes[0]^(cuid>>24));
+               PrintAndLog("Bitslicing best_first_byte^uid[3] (rollback byte): %02...", best_first_bytes[0]^(cuid>>24));
                // convert to 32 bit little-endian
                crypto1_bs_bitslice_value32((best_first_bytes[0]<<24)^cuid, bitsliced_rollback_byte, 8);
 
@@ -1744,14 +1747,14 @@ static bool brute_force(void)
                }
 
                time(&end);
-               double elapsed_time = difftime(end, start);
+               unsigned long  elapsed_time = difftime(end, start);
 
                if (keys_found && TestIfKeyExists(foundkey)) {
-                       PrintAndLog("Success! Tested %"PRIu32" states, found %u keys after %.f seconds", total_states_tested, keys_found, elapsed_time);
+                       PrintAndLog("Success! Tested %"PRIu32" states, found %u keys after %u seconds", total_states_tested, keys_found, elapsed_time);
                        PrintAndLog("\nFound key: %012"PRIx64"\n", foundkey);
                        ret = true;
                } else {
-                       PrintAndLog("Fail! Tested %"PRIu32" states, in %.f seconds", total_states_tested, elapsed_time);
+                       PrintAndLog("Fail! Tested %"PRIu32" states, in %u seconds", total_states_tested, elapsed_time);
                }
 
                // reset this counter for the next call
index dde05cb3d7b49be0acd14d07f463908cfa7dafff..d64a15c5adc2312aedbbd97cf2b37dd384735df6 100644 (file)
@@ -1019,10 +1019,17 @@ int CmdLFfind(const char *Cmd) {
        }
        if (cmdp == 'u' || cmdp == 'U') testRaw = 'u';
 
+       // if ( justNoise(GraphBuffer, GraphTraceLen) ) {
+               // PrintAndLog("Signal looks just like noise. Quitting.");
+               // return 0;
+       // }
+       
        PrintAndLog("NOTE: some demods output possible binary\n  if it finds something that looks like a tag");
        PrintAndLog("False Positives ARE possible\n");  
        PrintAndLog("\nChecking for known tags:\n");
 
+
+               
        ans=CmdFSKdemodIO("");
        if (ans>0) {
                PrintAndLog("\nValid IO Prox ID Found!");
index 14b03bcbb67510232b5bbd6c928b153ae9c98b26..95c4cf5f113931db3db30be288e1f94e7ef539ff 100644 (file)
@@ -156,7 +156,7 @@ int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, ui
 }
 
 // 32 bit recover key from 2 nonces
-bool tryMfk32(nonces_t data, uint64_t *outputkey) {
+bool tryMfk32(nonces_t data, uint64_t *outputkey, bool verbose) {
        struct Crypto1State *s,*t;
        uint64_t outkey = 0;
        uint64_t key=0;     // recovered key
@@ -166,22 +166,24 @@ bool tryMfk32(nonces_t data, uint64_t *outputkey) {
        uint32_t ar0_enc = data.ar;  // first encrypted reader response
        uint32_t nr1_enc = data.nr2; // second encrypted reader challenge
        uint32_t ar1_enc = data.ar2; // second encrypted reader response
-       clock_t t1 = clock();
        bool isSuccess = FALSE;
        uint8_t counter = 0;
-
-       printf("Recovering key for:\n");
-       printf("    uid: %08x\n",uid);
-       printf("     nt: %08x\n",nt);
-       printf(" {nr_0}: %08x\n",nr0_enc);
-       printf(" {ar_0}: %08x\n",ar0_enc);
-       printf(" {nr_1}: %08x\n",nr1_enc);
-       printf(" {ar_1}: %08x\n",ar1_enc);
-
-       printf("\nLFSR succesors of the tag challenge:\n");
+       
+       clock_t t1 = clock();
        uint32_t p64 = prng_successor(nt, 64);
-       printf("  nt': %08x\n", p64);
-       printf(" nt'': %08x\n", prng_successor(p64, 32));
+               
+       if ( verbose ) {
+               printf("Recovering key for:\n");
+               printf("    uid: %08x\n",uid);
+               printf("     nt: %08x\n",nt);
+               printf(" {nr_0}: %08x\n",nr0_enc);
+               printf(" {ar_0}: %08x\n",ar0_enc);
+               printf(" {nr_1}: %08x\n",nr1_enc);
+               printf(" {ar_1}: %08x\n",ar1_enc);
+               printf("\nLFSR succesors of the tag challenge:\n");
+               printf("  nt': %08x\n", p64);
+               printf(" nt'': %08x\n", prng_successor(p64, 32));
+       }
        
        s = lfsr_recovery32(ar0_enc ^ p64, 0);
   
@@ -193,7 +195,6 @@ bool tryMfk32(nonces_t data, uint64_t *outputkey) {
                crypto1_word(t, uid ^ nt, 0);
                crypto1_word(t, nr1_enc, 1);
                if (ar1_enc == (crypto1_word(t, 0, 0) ^ p64)) {
-                       //PrintAndLog("Found Key: [%012"llx"]", key);
                        outkey = key;
                        ++counter;
                        if (counter==20) break;
@@ -208,7 +209,7 @@ bool tryMfk32(nonces_t data, uint64_t *outputkey) {
        return isSuccess;
 }
 
-bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey) {
+bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey, bool verbose) {
        struct Crypto1State *s, *t;
        uint64_t outkey  = 0;
        uint64_t key     = 0;                        // recovered key
@@ -222,25 +223,25 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey) {
        uint32_t ar1_enc = data.ar2; // second encrypted reader response        
        bool isSuccess = FALSE;
        int counter = 0;
-       
-       printf("Recovering key for:\n");
-       printf("    uid: %08x\n",uid);
-       printf("   nt_0: %08x\n",nt0);
-       printf(" {nr_0}: %08x\n",nr0_enc);
-       printf(" {ar_0}: %08x\n",ar0_enc);
-       printf("   nt_1: %08x\n",nt1);
-       printf(" {nr_1}: %08x\n",nr1_enc);
-       printf(" {ar_1}: %08x\n",ar1_enc);
 
-       //PrintAndLog("Enter mfkey32_moebius");
        clock_t t1 = clock();
 
-       printf("\nLFSR succesors of the tag challenge:\n");
        uint32_t p640 = prng_successor(nt0, 64);
        uint32_t p641 = prng_successor(nt1, 64);
        
-       printf("  nt': %08x\n", p640);
-       printf(" nt'': %08x\n", prng_successor(p640, 32));
+       if (verbose) {
+               printf("Recovering key for:\n");
+               printf("    uid: %08x\n", uid);
+               printf("   nt_0: %08x\n", nt0);
+               printf(" {nr_0}: %08x\n", nr0_enc);
+               printf(" {ar_0}: %08x\n", ar0_enc);
+               printf("   nt_1: %08x\n", nt1);
+               printf(" {nr_1}: %08x\n", nr1_enc);
+               printf(" {ar_1}: %08x\n", ar1_enc);
+               printf("\nLFSR succesors of the tag challenge:\n");
+               printf("  nt': %08x\n", p640);
+               printf(" nt'': %08x\n", prng_successor(p640, 32));
+       }
        
        s = lfsr_recovery32(ar0_enc ^ p640, 0);
   
@@ -253,7 +254,6 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey) {
                crypto1_word(t, uid ^ nt1, 0);
                crypto1_word(t, nr1_enc, 1);
                if (ar1_enc == (crypto1_word(t, 0, 0) ^ p641)) {
-                       //PrintAndLog("Found Key: [%012"llx"]",key);
                        outkey=key;
                        ++counter;
                        if (counter==20) break;
index e8e2a01b88d9bd1d6ab2311c8163772365b7263b..026b8cfc47cd041617b4d5b303aa95afef9d8bde 100644 (file)
@@ -27,8 +27,8 @@ extern int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info,
 extern int nonce2key_ex(uint8_t blockno, uint8_t keytype, uint32_t uid, uint32_t nt, uint32_t nr, uint64_t ks_info, uint64_t * key);
 
 //iceman, added these to be able to crack key direct from "hf 14 sim" && "hf mf sim"
-bool tryMfk32(nonces_t data, uint64_t *outputkey );
-bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey );  // <<-- this one has best success
+bool tryMfk32(nonces_t data, uint64_t *outputkey, bool verbose );
+bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey, bool verbose);  // <<-- this one has best success
 int tryMfk64_ex(uint8_t *data, uint64_t *outputkey );
 int tryMfk64(uint32_t uid, uint32_t nt, uint32_t nr_enc, uint32_t ar_enc, uint32_t at_enc, uint64_t *outputkey);
 #endif
diff --git a/tools/mfkey/.gitignore b/tools/mfkey/.gitignore
new file mode 100644 (file)
index 0000000..ec7f413
--- /dev/null
@@ -0,0 +1,7 @@
+mfkey32
+mfkey32v2
+mfkey64
+
+mfkey32.exe
+mfkey32v2.exe
+mfkey64.exe
Impressum, Datenschutz