mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 23:36:31 +08:00
FIX: the time_t calls under mingw needs a #define _USE_32BIT_TIME_T 1 to be correct. It seems to work in "hf mf mifare" but not in "hf mf hardnested"
This commit is contained in:
parent
19693bdc06
commit
b403c30091
|
@ -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}
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,23 +11,20 @@
|
|||
#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>
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include "proxmark3.h"
|
||||
|
||||
#include "proxmark3.h" // time_t
|
||||
//#include "radixsort.h"
|
||||
#include <time.h>
|
||||
#include "common.h"
|
||||
#include "cmdmain.h"
|
||||
#include "ui.h"
|
||||
|
|
|
@ -12,20 +12,26 @@
|
|||
#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);
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef unsigned char byte_t;
|
|||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
|
10
client/ui.h
10
client/ui.h
|
@ -16,11 +16,19 @@
|
|||
#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"
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
#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))
|
||||
|
|
Loading…
Reference in a new issue