This commit is contained in:
Philippe Teuwen 2019-04-11 00:10:21 +02:00
parent 6416de1a38
commit 35e97ba96a
16 changed files with 31 additions and 27 deletions

View file

@ -11,7 +11,7 @@
#define MAX_ARGS 20 #define MAX_ARGS 20
int split(char *str, char *arr[MAX_ARGS]) { static int split(char *str, char *arr[MAX_ARGS]) {
int beginIndex = 0; int beginIndex = 0;
int endIndex; int endIndex;
int maxWords = MAX_ARGS; int maxWords = MAX_ARGS;
@ -389,7 +389,7 @@ int CmdrevengTestC(const char *Cmd) {
} }
//returns a calloced string (needs to be freed) //returns a calloced string (needs to be freed)
char *SwapEndianStr(const char *inStr, const size_t len, const uint8_t blockSize) { static char *SwapEndianStr(const char *inStr, const size_t len, const uint8_t blockSize) {
char *tmp = calloc(len + 1, sizeof(char)); char *tmp = calloc(len + 1, sizeof(char));
for (uint8_t block = 0; block < (uint8_t)(len / blockSize); block++) { for (uint8_t block = 0; block < (uint8_t)(len / blockSize); block++) {
for (size_t i = 0; i < blockSize; i += 2) { for (size_t i = 0; i < blockSize; i += 2) {

View file

@ -25,9 +25,11 @@
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
size_t nbytes(size_t nbits) { /*
static size_t nbytes(size_t nbits) {
return (nbits / 8) + ((nbits % 8) > 0); return (nbits / 8) + ((nbits % 8) > 0);
} }
*/
static int usage_hitag_sniff(void) { static int usage_hitag_sniff(void) {
PrintAndLogEx(NORMAL, "Sniff traffic between Hitag reader and tag. Use " _YELLOW_("`lf hitag list`")" to view collected data."); PrintAndLogEx(NORMAL, "Sniff traffic between Hitag reader and tag. Use " _YELLOW_("`lf hitag list`")" to view collected data.");
PrintAndLogEx(NORMAL, "Usage: lf hitag sniff [h] "); PrintAndLogEx(NORMAL, "Usage: lf hitag sniff [h] ");

View file

@ -52,7 +52,7 @@ static int usage_lf_indala_sim(void) {
// redesigned by marshmellow adjusted from existing decode functions // redesigned by marshmellow adjusted from existing decode functions
// indala id decoding // indala id decoding
int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) { static int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
uint8_t preamble64_i[] = {0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; uint8_t preamble64_i[] = {0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
uint8_t preamble224_i[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; uint8_t preamble224_i[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};

View file

@ -53,7 +53,7 @@ int detectNedap(uint8_t *dest, size_t *size) {
return (int) startIdx; return (int) startIdx;
} }
int GetNedapBits(uint32_t cn, uint8_t *nedapBits) { static int GetNedapBits(uint32_t cn, uint8_t *nedapBits) {
uint8_t pre[128]; uint8_t pre[128];
memset(pre, 0x00, sizeof(pre)); memset(pre, 0x00, sizeof(pre));

View file

@ -76,7 +76,7 @@ int getnoralsyBits(uint32_t id, uint16_t year, uint8_t *bits) {
// by iceman // by iceman
// find Noralsy preamble in already demoded data // find Noralsy preamble in already demoded data
int detectNoralsy(uint8_t *dest, size_t *size) { static int detectNoralsy(uint8_t *dest, size_t *size) {
if (*size < 96) return -1; //make sure buffer has data if (*size < 96) return -1; //make sure buffer has data
size_t startIdx = 0; size_t startIdx = 0;
uint8_t preamble[] = {1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0}; uint8_t preamble[] = {1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0};

View file

@ -72,7 +72,7 @@ int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) {
} }
// Works for 26bits. // Works for 26bits.
int GetPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) { static int GetPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
uint8_t pre[128]; uint8_t pre[128];
memset(pre, 0x00, sizeof(pre)); memset(pre, 0x00, sizeof(pre));

View file

@ -13,7 +13,7 @@ static int CmdHelp(const char *Cmd);
// by marshmellow // by marshmellow
// find Securakey preamble in already demoded data // find Securakey preamble in already demoded data
int detectSecurakey(uint8_t *dest, size_t *size) { static int detectSecurakey(uint8_t *dest, size_t *size) {
if (*size < 96) return -1; //make sure buffer has data if (*size < 96) return -1; //make sure buffer has data
size_t startIdx = 0; size_t startIdx = 0;
uint8_t preamble[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1}; uint8_t preamble[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1};

View file

@ -138,6 +138,7 @@ t55xx_conf_block_t Get_t55xx_Config(void);
void Set_t55xx_Config(t55xx_conf_block_t conf); void Set_t55xx_Config(t55xx_conf_block_t conf);
int CmdLFT55XX(const char *Cmd); int CmdLFT55XX(const char *Cmd);
int CmdT55xxChk(const char *Cmd); int CmdT55xxChk(const char *Cmd);
int CmdT55xxBruteForce(const char *Cmd); int CmdT55xxBruteForce(const char *Cmd);
int CmdT55xxSetConfig(const char *Cmd); int CmdT55xxSetConfig(const char *Cmd);

View file

@ -38,7 +38,7 @@ static int usage_lf_viking_sim(void) {
} }
// calc checksum // calc checksum
uint64_t getVikingBits(uint32_t id) { static uint64_t getVikingBits(uint32_t id) {
uint8_t checksum = ((id >> 24) & 0xFF) ^ ((id >> 16) & 0xFF) ^ ((id >> 8) & 0xFF) ^ (id & 0xFF) ^ 0xF2 ^ 0xA8; uint8_t checksum = ((id >> 24) & 0xFF) ^ ((id >> 16) & 0xFF) ^ ((id >> 8) & 0xFF) ^ (id & 0xFF) ^ 0xF2 ^ 0xA8;
uint64_t ret = (uint64_t)0xF2 << 56; uint64_t ret = (uint64_t)0xF2 << 56;
ret |= (uint64_t)id << 8; ret |= (uint64_t)id << 8;

View file

@ -39,7 +39,7 @@
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
int str_ends_with(const char *str, const char *suffix) { static int str_ends_with(const char *str, const char *suffix) {
if (str == NULL || suffix == NULL) if (str == NULL || suffix == NULL)
return 0; return 0;
@ -56,7 +56,7 @@ int str_ends_with(const char *str, const char *suffix) {
/** /**
* Utility to check the ending of a string (used to check file suffix) * Utility to check the ending of a string (used to check file suffix)
*/ */
bool endsWith(const char *base, const char *str) { static bool endsWith(const char *base, const char *str) {
int blen = strlen(base); int blen = strlen(base);
int slen = strlen(str); int slen = strlen(str);
return (blen >= slen) && (0 == strcmp(base + blen - slen, str)); return (blen >= slen) && (0 == strcmp(base + blen - slen, str));

View file

@ -109,7 +109,7 @@ out:
return retval; return retval;
} }
uint8_t GetATRTA1(uint8_t *atr, size_t atrlen) { static uint8_t GetATRTA1(uint8_t *atr, size_t atrlen) {
if (atrlen > 2) { if (atrlen > 2) {
uint8_t T0 = atr[1]; uint8_t T0 = atr[1];
if (T0 & 0x10) if (T0 & 0x10)
@ -176,17 +176,17 @@ float FArray[] = {
0 // b1111 RFU 0 // b1111 RFU
}; };
int GetATRDi(uint8_t *atr, size_t atrlen) { static int GetATRDi(uint8_t *atr, size_t atrlen) {
uint8_t TA1 = GetATRTA1(atr, atrlen); uint8_t TA1 = GetATRTA1(atr, atrlen);
return DiArray[TA1 & 0x0F]; // The 4 low-order bits of TA1 (4th MSbit to 1st LSbit) encode Di return DiArray[TA1 & 0x0F]; // The 4 low-order bits of TA1 (4th MSbit to 1st LSbit) encode Di
} }
int GetATRFi(uint8_t *atr, size_t atrlen) { static int GetATRFi(uint8_t *atr, size_t atrlen) {
uint8_t TA1 = GetATRTA1(atr, atrlen); uint8_t TA1 = GetATRTA1(atr, atrlen);
return FiArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi return FiArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
} }
float GetATRF(uint8_t *atr, size_t atrlen) { static float GetATRF(uint8_t *atr, size_t atrlen) {
uint8_t TA1 = GetATRTA1(atr, atrlen); uint8_t TA1 = GetATRTA1(atr, atrlen);
return FArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi return FArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
} }

View file

@ -58,16 +58,16 @@ static int usage_trace_save() {
return 0; return 0;
} }
bool is_last_record(uint16_t tracepos, uint8_t *trace, uint16_t traceLen) { static bool is_last_record(uint16_t tracepos, uint8_t *trace, uint16_t traceLen) {
return (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) >= traceLen); return (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) >= traceLen);
} }
bool next_record_is_response(uint16_t tracepos, uint8_t *trace) { static bool next_record_is_response(uint16_t tracepos, uint8_t *trace) {
uint16_t next_records_datalen = *((uint16_t *)(trace + tracepos + sizeof(uint32_t) + sizeof(uint16_t))); uint16_t next_records_datalen = *((uint16_t *)(trace + tracepos + sizeof(uint32_t) + sizeof(uint16_t)));
return ((next_records_datalen & 0x8000) == 0x8000); return ((next_records_datalen & 0x8000) == 0x8000);
} }
bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t *tracepos, uint16_t traceLen, static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t *tracepos, uint16_t traceLen,
uint8_t *trace, uint8_t *frame, uint8_t *topaz_reader_command, uint16_t *data_len) { uint8_t *trace, uint8_t *frame, uint8_t *topaz_reader_command, uint16_t *data_len) {
#define MAX_TOPAZ_READER_CMD_LEN 16 #define MAX_TOPAZ_READER_CMD_LEN 16
@ -105,7 +105,7 @@ bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t
return true; return true;
} }
uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol, bool showWaitCycles, bool markCRCBytes) { static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol, bool showWaitCycles, bool markCRCBytes) {
// sanity check // sanity check
if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen; if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
@ -307,7 +307,7 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui
return tracepos; return tracepos;
} }
void printFelica(uint16_t traceLen, uint8_t *trace) { static void printFelica(uint16_t traceLen, uint8_t *trace) {
PrintAndLogEx(NORMAL, "ISO18092 / FeliCa - Timings are not as accurate"); PrintAndLogEx(NORMAL, "ISO18092 / FeliCa - Timings are not as accurate");
PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |"); PrintAndLogEx(NORMAL, " Gap | Src | Data | CRC | Annotation |");

View file

@ -555,7 +555,7 @@ void SetSIMDInstr(SIMDExecInstr instr) {
bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch; bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch;
} }
SIMDExecInstr GetSIMDInstr() { static SIMDExecInstr GetSIMDInstr() {
SIMDExecInstr instr = SIMD_NONE; SIMDExecInstr instr = SIMD_NONE;
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)

View file

@ -7,6 +7,7 @@
#include <limits.h> #include <limits.h>
#include "pm3_bit_limits.h" #include "pm3_bit_limits.h"
#include "pm3_bitlib.h"
/* FIXME: Assumes lua_Integer is ptrdiff_t */ /* FIXME: Assumes lua_Integer is ptrdiff_t */

View file

@ -847,7 +847,7 @@ static int l_T55xx_detect(lua_State *L) {
* @param path * @param path
* @return * @return
*/ */
int setLuaPath(lua_State *L, const char *path) { static int setLuaPath(lua_State *L, const char *path) {
lua_getglobal(L, "package"); lua_getglobal(L, "package");
lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1) lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
const char *cur_path = lua_tostring(L, -1); // grab path string from top of stack const char *cur_path = lua_tostring(L, -1); // grab path string from top of stack

View file

@ -28,15 +28,15 @@ uint32_t GetT55xxClockBit(uint32_t clock) {
#include "ui.h" #include "ui.h"
#define PrintAndLogDevice(level, format, args...) PrintAndLogEx(level, format , ## args) #define PrintAndLogDevice(level, format, args...) PrintAndLogEx(level, format , ## args)
uint8_t isset(uint8_t val, uint8_t mask) { static uint8_t isset(uint8_t val, uint8_t mask) {
return (val & mask); return (val & mask);
} }
uint8_t notset(uint8_t val, uint8_t mask) { static uint8_t notset(uint8_t val, uint8_t mask) {
return !(val & mask); return !(val & mask);
} }
void fuse_config(const picopass_hdr *hdr) { static void fuse_config(const picopass_hdr *hdr) {
uint8_t fuses = hdr->conf.fuses; uint8_t fuses = hdr->conf.fuses;
if (isset(fuses, FUSE_FPERS)) if (isset(fuses, FUSE_FPERS))
@ -100,7 +100,7 @@ void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t *
} }
} }
void mem_app_config(const picopass_hdr *hdr) { static void mem_app_config(const picopass_hdr *hdr) {
uint8_t mem = hdr->conf.mem_config; uint8_t mem = hdr->conf.mem_config;
uint8_t chip = hdr->conf.chip_config; uint8_t chip = hdr->conf.chip_config;
uint8_t applimit = hdr->conf.app_limit; uint8_t applimit = hdr->conf.app_limit;
@ -136,7 +136,7 @@ void mem_app_config(const picopass_hdr *hdr) {
PrintAndLogDevice(NORMAL, "\tCredit - Kc"); PrintAndLogDevice(NORMAL, "\tCredit - Kc");
} }
} }
void print_picopass_info(const picopass_hdr *hdr) { static void print_picopass_info(const picopass_hdr *hdr) {
fuse_config(hdr); fuse_config(hdr);
mem_app_config(hdr); mem_app_config(hdr);
} }