Merge pull request #39 from RfidResearchGroup/master

Update from master
This commit is contained in:
mwalker33 2020-04-16 21:04:52 +10:00 committed by GitHub
commit 29ae24fee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
405 changed files with 884 additions and 764 deletions

View file

@ -20,7 +20,7 @@
#include "legicrf.h" #include "legicrf.h"
#include "legicrfsim.h" #include "legicrfsim.h"
#include "legic.h" // legic_card_select_t struct #include "legic.h" // legic_card_select_t struct
#include "spiffs.h" // flashmem #include "spiffs.h" // flashmem
/* /*
@ -47,7 +47,7 @@
void DownloadLogInstructions() { void DownloadLogInstructions() {
Dbprintf(""); Dbprintf("");
Dbprintf("[=] List all dumps from flash:"); Dbprintf("[=] List all dumps from flash:");
Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree"); Dbprintf("[=] " _YELLOW_("-") "mem spiffs tree");
Dbprintf(""); Dbprintf("");
Dbprintf("[=] To save a dump file from flash to client:"); Dbprintf("[=] To save a dump file from flash to client:");
Dbprintf("[=] " _YELLOW_("-") "mem spiffs dump o hf-legic-UID-dump.bin f hf-legic-UID-dump.bin"); Dbprintf("[=] " _YELLOW_("-") "mem spiffs dump o hf-legic-UID-dump.bin f hf-legic-UID-dump.bin");
@ -60,15 +60,15 @@ void save_dump_to_file(legic_card_select_t *p_card) {
// legic functions puts it memory in Emulator reserved memory. // legic functions puts it memory in Emulator reserved memory.
uint8_t *mem = BigBuf_get_EM_addr(); uint8_t *mem = BigBuf_get_EM_addr();
char *preferredName = (char*)BigBuf_malloc(30); char *preferredName = (char *)BigBuf_malloc(30);
if (preferredName == NULL) { if (preferredName == NULL) {
goto OUT; goto OUT;
} }
sprintf(preferredName, "hf-legic-%02X%02X%02X%02X-dump", p_card->uid[0], p_card->uid[1], p_card->uid[2], p_card->uid[3]); sprintf(preferredName, "hf-legic-%02X%02X%02X%02X-dump", p_card->uid[0], p_card->uid[1], p_card->uid[2], p_card->uid[3]);
uint16_t preferredNameLen = strlen(preferredName); uint16_t preferredNameLen = strlen(preferredName);
char *filename = (char*)BigBuf_malloc(preferredNameLen + 4 + 1 + 10); char *filename = (char *)BigBuf_malloc(preferredNameLen + 4 + 1 + 10);
if (filename == NULL) { if (filename == NULL) {
goto OUT; goto OUT;
} }
@ -106,7 +106,7 @@ void RunMod() {
DbpString("[=] press and HOLD button to exit standalone mode"); DbpString("[=] press and HOLD button to exit standalone mode");
for (;;) { for (;;) {
WDT_HIT(); WDT_HIT();
//exit from hf_legic, send usbcommand //exit from hf_legic, send usbcommand
if (data_available()) break; if (data_available()) break;
@ -136,18 +136,18 @@ void RunMod() {
//simulate if read successfully //simulate if read successfully
if (read_success != PM3_ESOFT) { if (read_success != PM3_ESOFT) {
legic_card_select_t *p_card; legic_card_select_t *p_card;
p_card = getLegicCardInfo(); p_card = getLegicCardInfo();
if (p_card->cardsize == 0) if (p_card->cardsize == 0)
continue; continue;
save_dump_to_file(p_card); save_dump_to_file(p_card);
LED_D_ON(); LED_D_ON();
uint8_t ct; uint8_t ct;
switch(p_card->tagtype) { switch (p_card->tagtype) {
case 0x0D: case 0x0D:
ct = 0; ct = 0;
break; break;
case 0x1D: case 0x1D:
@ -156,7 +156,7 @@ void RunMod() {
case 0x3D: case 0x3D:
ct = 2; ct = 2;
break; break;
default: default:
continue; continue;
} }

View file

@ -83,7 +83,7 @@ void RunMod() {
StandAloneMode(); StandAloneMode();
FpgaDownloadAndGo(FPGA_BITSTREAM_LF); FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
Dbprintf("[=] >> LF EM4100 simulator started <<"); Dbprintf("[=] >> LF EM4100 simulator started <<");
int selected = 0; //selected slot after start int selected = 0; //selected slot after start
slots_count = sizeof(low) / sizeof(low[0]); slots_count = sizeof(low) / sizeof(low[0]);
bba = BigBuf_get_addr(); bba = BigBuf_get_addr();

View file

@ -122,7 +122,7 @@ void RunMod() {
StandAloneMode(); StandAloneMode();
FpgaDownloadAndGo(FPGA_BITSTREAM_LF); FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
Dbprintf("[=] >> LF EM4100 read/write/clone started <<"); Dbprintf("[=] >> LF EM4100 read/write/clone started <<");
int selected = 0; int selected = 0;
//state 0 - select slot //state 0 - select slot
// 1 - read tag to selected slot, // 1 - read tag to selected slot,

View file

@ -524,7 +524,7 @@ int EPA_Setup() {
} }
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
// if we're here, there is no type A card, so we look for type B // if we're here, there is no type A card, so we look for type B
// power up the field // power up the field
iso14443b_setup(); iso14443b_setup();

View file

@ -52,8 +52,8 @@ size_t blocknr;
bool end = false; bool end = false;
//#define SENDBIT_TEST //#define SENDBIT_TEST
/* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3 /* array index 3 2 1 0 // bytes in sim.bin file are 0 1 2 3
// UID is 0 1 2 3 // tag.uid is 3210 // UID is 0 1 2 3 // tag.uid is 3210
// datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0 // datasheet HitagS_V11.pdf bytes in tables printed 3 2 1 0
#db# UID: 5F C2 11 84 #db# UID: 5F C2 11 84
@ -977,7 +977,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
// TC1: Capture mode, default timer source = MCK/2 (TIMER_CLOCK1), TIOA is external trigger, // TC1: Capture mode, default timer source = MCK/2 (TIMER_CLOCK1), TIOA is external trigger,
// external trigger rising edge, load RA on rising edge of TIOA. // external trigger rising edge, load RA on rising edge of TIOA.
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK
| AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING; | AT91C_TC_ETRGEDG_RISING | AT91C_TC_ABETRG | AT91C_TC_LDRA_RISING;
// Enable and reset counter // Enable and reset counter
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG; AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
@ -1051,7 +1051,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
// Enable and reset external trigger in timer for capturing future frames // Enable and reset external trigger in timer for capturing future frames
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG; AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
// Reset the received frame and response timing info // Reset the received frame and response timing info
memset(rx, 0x00, sizeof(rx)); memset(rx, 0x00, sizeof(rx));
response = 0; response = 0;

View file

@ -404,7 +404,7 @@ bool write_byte(uint16_t index, uint8_t byte, uint8_t addr_sz) {
// //
// Only this functions are public / called from appmain.c // Only this functions are public / called from appmain.c
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
legic_card_select_t* getLegicCardInfo(void) { legic_card_select_t *getLegicCardInfo(void) {
return &card; return &card;
} }
@ -471,7 +471,7 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv) {
goto OUT; goto OUT;
} }
legic_mem[i] = byte; legic_mem[i] = byte;
if (i < 4) { if (i < 4) {
card.uid[i] = byte; card.uid[i] = byte;
} }
@ -506,7 +506,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
goto OUT; goto OUT;
} }
legic_mem[i] = byte; legic_mem[i] = byte;
if (i < 4) { if (i < 4) {
card.uid[i] = byte; card.uid[i] = byte;
} }

View file

@ -21,5 +21,5 @@ int LegicRfReaderEx(uint16_t offset, uint16_t len, uint8_t iv);
void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv); void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv);
void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data); void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data);
legic_card_select_t* getLegicCardInfo(void); legic_card_select_t *getLegicCardInfo(void);
#endif /* __LEGICRF_H */ #endif /* __LEGICRF_H */

