From 8fb0999e0512fdf9cbe3317f05041d927c759c05 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:03:36 +0100 Subject: [PATCH 01/11] fix: 'data detect p' - removed bad clock detection, failed to set all other parameters. --- common/lfdemod.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/common/lfdemod.c b/common/lfdemod.c index aed21fbf7..1e8c3db35 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -262,7 +262,8 @@ bool preambleSearch(uint8_t *bits, uint8_t *preamble, size_t pLen, size_t *size, //(iceman) FINDONE, only finds start index. NOT SIZE!. I see Em410xDecode (lfdemod.c) uses SIZE to determine success bool preambleSearchEx(uint8_t *bits, uint8_t *preamble, size_t pLen, size_t *size, size_t *startIdx, bool findone) { // Sanity check. If preamble length is bigger than bits length. - if (*size <= pLen) return false; + if (*size <= pLen) + return false; uint8_t foundCnt = 0; for (size_t idx = 0; idx < *size - pLen; idx++) { @@ -967,11 +968,6 @@ int DetectPSKClock(uint8_t *dest, size_t size, int clock, size_t *firstPhaseShif uint8_t clk[] = {255, 16, 32, 40, 50, 64, 100, 128, 255}; //255 is not a valid clock uint16_t loopCnt = 4096; //don't need to loop through entire array... - //if we already have a valid clock quit - size_t i = 1; - for (; i < 8; ++i) - if (clk[i] == clock) return clock; - if (size < 160 + 20) return 0; // size must be larger than 20 here, and 160 later on. if (size < loopCnt) loopCnt = size - 20; @@ -995,7 +991,7 @@ int DetectPSKClock(uint8_t *dest, size_t size, int clock, size_t *firstPhaseShif uint16_t peaksdet[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; //find start of modulating data in trace - i = findModStart(dest, size, *fc); + size_t i = findModStart(dest, size, *fc); firstFullWave = pskFindFirstPhaseShift(dest, size, curPhase, i, *fc, &fullWaveLen); if (firstFullWave == 0) { From 800bce865da68a565f98296005fb120717832f53 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:39:09 +0100 Subject: [PATCH 02/11] fix: sprint_bin_break doesn't skip bits when newline printing --- client/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/util.c b/client/util.c index a3f275a0b..386e56e1e 100644 --- a/client/util.c +++ b/client/util.c @@ -256,12 +256,12 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea sprintf(tmp++, "."); else sprintf(tmp++, "%u", data[in_index]); + // check if a line break is needed and we have room to print it in our array if ((breaks > 0) && !((in_index + 1) % breaks) && (out_index + 1 != rowlen)) { - // increment and print line break - out_index++; sprintf(tmp++, "%s", "\n"); } + in_index++; } From 6bc3ab1e44f27cbf8b996bd15670d918bda86c3e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:39:49 +0100 Subject: [PATCH 03/11] chg: some pwd from forum --- client/default_pwd.dic | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/default_pwd.dic b/client/default_pwd.dic index 87423478b..42c06460f 100644 --- a/client/default_pwd.dic +++ b/client/default_pwd.dic @@ -18,6 +18,8 @@ A5B4C3D2, 1C0B5848, # paxton bullit? 575F4F4B, +# +50520901, # Default pwd, simple: 00000000, 11111111, From a820d59368dae37b6a21e7f0ca93ff7126749cd0 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:40:29 +0100 Subject: [PATCH 04/11] chg: one more step to unified debug printing clientside --- common/lfdemod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lfdemod.c b/common/lfdemod.c index 1e8c3db35..7e1e60f8f 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -57,7 +57,7 @@ extern void Dbprintf(const char *fmt, ...); #include "ui.h" # include "cmdparser.h" # include "cmddata.h" -# define prnt PrintAndLog +# define prnt(args...) PrintAndLogEx(DEBUG, ## args ); #else uint8_t g_debugMode = 0; # define prnt Dbprintf From 68fc65a8c5022a1227df140aa7167d4a876a1916 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:41:28 +0100 Subject: [PATCH 05/11] chg: 32bits binary strings used as default --- client/cmddata.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/client/cmddata.c b/client/cmddata.c index 72cab3755..505bc605e 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -375,7 +375,7 @@ void printDemodBuff(void) { } if (len > 512) len = 512; - PrintAndLogEx(NORMAL, "%s", sprint_bin_break(DemodBuffer, len, 16)); + PrintAndLogEx(NORMAL, "%s", sprint_bin_break(DemodBuffer, len, 32)); } int CmdPrintDemodBuff(const char *Cmd) { @@ -426,7 +426,7 @@ int CmdPrintDemodBuff(const char *Cmd) { } PrintAndLogEx(NORMAL, "DemodBuffer: %s", hex); } else { - PrintAndLogEx(NORMAL, "DemodBuffer:\n%s", sprint_bin_break(DemodBuffer + offset, length, 16)); + PrintAndLogEx(NORMAL, "DemodBuffer:\n%s", sprint_bin_break(DemodBuffer + offset, length, 32)); } return 1; } @@ -599,7 +599,7 @@ int Cmdmandecoderaw(const char *Cmd) { } PrintAndLogEx(NORMAL, "Manchester Decoded - # errors:%d - data:", errCnt); - PrintAndLogEx(NORMAL, "%s", sprint_bin_break(bits, size, 16)); + PrintAndLogEx(NORMAL, "%s", sprint_bin_break(bits, size, 32)); if (errCnt == 0) { uint64_t id = 0; @@ -650,7 +650,7 @@ int CmdBiphaseDecodeRaw(const char *Cmd) { PrintAndLogEx(WARNING, "# Errors found during Demod (shown as " _YELLOW_("7")" in bit stream): %d", errCnt); PrintAndLogEx(NORMAL, "Biphase Decoded using offset: %d - # invert:%d - data:", offset, invert); - PrintAndLogEx(NORMAL, "%s", sprint_bin_break(bits, size, 16)); + PrintAndLogEx(NORMAL, "%s", sprint_bin_break(bits, size, 32)); //remove first bit from raw demod if (offset) @@ -1094,7 +1094,9 @@ int CmdFSKrawdemod(const char *Cmd) { //attempt to psk1 demod graph buffer int PSKDemod(const char *Cmd, bool verbose) { int invert = 0, clk = 0, maxErr = 100; + sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); + if (clk == 1) { invert = 1; clk = 0; @@ -1107,28 +1109,29 @@ int PSKDemod(const char *Cmd, bool verbose) { if (getSignalProperties()->isnoise) return 0; - uint8_t BitStream[MAX_GRAPH_TRACE_LEN] = {0}; - size_t BitLen = getFromGraphBuf(BitStream); - if (BitLen == 0) return 0; - int errCnt = 0; + uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0}; + size_t bitlen = getFromGraphBuf(bits); + if (bitlen == 0) + return 0; + int startIdx = 0; - errCnt = pskRawDemod_ext(BitStream, &BitLen, &clk, &invert, &startIdx); + int errCnt = pskRawDemod_ext(bits, &bitlen, &clk, &invert, &startIdx); if (errCnt > maxErr) { - if (g_debugMode || verbose) PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, BitLen, errCnt); + if (g_debugMode || verbose) PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, bitlen, errCnt); return 0; } - if (errCnt < 0 || BitLen < 16) { //throw away static - allow 1 and -1 (in case of threshold command first) - if (g_debugMode || verbose) PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, BitLen, errCnt); + if (errCnt < 0 || bitlen < 16) { //throw away static - allow 1 and -1 (in case of threshold command first) + if (g_debugMode || verbose) PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, bitlen, errCnt); return 0; } if (verbose || g_debugMode) { - PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) Using Clock:%d, invert:%d, Bits Found:%d", clk, invert, BitLen); + PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) Using Clock:%d, invert:%d, Bits Found:%d", clk, invert, bitlen); if (errCnt > 0) { PrintAndLogEx(DEBUG, "DEBUG: (PSKdemod) errors during Demoding (shown as 7 in bit stream): %d", errCnt); } } //prime demod buffer for output - setDemodBuf(BitStream, BitLen, 0); + setDemodBuf(bits, bitlen, 0); setClockGrid(clk, startIdx); return 1; } From 0409fd1f4e6b6acbb14f8a9d582ecacfa1cde9d2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:51:54 +0100 Subject: [PATCH 06/11] style --- include/legic_prng.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/legic_prng.h b/include/legic_prng.h index 85d40e794..1f3042779 100644 --- a/include/legic_prng.h +++ b/include/legic_prng.h @@ -10,7 +10,7 @@ #define __LEGIC_PRNG_H #include -extern void legic_prng_init(uint8_t init); +extern void legic_prng_init(uint8_t iv); extern void legic_prng_forward(int count); extern uint32_t legic_prng_count(); extern uint8_t legic_prng_get_bit(); From 43902c7c46b83b3dbf5420dc2a516495c6f4170e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:52:57 +0100 Subject: [PATCH 07/11] style --- common/wiegand.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/wiegand.h b/common/wiegand.h index d856e3993..1db50607c 100644 --- a/common/wiegand.h +++ b/common/wiegand.h @@ -12,8 +12,8 @@ #include "common.h" #include "util.h" -uint8_t getParity(uint8_t *bits, uint8_t length, uint8_t type); -uint8_t checkParity(uint32_t bits, uint8_t bitlen, uint8_t type); +uint8_t getParity(uint8_t *bits, uint8_t len, uint8_t type); +uint8_t checkParity(uint32_t bits, uint8_t len, uint8_t type); void num_to_wiegand_bytes(uint64_t oem, uint64_t fc, uint64_t cn, uint8_t *dest, uint8_t formatlen); void num_to_wiegand_bits(uint64_t oem, uint64_t fc, uint64_t cn, uint8_t *dest, uint8_t formatlen); From bc5c07e5501ba82639b4b49bfecb4550137a37bc Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:57:10 +0100 Subject: [PATCH 08/11] style --- common/lfdemod.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lfdemod.h b/common/lfdemod.h index 96a91363f..6256aa0bc 100644 --- a/common/lfdemod.h +++ b/common/lfdemod.h @@ -38,7 +38,7 @@ typedef struct { } signal_t; signal_t *getSignalProperties(void); -void computeSignalProperties(uint8_t *bits, uint32_t size); +void computeSignalProperties(uint8_t *samples, uint32_t size); void removeSignalOffset(uint8_t *samples, uint32_t size); void getNextLow(uint8_t *samples, size_t size, int low, size_t *i); void getNextHigh(uint8_t *samples, size_t size, int high, size_t *i); @@ -61,7 +61,7 @@ extern int DetectNRZClock(uint8_t *dest, size_t size, int clock, size_t *cl extern int DetectPSKClock(uint8_t *dest, size_t size, int clock, size_t *firstPhaseShift, uint8_t *curPhase, uint8_t *fc); extern int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clock); extern bool DetectST(uint8_t *buffer, size_t *size, int *foundclock, size_t *ststart, size_t *stend); -extern size_t fskdemod(uint8_t *dest, size_t size, uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, int *startIdx); +extern size_t fskdemod(uint8_t *dest, size_t size, uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, int *start_idx); //extern void getHiLo(uint8_t *bits, size_t size, int *high, int *low, uint8_t fuzzHi, uint8_t fuzzLo); extern void getHiLo(int *high, int *low, uint8_t fuzzHi, uint8_t fuzzLo); extern uint32_t manchesterEncode2Bytes(uint16_t datain); From 962e58b47578c6631ab21b237686b702e93ec004 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 14:59:01 +0100 Subject: [PATCH 09/11] style --- common/wiegand.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/wiegand.c b/common/wiegand.c index 58d80cca4..3e90c61b6 100644 --- a/common/wiegand.c +++ b/common/wiegand.c @@ -36,22 +36,22 @@ uint8_t checkParity(uint32_t bits, uint8_t len, uint8_t type); // by marshmellow // takes a array of binary values, start position, length of bits per parity (includes parity bit), // Parity Type (1 for odd; 0 for even; 2 for Always 1's; 3 for Always 0's), and binary Length (length to run) -size_t removeParity(uint8_t *bitstream, size_t startIdx, uint8_t pLen, uint8_t pType, size_t bLen) { +size_t removeParity(uint8_t *bits, size_t startIdx, uint8_t pLen, uint8_t pType, size_t bLen) { uint32_t parityWd = 0; size_t j = 0, bitcount = 0; for (int word = 0; word < (bLen); word += pLen) { for (int bit = 0; bit < pLen; ++bit) { - parityWd = (parityWd << 1) | bitstream[startIdx + word + bit]; - bitstream[j++] = (bitstream[startIdx + word + bit]); + parityWd = (parityWd << 1) | bits[startIdx + word + bit]; + bits[j++] = (bits[startIdx + word + bit]); } j--; // overwrite parity with next data // if parity fails then return 0 switch (pType) { case 3: - if (bitstream[j] == 1) return 0; + if (bits[j] == 1) return 0; break; //should be 0 spacer bit case 2: - if (bitstream[j] == 0) return 0; + if (bits[j] == 0) return 0; break; //should be 1 spacer bit default: //test parity if (parityTest(parityWd, pLen, pType) == 0) return 0; From 8ce361202c651819a04f8eefcb90df635f7ae874 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 15:03:22 +0100 Subject: [PATCH 10/11] style - unused --- common/legic_prng.c | 4 ---- include/legic_prng.h | 1 - 2 files changed, 5 deletions(-) diff --git a/common/legic_prng.c b/common/legic_prng.c index 5406161fc..8646f55a9 100644 --- a/common/legic_prng.c +++ b/common/legic_prng.c @@ -46,10 +46,6 @@ void legic_prng_forward(int count) { } } -uint32_t legic_prng_count() { - return lfsr.c; -} - uint8_t legic_prng_get_bit() { uint8_t idx = 7 - ((lfsr.a & 4) | (lfsr.a >> 2 & 2) | (lfsr.a >> 4 & 1)); return lfsr.b >> idx & 1; diff --git a/include/legic_prng.h b/include/legic_prng.h index 1f3042779..16855ab90 100644 --- a/include/legic_prng.h +++ b/include/legic_prng.h @@ -12,7 +12,6 @@ #include extern void legic_prng_init(uint8_t iv); extern void legic_prng_forward(int count); -extern uint32_t legic_prng_count(); extern uint8_t legic_prng_get_bit(); extern uint32_t legic_prng_get_bits(uint8_t len); #endif From c939d99884507de0a6b65243dbf6d204a0dd369a Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Mar 2019 15:11:38 +0100 Subject: [PATCH 11/11] chg: remove LDC mod be default --- armsrc/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 707325d41..7a24b109f 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -58,8 +58,6 @@ APP_CFLAGS = $(PLATFORM_DEFS) \ # -DWITH_HF_COLIN # -DWITH_HF_BOG - -SRC_LCD = fonts.c LCD.c SRC_LF = lfops.c hitag2_crypto.c hitag2.c hitagS.c lfsampling.c pcf7931.c lfdemod.c SRC_ISO15693 = iso15693.c iso15693tools.c #SRC_ISO14443a = iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c @@ -91,6 +89,12 @@ else SRC_FPC = endif +ifneq (,$(findstring WITH_LCD,$(APP_CLAGS))) + SRC_LCD = fonts.c LCD.c +else + SRC_LCD = +endif + # Generic standalone Mode injection of source code SRC_STANDALONE = # WITH_LF_ICERUN