//-----------------------------------------------------------------------------
#include "mifaresniff.h"
-#include "apps.h"
+
#include "proxmark3.h"
#include "util.h"
#include "string.h"
#include "crapto1/crapto1.h"
#include "mifareutil.h"
#include "common.h"
+#include "usb_cdc.h"
+#include "BigBuf.h"
+#include "fpgaloader.h"
static int sniffState = SNF_INIT;
sniffSAK = 0;
sniffUIDType = SNF_UID_4;
- return FALSE;
+ return false;
}
bool MfSniffEnd(void){
cmd_send(CMD_ACK,0,0,0,0,0);
LED_B_OFF();
- return FALSE;
+ return false;
}
bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
memset(sniffATQA, 0x00, 2);
sniffSAK = 0;
sniffState = SNF_ATQA;
+ if (data[0] == 0x40)
+ sniffState = SNF_MAGIC_WUPC2;
}
break;
}
+ case SNF_MAGIC_WUPC2:
+ if ((len == 1) && (reader) && (data[0] == 0x43) ) {
+ sniffState = SNF_CARD_IDLE;
+ }
+ break;
case SNF_ATQA:{
if ((!reader) && (len == 2)) { // ATQA from tag
memcpy(sniffATQA, data, 2);
sniffBuf[11] = sniffSAK;
sniffBuf[12] = 0xFF;
sniffBuf[13] = 0xFF;
- LogTrace(sniffBuf, 14, 0, 0, NULL, TRUE);
+ LogTrace(sniffBuf, 14, 0, 0, NULL, true);
sniffState = SNF_CARD_CMD;
} // intentionally no break;
case SNF_CARD_CMD:{
- LogTrace(data, len, 0, 0, NULL, reader);
+ LogTrace(data, len, 0, 0, parity, reader);
timerData = GetTickCount();
break;
}
}
- return FALSE;
+ return false;
}
bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) {
if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) {
return intMfSniffSend();
}
- return FALSE;
+ return false;
}
// internal sending function. not a RAMFUNC.
while (pckLen > 0) {
pckSize = MIN(USB_CMD_DATA_SIZE, pckLen);
LED_B_ON();
- cmd_send(CMD_ACK, 1, BigBuf_get_traceLen(), pckSize, trace + BigBuf_get_traceLen() - pckLen, pckSize);
+ cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, 1, BigBuf_get_traceLen(), pckSize, trace + BigBuf_get_traceLen() - pckLen, pckSize);
LED_B_OFF();
pckLen -= pckSize;
}
LED_B_ON();
- cmd_send(CMD_ACK,2,0,0,0,0);
+ cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K,2,0,0,0,0);
LED_B_OFF();
clear_trace();
- return TRUE;
+ return true;
}