mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Merge branch 'strict'
* strict: (22 commits) chg: rpi aling warning chg: more LF demodulation tests lf nedap: fix cast align warning hf epa: fix cast align warning fix cast align warning update whereami and avoid compiling unnneded troublesome parts unknown to clang < 8: -Woverride-init silent zlib warning under AppVeyor adjust warning flags fix defined more warnings silent some bad-function-cast unshadow vars activate more warnings and ease their mgmt fix warning about cast realignment, WIP bug ifneq <> ifeq rework C includes in C++ stricter warnings: Wredundant-decls cflags stricter warnings, wip ...
This commit is contained in:
commit
94133a8798
84 changed files with 480 additions and 424 deletions
|
@ -44,3 +44,22 @@ else
|
|||
AR= ar rcs
|
||||
RANLIB= ranlib
|
||||
endif
|
||||
|
||||
DEFCFLAGS = -Wall -Werror -O3
|
||||
# Some more warnings we want as errors:
|
||||
DEFCFLAGS += -Wcast-align -Wbad-function-cast -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wshadow -Wundef -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations -Wempty-body -Wignored-qualifiers
|
||||
# Some more warnings we need first to eliminate, so temporarely tolerated:
|
||||
DEFCFLAGS += -Wno-error=cast-align
|
||||
# TODO?:
|
||||
#DEFCFLAGS += -Wunused-parameter -Wold-style-declaration -Wsign-compare -Wimplicit-fallthrough=3 -Wtype-limits -Wmissing-field-initializers -Wunused-but-set-parameter -Wswitch-enum -Wold-style-definition
|
||||
#DEFCFLAGS += -Wno-error=unused-parameter -Wno-error=old-style-declaration -Wno-error=sign-compare -Wno-error=implicit-fallthrough -Wno-error=type-limits -Wno-error=missing-field-initializers -Wno-error=unused-but-set-parameter -Wno-error=switch-enum -Wno-error=old-style-definition
|
||||
# unknown to clang: -Wclobbered -Wmissing-parameter-type -Wcast-function-type
|
||||
# unknown to clang < 8: -Woverride-init
|
||||
# unknown to gcc < 6: -Wshift-negative-value
|
||||
|
||||
ifeq ($(platform),Darwin)
|
||||
# their readline has strict-prototype issues
|
||||
DEFCFLAGS += -Wstrict-prototypes -Wno-error=strict-prototypes
|
||||
else
|
||||
DEFCFLAGS += -Wstrict-prototypes
|
||||
endif
|
||||
|
|
|
@ -15,7 +15,7 @@ ifeq ($(DEFSBEENHERE),)
|
|||
$(error Can't find Makefile.defs)
|
||||
endif
|
||||
|
||||
CFLAGS ?= -Wall -Werror -O3
|
||||
CFLAGS ?= $(DEFCFLAGS)
|
||||
CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
|
||||
|
||||
vpath %.c $(MYSRCPATHS)
|
||||
|
|
|
@ -55,9 +55,10 @@ ZLIB = $(OBJDIR)/libz.a
|
|||
|
||||
LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH) -I$(HARDNESTEDPATH) -I$(CLIPARSERPATH)
|
||||
INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS)
|
||||
CFLAGS ?= -Wall -Werror -O3
|
||||
CFLAGS ?= $(DEFCFLAGS)
|
||||
|
||||
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
|
||||
PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT)
|
||||
PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT) -DWAI_PM3_TUNED
|
||||
# WIP Testing
|
||||
#PM3CFLAGS = $(CFLAGS) -std=c11 -pedantic $(INCLUDES_CLIENT)
|
||||
PREFIX ?= /usr/local
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define HMAC_POS_DATA 0x008
|
||||
#define HMAC_POS_TAG 0x1B4
|
||||
|
||||
void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) {
|
||||
static void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) {
|
||||
memcpy(key + 0x00, dump + 0x029, 0x02);
|
||||
memset(key + 0x02, 0x00, 0x0E);
|
||||
memcpy(key + 0x10, dump + 0x1D4, 0x08);
|
||||
|
@ -21,14 +21,14 @@ void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) {
|
|||
memcpy(key + 0x20, dump + 0x1E8, 0x20);
|
||||
}
|
||||
|
||||
void nfc3d_amiibo_keygen(const nfc3d_keygen_masterkeys *masterKeys, const uint8_t *dump, nfc3d_keygen_derivedkeys *derivedKeys) {
|
||||
static void nfc3d_amiibo_keygen(const nfc3d_keygen_masterkeys *masterKeys, const uint8_t *dump, nfc3d_keygen_derivedkeys *derivedKeys) {
|
||||
uint8_t seed[NFC3D_KEYGEN_SEED_SIZE];
|
||||
|
||||
nfc3d_amiibo_calc_seed(dump, seed);
|
||||
nfc3d_keygen(masterKeys, seed, derivedKeys);
|
||||
}
|
||||
|
||||
void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in, uint8_t *out) {
|
||||
static void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in, uint8_t *out) {
|
||||
mbedtls_aes_context aes;
|
||||
size_t nc_off = 0;
|
||||
unsigned char nonce_counter[16];
|
||||
|
@ -47,7 +47,7 @@ void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in
|
|||
memcpy(out + 0x1D4, in + 0x1D4, 0x034);
|
||||
}
|
||||
|
||||
void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) {
|
||||
static void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) {
|
||||
memcpy(intl + 0x000, tag + 0x008, 0x008);
|
||||
memcpy(intl + 0x008, tag + 0x080, 0x020);
|
||||
memcpy(intl + 0x028, tag + 0x010, 0x024);
|
||||
|
@ -57,7 +57,7 @@ void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) {
|
|||
memcpy(intl + 0x1DC, tag + 0x054, 0x02C);
|
||||
}
|
||||
|
||||
void nfc3d_amiibo_internal_to_tag(const uint8_t *intl, uint8_t *tag) {
|
||||
static void nfc3d_amiibo_internal_to_tag(const uint8_t *intl, uint8_t *tag) {
|
||||
memcpy(tag + 0x008, intl + 0x000, 0x008);
|
||||
memcpy(tag + 0x080, intl + 0x008, 0x020);
|
||||
memcpy(tag + 0x010, intl + 0x028, 0x024);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
static char *self;
|
||||
|
||||
void amiitool_usage() {
|
||||
void amiitool_usage(void) {
|
||||
fprintf(stderr,
|
||||
/*"amiitool build %i (commit %s-%08x)\n"*/
|
||||
"by Marcos Del Sol Vives <marcos@dracon.es>\n"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys *baseKeys, const uint8_t *baseSeed, uint8_t *output, size_t *outputSize) {
|
||||
static void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys *baseKeys, const uint8_t *baseSeed, uint8_t *output, size_t *outputSize) {
|
||||
assert(baseKeys != NULL);
|
||||
assert(baseSeed != NULL);
|
||||
assert(output != NULL);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
MYSRCPATHS =
|
||||
MYINCLUDES = -I../../../common -I../../../include -I../../src
|
||||
MYCFLAGS =
|
||||
MYCFLAGS = -Wno-cast-align
|
||||
MYDEFS =
|
||||
MYSRCS = \
|
||||
argtable3.c \
|
||||
|
|
|
@ -143,7 +143,7 @@ int CLIParserParseStringEx(const char *str, void *vargtable[], size_t vargtableL
|
|||
return CLIParserParseArg(argc, argv, vargtable, vargtableLen, allowEmptyExec);
|
||||
}
|
||||
|
||||
void CLIParserFree() {
|
||||
void CLIParserFree(void) {
|
||||
arg_freetable(argtable, argtableLen);
|
||||
argtable = NULL;
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ void SetSIMDInstr(SIMDExecInstr instr) {
|
|||
bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch;
|
||||
}
|
||||
|
||||
static SIMDExecInstr GetSIMDInstr() {
|
||||
static SIMDExecInstr GetSIMDInstr(void) {
|
||||
SIMDExecInstr instr = SIMD_NONE;
|
||||
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
|
@ -578,7 +578,7 @@ static SIMDExecInstr GetSIMDInstr() {
|
|||
return instr;
|
||||
}
|
||||
|
||||
SIMDExecInstr GetSIMDInstrAuto() {
|
||||
SIMDExecInstr GetSIMDInstrAuto(void) {
|
||||
SIMDExecInstr instr = intSIMDInstr;
|
||||
if (instr == SIMD_AUTO)
|
||||
return GetSIMDInstr();
|
||||
|
|
|
@ -433,7 +433,7 @@ static bool read_bench_data(statelist_t *test_candidates) {
|
|||
}
|
||||
|
||||
|
||||
float brute_force_benchmark() {
|
||||
float brute_force_benchmark(void) {
|
||||
statelist_t test_candidates[NUM_BRUTE_FORCE_THREADS];
|
||||
|
||||
test_candidates[0].states[ODD_STATE] = malloc((TEST_BENCH_SIZE + 1) * sizeof(uint32_t));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
MYSRCPATHS =
|
||||
MYINCLUDES = -I.
|
||||
MYCFLAGS = -Wno-unused-function
|
||||
MYCFLAGS = -Wno-unused-function -Wno-cast-align -Wno-bad-function-cast
|
||||
MYDEFS = -DHAVE_STDINT_H
|
||||
MYSRCS = \
|
||||
dump.c \
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <jansson_private_config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ static int seed_from_timestamp_and_pid(uint32_t *seed) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t generate_seed() {
|
||||
static uint32_t generate_seed(void) {
|
||||
uint32_t seed = 0;
|
||||
int done = 0;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
MYSRCPATHS =
|
||||
MYINCLUDES = -I.
|
||||
# Lua lib requires GNU extensions (implicit declarations of functions): -std=gnu99 or -std=gnu11
|
||||
MYCFLAGS =
|
||||
MYCFLAGS = -Wno-cast-align -Wno-bad-function-cast
|
||||
MYDEFS = -DLUA_COMPAT_ALL $(SYSCFLAGS)
|
||||
MYSRCS = lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c \
|
||||
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c \
|
||||
|
|
|
@ -197,7 +197,7 @@ static void buffreplace(LexState *ls, char from, char to) {
|
|||
}
|
||||
|
||||
|
||||
#if ANDROID
|
||||
#if defined(ANDROID)
|
||||
#define getlocaldecpoint() '.'
|
||||
#elif !defined(getlocaledecpoint)
|
||||
#define getlocaledecpoint() (localeconv()->decimal_point[0])
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "fileutils.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
int openAIDFile(json_t **root, bool verbose) {
|
||||
static int openAIDFile(json_t **root, bool verbose) {
|
||||
json_error_t error;
|
||||
|
||||
char *path;
|
||||
|
@ -42,7 +42,7 @@ out:
|
|||
return retval;
|
||||
}
|
||||
|
||||
int closeAIDFile(json_t *root) {
|
||||
static int closeAIDFile(json_t *root) {
|
||||
|
||||
json_decref(root);
|
||||
return PM3_SUCCESS;
|
||||
|
@ -71,7 +71,7 @@ int AIDSearchFree(json_t *root) {
|
|||
return closeAIDFile(root);
|
||||
}
|
||||
|
||||
const char *jsonStrGet(json_t *data, char *name) {
|
||||
static const char *jsonStrGet(json_t *data, const char *name) {
|
||||
json_t *jstr;
|
||||
|
||||
jstr = json_object_get(data, name);
|
||||
|
@ -88,7 +88,7 @@ const char *jsonStrGet(json_t *data, char *name) {
|
|||
return cstr;
|
||||
}
|
||||
|
||||
bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
||||
static bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
||||
if (strcmp(aidlarge, aidsmall) == 0)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@ int PrintAIDDescriptionBuf(json_t *root, uint8_t *aid, size_t aidlen, bool verbo
|
|||
json_t *AIDSearchInit(bool verbose);
|
||||
json_t *AIDSearchGetElm(json_t *root, int elmindx);
|
||||
bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen);
|
||||
int AIDSearchFree();
|
||||
int AIDSearchFree(json_t *root);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "cmdparser.h" // for command_t
|
||||
#include "ui.h" // for show graph controls
|
||||
#include "proxgui.h"
|
||||
#include "graph.h" // for graph data
|
||||
#include "comms.h"
|
||||
#include "lfdemod.h" // for demod code
|
||||
|
@ -287,7 +288,7 @@ static int usage_data_buffclear(void) {
|
|||
PrintAndLogEx(NORMAL, " h This help");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_data_fsktonrz() {
|
||||
static int usage_data_fsktonrz(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: data fsktonrz c <clock> l <fc_low> f <fc_high>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h This help");
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#include <stdlib.h> //size_t
|
||||
|
||||
int CmdData(const char *Cmd);
|
||||
|
@ -81,6 +85,8 @@ extern size_t DemodBufferLen;
|
|||
|
||||
extern int g_DemodClock;
|
||||
extern size_t g_DemodStartIdx;
|
||||
extern uint8_t g_debugMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
#include "cmdhfcryptorf.h" // CryptoRF
|
||||
#include "cmdtrace.h" // trace list
|
||||
#include "ui.h"
|
||||
#include "proxgui.h"
|
||||
#include "cmddata.h"
|
||||
#include "graph.h"
|
||||
#include "fpga.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int usage_hf_search() {
|
||||
static int usage_hf_search(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: hf search");
|
||||
PrintAndLogEx(NORMAL, "Will try to find a HF read out of the unknown tag. Stops when found.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -52,7 +53,7 @@ static int usage_hf_search() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_sniff() {
|
||||
static int usage_hf_sniff(void) {
|
||||
PrintAndLogEx(NORMAL, "The high frequence sniffer will assign all available memory on device for sniffed data");
|
||||
PrintAndLogEx(NORMAL, "Use " _YELLOW_("'data samples'")" command to download from device, and " _YELLOW_("'data plot'")" to look at it");
|
||||
PrintAndLogEx(NORMAL, "Press button to quit the sniffing.\n");
|
||||
|
@ -68,7 +69,7 @@ static int usage_hf_sniff() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_tune() {
|
||||
static int usage_hf_tune(void) {
|
||||
PrintAndLogEx(NORMAL, "Continuously measure HF antenna tuning.");
|
||||
PrintAndLogEx(NORMAL, "Press button or Enter to interrupt.");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf tune [h] [<iter>]");
|
||||
|
|
|
@ -1245,7 +1245,7 @@ int CmdHF14A(const char *Cmd) {
|
|||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
static void printTag(char *tag) {
|
||||
static void printTag(const char *tag) {
|
||||
PrintAndLogEx(SUCCESS, "POSSIBLE TYPE:" _YELLOW_(" %s"), tag);
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1261,7 @@ typedef enum {
|
|||
} nxp_mifare_type_t;
|
||||
|
||||
// According to NXP AN10833 Rev 3.6 MIFARE Type Identification, Table 6
|
||||
int detect_nxp_card(uint8_t sak, uint16_t atqa) {
|
||||
static int detect_nxp_card(uint8_t sak, uint16_t atqa) {
|
||||
int type = MTNONE;
|
||||
|
||||
if (sak == 0x00) {
|
||||
|
@ -1340,7 +1340,7 @@ int detect_nxp_card(uint8_t sak, uint16_t atqa) {
|
|||
typedef struct {
|
||||
uint8_t uid0;
|
||||
uint8_t uid1;
|
||||
char *desc;
|
||||
const char *desc;
|
||||
} uidname;
|
||||
|
||||
const uidname uidmap[] = {
|
||||
|
@ -1355,7 +1355,7 @@ const uidname uidmap[] = {
|
|||
{0x00, 0x00, "None"}
|
||||
};
|
||||
|
||||
void getTagLabel(uint8_t uid0, uint8_t uid1) {
|
||||
static void getTagLabel(uint8_t uid0, uint8_t uid1) {
|
||||
int i = 0;
|
||||
while (uidmap[i].uid0 != 0x00) {
|
||||
if ((uidmap[i].uid0 == uid0) && (uidmap[i].uid1 == uid1)) {
|
||||
|
|
|
@ -684,7 +684,7 @@ static bool HF14B_Std_Reader(bool verbose) {
|
|||
}
|
||||
|
||||
// test for other 14b type tags (mimic another reader - don't have tags to identify)
|
||||
static bool HF14B_Other_Reader() {
|
||||
static bool HF14B_Other_Reader(void) {
|
||||
|
||||
// uint8_t data[] = {0x00, 0x0b, 0x3f, 0x80};
|
||||
// uint8_t datalen = 4;
|
||||
|
|
|
@ -92,8 +92,8 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
|||
while (Cmd[skip] != ' ' && Cmd[skip] != '\0') {
|
||||
// convert
|
||||
scan_return = sscanf(Cmd + skip,
|
||||
"%2X%n",
|
||||
(unsigned int *)(apdus[i] + apdu_lengths[i]),
|
||||
"%2" SCNx8 "%n",
|
||||
apdus[i] + apdu_lengths[i],
|
||||
&skip_add
|
||||
);
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ static int usage_hf_felica_request_response(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void print_status_flag1_interpretation() {
|
||||
static void print_status_flag1_interpretation(void) {
|
||||
PrintAndLogEx(NORMAL, "\nStatus Flag1:");
|
||||
PrintAndLogEx(NORMAL, " - 00h : Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(NORMAL, " - FFh : If an error occurs during the processing of a command that includes no list in the command packet, or if "
|
||||
|
@ -133,7 +133,7 @@ static void print_status_flag1_interpretation() {
|
|||
"indicating the location of the error.");
|
||||
}
|
||||
|
||||
static void print_status_flag2_interpration() {
|
||||
static void print_status_flag2_interpration(void) {
|
||||
PrintAndLogEx(NORMAL, "\nStatus Flag2:");
|
||||
PrintAndLogEx(NORMAL, " - 00h : Indicates the successful completion of a command.");
|
||||
PrintAndLogEx(NORMAL, " - 01h : The calculated result is either less than zero when the purse data is decremented, or exceeds 4"
|
||||
|
@ -167,7 +167,7 @@ static void print_status_flag2_interpration() {
|
|||
PrintAndLogEx(NORMAL, " - C2h : Command is disabled already: This is the error that occurs in issuance commands.");
|
||||
}
|
||||
|
||||
static void print_block_list_element_constraints() {
|
||||
static void print_block_list_element_constraints(void) {
|
||||
PrintAndLogEx(NORMAL, " - Each Block List Element shall satisfy the following conditions:");
|
||||
PrintAndLogEx(NORMAL, " - The value of Service Code List Order shall not exceed Number of Service.");
|
||||
PrintAndLogEx(NORMAL, " - Access Mode shall be 000b.");
|
||||
|
@ -177,22 +177,22 @@ static void print_block_list_element_constraints() {
|
|||
PrintAndLogEx(NORMAL, " - Block Number shall be in the range of the number of Blocks assigned to the specified Service.");
|
||||
}
|
||||
|
||||
static void print_number_of_service_constraints() {
|
||||
static void print_number_of_service_constraints(void) {
|
||||
PrintAndLogEx(NORMAL, " - Number of Service: shall be a positive integer in the range of 1 to 16, inclusive.");
|
||||
}
|
||||
|
||||
static void print_number_of_block_constraints() {
|
||||
static void print_number_of_block_constraints(void) {
|
||||
PrintAndLogEx(NORMAL, " - Number of Block: shall be less than or equal to the maximum number of Blocks that can be read simultaneously. "
|
||||
"The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used. Use as default 01");
|
||||
}
|
||||
|
||||
static void print_service_code_list_constraints() {
|
||||
static void print_service_code_list_constraints(void) {
|
||||
PrintAndLogEx(NORMAL, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:");
|
||||
PrintAndLogEx(NORMAL, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not be specified to Service Code List.");
|
||||
PrintAndLogEx(NORMAL, " - For existence or nonexistence of Service in a product, please check using the Request Service (or Request Service v2) command.");
|
||||
}
|
||||
|
||||
static int usage_hf_felica_read_without_encryption() {
|
||||
static int usage_hf_felica_read_without_encryption(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Use this command to read Block Data from authentication-not-required Service.");
|
||||
PrintAndLogEx(NORMAL, " - Mode shall be Mode0.");
|
||||
print_number_of_service_constraints();
|
||||
|
@ -215,7 +215,7 @@ static int usage_hf_felica_read_without_encryption() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_write_without_encryption() {
|
||||
static int usage_hf_felica_write_without_encryption(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Use this command to write Block Data to authentication-not-required Service.");
|
||||
PrintAndLogEx(NORMAL, " - Mode shall be Mode0.");
|
||||
print_number_of_service_constraints();
|
||||
|
@ -234,7 +234,7 @@ static int usage_hf_felica_write_without_encryption() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_request_system_code() {
|
||||
static int usage_hf_felica_request_system_code(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Use this command to acquire System Code registered to the card.");
|
||||
PrintAndLogEx(NORMAL, " - If a card is divided into more than one System, this command acquires System Code of each System existing in the card.");
|
||||
PrintAndLogEx(NORMAL, "\nUsage: hf felica rqsyscode [-h] [-i]");
|
||||
|
@ -246,7 +246,7 @@ static int usage_hf_felica_request_system_code() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_reset_mode() {
|
||||
static int usage_hf_felica_reset_mode(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Use this command to reset Mode to Mode 0.");
|
||||
print_status_flag1_interpretation();
|
||||
print_status_flag2_interpration();
|
||||
|
@ -261,7 +261,7 @@ static int usage_hf_felica_reset_mode() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_request_specification_version() {
|
||||
static int usage_hf_felica_request_specification_version(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Use this command to acquire the version of card OS.");
|
||||
PrintAndLogEx(NORMAL, " - Response:");
|
||||
PrintAndLogEx(NORMAL, " - Format Version: Fixed value 00h. Provided only if Status Flag1 = 00h.");
|
||||
|
@ -283,7 +283,7 @@ static int usage_hf_felica_request_specification_version() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_authentication1() {
|
||||
static int usage_hf_felica_authentication1(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Initiate mutual authentication. This command must always be executed before Authentication2 command"
|
||||
", and mutual authentication is achieve only after Authentication2 command has succeeded.");
|
||||
PrintAndLogEx(NORMAL, " - Auth1 Parameters:");
|
||||
|
@ -311,7 +311,7 @@ static int usage_hf_felica_authentication1() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_hf_felica_authentication2() {
|
||||
static int usage_hf_felica_authentication2(void) {
|
||||
PrintAndLogEx(NORMAL, "\nInfo: Complete mutual authentication. This command can only be executed subsquent to Authentication1"
|
||||
" command.");
|
||||
PrintAndLogEx(NORMAL, " - Auth2 Parameters:");
|
||||
|
@ -551,7 +551,7 @@ static bool check_last_idm(uint8_t *data, uint16_t datalen) {
|
|||
* @param wr_noCry_resp frame in which the response will be saved.
|
||||
* @return success if response was received.
|
||||
*/
|
||||
int send_wr_unencrypted(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose, felica_status_response_t *wr_noCry_resp) {
|
||||
static int send_wr_unencrypted(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose, felica_status_response_t *wr_noCry_resp) {
|
||||
clear_and_send_command(flags, datalen, data, verbose);
|
||||
PacketResponseNG resp;
|
||||
if (!waitCmdFelica(0, &resp, verbose)) {
|
||||
|
@ -1464,7 +1464,7 @@ static int CmdHFFelicaSimLite(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void printSep() {
|
||||
static void printSep(void) {
|
||||
PrintAndLogEx(INFO, "------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ static int usage_hf_iclass_readblock(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_hf_iclass_readtagfile() {
|
||||
static int usage_hf_iclass_readtagfile(void) {
|
||||
PrintAndLogEx(NORMAL, "Print a iClass tag-dump file\n");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf iClass readtagfile [f <filename>] [s <startblock>] [e <endblock>] [v]\n");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
|
|
@ -880,7 +880,7 @@ int legic_get_type(legic_card_select_t *card) {
|
|||
if (!isOK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
memcpy(card, (legic_card_select_t *)resp.data.asBytes, sizeof(legic_card_select_t));
|
||||
memcpy(card, resp.data.asBytes, sizeof(legic_card_select_t));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
void legic_chk_iv(uint32_t *iv) {
|
||||
|
|
|
@ -37,7 +37,7 @@ enum MifareAuthSeq {
|
|||
static enum MifareAuthSeq MifareAuthState;
|
||||
static TAuthData AuthData;
|
||||
|
||||
void ClearAuthData() {
|
||||
void ClearAuthData(void) {
|
||||
AuthData.uid = 0;
|
||||
AuthData.nt = 0;
|
||||
AuthData.first_auth = true;
|
||||
|
|
|
@ -3132,7 +3132,7 @@ out:
|
|||
sector_t *k_sector = NULL;
|
||||
uint8_t k_sectorsCount = 40;
|
||||
|
||||
void showSectorTable() {
|
||||
void showSectorTable(void) {
|
||||
if (k_sector != NULL) {
|
||||
printKeyTable(k_sectorsCount, k_sector);
|
||||
free(k_sector);
|
||||
|
@ -4806,7 +4806,7 @@ static int CmdHFMFNDEF(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdHFMFPersonalize(const char *cmd) {
|
||||
static int CmdHFMFPersonalize(const char *cmd) {
|
||||
|
||||
CLIParserInit("hf mf personalize",
|
||||
"Personalize the UID of a Mifare Classic EV1 card. This is only possible if it is a 7Byte UID card and if it is not already personalized.",
|
||||
|
|
|
@ -170,7 +170,7 @@ typedef enum {
|
|||
CL_AMISC7 = 0xFF,
|
||||
} aidcluster_h;
|
||||
|
||||
static char *cluster_to_text(uint8_t cluster) {
|
||||
static const char *cluster_to_text(uint8_t cluster) {
|
||||
switch (cluster) {
|
||||
case CL_ADMIN:
|
||||
return "card administration";
|
||||
|
@ -375,7 +375,7 @@ static char *getVersionStr(uint8_t major, uint8_t minor) {
|
|||
}
|
||||
|
||||
|
||||
int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t *result, int max_result_len, int *result_len, uint16_t *sw) {
|
||||
static int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t *result, int max_result_len, int *result_len, uint16_t *sw) {
|
||||
|
||||
*result_len = 0;
|
||||
if (sw) *sw = 0;
|
||||
|
@ -433,7 +433,7 @@ int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static char *getstatus(uint16_t *sw) {
|
||||
static const char *getstatus(uint16_t *sw) {
|
||||
if (sw == NULL) return "--> sw argument error. This should never happen !";
|
||||
if (((*sw >> 8) & 0xFF) == 0x91) {
|
||||
switch (*sw & 0xFF) {
|
||||
|
@ -500,7 +500,7 @@ static char *getstatus(uint16_t *sw) {
|
|||
return "Unknown error";
|
||||
}
|
||||
|
||||
static char *GetErrorString(int res, uint16_t *sw) {
|
||||
static const char *GetErrorString(int res, uint16_t *sw) {
|
||||
switch (res) {
|
||||
case PM3_EAPDU_FAIL:
|
||||
return getstatus(sw);
|
||||
|
@ -642,7 +642,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) {
|
|||
return DESFIRE_UNKNOWN;
|
||||
}
|
||||
|
||||
int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload, bool defaultkey) {
|
||||
static int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload, bool def_key) {
|
||||
// 3 different way to authenticate AUTH (CRC16) , AUTH_ISO (CRC32) , AUTH_AES (CRC32)
|
||||
// 4 different crypto arg1 DES, 3DES, 3K3DES, AES
|
||||
// 3 different communication modes, PLAIN,MAC,CRYPTO
|
||||
|
@ -679,7 +679,7 @@ int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload,
|
|||
|
||||
|
||||
// Part 1
|
||||
if (defaultkey) {
|
||||
if (def_key) {
|
||||
if (payload->algo == MFDES_AUTH_DES) {
|
||||
memcpy(keybytes, PICC_MASTER_KEY8, 8);
|
||||
} else if (payload->algo == MFDES_ALGO_AES || payload->algo == MFDES_ALGO_3DES) {
|
||||
|
@ -913,7 +913,7 @@ int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload,
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void AuthToError(int error) {
|
||||
static void AuthToError(int error) {
|
||||
switch (error) {
|
||||
case 1:
|
||||
PrintAndLogEx(SUCCESS, "Sending auth command failed");
|
||||
|
@ -953,7 +953,7 @@ void AuthToError(int error) {
|
|||
}
|
||||
}
|
||||
// -- test if card supports 0x0A
|
||||
static int test_desfire_authenticate() {
|
||||
static int test_desfire_authenticate(void) {
|
||||
uint8_t data[] = {0x00};
|
||||
sAPDU apdu = {0x90, MFDES_AUTHENTICATE, 0x00, 0x00, 0x01, data}; // 0x0A, KEY 0
|
||||
int recv_len = 0;
|
||||
|
@ -968,7 +968,7 @@ static int test_desfire_authenticate() {
|
|||
}
|
||||
|
||||
// -- test if card supports 0x1A
|
||||
static int test_desfire_authenticate_iso() {
|
||||
static int test_desfire_authenticate_iso(void) {
|
||||
uint8_t data[] = {0x00};
|
||||
sAPDU apdu = {0x90, MFDES_AUTHENTICATE_ISO, 0x00, 0x00, 0x01, data}; // 0x1A, KEY 0
|
||||
int recv_len = 0;
|
||||
|
@ -983,7 +983,7 @@ static int test_desfire_authenticate_iso() {
|
|||
}
|
||||
|
||||
// -- test if card supports 0xAA
|
||||
static int test_desfire_authenticate_aes() {
|
||||
static int test_desfire_authenticate_aes(void) {
|
||||
uint8_t data[] = {0x00};
|
||||
sAPDU apdu = {0x90, MFDES_AUTHENTICATE_AES, 0x00, 0x00, 0x01, data}; // 0xAA, KEY 0
|
||||
int recv_len = 0;
|
||||
|
@ -1210,7 +1210,7 @@ static int handler_desfire_keyversion(uint8_t curr_key, uint8_t *num_versions) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static int handler_desfire_commit_transaction() {
|
||||
static int handler_desfire_commit_transaction(void) {
|
||||
sAPDU apdu = {0x90, MFDES_COMMIT_TRANSACTION, 0x00, 0x00, 0x00, NULL}; //0xC7
|
||||
int recv_len = 0;
|
||||
uint16_t sw = 0;
|
||||
|
@ -1225,7 +1225,7 @@ static int handler_desfire_commit_transaction() {
|
|||
return res;
|
||||
}
|
||||
|
||||
/*static int handler_desfire_abort_transaction() {
|
||||
/*static int handler_desfire_abort_transaction(void) {
|
||||
sAPDU apdu = {0x90, MFDES_ABORT_TRANSACTION, 0x00, 0x00, 0x00, NULL}; //0xA7
|
||||
int recv_len = 0;
|
||||
uint16_t sw = 0;
|
||||
|
@ -1647,7 +1647,7 @@ static int handler_desfire_create_backup_file(mfdes_file_t *file) {
|
|||
return res;
|
||||
}
|
||||
|
||||
int getKeySettings(uint8_t *aid) {
|
||||
static int getKeySettings(uint8_t *aid) {
|
||||
if (aid == NULL) return PM3_EINVARG;
|
||||
|
||||
int res = 0;
|
||||
|
@ -3558,7 +3558,7 @@ static int CmdHF14ADesAuth(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t *aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t *k3kkeyListLen, uint32_t *startPattern) {
|
||||
static void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t *aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t *k3kkeyListLen, uint32_t *startPattern) {
|
||||
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
|
||||
if (*deskeyListLen != MAX_KEYS_LIST_LEN) {
|
||||
deskeyList[*deskeyListLen][0] = (pt >> 8) & 0xff;
|
||||
|
|
|
@ -793,7 +793,8 @@ static void update_p_K(void) {
|
|||
}
|
||||
for (uint8_t sum_a8_idx = 0; sum_a8_idx < NUM_SUMS; sum_a8_idx++) {
|
||||
uint16_t sum_a8 = sums[sum_a8_idx];
|
||||
my_p_K[sum_a8_idx] = (float)estimated_num_states_coarse(sum_a0, sum_a8) / total_count;
|
||||
float f = estimated_num_states_coarse(sum_a0, sum_a8);
|
||||
my_p_K[sum_a8_idx] = f / total_count;
|
||||
}
|
||||
// PrintAndLogEx(NORMAL, "my_p_K = [");
|
||||
// for (uint8_t sum_a8_idx = 0; sum_a8_idx < NUM_SUMS; sum_a8_idx++) {
|
||||
|
@ -1302,7 +1303,7 @@ static void simulate_MFplus_RNG(uint32_t test_cuid, uint64_t test_key, uint32_t
|
|||
|
||||
}
|
||||
|
||||
static void simulate_acquire_nonces() {
|
||||
static void simulate_acquire_nonces(void) {
|
||||
time_t time1 = time(NULL);
|
||||
last_sample_clock = 0;
|
||||
sample_period = 1000; // for simulation
|
||||
|
@ -1739,24 +1740,24 @@ static void bitarray_to_list(uint8_t byte, uint32_t *bitarray, uint32_t *state_l
|
|||
}
|
||||
|
||||
|
||||
static void add_cached_states(statelist_t *candidates, uint16_t part_sum_a0, uint16_t part_sum_a8, odd_even_t odd_even) {
|
||||
candidates->states[odd_even] = sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].sl;
|
||||
candidates->len[odd_even] = sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].len;
|
||||
static void add_cached_states(statelist_t *cands, uint16_t part_sum_a0, uint16_t part_sum_a8, odd_even_t odd_even) {
|
||||
cands->states[odd_even] = sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].sl;
|
||||
cands->len[odd_even] = sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].len;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void add_matching_states(statelist_t *candidates, uint8_t part_sum_a0, uint8_t part_sum_a8, odd_even_t odd_even) {
|
||||
static void add_matching_states(statelist_t *cands, uint8_t part_sum_a0, uint8_t part_sum_a8, odd_even_t odd_even) {
|
||||
const uint32_t worstcase_size = 1 << 20;
|
||||
candidates->states[odd_even] = (uint32_t *)malloc(sizeof(uint32_t) * worstcase_size);
|
||||
if (candidates->states[odd_even] == NULL) {
|
||||
cands->states[odd_even] = (uint32_t *)malloc(sizeof(uint32_t) * worstcase_size);
|
||||
if (cands->states[odd_even] == NULL) {
|
||||
PrintAndLogEx(ERR, "Out of memory error in add_matching_states() - statelist.\n");
|
||||
exit(4);
|
||||
}
|
||||
uint32_t *candidates_bitarray = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * worstcase_size);
|
||||
if (candidates_bitarray == NULL) {
|
||||
uint32_t *cands_bitarray = (uint32_t *)malloc_bitarray(sizeof(uint32_t) * worstcase_size);
|
||||
if (cands_bitarray == NULL) {
|
||||
PrintAndLogEx(ERR, "Out of memory error in add_matching_states() - bitarray.\n");
|
||||
free(candidates->states[odd_even]);
|
||||
free(cands->states[odd_even]);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
|
@ -1764,21 +1765,21 @@ static void add_matching_states(statelist_t *candidates, uint8_t part_sum_a0, ui
|
|||
uint32_t *bitarray_a8 = part_sum_a8_bitarrays[odd_even][part_sum_a8 / 2];
|
||||
uint32_t *bitarray_bitflips = nonces[best_first_bytes[0]].states_bitarray[odd_even];
|
||||
|
||||
bitarray_AND4(candidates_bitarray, bitarray_a0, bitarray_a8, bitarray_bitflips);
|
||||
bitarray_AND4(cands_bitarray, bitarray_a0, bitarray_a8, bitarray_bitflips);
|
||||
|
||||
bitarray_to_list(best_first_bytes[0], candidates_bitarray, candidates->states[odd_even], &(candidates->len[odd_even]), odd_even);
|
||||
bitarray_to_list(best_first_bytes[0], cands_bitarray, cands->states[odd_even], &(cands->len[odd_even]), odd_even);
|
||||
|
||||
if (candidates->len[odd_even] == 0) {
|
||||
free(candidates->states[odd_even]);
|
||||
candidates->states[odd_even] = NULL;
|
||||
} else if (candidates->len[odd_even] + 1 < worstcase_size) {
|
||||
candidates->states[odd_even] = realloc(candidates->states[odd_even], sizeof(uint32_t) * (candidates->len[odd_even] + 1));
|
||||
if (cands->len[odd_even] == 0) {
|
||||
free(cands->states[odd_even]);
|
||||
cands->states[odd_even] = NULL;
|
||||
} else if (cands->len[odd_even] + 1 < worstcase_size) {
|
||||
cands->states[odd_even] = realloc(cands->states[odd_even], sizeof(uint32_t) * (cands->len[odd_even] + 1));
|
||||
}
|
||||
free_bitarray(candidates_bitarray);
|
||||
free_bitarray(cands_bitarray);
|
||||
|
||||
pthread_mutex_lock(&statelist_cache_mutex);
|
||||
sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].sl = candidates->states[odd_even];
|
||||
sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].len = candidates->len[odd_even];
|
||||
sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].sl = cands->states[odd_even];
|
||||
sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].len = cands->len[odd_even];
|
||||
sl_cache[part_sum_a0 / 2][part_sum_a8 / 2][odd_even].cache_status = COMPLETED;
|
||||
pthread_mutex_unlock(&statelist_cache_mutex);
|
||||
return;
|
||||
|
@ -2108,7 +2109,7 @@ static uint16_t SumProperty(struct Crypto1State *s) {
|
|||
return (sum_odd * (16 - sum_even) + (16 - sum_odd) * sum_even);
|
||||
}
|
||||
|
||||
static void Tests() {
|
||||
static void Tests(void) {
|
||||
|
||||
if (known_target_key == -1)
|
||||
return;
|
||||
|
|
|
@ -949,7 +949,7 @@ static int CmdHFMFPWrbl(const char *Cmd) {
|
|||
#define AES_KEY_LEN 16
|
||||
#define MAX_KEYS_LIST_LEN 1024
|
||||
|
||||
int MFPKeyCheck(uint8_t startSector, uint8_t endSector, uint8_t startKeyAB, uint8_t endKeyAB,
|
||||
static int MFPKeyCheck(uint8_t startSector, uint8_t endSector, uint8_t startKeyAB, uint8_t endKeyAB,
|
||||
uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], size_t keyListLen, uint8_t foundKeys[2][64][AES_KEY_LEN + 1],
|
||||
bool verbose) {
|
||||
int res;
|
||||
|
@ -1027,7 +1027,7 @@ int MFPKeyCheck(uint8_t startSector, uint8_t endSector, uint8_t startKeyAB, uint
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void Fill2bPattern(uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], size_t *keyListLen, uint32_t *startPattern) {
|
||||
static void Fill2bPattern(uint8_t keyList[MAX_KEYS_LIST_LEN][AES_KEY_LEN], size_t *keyListLen, uint32_t *startPattern) {
|
||||
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
|
||||
keyList[*keyListLen][0] = (pt >> 8) & 0xff;
|
||||
keyList[*keyListLen][1] = pt & 0xff;
|
||||
|
|
|
@ -855,7 +855,7 @@ static int ulev1_print_configuration(uint32_t tagtype, uint8_t *data, uint8_t st
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int ulev1_print_counters() {
|
||||
static int ulev1_print_counters(void) {
|
||||
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Counters"));
|
||||
uint8_t tear[1] = {0};
|
||||
uint8_t counter[3] = {0, 0, 0};
|
||||
|
@ -1004,7 +1004,7 @@ static int ulc_magic_test(){
|
|||
return returnValue;
|
||||
}
|
||||
*/
|
||||
static int ul_magic_test() {
|
||||
static int ul_magic_test(void) {
|
||||
// Magic Ultralight tests
|
||||
// 1) take present UID, and try to write it back. OBSOLETE
|
||||
// 2) make a wrong length write to page0, and see if tag answers with ACK/NACK:
|
||||
|
|
|
@ -29,15 +29,6 @@ void printMFUdumpEx(mfu_dump_t *card, uint16_t pages, uint8_t startpage);
|
|||
|
||||
int CmdHFMFUltra(const char *Cmd);
|
||||
|
||||
uint32_t ul_ev1_pwdgenA(uint8_t *uid);
|
||||
uint32_t ul_ev1_pwdgenA(uint8_t *uid);
|
||||
uint32_t ul_ev1_pwdgenC(uint8_t *uid);
|
||||
uint32_t ul_ev1_pwdgenD(uint8_t *uid);
|
||||
|
||||
uint16_t ul_ev1_packgenA(uint8_t *uid);
|
||||
uint16_t ul_ev1_packgenB(uint8_t *uid);
|
||||
uint16_t ul_ev1_packgenC(uint8_t *uid);
|
||||
uint16_t ul_ev1_packgenD(uint8_t *uid);
|
||||
uint16_t ul_ev1_packgen_VCNEW(uint8_t *uid, uint32_t pwd);
|
||||
|
||||
uint32_t ul_ev1_otpgenA(uint8_t *uid);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "lfdemod.h" // device/client demods of LF signals
|
||||
#include "ui.h" // for show graph controls
|
||||
#include "proxgui.h"
|
||||
#include "graph.h" // for graph data
|
||||
#include "cmddata.h" // for `lf search`
|
||||
#include "cmdlfawid.h" // for awid menu
|
||||
|
@ -669,7 +670,7 @@ int CmdLFSniff(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void ChkBitstream() {
|
||||
static void ChkBitstream(void) {
|
||||
// convert to bitstream if necessary
|
||||
for (int i = 0; i < (int)(GraphTraceLen / 2); i++) {
|
||||
if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "util_posix.h"
|
||||
#include "protocols.h"
|
||||
#include "ui.h"
|
||||
#include "proxgui.h"
|
||||
#include "graph.h"
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h"
|
||||
|
@ -1054,7 +1055,7 @@ static int CmdEM4x50Dump(const char *Cmd) {
|
|||
|
||||
#define EM_PREAMBLE_LEN 6
|
||||
// download samples from device and copy to Graphbuffer
|
||||
static bool downloadSamplesEM() {
|
||||
static bool downloadSamplesEM(void) {
|
||||
|
||||
// 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
|
||||
uint8_t got[6000];
|
||||
|
@ -1096,7 +1097,7 @@ static bool doPreambleSearch(size_t *startIdx) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool detectFSK() {
|
||||
static bool detectFSK(void) {
|
||||
// detect fsk clock
|
||||
if (GetFskClock("", false) == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: FSK clock failed");
|
||||
|
@ -1111,7 +1112,7 @@ static bool detectFSK() {
|
|||
return true;
|
||||
}
|
||||
// PSK clocks should be easy to detect ( but difficult to demod a non-repeating pattern... )
|
||||
static bool detectPSK() {
|
||||
static bool detectPSK(void) {
|
||||
int ans = GetPskClock("", false);
|
||||
if (ans <= 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK clock failed");
|
||||
|
@ -1135,7 +1136,7 @@ static bool detectPSK() {
|
|||
return true;
|
||||
}
|
||||
// try manchester - NOTE: ST only applies to T55x7 tags.
|
||||
static bool detectASK_MAN() {
|
||||
static bool detectASK_MAN(void) {
|
||||
bool stcheck = false;
|
||||
if (ASKDemod_ext("0 0 0", false, false, 1, &stcheck) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/Manchester Demod failed");
|
||||
|
@ -1144,7 +1145,7 @@ static bool detectASK_MAN() {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool detectASK_BI() {
|
||||
static bool detectASK_BI(void) {
|
||||
int ans = ASKbiphaseDemod("0 0 1", false);
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed");
|
||||
|
@ -1157,7 +1158,7 @@ static bool detectASK_BI() {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
static bool detectNRZ() {
|
||||
static bool detectNRZ(void) {
|
||||
int ans = NRZrawDemod("0 0 1", false);
|
||||
if (ans != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: NRZ normal demod failed");
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static char *getHitagTypeStr(uint32_t uid) {
|
||||
static const char *getHitagTypeStr(uint32_t uid) {
|
||||
//uid s/n ********
|
||||
uint8_t type = (uid >> 4) & 0xF;
|
||||
switch (type) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "cliparser.h"
|
||||
#include "commonutil.h"
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "proxgui.h"
|
||||
#include "lfdemod.h" // parityTest, bitbytes_to_byte
|
||||
#include "cmddata.h"
|
||||
#include "cmdlf.h" // lf_read
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
@ -70,9 +69,9 @@ static uint64_t getJablontronCardId(uint64_t rawcode) {
|
|||
uint64_t id = 0;
|
||||
uint8_t bytes[] = {0, 0, 0, 0, 0};
|
||||
num_to_bytes(rawcode, 5, bytes);
|
||||
for (int i = 4, j = 0; i > -1; --i, j += 2) {
|
||||
id += NIBBLE_LOW(bytes[i]) * (int)pow(10, j);
|
||||
id += NIBBLE_HIGH(bytes[i]) * (int)pow(10, j + 1);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
id *= 100;
|
||||
id += NIBBLE_HIGH(bytes[i]) * 10 + NIBBLE_LOW(bytes[i]);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,9 @@ static inline uint32_t bitcount(uint32_t a) {
|
|||
}
|
||||
|
||||
static uint8_t isEven_64_63(const uint8_t *data) { // 8
|
||||
return (bitcount(*(uint32_t *) data) + (bitcount((*(uint32_t *)(data + 4)) & 0xfeffffff))) & 1;
|
||||
uint32_t tmp[2];
|
||||
memcpy(tmp, data, 8);
|
||||
return (bitcount(tmp[0]) + (bitcount(tmp[1] & 0xfeffffff))) & 1;
|
||||
}
|
||||
|
||||
//NEDAP demod - ASK/Biphase (or Diphase), RF/64 with preamble of 1111111110 (always a 128 bit data stream)
|
||||
|
@ -163,14 +165,14 @@ static int CmdLFNedapDemod(const char *Cmd) {
|
|||
|
||||
buffer[6] = (data[3] << 7) | ((data[4] & 0xe0) >> 1) | ((data[4] & 0x01) << 3) | ((data[5] & 0xe0) >> 5);
|
||||
buffer[5] = (data[5] << 7) | ((data[6] & 0xe0) >> 1) | ((data[6] & 0x01) << 3) | ((data[7] & 0xe0) >> 5);
|
||||
|
||||
bool isValid = (checksum == *(uint16_t *)(buffer + 5));
|
||||
uint16_t checksum2 = (buffer[6] << 8) + buffer[5];
|
||||
bool isValid = (checksum == checksum2);
|
||||
|
||||
subtype = (data[1] & 0x1e) >> 1;
|
||||
customerCode = ((data[1] & 0x01) << 11) | (data[2] << 3) | ((data[3] & 0xe0) >> 5);
|
||||
|
||||
if (isValid == false) {
|
||||
PrintAndLogEx(ERR, "Checksum : %s (calc 0x%04X != 0x%04X)", _RED_("failed"), checksum, *(uint16_t *)(buffer + 5));
|
||||
PrintAndLogEx(ERR, "Checksum : %s (calc 0x%04X != 0x%04X)", _RED_("failed"), checksum, checksum2);
|
||||
ret = PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct pcf7931_config configPcf = {
|
|||
};
|
||||
|
||||
// Resets the configuration settings to default values.
|
||||
int pcf7931_resetConfig() {
|
||||
int pcf7931_resetConfig(void) {
|
||||
memset(configPcf.Pwd, 0xFF, sizeof(configPcf.Pwd));
|
||||
configPcf.InitDelay = PCF7931_DEFAULT_INITDELAY;
|
||||
configPcf.OffsetWidth = PCF7931_DEFAULT_OFFSET_WIDTH;
|
||||
|
@ -40,7 +40,7 @@ int pcf7931_resetConfig() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int pcf7931_printConfig() {
|
||||
int pcf7931_printConfig(void) {
|
||||
PrintAndLogEx(NORMAL, "Password (LSB first on bytes) : %s", sprint_hex(configPcf.Pwd, sizeof(configPcf.Pwd)));
|
||||
PrintAndLogEx(NORMAL, "Tag initialization delay : %d us", configPcf.InitDelay);
|
||||
PrintAndLogEx(NORMAL, "Offset low pulses width : %d us", configPcf.OffsetWidth);
|
||||
|
@ -48,7 +48,7 @@ int pcf7931_printConfig() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_pcf7931_read() {
|
||||
static int usage_pcf7931_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf pcf7931 read [h] ");
|
||||
PrintAndLogEx(NORMAL, "This command tries to read a PCF7931 tag.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -58,7 +58,7 @@ static int usage_pcf7931_read() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_pcf7931_write() {
|
||||
static int usage_pcf7931_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf pcf7931 write [h] <block address> <byte address> <data>");
|
||||
PrintAndLogEx(NORMAL, "This command tries to write a PCF7931 tag.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -71,7 +71,7 @@ static int usage_pcf7931_write() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_pcf7931_config() {
|
||||
static int usage_pcf7931_config(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf pcf7931 config [h] [r] <pwd> <delay> <offset width> <offset position>");
|
||||
PrintAndLogEx(NORMAL, "This command tries to set the configuration used with PCF7931 commands");
|
||||
PrintAndLogEx(NORMAL, "The time offsets could be useful to correct slew rate generated by the antenna");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "comms.h"
|
||||
#include "commonutil.h"
|
||||
#include "protocols.h"
|
||||
#include "proxgui.h"
|
||||
#include "graph.h"
|
||||
#include "cmddata.h"
|
||||
#include "lfdemod.h"
|
||||
|
@ -56,7 +57,7 @@ t55xx_conf_block_t config = {
|
|||
|
||||
t55xx_memory_item_t cardmem[T55x7_BLOCK_COUNT] = {{0}};
|
||||
|
||||
t55xx_conf_block_t Get_t55xx_Config() {
|
||||
t55xx_conf_block_t Get_t55xx_Config(void) {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,7 @@ static void print_usage_t55xx_downloadlink(uint8_t ShowAll, uint8_t dl_mode_defa
|
|||
PrintAndLogEx(NORMAL, " 4 - Try all downlink modes%s", (dl_mode_default == 4) ? " (default)" : "");
|
||||
}
|
||||
|
||||
static int usage_t55xx_config() {
|
||||
static int usage_t55xx_config(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx config [c <blk0>] [d <demodulation>] [i [0/1]] [o <offset>] [Q5 [0/1]] [ST [0/1]]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h - This help");
|
||||
|
@ -98,7 +99,7 @@ static int usage_t55xx_config() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_read() {
|
||||
static int usage_t55xx_read(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx read [r <mode>] b <block> [p <password>] [o] <page1>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " b <block> - block number to read. Between 0-7");
|
||||
|
@ -118,7 +119,7 @@ static int usage_t55xx_read() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_resetread() {
|
||||
static int usage_t55xx_resetread(void) {
|
||||
PrintAndLogEx(NORMAL, "Send Reset Cmd then lf read the stream to attempt to identify the start of it (needs a demod and/or plot after)");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx resetread [r <mode>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -129,7 +130,7 @@ static int usage_t55xx_resetread() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_write() {
|
||||
static int usage_t55xx_write(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx write [r <mode>] b <block> d <data> [p <password>] [1] [t] [v]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " b <block> - block number to write. Between 0-7");
|
||||
|
@ -147,7 +148,7 @@ static int usage_t55xx_write() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_trace() {
|
||||
static int usage_t55xx_trace(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx trace [1] [r mode]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
print_usage_t55xx_downloadlink(T55XX_DLMODE_SINGLE, config.downlink_mode);
|
||||
|
@ -159,7 +160,7 @@ static int usage_t55xx_trace() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_info() {
|
||||
static int usage_t55xx_info(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx info [1] [r <mode>] [c <blk0> [q]]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " (default) - read data from tag.");
|
||||
|
@ -179,7 +180,7 @@ static int usage_t55xx_info() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_dump() {
|
||||
static int usage_t55xx_dump(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx dump [r <mode>] [p <password> [o]]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " p <password> - OPTIONAL password 4bytes (8 hex symbols)");
|
||||
|
@ -193,7 +194,7 @@ static int usage_t55xx_dump() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_restore() {
|
||||
static int usage_t55xx_restore(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx restore f <filename> [p password]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " f <filename> - filename of the dump file (.bin/.eml)");
|
||||
|
@ -207,7 +208,7 @@ static int usage_t55xx_restore() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_t55xx_detect() {
|
||||
static int usage_t55xx_detect(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx detect [1] [r <mode>] [p <password>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag.");
|
||||
|
@ -221,7 +222,7 @@ static int usage_t55xx_detect() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_detectP1() {
|
||||
static int usage_t55xx_detectP1(void) {
|
||||
PrintAndLogEx(NORMAL, "Command: Detect Page 1 of a t55xx chip");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx p1detect [1] [r <mode>] [p <password>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -236,7 +237,7 @@ static int usage_t55xx_detectP1() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_wakup() {
|
||||
static int usage_t55xx_wakup(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx wakeup [h] [r <mode>] p <password>");
|
||||
PrintAndLogEx(NORMAL, "This commands sends the Answer-On-Request command and leaves the readerfield ON afterwards.");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -248,7 +249,7 @@ static int usage_t55xx_wakup() {
|
|||
PrintAndLogEx(NORMAL, " lf t55xx wakeup p 11223344 - send wakeup password");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_chk() {
|
||||
static int usage_t55xx_chk(void) {
|
||||
PrintAndLogEx(NORMAL, "This command uses a dictionary attack");
|
||||
PrintAndLogEx(NORMAL, "press " _YELLOW_("'enter'") " to cancel the command");
|
||||
PrintAndLogEx(NORMAL, _RED_("WARNING:") " this may brick non-password protected chips!");
|
||||
|
@ -266,7 +267,7 @@ static int usage_t55xx_chk() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_bruteforce() {
|
||||
static int usage_t55xx_bruteforce(void) {
|
||||
PrintAndLogEx(NORMAL, "This command uses bruteforce to scan a number range");
|
||||
PrintAndLogEx(NORMAL, "press " _YELLOW_("'enter'") " to cancel the command");
|
||||
PrintAndLogEx(NORMAL, _RED_("WARNING:") " this may brick non-password protected chips!");
|
||||
|
@ -284,7 +285,7 @@ static int usage_t55xx_bruteforce() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_recoverpw() {
|
||||
static int usage_t55xx_recoverpw(void) {
|
||||
PrintAndLogEx(NORMAL, "This command uses a few tricks to try to recover mangled password");
|
||||
PrintAndLogEx(NORMAL, "press " _YELLOW_("'enter'") " to cancel the command");
|
||||
PrintAndLogEx(NORMAL, _RED_("WARNING:") " this may brick non-password protected chips!");
|
||||
|
@ -305,7 +306,7 @@ static int usage_t55xx_recoverpw() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_wipe() {
|
||||
static int usage_t55xx_wipe(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx wipe [h] [Q5] [p <password>] [c <blk0>]");
|
||||
PrintAndLogEx(NORMAL, "This commands wipes a tag, fills blocks 1-7 with zeros and a default configuration block");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -318,7 +319,7 @@ static int usage_t55xx_wipe() {
|
|||
PrintAndLogEx(NORMAL, " lf t55xx wipe q - wipes a T5555 ( Q5 ) tag, config block 0x6001F004");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_deviceconfig() {
|
||||
static int usage_t55xx_deviceconfig(void) {
|
||||
PrintAndLogEx(NORMAL, "Sets t55x7 timings for direct commands. The timings are set here in Field Clocks (FC), \nwhich is converted to (US) on device");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx deviceconfig [r <mode>] a <gap> b <gap> c <gap> d <gap> e <gap> f <gap> g <gap> [p]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -339,7 +340,7 @@ static int usage_t55xx_deviceconfig() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_protect() {
|
||||
static int usage_t55xx_protect(void) {
|
||||
PrintAndLogEx(NORMAL, "This command sets the pwd bit on T5577.");
|
||||
PrintAndLogEx(NORMAL, _RED_("WARNING:") " this locks the tag!");
|
||||
PrintAndLogEx(NORMAL, "Usage: lf t55xx protect [r <mode>] [p <password>] [o] [n <new_password>]");
|
||||
|
@ -355,7 +356,7 @@ static int usage_t55xx_protect() {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_t55xx_dangerraw() {
|
||||
static int usage_t55xx_dangerraw(void) {
|
||||
PrintAndLogEx(NORMAL, "This command allows to emit arbitrary raw commands on T5577 and cut the field after arbitrary duration.");
|
||||
PrintAndLogEx(NORMAL, _RED_("WARNING:") " this may lock definitively the tag in an unusable state!");
|
||||
PrintAndLogEx(NORMAL, "Uncontrolled usage can easily write an invalid configuration, activate lock bits,");
|
||||
|
@ -371,7 +372,7 @@ static int usage_t55xx_dangerraw() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_t55xx_clonehelp() {
|
||||
static int usage_t55xx_clonehelp(void) {
|
||||
PrintAndLogEx(NORMAL, "For cloning specific techs on T55xx tags, see commands available in corresponding LF sub-menus, e.g.:");
|
||||
PrintAndLogEx(NORMAL, _GREEN_("lf awid clone"));
|
||||
// todo: rename to clone
|
||||
|
@ -407,13 +408,13 @@ static int CmdT55xxCloneHelp(const char *Cmd) {
|
|||
return usage_t55xx_clonehelp();
|
||||
}
|
||||
|
||||
void T55x7_SaveBlockData(uint8_t idx, uint32_t data) {
|
||||
static void T55x7_SaveBlockData(uint8_t idx, uint32_t data) {
|
||||
if (idx < T55x7_BLOCK_COUNT) {
|
||||
cardmem[idx].valid = true;
|
||||
cardmem[idx].blockdata = data;
|
||||
}
|
||||
}
|
||||
void T55x7_ClearAllBlockData(void) {
|
||||
static void T55x7_ClearAllBlockData(void) {
|
||||
for (uint8_t idx = 0; idx < T55x7_BLOCK_COUNT; idx++) {
|
||||
cardmem[idx].valid = false;
|
||||
cardmem[idx].blockdata = 0x00;
|
||||
|
@ -1010,7 +1011,7 @@ static int SanityOfflineCheck(bool useGraphBuffer) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void T55xx_Print_DownlinkMode(uint8_t downlink_mode) {
|
||||
static void T55xx_Print_DownlinkMode(uint8_t downlink_mode) {
|
||||
char msg[80];
|
||||
sprintf(msg, "Downlink Mode used : ");
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "comms.h"
|
||||
#include "crc16.h"
|
||||
#include "ui.h"
|
||||
#include "proxgui.h"
|
||||
#include "graph.h"
|
||||
#include "cmdlfti.h"
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ static int usage_auto(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static void AppendDate(char *s, size_t slen, char *fmt) {
|
||||
static void AppendDate(char *s, size_t slen, const char *fmt) {
|
||||
struct tm *ct, tm_buf;
|
||||
time_t now = time(NULL);
|
||||
#if defined(_WIN32)
|
||||
|
@ -287,7 +287,7 @@ int CommandReceived(char *Cmd) {
|
|||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
command_t *getTopLevelCommandTable() {
|
||||
command_t *getTopLevelCommandTable(void) {
|
||||
return CommandTable;
|
||||
}
|
||||
|
||||
|
|
|
@ -875,7 +875,7 @@ static int CmdSmartList(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void smart_brute_prim() {
|
||||
static void smart_brute_prim(void) {
|
||||
|
||||
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
if (!buf)
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
// trace pointer
|
||||
static uint8_t *trace;
|
||||
long traceLen = 0;
|
||||
static uint8_t *g_trace;
|
||||
long g_traceLen = 0;
|
||||
|
||||
static int usage_trace_list() {
|
||||
static int usage_trace_list(void) {
|
||||
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
|
||||
PrintAndLogEx(NORMAL, "Usage: trace list <protocol> [f][c| <0|1>");
|
||||
PrintAndLogEx(NORMAL, " f - show frame delay times as well");
|
||||
|
@ -56,14 +56,14 @@ static int usage_trace_list() {
|
|||
PrintAndLogEx(NORMAL, " trace list iclass");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_trace_load() {
|
||||
static int usage_trace_load(void) {
|
||||
PrintAndLogEx(NORMAL, "Load protocol data from file to trace buffer.");
|
||||
PrintAndLogEx(NORMAL, "Usage: trace load <filename>");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " trace load mytracefile.bin");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_trace_save() {
|
||||
static int usage_trace_save(void) {
|
||||
PrintAndLogEx(NORMAL, "Save protocol data from trace buffer to file.");
|
||||
PrintAndLogEx(NORMAL, "Usage: trace save <filename>");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
|
@ -491,26 +491,26 @@ static int CmdTraceLoad(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (trace)
|
||||
free(trace);
|
||||
if (g_trace)
|
||||
free(g_trace);
|
||||
|
||||
trace = calloc(fsize, sizeof(uint8_t));
|
||||
if (!trace) {
|
||||
g_trace = calloc(fsize, sizeof(uint8_t));
|
||||
if (!g_trace) {
|
||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||
fclose(f);
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
size_t bytes_read = fread(trace, 1, fsize, f);
|
||||
traceLen = bytes_read;
|
||||
size_t bytes_read = fread(g_trace, 1, fsize, f);
|
||||
g_traceLen = bytes_read;
|
||||
fclose(f);
|
||||
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = %lu bytes) loaded from file %s", traceLen, filename);
|
||||
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = %lu bytes) loaded from file %s", g_traceLen, filename);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdTraceSave(const char *Cmd) {
|
||||
|
||||
if (traceLen == 0) {
|
||||
if (g_traceLen == 0) {
|
||||
PrintAndLogEx(WARNING, "trace is empty, nothing to save");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ static int CmdTraceSave(const char *Cmd) {
|
|||
if (strlen(Cmd) < 1 || cmdp == 'h') return usage_trace_save();
|
||||
|
||||
param_getstr(Cmd, 0, filename, sizeof(filename));
|
||||
saveFile(filename, ".bin", trace, traceLen);
|
||||
saveFile(filename, ".bin", g_trace, g_traceLen);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -628,10 +628,10 @@ int CmdTraceList(const char *Cmd) {
|
|||
|
||||
uint16_t tracepos = 0;
|
||||
|
||||
// reserv some space.
|
||||
if (!trace) {
|
||||
trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
if (trace == NULL) {
|
||||
// reserve some space.
|
||||
if (!g_trace) {
|
||||
g_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
if (g_trace == NULL) {
|
||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
@ -640,38 +640,38 @@ int CmdTraceList(const char *Cmd) {
|
|||
if (isOnline) {
|
||||
// Query for the size of the trace, downloading PM3_CMD_DATA_SIZE
|
||||
PacketResponseNG response;
|
||||
if (!GetFromDevice(BIG_BUF, trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) {
|
||||
if (!GetFromDevice(BIG_BUF, g_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
traceLen = response.oldarg[2];
|
||||
if (traceLen > PM3_CMD_DATA_SIZE) {
|
||||
uint8_t *p = realloc(trace, traceLen);
|
||||
g_traceLen = response.oldarg[2];
|
||||
if (g_traceLen > PM3_CMD_DATA_SIZE) {
|
||||
uint8_t *p = realloc(g_trace, g_traceLen);
|
||||
if (p == NULL) {
|
||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||
free(trace);
|
||||
free(g_trace);
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
trace = p;
|
||||
if (!GetFromDevice(BIG_BUF, trace, traceLen, 0, NULL, 0, NULL, 2500, false)) {
|
||||
g_trace = p;
|
||||
if (!GetFromDevice(BIG_BUF, g_trace, g_traceLen, 0, NULL, 0, NULL, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
free(trace);
|
||||
free(g_trace);
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Recorded activity (trace len = " _YELLOW_("%lu") " bytes)", traceLen);
|
||||
PrintAndLogEx(SUCCESS, "Recorded activity (trace len = " _YELLOW_("%lu") " bytes)", g_traceLen);
|
||||
|
||||
/*
|
||||
if (protocol == FELICA) {
|
||||
printFelica(traceLen, trace);
|
||||
printFelica(g_traceLen, g_trace);
|
||||
} */
|
||||
|
||||
if (showHex) {
|
||||
while (tracepos < traceLen) {
|
||||
tracepos = printHexLine(tracepos, traceLen, trace, protocol);
|
||||
while (tracepos < g_traceLen) {
|
||||
tracepos = printHexLine(tracepos, g_traceLen, g_trace, protocol);
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(INFO, _YELLOW_("Start") " = Start of Start Bit, " _YELLOW_("End") " = End of last modulation. " _YELLOW_("Src") " = Source of Transfer");
|
||||
|
@ -700,8 +700,8 @@ int CmdTraceList(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "------------+------------+-----+-------------------------------------------------------------------------+-----+--------------------");
|
||||
|
||||
ClearAuthData();
|
||||
while (tracepos < traceLen) {
|
||||
tracepos = printTraceLine(tracepos, traceLen, trace, protocol, showWaitCycles, markCRCBytes);
|
||||
while (tracepos < g_traceLen) {
|
||||
tracepos = printTraceLine(tracepos, g_traceLen, g_trace, protocol, showWaitCycles, markCRCBytes);
|
||||
|
||||
if (kbd_enter_pressed())
|
||||
break;
|
||||
|
|
|
@ -274,7 +274,7 @@ static int usart_bt_testcomm(uint32_t baudrate, uint8_t parity) {
|
|||
if (ret != PM3_SUCCESS)
|
||||
return ret;
|
||||
|
||||
char *string = "AT+VERSION";
|
||||
const char *string = "AT+VERSION";
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
size_t len = 0;
|
||||
|
||||
|
@ -359,7 +359,7 @@ static int CmdUsartBtFactory(const char *Cmd) {
|
|||
}
|
||||
|
||||
PrintAndLogEx(INFO, "Reconfiguring add-on to default settings.");
|
||||
char *string;
|
||||
const char *string;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
size_t len = 0;
|
||||
memset(data, 0, sizeof(data));
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int usage_wiegand_list() {
|
||||
static int usage_wiegand_list(void) {
|
||||
PrintAndLogEx(NORMAL, "List available wiegand formats");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_wiegand_encode() {
|
||||
static int usage_wiegand_encode(void) {
|
||||
PrintAndLogEx(NORMAL, "Encode wiegand formatted number to raw hex");
|
||||
PrintAndLogEx(NORMAL, "Usage: wiegand encode [w <format>] [<field> <value (decimal)>] {...}");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -42,7 +42,7 @@ static int usage_wiegand_encode() {
|
|||
PrintAndLogEx(NORMAL, " wiegand encode w H10301 f 101 c 1337");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_wiegand_decode() {
|
||||
static int usage_wiegand_decode(void) {
|
||||
PrintAndLogEx(NORMAL, "Decode raw hex to wiegand format");
|
||||
PrintAndLogEx(NORMAL, "Usage: wiegand decode [id] <p>");
|
||||
PrintAndLogEx(NORMAL, " p ignore invalid parity");
|
||||
|
@ -52,7 +52,7 @@ static int usage_wiegand_decode() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
void PrintTagId(wiegand_message_t *packed) {
|
||||
static void PrintTagId(wiegand_message_t *packed) {
|
||||
if (packed->Top != 0) {
|
||||
PrintAndLogEx(SUCCESS, "Card ID: %X%08X%08X",
|
||||
(uint32_t)packed->Top,
|
||||
|
|
|
@ -202,7 +202,7 @@ void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, v
|
|||
* A better method could have been to have explicit command-ACKS, so we can know which ACK goes to which
|
||||
* operation. Right now we'll just have to live with this.
|
||||
*/
|
||||
void clearCommandBuffer() {
|
||||
void clearCommandBuffer(void) {
|
||||
//This is a very simple operation
|
||||
pthread_mutex_lock(&rxBufferMutex);
|
||||
cmd_tail = cmd_head;
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
#include "pm3_cmd.h" // Packet structs
|
||||
#include "util.h" // FILE_PATH_SIZE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DropField
|
||||
#define DropField() { \
|
||||
clearCommandBuffer(); SendCommandNG(CMD_HF_DROPFIELD, NULL, 0); \
|
||||
|
@ -83,6 +87,9 @@ bool WaitForResponse(uint32_t cmd, PacketResponseNG *response);
|
|||
//bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, uint8_t *data, uint32_t datalen, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1151,7 +1151,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
fclose(f);
|
||||
goto out;
|
||||
} else {
|
||||
memset(*pdata + (mem_size - block_size), 0, block_size);
|
||||
memset((uint8_t *)*pdata + (mem_size - block_size), 0, block_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
|
||||
uint64_t key = strtoull(line, NULL, 16);
|
||||
|
||||
num_to_bytes(key, keylen >> 1, *pdata + (*keycnt * (keylen >> 1)));
|
||||
num_to_bytes(key, keylen >> 1, (uint8_t *)*pdata + (*keycnt * (keylen >> 1)));
|
||||
|
||||
(*keycnt)++;
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
|||
(strcmp(FIRMWARES_SUBDIR, pm3dir) == 0) ||
|
||||
(strcmp(BOOTROM_SUBDIR, pm3dir) == 0) ||
|
||||
(strcmp(FULLIMAGE_SUBDIR, pm3dir) == 0))) {
|
||||
char *above = "../";
|
||||
const char *above = "../";
|
||||
char *path = calloc(strlen(exec_path) + strlen(above) + strlen(pm3dir) + strlen(filename) + 1, sizeof(char));
|
||||
if (path == NULL)
|
||||
goto out;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ui.h"
|
||||
#include "proxgui.h"
|
||||
#include "util.h" //param_get32ex
|
||||
#include "lfdemod.h"
|
||||
#include "cmddata.h" //for g_debugmode
|
||||
|
@ -115,7 +116,7 @@ bool isGraphBitstream(void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void convertGraphFromBitstream() {
|
||||
void convertGraphFromBitstream(void) {
|
||||
convertGraphFromBitstreamEx(1, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void AppendGraph(bool redraw, uint16_t clock, int bit);
|
||||
size_t ClearGraph(bool redraw);
|
||||
bool HasGraphData(void);
|
||||
|
@ -30,10 +34,7 @@ int GetNrzClock(const char *str, bool printAns);
|
|||
int GetFskClock(const char *str, bool printAns);
|
||||
bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge);
|
||||
|
||||
// Max graph trace len: 40000 (bigbuf) * 8 (at 1 bit per sample)
|
||||
#ifndef MAX_GRAPH_TRACE_LEN
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8 )
|
||||
#endif
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8)
|
||||
#define GRAPH_SAVE 1
|
||||
#define GRAPH_RESTORE 0
|
||||
|
||||
|
@ -41,4 +42,7 @@ extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
|||
extern size_t GraphTraceLen;
|
||||
extern int s_Buff[MAX_GRAPH_TRACE_LEN];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -283,7 +283,7 @@ void doMAC_N(uint8_t *address_data_p, uint8_t address_data_size, uint8_t *div_ke
|
|||
}
|
||||
|
||||
#ifndef ON_DEVICE
|
||||
int testMAC() {
|
||||
int testMAC(void) {
|
||||
PrintAndLogEx(SUCCESS, "Testing MAC calculation...");
|
||||
|
||||
//From the "dismantling.IClass" paper:
|
||||
|
|
|
@ -190,7 +190,7 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
|
|||
//-----------------------------
|
||||
|
||||
#ifndef ON_DEVICE
|
||||
static int testBitStream() {
|
||||
static int testBitStream(void) {
|
||||
uint8_t input [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF};
|
||||
uint8_t output [] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
BitstreamIn in = { input, sizeof(input) * 8, 0};
|
||||
|
@ -215,7 +215,7 @@ static int testBitStream() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int testReversedBitstream() {
|
||||
static int testReversedBitstream(void) {
|
||||
uint8_t input [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD, 0xBE, 0xEF};
|
||||
uint8_t reverse [] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t output [] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
|
|
@ -61,7 +61,6 @@ void pushBit(BitstreamOut *stream, bool bit);
|
|||
int bitsLeft(BitstreamIn *stream);
|
||||
#ifndef ON_DEVICE
|
||||
int testCipherUtils(void);
|
||||
int testMAC(void);
|
||||
#endif
|
||||
void push6bits(BitstreamOut *stream, uint8_t bits);
|
||||
void EncryptDES(bool key[56], bool outBlk[64], bool inBlk[64], int verbose) ;
|
||||
|
|
|
@ -568,7 +568,7 @@ int bruteforceFileNoKeys(const char *filename) {
|
|||
// ----------------------------------------------------------------------------
|
||||
// TEST CODE BELOW
|
||||
// ----------------------------------------------------------------------------
|
||||
static int _testBruteforce() {
|
||||
static int _testBruteforce(void) {
|
||||
|
||||
PrintAndLogEx(INFO, "Testing crack from dumpfile...");
|
||||
|
||||
|
@ -596,7 +596,7 @@ static int _testBruteforce() {
|
|||
return errors;
|
||||
}
|
||||
|
||||
static int _test_iclass_key_permutation() {
|
||||
static int _test_iclass_key_permutation(void) {
|
||||
uint8_t testcase[8] = {0x6c, 0x8d, 0x44, 0xf9, 0x2a, 0x2d, 0x01, 0xbf};
|
||||
uint8_t testcase_output[8] = {0};
|
||||
uint8_t testcase_output_correct[8] = {0x8a, 0x0d, 0xb9, 0x88, 0xbb, 0xa7, 0x90, 0xea};
|
||||
|
@ -622,7 +622,7 @@ static int _test_iclass_key_permutation() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int _testHash1() {
|
||||
static int _testHash1(void) {
|
||||
uint8_t expected[8] = {0x7E, 0x72, 0x2F, 0x40, 0x2D, 0x02, 0x51, 0x42};
|
||||
uint8_t csn[8] = {0x01, 0x02, 0x03, 0x04, 0xF7, 0xFF, 0x12, 0xE0};
|
||||
uint8_t k[8] = {0};
|
||||
|
|
|
@ -219,7 +219,7 @@ static void permute(BitstreamIn *p_in, uint64_t z, int l, int r, BitstreamOut *o
|
|||
}
|
||||
}
|
||||
|
||||
static void printbegin() {
|
||||
static void printbegin(void) {
|
||||
if (debug_print < 2)
|
||||
return;
|
||||
|
||||
|
@ -369,7 +369,7 @@ void diversifyKey(uint8_t csn[8], uint8_t key[8], uint8_t div_key[8]) {
|
|||
hash0(crypt_csn, div_key);
|
||||
}
|
||||
/*
|
||||
static void testPermute() {
|
||||
static void testPermute(void) {
|
||||
uint64_t x = 0;
|
||||
pushbackSixBitByte(&x, 0x00, 0);
|
||||
pushbackSixBitByte(&x, 0x01, 1);
|
||||
|
@ -555,7 +555,7 @@ Testcase testcases[] = {
|
|||
{{0}, {0}, {0}}
|
||||
};
|
||||
|
||||
static int testKeyDiversificationWithMasterkeyTestcases() {
|
||||
static int testKeyDiversificationWithMasterkeyTestcases(void) {
|
||||
int i, error = 0;
|
||||
uint8_t empty[8] = {0};
|
||||
|
||||
|
@ -630,7 +630,7 @@ static int testDES2(uint64_t csn, uint64_t expected) {
|
|||
* @brief doTestsWithKnownInputs
|
||||
* @return
|
||||
*/
|
||||
static int doTestsWithKnownInputs() {
|
||||
static int doTestsWithKnownInputs(void) {
|
||||
// KSel from http://www.proxmark.org/forum/viewtopic.php?pid=10977#p10977
|
||||
int errors = 0;
|
||||
PrintAndLogEx(SUCCESS, "Testing DES encryption");
|
||||
|
|
|
@ -45,11 +45,14 @@ uint32_t intersection(uint64_t *listA, uint64_t *listB) {
|
|||
// Darkside attack (hf mf mifare)
|
||||
// if successful it will return a list of keys, not just one.
|
||||
uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par_info, uint64_t ks_info, uint64_t **keys) {
|
||||
struct Crypto1State *states;
|
||||
union {
|
||||
struct Crypto1State *states;
|
||||
uint64_t *keylist;
|
||||
} unionstate;
|
||||
|
||||
uint32_t i, pos;
|
||||
uint8_t ks3x[8], par[8][8];
|
||||
uint64_t key_recovered;
|
||||
uint64_t *keylist;
|
||||
|
||||
// Reset the last three significant bits of the reader nonce
|
||||
nr &= 0xFFFFFF1F;
|
||||
|
@ -68,23 +71,21 @@ uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t
|
|||
par[7 - pos][7] = (bt >> 7) & 1;
|
||||
}
|
||||
|
||||
states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0));
|
||||
unionstate.states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0));
|
||||
|
||||
if (!states) {
|
||||
if (!unionstate.states) {
|
||||
*keys = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
keylist = (uint64_t *)states;
|
||||
|
||||
for (i = 0; keylist[i]; i++) {
|
||||
lfsr_rollback_word(states + i, uid ^ nt, 0);
|
||||
crypto1_get_lfsr(states + i, &key_recovered);
|
||||
keylist[i] = key_recovered;
|
||||
for (i = 0; unionstate.keylist[i]; i++) {
|
||||
lfsr_rollback_word(unionstate.states + i, uid ^ nt, 0);
|
||||
crypto1_get_lfsr(unionstate.states + i, &key_recovered);
|
||||
unionstate.keylist[i] = key_recovered;
|
||||
}
|
||||
keylist[i] = -1;
|
||||
unionstate.keylist[i] = -1;
|
||||
|
||||
*keys = keylist;
|
||||
*keys = unionstate.keylist;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,42 +90,42 @@ const char *mfGetAccessConditionsDesc(uint8_t blockn, uint8_t *data) {
|
|||
return StaticNone;
|
||||
}
|
||||
/*
|
||||
static int CalculateEncIVCommand(mf4Session_t *session, uint8_t *iv, bool verbose) {
|
||||
memcpy(&iv[0], &session->TI, 4);
|
||||
memcpy(&iv[4], &session->R_Ctr, 2);
|
||||
memcpy(&iv[6], &session->W_Ctr, 2);
|
||||
memcpy(&iv[8], &session->R_Ctr, 2);
|
||||
memcpy(&iv[10], &session->W_Ctr, 2);
|
||||
memcpy(&iv[12], &session->R_Ctr, 2);
|
||||
memcpy(&iv[14], &session->W_Ctr, 2);
|
||||
static int CalculateEncIVCommand(mf4Session_t *mf4session, uint8_t *iv, bool verbose) {
|
||||
memcpy(&iv[0], &mf4session->TI, 4);
|
||||
memcpy(&iv[4], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[6], &mf4session->W_Ctr, 2);
|
||||
memcpy(&iv[8], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[10], &mf4session->W_Ctr, 2);
|
||||
memcpy(&iv[12], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[14], &mf4session->W_Ctr, 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int CalculateEncIVResponse(mf4Session *session, uint8_t *iv, bool verbose) {
|
||||
memcpy(&iv[0], &session->R_Ctr, 2);
|
||||
memcpy(&iv[2], &session->W_Ctr, 2);
|
||||
memcpy(&iv[4], &session->R_Ctr, 2);
|
||||
memcpy(&iv[6], &session->W_Ctr, 2);
|
||||
memcpy(&iv[8], &session->R_Ctr, 2);
|
||||
memcpy(&iv[10], &session->W_Ctr, 2);
|
||||
memcpy(&iv[12], &session->TI, 4);
|
||||
static int CalculateEncIVResponse(mf4Session *mf4session, uint8_t *iv, bool verbose) {
|
||||
memcpy(&iv[0], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[2], &mf4session->W_Ctr, 2);
|
||||
memcpy(&iv[4], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[6], &mf4session->W_Ctr, 2);
|
||||
memcpy(&iv[8], &mf4session->R_Ctr, 2);
|
||||
memcpy(&iv[10], &mf4session->W_Ctr, 2);
|
||||
memcpy(&iv[12], &mf4session->TI, 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
int CalculateMAC(mf4Session_t *session, MACType_t mtype, uint8_t blockNum, uint8_t blockCount, uint8_t *data, int datalen, uint8_t *mac, bool verbose) {
|
||||
if (!session || !session->Authenticated || !mac || !data || !datalen)
|
||||
int CalculateMAC(mf4Session_t *mf4session, MACType_t mtype, uint8_t blockNum, uint8_t blockCount, uint8_t *data, int datalen, uint8_t *mac, bool verbose) {
|
||||
if (!mf4session || !mf4session->Authenticated || !mac || !data || !datalen)
|
||||
return 1;
|
||||
|
||||
memset(mac, 0x00, 8);
|
||||
|
||||
uint16_t ctr = session->R_Ctr;
|
||||
uint16_t ctr = mf4session->R_Ctr;
|
||||
switch (mtype) {
|
||||
case mtypWriteCmd:
|
||||
case mtypWriteResp:
|
||||
ctr = session->W_Ctr;
|
||||
ctr = mf4session->W_Ctr;
|
||||
break;
|
||||
case mtypReadCmd:
|
||||
case mtypReadResp:
|
||||
|
@ -134,7 +134,7 @@ int CalculateMAC(mf4Session_t *session, MACType_t mtype, uint8_t blockNum, uint8
|
|||
|
||||
uint8_t macdata[2049] = {data[0], (ctr & 0xFF), (ctr >> 8), 0};
|
||||
int macdatalen = datalen;
|
||||
memcpy(&macdata[3], session->TI, 4);
|
||||
memcpy(&macdata[3], mf4session->TI, 4);
|
||||
|
||||
switch (mtype) {
|
||||
case mtypReadCmd:
|
||||
|
@ -160,10 +160,10 @@ int CalculateMAC(mf4Session_t *session, MACType_t mtype, uint8_t blockNum, uint8
|
|||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "MAC data[%d]: %s", macdatalen, sprint_hex(macdata, macdatalen));
|
||||
|
||||
return aes_cmac8(NULL, session->Kmac, macdata, mac, macdatalen);
|
||||
return aes_cmac8(NULL, mf4session->Kmac, macdata, mac, macdatalen);
|
||||
}
|
||||
|
||||
int MifareAuth4(mf4Session_t *session, uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool dropFieldIfError, bool verbose, bool silentMode) {
|
||||
int MifareAuth4(mf4Session_t *mf4session, uint8_t *keyn, uint8_t *key, bool activateField, bool leaveSignalON, bool dropFieldIfError, bool verbose, bool silentMode) {
|
||||
uint8_t data[257] = {0};
|
||||
int datalen = 0;
|
||||
|
||||
|
@ -173,8 +173,8 @@ int MifareAuth4(mf4Session_t *session, uint8_t *keyn, uint8_t *key, bool activat
|
|||
if (silentMode)
|
||||
verbose = false;
|
||||
|
||||
if (session)
|
||||
session->Authenticated = false;
|
||||
if (mf4session)
|
||||
mf4session->Authenticated = false;
|
||||
|
||||
uint8_t cmd1[] = {0x70, keyn[1], keyn[0], 0x00};
|
||||
int res = ExchangeRAW14a(cmd1, sizeof(cmd1), activateField, true, data, sizeof(data), &datalen, silentMode);
|
||||
|
@ -284,19 +284,19 @@ int MifareAuth4(mf4Session_t *session, uint8_t *keyn, uint8_t *key, bool activat
|
|||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
if (session) {
|
||||
session->Authenticated = true;
|
||||
session->R_Ctr = 0;
|
||||
session->W_Ctr = 0;
|
||||
session->KeyNum = keyn[1] + (keyn[0] << 8);
|
||||
memmove(session->RndA, RndA, 16);
|
||||
memmove(session->RndB, RndB, 16);
|
||||
memmove(session->Key, key, 16);
|
||||
memmove(session->TI, raw, 4);
|
||||
memmove(session->PICCap2, &raw[20], 6);
|
||||
memmove(session->PCDCap2, &raw[26], 6);
|
||||
memmove(session->Kenc, kenc, 16);
|
||||
memmove(session->Kmac, kmac, 16);
|
||||
if (mf4session) {
|
||||
mf4session->Authenticated = true;
|
||||
mf4session->R_Ctr = 0;
|
||||
mf4session->W_Ctr = 0;
|
||||
mf4session->KeyNum = keyn[1] + (keyn[0] << 8);
|
||||
memmove(mf4session->RndA, RndA, 16);
|
||||
memmove(mf4session->RndB, RndB, 16);
|
||||
memmove(mf4session->Key, key, 16);
|
||||
memmove(mf4session->TI, raw, 4);
|
||||
memmove(mf4session->PICCap2, &raw[20], 6);
|
||||
memmove(mf4session->PCDCap2, &raw[26], 6);
|
||||
memmove(mf4session->Kenc, kenc, 16);
|
||||
memmove(mf4session->Kmac, kmac, 16);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
|
@ -330,39 +330,39 @@ int MFPCommitPerso(bool activateField, bool leaveSignalON, uint8_t *dataout, int
|
|||
return intExchangeRAW14aPlus(rcmd, sizeof(rcmd), activateField, leaveSignalON, dataout, maxdataoutlen, dataoutlen);
|
||||
}
|
||||
|
||||
int MFPReadBlock(mf4Session_t *session, bool plain, uint8_t blockNum, uint8_t blockCount, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, uint8_t *mac) {
|
||||
int MFPReadBlock(mf4Session_t *mf4session, bool plain, uint8_t blockNum, uint8_t blockCount, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, uint8_t *mac) {
|
||||
uint8_t rcmd[4 + 8] = {(plain ? (0x37) : (0x33)), blockNum, 0x00, blockCount};
|
||||
if (!plain && session)
|
||||
CalculateMAC(session, mtypReadCmd, blockNum, blockCount, rcmd, 4, &rcmd[4], VerboseMode);
|
||||
if (!plain && mf4session)
|
||||
CalculateMAC(mf4session, mtypReadCmd, blockNum, blockCount, rcmd, 4, &rcmd[4], VerboseMode);
|
||||
|
||||
int res = intExchangeRAW14aPlus(rcmd, plain ? 4 : sizeof(rcmd), activateField, leaveSignalON, dataout, maxdataoutlen, dataoutlen);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (session)
|
||||
session->R_Ctr++;
|
||||
if (mf4session)
|
||||
mf4session->R_Ctr++;
|
||||
|
||||
if (session && mac && *dataoutlen > 11)
|
||||
CalculateMAC(session, mtypReadResp, blockNum, blockCount, dataout, *dataoutlen - 8 - 2, mac, VerboseMode);
|
||||
if (mf4session && mac && *dataoutlen > 11)
|
||||
CalculateMAC(mf4session, mtypReadResp, blockNum, blockCount, dataout, *dataoutlen - 8 - 2, mac, VerboseMode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MFPWriteBlock(mf4Session_t *session, uint8_t blockNum, uint8_t *data, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, uint8_t *mac) {
|
||||
int MFPWriteBlock(mf4Session_t *mf4session, uint8_t blockNum, uint8_t *data, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, uint8_t *mac) {
|
||||
uint8_t rcmd[1 + 2 + 16 + 8] = {0xA3, blockNum, 0x00};
|
||||
memmove(&rcmd[3], data, 16);
|
||||
if (session)
|
||||
CalculateMAC(session, mtypWriteCmd, blockNum, 1, rcmd, 19, &rcmd[19], VerboseMode);
|
||||
if (mf4session)
|
||||
CalculateMAC(mf4session, mtypWriteCmd, blockNum, 1, rcmd, 19, &rcmd[19], VerboseMode);
|
||||
|
||||
int res = intExchangeRAW14aPlus(rcmd, sizeof(rcmd), activateField, leaveSignalON, dataout, maxdataoutlen, dataoutlen);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
if (session)
|
||||
session->W_Ctr++;
|
||||
if (mf4session)
|
||||
mf4session->W_Ctr++;
|
||||
|
||||
if (session && mac && *dataoutlen > 3)
|
||||
CalculateMAC(session, mtypWriteResp, blockNum, 1, dataout, *dataoutlen, mac, VerboseMode);
|
||||
if (mf4session && mac && *dataoutlen > 3)
|
||||
CalculateMAC(mf4session, mtypWriteResp, blockNum, 1, dataout, *dataoutlen, mac, VerboseMode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ __attribute__((force_align_arg_pointer))
|
|||
StateList_t *statelist = arg;
|
||||
statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt_enc ^ statelist->uid);
|
||||
|
||||
for (p1 = statelist->head.slhead; * (uint64_t *)p1 != 0; p1++) {};
|
||||
for (p1 = statelist->head.slhead; p1->odd | p1->even; p1++) {};
|
||||
|
||||
statelist->len = p1 - statelist->head.slhead;
|
||||
statelist->tail.sltail = --p1;
|
||||
|
@ -492,8 +492,10 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
|||
}
|
||||
}
|
||||
|
||||
*(uint64_t *)p3 = -1;
|
||||
*(uint64_t *)p4 = -1;
|
||||
p3->odd = -1;
|
||||
p3->even = -1;
|
||||
p4->odd = -1;
|
||||
p4->even = -1;
|
||||
statelists[0].len = p3 - statelists[0].head.slhead;
|
||||
statelists[1].len = p4 - statelists[1].head.slhead;
|
||||
statelists[0].tail.sltail = --p3;
|
||||
|
@ -637,7 +639,8 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl
|
|||
}
|
||||
}
|
||||
|
||||
*(uint64_t *)p3 = -1;
|
||||
p3->odd = -1;
|
||||
p3->even = -1;
|
||||
statelists[0].len = p3 - statelists[0].head.slhead;
|
||||
statelists[0].tail.sltail = --p3;
|
||||
|
||||
|
|
|
@ -203,7 +203,8 @@ static int l_unpack(lua_State *L) { /** unpack(f,s, [init]) */
|
|||
#define PACKNUMBER(OP,T) \
|
||||
case OP: \
|
||||
{ \
|
||||
T a=(T)luaL_checknumber(L,i++); \
|
||||
lua_Number n = luaL_checknumber(L,i++); \
|
||||
T a=(T)n; \
|
||||
doswap(swap,&a,sizeof(a)); \
|
||||
luaL_addlstring(&b,(char*)&a,sizeof(a)); \
|
||||
break; \
|
||||
|
@ -318,6 +319,7 @@ static const luaL_Reg binlib[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
LUALIB_API int luaopen_binlib(lua_State *L);
|
||||
LUALIB_API int luaopen_binlib(lua_State *L) {
|
||||
luaL_newlib(L, binlib);
|
||||
return 1;
|
||||
|
|
|
@ -92,16 +92,18 @@ typedef size_t lua_UInteger;
|
|||
#define LOGICAL_SHIFT(name, op) \
|
||||
static int bit_ ## name(lua_State *L) { \
|
||||
lua_Number f; \
|
||||
lua_Number n = luaL_checknumber(L, 2); \
|
||||
lua_pushinteger(L, BIT_TRUNCATE(BIT_TRUNCATE((lua_UInteger)TOBIT(L, 1, f)) op \
|
||||
(unsigned)luaL_checknumber(L, 2))); \
|
||||
(unsigned)n)); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
#define ARITHMETIC_SHIFT(name, op) \
|
||||
static int bit_ ## name(lua_State *L) { \
|
||||
lua_Number f; \
|
||||
lua_Number n = luaL_checknumber(L, 2); \
|
||||
lua_pushinteger(L, BIT_TRUNCATE((lua_Integer)TOBIT(L, 1, f) op \
|
||||
(unsigned)luaL_checknumber(L, 2))); \
|
||||
(unsigned)n)); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
|
@ -126,6 +128,7 @@ static const struct luaL_Reg bitlib[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
LUALIB_API int luaopen_bit(lua_State *L);
|
||||
LUALIB_API int luaopen_bit(lua_State *L) {
|
||||
luaL_newlib(L, bitlib);
|
||||
//luaL_register(L, "bit", bitlib);
|
||||
|
|
|
@ -44,7 +44,7 @@ static char *prefGetFilename(void) {
|
|||
if (searchHomeFilePath(&path, preferencesFilename, false) == PM3_SUCCESS)
|
||||
return path;
|
||||
else
|
||||
return preferencesFilename;
|
||||
return strdup(preferencesFilename);
|
||||
}
|
||||
|
||||
int preferences_load(void) {
|
||||
|
@ -314,7 +314,7 @@ void preferences_load_callback(json_t *root) {
|
|||
|
||||
// Help Functions
|
||||
|
||||
static int usage_set_emoji() {
|
||||
static int usage_set_emoji(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set emoji <alias | emoji | alttext | erase>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -325,7 +325,7 @@ static int usage_set_emoji() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_set_color() {
|
||||
static int usage_set_color(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set color <off | ansi>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -334,7 +334,7 @@ static int usage_set_color() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_set_debug() {
|
||||
static int usage_set_debug(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set clientdebug <off | simple | full>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -344,7 +344,7 @@ static int usage_set_debug() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
/*
|
||||
static int usage_set_devicedebug() {
|
||||
static int usage_set_devicedebug(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set devicedebug <off | error | info | debug | extended>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -357,7 +357,7 @@ static int usage_set_devicedebug() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
static int usage_set_hints() {
|
||||
static int usage_set_hints(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set hints <off | on>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -366,7 +366,7 @@ static int usage_set_hints() {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
/*
|
||||
static int usage_set_savePaths() {
|
||||
static int usage_set_savePaths(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: pref set savepaths [help] [create] [default <path>] [dump <path>] [trace <path>]");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " "_GREEN_("help")" - This help");
|
||||
|
@ -382,7 +382,7 @@ static int usage_set_savePaths() {
|
|||
// typedef enum preferenceId {prefNONE,prefHELP,prefEMOJI,prefCOLOR,prefPLOT,prefOVERLAY,prefHINTS,prefCLIENTDEBUG} preferenceId_t;
|
||||
typedef enum prefShowOpt {prefShowNone, prefShowOLD, prefShowNEW} prefShowOpt_t;
|
||||
|
||||
const char *prefShowMsg(prefShowOpt_t Opt) {
|
||||
static const char *prefShowMsg(prefShowOpt_t Opt) {
|
||||
switch (Opt) {
|
||||
case prefShowOLD:
|
||||
return _YELLOW_("[old]");
|
||||
|
@ -395,7 +395,7 @@ const char *prefShowMsg(prefShowOpt_t Opt) {
|
|||
return "";
|
||||
}
|
||||
|
||||
void showEmojiState(prefShowOpt_t Opt) {
|
||||
static void showEmojiState(prefShowOpt_t Opt) {
|
||||
|
||||
switch (session.emoji_mode) {
|
||||
case ALIAS:
|
||||
|
@ -415,7 +415,7 @@ void showEmojiState(prefShowOpt_t Opt) {
|
|||
}
|
||||
}
|
||||
|
||||
void showColorState(prefShowOpt_t Opt) {
|
||||
static void showColorState(prefShowOpt_t Opt) {
|
||||
|
||||
if (session.supports_colors)
|
||||
PrintAndLogEx(NORMAL, " %s color.................. "_GREEN_("ansi"), prefShowMsg(Opt));
|
||||
|
@ -423,7 +423,7 @@ void showColorState(prefShowOpt_t Opt) {
|
|||
PrintAndLogEx(NORMAL, " %s color.................. "_WHITE_("off"), prefShowMsg(Opt));
|
||||
}
|
||||
|
||||
void showClientDebugState(prefShowOpt_t Opt) {
|
||||
static void showClientDebugState(prefShowOpt_t Opt) {
|
||||
|
||||
switch (session.client_debug_level) {
|
||||
case cdbOFF:
|
||||
|
@ -440,7 +440,7 @@ void showClientDebugState(prefShowOpt_t Opt) {
|
|||
}
|
||||
}
|
||||
/*
|
||||
void showDeviceDebugState(prefShowOpt_t Opt) {
|
||||
static void showDeviceDebugState(prefShowOpt_t Opt) {
|
||||
switch (session.device_debug_level) {
|
||||
case ddbOFF:
|
||||
PrintAndLogEx(NORMAL, " %s device debug........... "_WHITE_("off"), prefShowMsg(Opt));
|
||||
|
@ -463,7 +463,7 @@ void showDeviceDebugState(prefShowOpt_t Opt) {
|
|||
}
|
||||
*/
|
||||
/*
|
||||
void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||
static void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
||||
|
||||
char tempStr[50];
|
||||
|
||||
|
@ -485,18 +485,19 @@ void showSavePathState(savePaths_t pathIndex, prefShowOpt_t Opt) {
|
|||
else
|
||||
PrintAndLogEx(NORMAL, " %s %s "_GREEN_("%s"), prefShowMsg(Opt), tempStr, session.defaultPaths[pathIndex]);
|
||||
}
|
||||
*/
|
||||
void showPlotPosState(void) {
|
||||
|
||||
static void showPlotPosState(void) {
|
||||
PrintAndLogEx(NORMAL, " Plot window............ X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.plot.x, session.plot.y, session.plot.h, session.plot.w);
|
||||
}
|
||||
|
||||
void showOverlayPosState(void) {
|
||||
static void showOverlayPosState(void) {
|
||||
PrintAndLogEx(NORMAL, " Slider/Overlay window.. X "_GREEN_("%4d")" Y "_GREEN_("%4d")" H "_GREEN_("%4d")" W "_GREEN_("%4d"),
|
||||
session.overlay.x, session.overlay.y, session.overlay.h, session.overlay.w);
|
||||
}
|
||||
*/
|
||||
|
||||
void showHintsState(prefShowOpt_t Opt) {
|
||||
static void showHintsState(prefShowOpt_t Opt) {
|
||||
if (session.show_hints)
|
||||
PrintAndLogEx(NORMAL, " %s hints.................. "_GREEN_("on"), prefShowMsg(Opt));
|
||||
else
|
||||
|
@ -850,28 +851,28 @@ static int setCmdSavePaths (const char *Cmd) {
|
|||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
int getCmdHelp(const char *Cmd) {
|
||||
static int getCmdHelp(const char *Cmd) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
int getCmdEmoji(const char *Cmd) {
|
||||
static int getCmdEmoji(const char *Cmd) {
|
||||
showEmojiState(prefShowNone);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int getCmdHint(const char *Cmd) {
|
||||
static int getCmdHint(const char *Cmd) {
|
||||
showHintsState(prefShowNone);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int getCmdColor(const char *Cmd) {
|
||||
static int getCmdColor(const char *Cmd) {
|
||||
showColorState(prefShowNone);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int getCmdDebug(const char *Cmd) {
|
||||
static int getCmdDebug(const char *Cmd) {
|
||||
showClientDebugState(prefShowNone);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
@ -904,12 +905,12 @@ static int setCmdHelp(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdPrefGet(const char *Cmd) {
|
||||
static int CmdPrefGet(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(getCommandTable, Cmd);
|
||||
}
|
||||
|
||||
int CmdPrefSet(const char *Cmd) {
|
||||
static int CmdPrefSet(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(setCommandTable, Cmd);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ extern "C" {
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
//#include "comms.h"
|
||||
|
||||
void ShowGraphWindow(void);
|
||||
void HideGraphWindow(void);
|
||||
|
@ -26,12 +25,6 @@ void RepaintGraphWindow(void);
|
|||
void MainGraphics(void);
|
||||
void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
|
||||
void ExitGraphics(void);
|
||||
#ifndef MAX_GRAPH_TRACE_LEN
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8)
|
||||
#endif
|
||||
extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||
extern size_t GraphTraceLen;
|
||||
extern int s_Buff[MAX_GRAPH_TRACE_LEN];
|
||||
|
||||
extern double CursorScaleFactor;
|
||||
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset;
|
||||
|
@ -40,26 +33,12 @@ extern int CommandFinished;
|
|||
extern int offline;
|
||||
extern bool GridLocked;
|
||||
|
||||
//Operations defined in data_operations
|
||||
//int autoCorr(const int* in, int *out, size_t len, int window);
|
||||
int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
|
||||
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);
|
||||
void save_restoreGB(uint8_t saveOpt);
|
||||
|
||||
#define GRAPH_SAVE 1
|
||||
#define GRAPH_RESTORE 0
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
extern size_t DemodBufferLen;
|
||||
extern size_t g_DemodStartIdx;
|
||||
extern bool showDemod;
|
||||
extern uint8_t g_debugMode;
|
||||
|
||||
#ifndef FILE_PATH_SIZE
|
||||
#define FILE_PATH_SIZE 1000
|
||||
#endif
|
||||
extern uint8_t gui_serial_port_name[FILE_PATH_SIZE];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@
|
|||
#include <QSlider>
|
||||
#include <QHBoxLayout>
|
||||
#include <string.h>
|
||||
#include "proxgui.h"
|
||||
#include <QtGui>
|
||||
#include "proxgui.h"
|
||||
#include "ui.h"
|
||||
#include "comms.h"
|
||||
#include "graph.h"
|
||||
#include "cmddata.h"
|
||||
#include "util_darwin.h"
|
||||
|
||||
extern "C" int preferences_save(void);
|
||||
|
||||
extern "C" {
|
||||
#include "util_darwin.h"
|
||||
}
|
||||
|
||||
bool g_useOverlays = false;
|
||||
int g_absVMax = 0;
|
||||
uint32_t startMax; // Maximum offset in the graph (right side of graph)
|
||||
|
|
|
@ -90,7 +90,7 @@ static void showBanner(void) {
|
|||
g_printAndLog = PRINTANDLOG_PRINT;
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
#if defined(__linux__) || (__APPLE__) || (_WIN32)
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(_WIN32)
|
||||
PrintAndLogEx(NORMAL, " " _BLUE_("██████╗ ███╗ ███╗ ████╗ "));
|
||||
PrintAndLogEx(NORMAL, " " _BLUE_("██╔══██╗████╗ ████║ ══█║"));
|
||||
PrintAndLogEx(NORMAL, " " _BLUE_("██████╔╝██╔████╔██║ ████╔╝"));
|
||||
|
@ -116,8 +116,8 @@ static void showBanner(void) {
|
|||
static const char *prompt_dev = "";
|
||||
static const char *prompt_ctx = "";
|
||||
|
||||
static void prompt_compose(char *buf, size_t buflen, const char *prompt_ctx, const char *prompt_dev) {
|
||||
snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, prompt_dev, prompt_ctx);
|
||||
static void prompt_compose(char *buf, size_t buflen, const char *promptctx, const char *promptdev) {
|
||||
snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, promptdev, promptctx);
|
||||
}
|
||||
|
||||
static int check_comm(void) {
|
||||
|
@ -155,11 +155,11 @@ int push_cmdscriptfile(char *path, bool stayafter) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static FILE *current_cmdscriptfile() {
|
||||
static FILE *current_cmdscriptfile(void) {
|
||||
return cmdscriptfile[cmdscriptfile_idx];
|
||||
}
|
||||
|
||||
static bool pop_cmdscriptfile() {
|
||||
static bool pop_cmdscriptfile(void) {
|
||||
fclose(cmdscriptfile[cmdscriptfile_idx]);
|
||||
cmdscriptfile[cmdscriptfile_idx--] = NULL;
|
||||
if (cmdscriptfile_idx == 0)
|
||||
|
@ -893,7 +893,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
session.stdinOnTTY = isatty(STDIN_FILENO);
|
||||
session.stdoutOnTTY = isatty(STDOUT_FILENO);
|
||||
#if defined(__linux__) || (__APPLE__)
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// it's okay to use color if:
|
||||
// * Linux or OSX
|
||||
// * Not redirected to a file but printed to term
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "protocols.h"
|
||||
#include "fileutils.h" // searchfile
|
||||
#include "cmdlf.h" // lf_config
|
||||
#include "generator.h"
|
||||
|
||||
static int returnToLuaWithError(lua_State *L, const char *fmt, ...) {
|
||||
char buffer[200];
|
||||
|
|
|
@ -11,10 +11,14 @@
|
|||
#ifndef UI_H__
|
||||
#define UI_H__
|
||||
|
||||
#include "common.h"
|
||||
#include <pthread.h>
|
||||
#include "common.h"
|
||||
#include "ansi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t;
|
||||
|
@ -42,32 +46,25 @@ typedef struct {
|
|||
} session_arg_t;
|
||||
|
||||
extern session_arg_t session;
|
||||
|
||||
extern bool showDemod;
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
#endif
|
||||
#define MAX_PRINT_BUFFER 2048
|
||||
|
||||
void ShowGui(void);
|
||||
void HideGraphWindow(void);
|
||||
void ShowGraphWindow(void);
|
||||
void RepaintGraphWindow(void);
|
||||
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space);
|
||||
void PrintAndLogEx(logLevel_t level, const char *fmt, ...);
|
||||
void SetFlushAfterWrite(bool value);
|
||||
void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter);
|
||||
void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode);
|
||||
|
||||
extern double CursorScaleFactor;
|
||||
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset;
|
||||
extern uint32_t CursorCPos, CursorDPos;
|
||||
extern bool GridLocked;
|
||||
extern bool showDemod;
|
||||
|
||||
int searchHomeFilePath(char **foundpath, const char *filename, bool create_home);
|
||||
|
||||
extern pthread_mutex_t print_lock;
|
||||
|
||||
void iceIIR_Butterworth(int *data, const size_t len);
|
||||
void iceSimple_Filter(int *data, const size_t len, uint8_t k);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -823,12 +823,6 @@ void wiegand_add_parity_swapped(uint8_t *target, uint8_t *source, uint8_t length
|
|||
*(target) = GetParity(source + length / 2, EVEN, length / 2);
|
||||
}
|
||||
|
||||
// xor two arrays together for len items. The dst array contains the new xored values.
|
||||
void xor(unsigned char *dst, unsigned char *src, size_t len) {
|
||||
for (; len > 0; len--, dst++, src++)
|
||||
*dst ^= *src;
|
||||
}
|
||||
|
||||
// Pack a bitarray into a uint32_t.
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bits) {
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
# define FILE_PATH_SIZE 1000
|
||||
#endif
|
||||
|
||||
uint8_t g_debugMode;
|
||||
uint8_t g_printAndLog;
|
||||
extern uint8_t g_debugMode;
|
||||
extern uint8_t g_printAndLog;
|
||||
|
||||
#define PRINTANDLOG_PRINT 1
|
||||
#define PRINTANDLOG_LOG 2
|
||||
|
@ -87,7 +87,6 @@ void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length);
|
|||
void wiegand_add_parity_swapped(uint8_t *target, uint8_t *source, uint8_t length);
|
||||
|
||||
//void xor(unsigned char *dst, unsigned char *src, size_t len);
|
||||
int32_t le24toh(uint8_t data[3]);
|
||||
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bits);
|
||||
uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
|
||||
|
|
|
@ -11,9 +11,16 @@
|
|||
#ifndef UTIL_DARWIN_H__
|
||||
#define UTIL_DARWIN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void disableAppNap(const char *reason);
|
||||
void enableAppNap(void);
|
||||
void makeUnfocusable(void);
|
||||
void makeFocusable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
// by Gregory Pakosz (@gpakosz)
|
||||
// https://github.com/gpakosz/whereami
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef WAI_PM3_TUNED
|
||||
|
||||
#include "whereami.h"
|
||||
|
||||
|
@ -14,6 +12,19 @@ extern "C" {
|
|||
#define _DEFAULT_SOURCE
|
||||
#endif
|
||||
|
||||
#else // WAI_PM3_TUNED
|
||||
|
||||
// in case you want to #include "whereami.c" in a larger compilation unit
|
||||
#if !defined(WHEREAMI_H)
|
||||
#include <whereami.h>
|
||||
#endif
|
||||
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(WAI_MALLOC) || !defined(WAI_FREE) || !defined(WAI_REALLOC)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
@ -50,11 +61,14 @@ extern "C" {
|
|||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push, 3)
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <intrin.h>
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -123,36 +137,36 @@ static int WAI_PREFIX(getModulePath_)(HMODULE module, char *out, int capacity, i
|
|||
return length;
|
||||
}
|
||||
|
||||
WAI_NOINLINE
|
||||
WAI_FUNCSPEC
|
||||
WAI_NOINLINE WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length) {
|
||||
return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length);
|
||||
}
|
||||
|
||||
// GetModuleHandleEx() is not available on old mingw environments. We don't need getModulePath() yet.
|
||||
// Sacrifice it for the time being to improve backwards compatibility
|
||||
/* WAI_NOINLINE
|
||||
WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
|
||||
{
|
||||
HMODULE module;
|
||||
int length = -1;
|
||||
#ifndef WAI_PM3_TUNED
|
||||
|
||||
WAI_NOINLINE WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||
HMODULE module;
|
||||
int length = -1;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4054)
|
||||
#endif
|
||||
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)WAI_RETURN_ADDRESS(), &module))
|
||||
if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCTSTR)WAI_RETURN_ADDRESS(), &module))
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
{
|
||||
length = WAI_PREFIX(getModulePath_)(module, out, capacity, dirname_length);
|
||||
}
|
||||
{
|
||||
length = WAI_PREFIX(getModulePath_)(module, out, capacity, dirname_length);
|
||||
}
|
||||
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(WAI_USE_PROC_SELF_EXE)
|
||||
|
||||
|
@ -228,14 +242,14 @@ int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length)
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
WAI_NOINLINE
|
||||
WAI_FUNCSPEC
|
||||
#ifndef WAI_PM3_TUNED
|
||||
|
||||
WAI_NOINLINE WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||
int length = -1;
|
||||
FILE *maps = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < WAI_PROC_SELF_MAPS_RETRY; ++i) {
|
||||
for (int r = 0; r < WAI_PROC_SELF_MAPS_RETRY; ++r) {
|
||||
maps = fopen(WAI_PROC_SELF_MAPS, "r");
|
||||
if (!maps)
|
||||
break;
|
||||
|
@ -252,8 +266,8 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
if (!fgets(buffer, sizeof(buffer), maps))
|
||||
break;
|
||||
|
||||
if (sscanf(buffer, "%" SCNx64 "-%" SCNx64 " %s %" SCNx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8) {
|
||||
uint64_t addr = (uint64_t)(uintptr_t)WAI_RETURN_ADDRESS();
|
||||
if (sscanf(buffer, "%" PRIx64 "-%" PRIx64 " %s %" PRIx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8) {
|
||||
uint64_t addr = (uintptr_t)WAI_RETURN_ADDRESS();
|
||||
if (low <= addr && addr <= high) {
|
||||
char *resolved;
|
||||
|
||||
|
@ -299,9 +313,11 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
memcpy(out, resolved, length);
|
||||
|
||||
if (dirname_length) {
|
||||
for (int j = length - 1; j >= 0; --j) {
|
||||
if (out[j] == '/') {
|
||||
*dirname_length = j;
|
||||
int i;
|
||||
|
||||
for (i = length - 1; i >= 0; --i) {
|
||||
if (out[i] == '/') {
|
||||
*dirname_length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -325,6 +341,7 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
|
||||
return length;
|
||||
}
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
|
@ -380,8 +397,9 @@ int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length)
|
|||
return length;
|
||||
}
|
||||
|
||||
WAI_NOINLINE
|
||||
WAI_FUNCSPEC
|
||||
#ifndef WAI_PM3_TUNED
|
||||
|
||||
WAI_NOINLINE WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||
char buffer[PATH_MAX];
|
||||
char *resolved = NULL;
|
||||
|
@ -418,6 +436,8 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
return length;
|
||||
}
|
||||
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#elif defined(__QNXNTO__)
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -474,6 +494,8 @@ int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length)
|
|||
return length;
|
||||
}
|
||||
|
||||
#ifndef WAI_PM3_TUNED
|
||||
|
||||
WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||
char buffer[PATH_MAX];
|
||||
|
@ -511,11 +533,12 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
return length;
|
||||
}
|
||||
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
|
||||
defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -531,8 +554,8 @@ int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length)
|
|||
int length = -1;
|
||||
|
||||
for (;;) {
|
||||
#ifdef KERN_PROC_ARGV
|
||||
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
|
||||
#if defined(__NetBSD__)
|
||||
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
|
||||
#else
|
||||
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
|
||||
#endif
|
||||
|
@ -570,8 +593,9 @@ int WAI_PREFIX(getExecutablePath)(char *out, int capacity, int *dirname_length)
|
|||
return length;
|
||||
}
|
||||
|
||||
WAI_NOINLINE
|
||||
WAI_FUNCSPEC
|
||||
#ifndef WAI_PM3_TUNED
|
||||
|
||||
WAI_NOINLINE WAI_FUNCSPEC
|
||||
int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
||||
char buffer[PATH_MAX];
|
||||
char *resolved = NULL;
|
||||
|
@ -608,6 +632,8 @@ int WAI_PREFIX(getModulePath)(char *out, int capacity, int *dirname_length) {
|
|||
return length;
|
||||
}
|
||||
|
||||
#endif // WAI_PM3_TUNED
|
||||
|
||||
#else
|
||||
|
||||
#error unsupported platform
|
||||
|
|
|
@ -602,7 +602,7 @@ static const cardformat_t FormatTable[] = {
|
|||
{NULL, NULL, NULL, NULL, {0, 0, 0, 0, 0}} // Must null terminate array
|
||||
};
|
||||
|
||||
void HIDListFormats() {
|
||||
void HIDListFormats(void) {
|
||||
if (FormatTable[0].Name == NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
|||
cardformatdescriptor_t Fields;
|
||||
} cardformat_t;
|
||||
|
||||
void HIDListFormats();
|
||||
void HIDListFormats(void);
|
||||
int HIDFindCardFormat(const char *format);
|
||||
cardformat_t HIDGetCardFormat(int idx);
|
||||
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed);
|
||||
|
|
|
@ -64,7 +64,7 @@ bool set_bit_by_position(wiegand_message_t *data, bool value, uint8_t pos) {
|
|||
* If the definition of the wiegand_message struct changes, this function must also
|
||||
* be updated to match.
|
||||
*/
|
||||
void message_datacopy(wiegand_message_t *src, wiegand_message_t *dest) {
|
||||
static void message_datacopy(wiegand_message_t *src, wiegand_message_t *dest) {
|
||||
dest->Bot = src->Bot;
|
||||
dest->Mid = src->Mid;
|
||||
dest->Top = src->Top;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#if !defined LOWMEM && defined __GNUC__
|
||||
static uint8_t filterlut[1 << 20];
|
||||
static void __attribute__((constructor)) fill_lut() {
|
||||
static void __attribute__((constructor)) fill_lut(void) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < 1 << 20; ++i)
|
||||
filterlut[i] = filter(i);
|
||||
|
|
|
@ -23,8 +23,10 @@ void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc) {
|
|||
for (size_t i = 0; i < len; i++) {
|
||||
crc32_byte(&desfire_crc, data[i]);
|
||||
}
|
||||
|
||||
*((uint32_t *)(crc)) = htole32(desfire_crc);
|
||||
uint32_t crctmp = htole32(desfire_crc);
|
||||
for (size_t i=0; i < sizeof(uint32_t); i++) {
|
||||
crc[i] = ((uint8_t *) &crctmp)[i];
|
||||
}
|
||||
}
|
||||
|
||||
void crc32_append(uint8_t *data, const size_t len) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
// XYZ 3D printing
|
||||
// Vinglock
|
||||
//------------------------------------
|
||||
void transform_D(uint8_t *ru) {
|
||||
static void transform_D(uint8_t *ru) {
|
||||
|
||||
const uint32_t c_D[] = {
|
||||
0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8,
|
||||
|
@ -111,18 +111,17 @@ uint32_t ul_ev1_pwdgenB(uint8_t *uid) {
|
|||
// Lego Dimension pwd generation algo nickname C.
|
||||
uint32_t ul_ev1_pwdgenC(uint8_t *uid) {
|
||||
uint32_t pwd = 0;
|
||||
uint8_t base[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x28,
|
||||
0x63, 0x29, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72,
|
||||
0x69, 0x67, 0x68, 0x74, 0x20, 0x4c, 0x45, 0x47,
|
||||
0x4f, 0x20, 0x32, 0x30, 0x31, 0x34, 0xaa, 0xaa
|
||||
uint32_t base[] = {
|
||||
0xffffffff, 0x28ffffff,
|
||||
0x43202963, 0x7279706f,
|
||||
0x74686769, 0x47454c20,
|
||||
0x3032204f, 0xaaaa3431
|
||||
};
|
||||
|
||||
memcpy(base, uid, 7);
|
||||
|
||||
for (int i = 0; i < 32; i += 4) {
|
||||
uint32_t b = *(uint32_t *)(base + i);
|
||||
pwd = b + ROTR(pwd, 25) + ROTR(pwd, 10) - pwd;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
pwd = base[i] + ROTR(pwd, 25) + ROTR(pwd, 10) - pwd;
|
||||
}
|
||||
return BSWAP_32(pwd);
|
||||
}
|
||||
|
@ -415,7 +414,7 @@ int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys) {
|
|||
//------------------------------------
|
||||
// Self tests
|
||||
//------------------------------------
|
||||
int generator_selftest() {
|
||||
int generator_selftest(void) {
|
||||
|
||||
#define NUM_OF_TEST 5
|
||||
|
||||
|
|
|
@ -32,9 +32,6 @@ int mfc_algo_yale_all(uint8_t *uid, uint8_t *keys);
|
|||
int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
|
||||
int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys);
|
||||
|
||||
int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
|
||||
int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys);
|
||||
|
||||
int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
|
||||
int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys);
|
||||
|
||||
|
@ -44,5 +41,5 @@ int mfc_algo_di_all(uint8_t *uid, uint8_t *keys);
|
|||
int mfc_algo_sky_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);
|
||||
int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys);
|
||||
|
||||
int generator_selftest();
|
||||
int generator_selftest(void);
|
||||
#endif
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#ifndef ON_DEVICE
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
# include "cmddata.h"
|
||||
# define prnt(args...) PrintAndLogEx(DEBUG, ## args );
|
||||
#else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
MYSRCPATHS =
|
||||
MYINCLUDES = -I. -I..
|
||||
MYCFLAGS =
|
||||
MYCFLAGS = -Wno-cast-align
|
||||
MYDEFS =
|
||||
MYSRCS = \
|
||||
aes.c \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
MYSRCPATHS = ../../common/zlib
|
||||
MYSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
|
||||
MYINCLUDES = -I../../common/zlib
|
||||
MYCFLAGS =
|
||||
MYCFLAGS = -Wno-error=strict-prototypes
|
||||
MYDEFS = -DZ_SOLO -DNO_GZIP -DZLIB_PM3_TUNED
|
||||
#-DDEBUG -Dverbose=1
|
||||
|
||||
|
|
|
@ -82,6 +82,9 @@ local void slide_hash OF((deflate_state *s));
|
|||
local void fill_window OF((deflate_state *s));
|
||||
local block_state deflate_stored OF((deflate_state *s, int flush));
|
||||
local block_state deflate_fast OF((deflate_state *s, int flush));
|
||||
#ifdef ZLIB_PM3_TUNED
|
||||
local uInt try_harder OF((deflate_state *s, uInt strstart, uInt lookahead, IPos hash_head));
|
||||
#endif
|
||||
#ifndef FASTEST
|
||||
local block_state deflate_slow OF((deflate_state *s, int flush));
|
||||
#endif
|
||||
|
|
20
pm3test.sh
20
pm3test.sh
|
@ -110,15 +110,19 @@ while true; do
|
|||
if ! CheckExecute "mfu pwdgen test" "$PM3BIN -c 'hf mfu pwdgen t'" "Selftest OK"; then break; fi
|
||||
|
||||
printf "\n${C_BLUE}Testing LF:${C_NC}\n"
|
||||
if ! CheckExecute "lf em4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
|
||||
if ! CheckExecute "lf em410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
|
||||
if ! CheckExecute "lf visa2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
|
||||
if ! CheckExecute "lf awid test" "$PM3BIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
|
||||
if ! CheckExecute "lf securakey test" "$PM3BIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
|
||||
if ! CheckExecute "lf keri test" "$PM3BIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
|
||||
if ! CheckExecute "lf EM4x05 test" "$PM3BIN -c 'data load traces/em4x05.pm3;lf search 1'" "FDX-B ID found"; then break; fi
|
||||
if ! CheckExecute "lf EM410x test" "$PM3BIN -c 'data load traces/EM4102-1.pm3;lf search 1'" "EM410x ID found"; then break; fi
|
||||
if ! CheckExecute "lf VISA2000 test" "$PM3BIN -c 'data load traces/visa2000.pm3;lf search 1'" "Visa2000 ID found"; then break; fi
|
||||
if ! CheckExecute "lf AWID test" "$PM3BIN -c 'data load traces/AWID-15-259.pm3;lf search 1'" "AWID ID found"; then break; fi
|
||||
if ! CheckExecute "lf SECURAKEY test" "$PM3BIN -c 'data load traces/securakey-64169.pm3;lf search 1 '" "Securakey ID found"; then break; fi
|
||||
if ! CheckExecute "lf NEXWATCH test" "$PM3BIN -c 'data load traces/quadrakey-521512301.pm3;lf search 1 '" "NexWatch ID found"; then break; fi
|
||||
if ! CheckExecute "lf KERI test" "$PM3BIN -c 'data load traces/keri.pm3;lf search 1'" "Pyramid ID found"; then break; fi
|
||||
if ! CheckExecute "lf HID Prox test" "$PM3BIN -c 'data load traces/hid-proxCardII-05512-11432784-1.pm3;lf search 1'" "HID Prox ID found"; then break; fi
|
||||
if ! CheckExecute "lf Paradox test" "$PM3BIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
|
||||
if ! CheckExecute "lf IO Prox test" "$PM3BIN -c 'data load traces/ioprox-XSF-01-3B-44725.pm3;lf search 1'" "IO Prox ID found"; then break; fi
|
||||
if ! CheckExecute "lf PARADOX test" "$PM3BIN -c 'data load traces/Paradox-96_40426-APJN08.pm3;lf search 1'" "Paradox ID found"; then break; fi
|
||||
if ! CheckExecute "lf PAC test" "$PM3BIN -c 'data load traces/pac-8E4C058E.pm3;lf search 1'" "PAC/Stanley ID found"; then break; fi
|
||||
if ! CheckExecute "lf VIKING test" "$PM3BIN -c 'data load traces/Transit999-best.pm3;lf search 1'" "Viking ID found"; then break; fi
|
||||
if ! CheckExecute "lf FDX-B test" "$PM3BIN -c 'data load traces/homeagain1600.pm3;lf search 1'" "FDX-B ID found"; then break; fi
|
||||
if ! CheckExecute "lf INDALA test" "$PM3BIN -c 'data load traces/indala-504278295.pm3;lf search 1'" "Indala ID found"; then break; fi
|
||||
|
||||
printf "\n${C_BLUE}Testing HF:${C_NC}\n"
|
||||
if ! CheckExecute "hf mf offline text" "$PM3BIN -c 'hf mf'" "at_enc"; then break; fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue