]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: the time_t calls under mingw needs a #define _USE_32BIT_TIME_T 1 to be correct...
authoriceman1001 <iceman@iuse.se>
Sat, 29 Oct 2016 19:42:46 +0000 (21:42 +0200)
committericeman1001 <iceman@iuse.se>
Sat, 29 Oct 2016 19:42:46 +0000 (21:42 +0200)
client/cmdanalyse.c
client/cmdanalyse.h
client/cmdhfmfhard.c
client/cmdhfmfhard.h
client/mifarehost.h
client/proxmark3.h
client/uart.h
client/ui.h
client/util.h

index e7a638eed8bd724a31422f21957c779db60039d9..fb084f433083545b428ff348ae687c91880a685f 100644 (file)
@@ -8,6 +8,7 @@
 // Analyse bytes commands
 //-----------------------------------------------------------------------------
 #include "cmdanalyse.h"
+#include "nonce2key/nonce2key.h"
 
 static int CmdHelp(const char *Cmd);
 
@@ -124,6 +125,29 @@ static uint8_t calcSumNibbleSubOnes( uint8_t* bytes, uint8_t len, uint32_t mask)
        return ~calcSumNibbleSub(bytes, len, mask);
 }
 
+// measuring LFSR maximum length
+int CmdAnalyseLfsr(const char *Cmd){
+
+    uint16_t start_state = 0;  /* Any nonzero start state will work. */
+    uint16_t lfsr = start_state;
+    //uint32_t period = 0;
+
+       uint8_t iv = param_get8ex(Cmd, 0, 0, 16);
+       uint8_t find = param_get8ex(Cmd, 1, 0, 16);
+       
+       printf("LEGIC LFSR IV 0x%02X: \n", iv);
+       printf(" bit# | lfsr | ^0x40 |  0x%02X ^ lfsr \n",find);
+       
+       for (uint8_t i = 0x01; i < 0x30; i += 1) {
+               //period = 0;
+               legic_prng_init(iv);
+               legic_prng_forward(i);
+               lfsr = legic_prng_get_bits(12);
+
+               printf(" %02X | %03X | %03X | %03X \n",i, lfsr, 0x40 ^ lfsr, find ^ lfsr);
+       }
+       return 0;
+}
 int CmdAnalyseLCR(const char *Cmd) {
        uint8_t data[50];
        char cmdp = param_getchar(Cmd, 0);
@@ -284,6 +308,25 @@ int CmdAnalyseTEASelfTest(const char *Cmd){
        return 0;
 }
 
+int CmdAnalyseA(const char *Cmd){
+       
+// uid(2e086b1a) nt(230736f6) par(0000000000000000) ks(0b0008000804000e) nr(000000000)
+// uid(2e086b1a) nt(230736f6) par(0000000000000000) ks(0e0b0e0b090c0d02) nr(000000001)
+// uid(2e086b1a) nt(230736f6) par(0000000000000000) ks(0e05060e01080b08) nr(000000002)
+       uint32_t uid = 0x2e086b1a, nt = 0x230736f6, nr = 0x000000001;
+       uint64_t ks_list = 0x0e0b0e0b090c0d02, r_key = 0;
+
+       nonce2key_ex(0, 0 , uid, nt, nr, ks_list, &r_key);
+
+       nr = 0x000000002;
+       ks_list = 0x0e05060e01080b08;
+       nonce2key_ex(0, 0 , uid, nt, nr, ks_list, &r_key);
+
+       printf("Found valid key: %012"llx" \n", r_key); 
+       return 0;
+}
+
+
 static command_t CommandTable[] = {
        {"help",        CmdHelp,            1, "This help"},
        {"lcr",         CmdAnalyseLCR,          1, "Generate final byte for XOR LRC"},
@@ -291,6 +334,8 @@ static command_t CommandTable[] = {
        {"chksum",      CmdAnalyseCHKSUM,       1, "Checksum with adding, masking and one's complement"},
        {"dates",       CmdAnalyseDates,        1, "Look for datestamps in a given array of bytes"},
        {"tea",         CmdAnalyseTEASelfTest,  1, "Crypto TEA test"},
+       {"lfsr",        CmdAnalyseLfsr,         1,      "LFSR tests"},
+       {"a",           CmdAnalyseA,            1,      "num bits test"},
        {NULL, NULL, 0, NULL}
 };
 
index ec05cee22d15010d1fef5731fb942acb1821aa08..4103a2b982ba7df567329ed7eacb95a2e4a88dc0 100644 (file)
@@ -1,5 +1,5 @@
 //-----------------------------------------------------------------------------
-// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+// Copyright (C) 2016 iceman <iceman at ...>
 //
 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
 // at your option, any later version. See the LICENSE.txt file for the text of
@@ -20,6 +20,7 @@
 #include "crc.h"
 #include "../common/iso15693tools.h"
 #include "tea.h"
+#include "../include/legic_prng.h"
 
 int usage_analyse_lcr(void);
 int usage_analyse_checksum(void);
@@ -31,4 +32,5 @@ int CmdAnalyseCHKSUM(const char *Cmd);
 int CmdAnalyseDates(const char *Cmd);
 int CmdAnalyseCRC(const char *Cmd);
 int CmdAnalyseTEASelfTest(const char *Cmd);
+int CmdAnalyseLfsr(const char *Cmd);
 #endif
index fb576441bc5271b8ffa093915a684fcab7ac7e37..a6b8bc51e9dc6194b1688dc488664b537bb9b268 100644 (file)
@@ -1275,7 +1275,7 @@ static bool TestIfKeyExists(uint64_t key)
                }
                count += (p_odd - p->states[ODD_STATE]) * (p_even - p->states[EVEN_STATE]);
                if (found_odd && found_even) {
-                       PrintAndLog("Key Found after testing %lld (2^%1.1f) out of %lld (2^%1.1f) keys. ", 
+                       PrintAndLog("\nKey Found after testing %lld (2^%1.1f) out of %lld (2^%1.1f) keys. ", 
                                count,
                                log(count)/log(2), 
                                maximum_states,
@@ -1698,8 +1698,10 @@ static bool brute_force(void)
                if (maximum_states == 0) return false; // prevent keyspace reduction error (2^-inf)
 
                PrintAndLog("Brute force phase starting.");
-               time_t start, end;
-               time(&start);
+
+//             clock_t time1 = clock();                
+               time_t start1, end1;
+               time(&start1);
                keys_found = 0;
                foundkey = 0;
 
@@ -1746,11 +1748,16 @@ static bool brute_force(void)
                        pthread_join(threads[i], 0);
                }
 
-               time(&end);
-               unsigned long  elapsed_time = difftime(end, start);
+               time(&end1);
+               unsigned long elapsed_time = difftime(end1, start1);
+               // time1 = clock() - time1;
+               // if ( time1 > 0 ) {
+                       // ((float)time1)/CLOCKS_PER_SEC
+               // }
 
                if (keys_found && TestIfKeyExists(foundkey)) {
-                       PrintAndLog("Success! Tested %"PRIu32" states, found %u keys after %u seconds", total_states_tested, keys_found, elapsed_time);
+                       printf("ICE: %u | %u | %u \n", start1, end1, elapsed_time);
+                       PrintAndLog("Success! Found %u keys after %u seconds", keys_found, elapsed_time);
                        PrintAndLog("\nFound key: %012"PRIx64"\n", foundkey);
                        ret = true;
                } else {
@@ -1850,6 +1857,4 @@ int mfnestedhard(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBloc
                candidates = NULL;
        }
        return 0;
-}
-
-
+}
\ No newline at end of file
index 72cc850ad1ad8470d95f3a369591cf6a1638db2e..a12875aca5a4d0c1aac5b2248caa3d0c55f880cd 100644 (file)
 #ifndef CMDHFMFHARD_H__
 #define CMDHFMFHARD_H__
 
-#include "sleep.h"
 #include <stdlib.h> 
 #include <stdio.h>
 #include <string.h>
 #include <pthread.h>
 #include <locale.h>
 #include <math.h>
-#include "proxmark3.h"
+#include "proxmark3.h"         // time_t , PRIu32
+#include "sleep.h"
 #include "cmdmain.h"
 #include "ui.h"
 #include "util.h"
 #include "nonce2key/crapto1.h"
 #include "nonce2key/crypto1_bs.h"
 #include "parity.h"
-#ifdef __WIN32
-       #include <windows.h>
-#endif
 // don't include for APPLE/mac which has malloc stuff elsewhere.
 #ifndef __APPLE__
        #include <malloc.h>
index 1593c390bc641aaa1c94d096c03d55597cfc82ed..754cc4839eb5e4a367c7ef85c1309149d245ecc9 100644 (file)
@@ -13,9 +13,9 @@
 #include <unistd.h>\r
 #include <string.h>\r
 #include <pthread.h>\r
-#include "proxmark3.h"\r
+\r
+#include "proxmark3.h" // time_t\r
 //#include "radixsort.h"\r
-#include <time.h>\r
 #include "common.h"\r
 #include "cmdmain.h"\r
 #include "ui.h"\r
index 89cac87818253e6122fc9fa3f0071dff161abe8f..87cf3e74b65aa749562097673ec2e541637c2a05 100644 (file)
 #ifndef PROXMARK3_H__
 #define PROXMARK3_H__
 
+// Handle platform specific includes
 #ifdef __WIN32
 // for MINGW32 environments
-   #define _USE_32BIT_TIME_T 1
-#endif   
+  #define _USE_32BIT_TIME_T 1
+  #include <time.h>
+  #include <windows.h>
+#else
+  #include <sys/time.h>
+#endif
+
 #define __STDC_FORMAT_MACROS 1
 #include <inttypes.h>
+#include "usb_cmd.h"
+
+#define lu PRIu32
 #define lx  PRIx32
 #define llx PRIx64
 #define lli PRIi64
 #define llu PRIu64
 #define hhu PRIu8
-
-#include "usb_cmd.h"
-
 #define PROXPROMPT "pm3 --> "
 
 void SendCommand(UsbCommand *c);
index d520e7f4bb031644d2dae1393d75b730bb957d7c..33248fb2d638fba2b8cd02acd2d8d00a77073113 100644 (file)
@@ -54,6 +54,7 @@ typedef unsigned char byte_t;
   #include <sys/time.h>
   #include <errno.h>
 #else
+  #include <time.h>
   #include <windows.h>
 #endif
 
index 8d6c21b5b8a30935e81efad4b111af2b4ede40dd..6891a82150a552419b5638179af38f448f7772b3 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
-#include <time.h>
 #include <readline/readline.h>
 #include <pthread.h>
 #include <math.h>
 #include <complex.h>
+
+// Handle platform specific includes
+#ifndef _WIN32
+  #include <sys/time.h>
+#else
+  #include <time.h>
+  #include <windows.h>
+#endif
+
 #include "loclass/cipherutils.h"
 #include "util.h"
 #include "cmdmain.h"
index f81d7d88ce9232cef96ae08c22226b3ba1ae46d7..7a2fd46fce495375939a4ebb64c7dd584214438e 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <time.h>
 #include <math.h>              // math.pow
+#include "proxmark3.h" // time_t
 #include "data.h"              // for FILE_PATH_SIZE
-#include "proxmark3.h"
 
 #ifndef BITMASK
 # define BITMASK(X) (1 << (X))
Impressum, Datenschutz