View file

@ -2405,7 +2405,7 @@ void SendForward(uint8_t fwd_bit_count) {
WaitUS(32 * 8); WaitUS(32 * 8);
} else { } else {
TurnReadLF_off(23 * 8); TurnReadLF_off(23 * 8);
TurnReadLFOn((32-23) * 8); TurnReadLFOn((32 - 23) * 8);
} }
} }
} }

View file

@ -334,16 +334,16 @@ void MifareDES_Auth1(uint8_t *datain) {
return; return;
} }
int rndlen=8; int rndlen = 8;
int expectedlen = 1 + 8 + 2 + 2; int expectedlen = 1 + 8 + 2 + 2;
if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) { if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3K3DES) {
expectedlen = 1 + 16 + 2 + 2; expectedlen = 1 + 16 + 2 + 2;
rndlen=16; rndlen = 16;
} }
if (payload->mode == MFDES_AUTH_PICC) { if (payload->mode == MFDES_AUTH_PICC) {
expectedlen = 1 + 1 + 8 + 2; expectedlen = 1 + 1 + 8 + 2;
rndlen=8; rndlen = 8;
} }
if (len != expectedlen) { if (len != expectedlen) {

View file

@ -15,7 +15,7 @@
// PRIx64 definition missing with gcc-arm-none-eabi v8? // PRIx64 definition missing with gcc-arm-none-eabi v8?
#ifndef PRIx64 #ifndef PRIx64
#define PRIx64 "llx" #define PRIx64 "llx"
#endif #endif
// Basic macros // Basic macros

View file

@ -17,7 +17,7 @@ include ../Makefile.defs
INSTALLBIN = proxmark3 INSTALLBIN = proxmark3
INSTALLSHARE = cmdscripts lualibs luascripts resources dictionaries INSTALLSHARE = cmdscripts lualibs luascripts resources dictionaries
VPATH = ../common uart VPATH = ../common src/uart src deps
vpath %.dic dictionaries vpath %.dic dictionaries
OBJDIR = obj OBJDIR = obj
@ -32,15 +32,15 @@ ifneq ($(platform),Darwin)
endif endif
# local libraries # local libraries
LUALIBPATH = ./liblua LUALIBPATH = ./deps/liblua
LUALIB = $(LUALIBPATH)/liblua.a LUALIB = $(LUALIBPATH)/liblua.a
JANSSONLIBPATH = ./jansson JANSSONLIBPATH = ./deps/jansson
JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
CBORLIBPATH = ./tinycbor CBORLIBPATH = ./deps/tinycbor
CBORLIB = $(CBORLIBPATH)/tinycbor.a CBORLIB = $(CBORLIBPATH)/tinycbor.a
REVENGPATH = ./reveng REVENGPATH = ./deps/reveng
REVENGLIB = $(REVENGPATH)/libreveng.a REVENGLIB = $(REVENGPATH)/libreveng.a
AMIIBOLIBPATH = ./amiitool AMIIBOLIBPATH = ./deps/amiitool
AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
# common libraries # common libraries
@ -50,7 +50,7 @@ ZLIBPATH = ../common/zlib
ZLIB = $(OBJDIR)/libz.a ZLIB = $(OBJDIR)/libz.a
LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH) LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH)
INCLUDES_CLIENT = -I. -I../include -I../common -Iuart $(LIBS) INCLUDES_CLIENT = -I./src -I./deps -I../include -I../common -I./deps/cliparser -I./src/uart $(LIBS)
CFLAGS ?= -Wall -Werror -g -O3 CFLAGS ?= -Wall -Werror -g -O3
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env: # We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
PM3CFLAGS = $(CFLAGS) -std=c99 -D_ISOC99_SOURCE $(INCLUDES_CLIENT) PM3CFLAGS = $(CFLAGS) -std=c99 -D_ISOC99_SOURCE $(INCLUDES_CLIENT)
@ -59,7 +59,7 @@ ifneq (,$(findstring MINGW,$(platform)))
PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850 PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
endif endif
CXXFLAGS ?= -Wall -Werror -O3 CXXFLAGS ?= -Wall -Werror -O3
PM3CXXFLAGS = $(CXXFLAGS) -I../include PM3CXXFLAGS = $(CXXFLAGS) -I../include -I/.deps/cliparser
LUAPLATFORM = generic LUAPLATFORM = generic
ifneq (,$(findstring MINGW,$(platform))) ifneq (,$(findstring MINGW,$(platform)))
@ -130,6 +130,7 @@ CORESRCS = uart_posix.c \
util_posix.c \ util_posix.c \
scandir.c \ scandir.c \
crc16.c \ crc16.c \
crc32.c \
comms.c comms.c
CMDSRCS = crapto1/crapto1.c \ CMDSRCS = crapto1/crapto1.c \
@ -200,7 +201,7 @@ CMDSRCS = crapto1/crapto1.c \
cmdhfmfu.c \ cmdhfmfu.c \
cmdhfmfp.c \ cmdhfmfp.c \
cmdhfmfhard.c \ cmdhfmfhard.c \
hardnested/hardnested_bruteforce.c \ deps/hardnested/hardnested_bruteforce.c \
cmdhfmfdes.c \ cmdhfmfdes.c \
cmdhftopaz.c \ cmdhftopaz.c \
cmdhffido.c \ cmdhffido.c \
@ -258,13 +259,13 @@ CMDSRCS = crapto1/crapto1.c \
cpu_arch = $(shell uname -m) cpu_arch = $(shell uname -m)
ifneq ($(findstring 86, $(cpu_arch)), ) ifneq ($(findstring 86, $(cpu_arch)), )
MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c MULTIARCHSRCS = deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c
endif endif
ifneq ($(findstring amd64, $(cpu_arch)), ) ifneq ($(findstring amd64, $(cpu_arch)), )
MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c MULTIARCHSRCS = deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c
endif endif
ifeq ($(MULTIARCHSRCS), ) ifeq ($(MULTIARCHSRCS), )
CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c CMDSRCS += deps/hardnested/hardnested_bf_core.c deps/hardnested/hardnested_bitarray_core.c
endif endif
@ -310,13 +311,13 @@ proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS)
$(info [=] LD $@) $(info [=] LD $@)
$(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@ $(Q)$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@
proxgui.cpp: ui/ui_overlays.h src/proxgui.cpp: src/ui/ui_overlays.h
proxguiqt.moc.cpp: proxguiqt.h src/proxguiqt.moc.cpp: src/proxguiqt.h
$(info [-] MOC $@) $(info [-] MOC $@)
$(Q)$(MOC) -o$@ $^ $(Q)$(MOC) -o$@ $^
ui/ui_overlays.h: ui/overlays.ui src/ui/ui_overlays.h: src/ui/overlays.ui
$(info [-] UIC $@) $(info [-] UIC $@)
$(Q)$(UIC) $^ > $@ $(Q)$(UIC) $^ > $@

View file

@ -1,5 +1,5 @@
MYSRCPATHS = MYSRCPATHS =
MYINCLUDES = -I. -I.. -I../jansson -I../../common/ -I../../include/ MYINCLUDES = -I. -I.. -I../jansson -I../../../common -I../../../include
MYCFLAGS = -std=c99 -D_ISOC99_SOURCE MYCFLAGS = -std=c99 -D_ISOC99_SOURCE
MYDEFS = MYDEFS =
MYSRCS = \ MYSRCS = \
@ -9,11 +9,11 @@ MYSRCS = \
LIB_A = libamiibo.a LIB_A = libamiibo.a
include ../../Makefile.host include ../../../Makefile.host
# just for testing amiitool before complete migration into a lib: # just for testing amiitool before complete migration into a lib:
amiitool: amiitool:
gcc $(CFLAGS) \ gcc $(CFLAGS) \
amiitool.c $(MYSRCS) ../../common/commonutil.c ../ui.c -lreadline -lm ../../common/mbedtls/libmbedtls.a \ amiitool.c $(MYSRCS) ../../../common/commonutil.c ../ui.c -lreadline -lm ../../../common/mbedtls/libmbedtls.a \
-o amiitool -o amiitool

View file

@ -7,7 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "fileutils.h" #include "src/fileutils.h"
#include "amiibo.h" #include "amiibo.h"
#include "getopt.h" #include "getopt.h"

View file

@ -165,7 +165,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
if (ibuf == 0) { if (ibuf == 0) {
return res; return res;
} }
switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) { switch (param_gethex_to_eol((char *)tmp_buf, 0, data, maxdatalen, datalen)) {
case 1: case 1:
printf("Parameter error: Invalid HEX value.\n"); printf("Parameter error: Invalid HEX value.\n");

View file

@ -59,8 +59,8 @@ THE SOFTWARE.
#include <string.h> #include <string.h>
#include "crapto1/crapto1.h" #include "crapto1/crapto1.h"
#include "parity.h" #include "parity.h"
#include "util.h" //#include "util.h"
#include "common.h" //#include "common.h"
// bitslice type // bitslice type
// while AVX supports 256 bit vector floating point operations, we need integer operations for boolean logic // while AVX supports 256 bit vector floating point operations, we need integer operations for boolean logic

View file

@ -19,7 +19,33 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "cmdhfmfhard.h"
#define NUM_SUMS 19 // number of possible sum property values
typedef struct guess_sum_a8 {
float prob;
uint64_t num_states;
uint8_t sum_a8_idx;
} guess_sum_a8_t;
typedef struct noncelistentry {
uint32_t nonce_enc;
uint8_t par_enc;
void *next;
} noncelistentry_t;
typedef struct noncelist {
uint16_t num;
uint16_t Sum;
guess_sum_a8_t sum_a8_guess[NUM_SUMS];
bool sum_a8_guess_dirty;
float expected_num_brute_force;
uint8_t BitFlips[0x400];
uint32_t *states_bitarray[2];
uint32_t num_states_bitarray[2];
bool all_bitflips_dirty[2];
noncelistentry_t *first;
} noncelist_t;
typedef struct { typedef struct {
uint32_t *states[2]; uint32_t *states[2];

View file

@ -18,4 +18,4 @@ MYSRCS = \
LIB_A = libjansson.a LIB_A = libjansson.a
include ../../Makefile.host include ../../../Makefile.host

View file

@ -16,7 +16,7 @@
#include <stdint.h> #include <stdint.h>
#endif #endif
#include <jansson_config.h> /* for JSON_INLINE */ #include "jansson_config.h" /* for JSON_INLINE */
#include "jansson_private.h" /* for container_of() */ #include "jansson_private.h" /* for container_of() */
#include "hashtable.h" #include "hashtable.h"

View file

@ -10,7 +10,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <jansson.h> #include "jansson.h"
#include "jansson_private.h" #include "jansson_private.h"
json_t *json_path_get(const json_t *json, const char *path) { json_t *json_path_get(const json_t *json, const char *path) {

View file

@ -21,7 +21,7 @@ PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
default: $(PLAT) default: $(PLAT)
include ../../Makefile.host include ../../../Makefile.host
# Convenience targets for popular platforms # Convenience targets for popular platforms
ALL= all ALL= all

Some files were not shown because too many files have changed in this diff Show more