diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 062f22c06..58278c9cc 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -3394,6 +3394,7 @@ static int CmdHF14AMfSniff(const char *Cmd) { SendCommandNG(CMD_HF_MIFARE_SNIFF, NULL, 0); PacketResponseNG resp; + struct Crypto1State *traceCrypto1 = NULL; // wait cycle while (true) { @@ -3490,13 +3491,13 @@ static int CmdHF14AMfSniff(const char *Cmd) { PrintAndLogEx(SUCCESS, "Trace saved to %s", logHexFileName); } if (wantDecrypt) - mfTraceInit(uid, uid_len, atqa, sak, wantSaveToEmlFile); + mfTraceInit(&traceCrypto1, uid, uid_len, atqa, sak, wantSaveToEmlFile); } else { PrintAndLogEx(NORMAL, "%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len)); if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG| " : "RDR| ", bufPtr, len); if (wantDecrypt) - mfTraceDecode(bufPtr, len, wantSaveToEmlFile); + mfTraceDecode(traceCrypto1, bufPtr, len, wantSaveToEmlFile); num++; } bufPtr += len; diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 173d8eb22..a4a885e1f 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -54,7 +54,7 @@ t55xx_conf_block_t config = { .downlink_mode = refFixedBit }; -t55xx_memory_item_t cardmem[T55x7_BLOCK_COUNT] = {{0}}; +static t55xx_memory_item_t cardmem[T55x7_BLOCK_COUNT] = {{0}}; t55xx_conf_block_t Get_t55xx_Config(void) { return config; diff --git a/client/src/comms.c b/client/src/comms.c index 09e39696c..f2788ad19 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -36,7 +36,7 @@ static bool comm_thread_dead = false; // Transmit buffer. static PacketCommandOLD txBuffer; static PacketCommandNGRaw txBufferNG; -size_t txBufferNGLen; +static size_t txBufferNGLen; static bool txBuffer_pending = false; static pthread_mutex_t txBufferMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t txBufferSig = PTHREAD_COND_INITIALIZER; diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c index fae64a2f6..df0a12ed0 100644 --- a/client/src/mifare/mifarehost.c +++ b/client/src/mifare/mifarehost.c @@ -955,9 +955,6 @@ static int traceState = TRACE_IDLE; static uint8_t traceCurBlock = 0; static uint8_t traceCurKey = 0; -struct Crypto1State *traceCrypto1 = NULL; -struct Crypto1State *revstate = NULL; - uint32_t cuid = 0; // uid part used for crypto1. int isTraceCardEmpty(void) { @@ -1046,12 +1043,12 @@ int saveTraceCard(void) { return PM3_SUCCESS; } // -int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) { +int mfTraceInit(struct Crypto1State **traceCrypto1, uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) { - if (traceCrypto1) - crypto1_destroy(traceCrypto1); + if (*traceCrypto1) + crypto1_destroy(*traceCrypto1); - traceCrypto1 = NULL; + *traceCrypto1 = NULL; if (wantSaveToEmlFile) loadTraceCard(tuid, uidlen); @@ -1079,7 +1076,7 @@ void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool i } } -int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) { +int mfTraceDecode(struct Crypto1State *traceCrypto1, uint8_t *data_src, int len, bool wantSaveToEmlFile) { if (traceState == TRACE_ERROR) return PM3_ESOFT; @@ -1209,7 +1206,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) { uint64_t key = 0; uint32_t ks2 = ar_enc ^ prng_successor(nt, 64); uint32_t ks3 = at_enc ^ prng_successor(nt, 96); - revstate = lfsr_recovery64(ks2, ks3); + struct Crypto1State *revstate = lfsr_recovery64(ks2, ks3); lfsr_rollback_word(revstate, 0, 0); lfsr_rollback_word(revstate, 0, 0); lfsr_rollback_word(revstate, nr_enc, 1); diff --git a/client/src/mifare/mifarehost.h b/client/src/mifare/mifarehost.h index 6f179c573..0595b2f8b 100644 --- a/client/src/mifare/mifarehost.h +++ b/client/src/mifare/mifarehost.h @@ -81,8 +81,8 @@ int mfCWipe(uint8_t *uid, uint8_t *atqa, uint8_t *sak); int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params); int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params); -int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile); -int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile); +int mfTraceInit(struct Crypto1State **traceCrypto1, uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile); +int mfTraceDecode(struct Crypto1State *traceCrypto1, uint8_t *data_src, int len, bool wantSaveToEmlFile); int isTraceCardEmpty(void); int isBlockEmpty(int blockN);