X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/f5a1a9ce477df5dee44b230d7e6dfd0377eb167f..refs/pull/252/head:/armsrc/mifaresniff.c diff --git a/armsrc/mifaresniff.c b/armsrc/mifaresniff.c index 3e5570f9..7f94b0fe 100644 --- a/armsrc/mifaresniff.c +++ b/armsrc/mifaresniff.c @@ -10,13 +10,22 @@ #include "mifaresniff.h" #include "apps.h" +#include "proxmark3.h" +#include "util.h" +#include "string.h" +#include "iso14443crc.h" +#include "iso14443a.h" +#include "crapto1/crapto1.h" +#include "mifareutil.h" +#include "common.h" + static int sniffState = SNF_INIT; static uint8_t sniffUIDType; -static uint8_t sniffUID[8]; -static uint8_t sniffATQA[2]; +static uint8_t sniffUID[8] = {0x00}; +static uint8_t sniffATQA[2] = {0x00}; static uint8_t sniffSAK; -static uint8_t sniffBuf[16]; +static uint8_t sniffBuf[16] = {0x00}; static uint32_t timerData = 0; @@ -37,7 +46,7 @@ bool MfSniffEnd(void){ return FALSE; } -bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint32_t parity, uint16_t bitCnt, bool reader) { +bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) { if (reader && (len == 1) && (bitCnt == 7)) { // reset on 7-Bit commands from reader sniffState = SNF_INIT; @@ -114,16 +123,16 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint32_t parity, ui sniffBuf[11] = sniffSAK; sniffBuf[12] = 0xFF; sniffBuf[13] = 0xFF; - LogTrace(sniffBuf, 14, 0, parity, true); + LogTrace(sniffBuf, 14, 0, 0, NULL, TRUE); } // intentionally no break; case SNF_CARD_CMD:{ - LogTrace(data, len, 0, parity, true); + LogTrace(data, len, 0, 0, NULL, TRUE); sniffState = SNF_CARD_RESP; timerData = GetTickCount(); break; } case SNF_CARD_RESP:{ - LogTrace(data, len, 0, parity, false); + LogTrace(data, len, 0, 0, NULL, FALSE); sniffState = SNF_CARD_CMD; timerData = GetTickCount(); break; @@ -139,7 +148,7 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint32_t parity, ui } bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) { - if (traceLen && (GetTickCount() > timerData + maxTimeoutMs)) { + if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) { return intMfSniffSend(); } return FALSE; @@ -149,14 +158,15 @@ bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) { bool intMfSniffSend() { int pckSize = 0; - int pckLen = traceLen; + int pckLen = BigBuf_get_traceLen(); int pckNum = 0; - + uint8_t *trace = BigBuf_get_addr(); + FpgaDisableSscDma(); while (pckLen > 0) { pckSize = MIN(USB_CMD_DATA_SIZE, pckLen); LED_B_ON(); - cmd_send(CMD_ACK, 1, pckSize, pckNum, trace + traceLen - pckLen, pckSize); + cmd_send(CMD_ACK, 1, BigBuf_get_traceLen(), pckSize, trace + BigBuf_get_traceLen() - pckLen, pckSize); LED_B_OFF(); pckLen -= pckSize; @@ -167,7 +177,7 @@ bool intMfSniffSend() { cmd_send(CMD_ACK,2,0,0,0,0); LED_B_OFF(); - iso14a_clear_trace(); + clear_trace(); return TRUE; }