]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifaresniff.c
Fix some printf/scanf format strings
[proxmark3-svn] / armsrc / mifaresniff.c
index 08fb9f2302c194fbb059bb6031c519e44995dd12..f3ee4a3f79dde9566b23a92581be5fd7ee829278 100644 (file)
@@ -9,7 +9,7 @@
 //-----------------------------------------------------------------------------
 
 #include "mifaresniff.h"
 //-----------------------------------------------------------------------------
 
 #include "mifaresniff.h"
-#include "apps.h"
+
 #include "proxmark3.h"
 #include "util.h"
 #include "string.h"
 #include "proxmark3.h"
 #include "util.h"
 #include "string.h"
@@ -18,6 +18,9 @@
 #include "crapto1/crapto1.h"
 #include "mifareutil.h"
 #include "common.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;
 
 
 static int sniffState = SNF_INIT;
@@ -35,7 +38,7 @@ bool MfSniffInit(void){
        sniffSAK = 0;
        sniffUIDType = SNF_UID_4;
 
        sniffSAK = 0;
        sniffUIDType = SNF_UID_4;
 
-       return FALSE;
+       return false;
 }
 
 bool MfSniffEnd(void){
 }
 
 bool MfSniffEnd(void){
@@ -43,7 +46,7 @@ bool MfSniffEnd(void){
        cmd_send(CMD_ACK,0,0,0,0,0);
        LED_B_OFF();
 
        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) {
 }
 
 bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, uint16_t bitCnt, bool reader) {
@@ -59,38 +62,31 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
                                memset(sniffUID, 0x00, 8);
                                memset(sniffATQA, 0x00, 2);
                                sniffSAK = 0;
                                memset(sniffUID, 0x00, 8);
                                memset(sniffATQA, 0x00, 2);
                                sniffSAK = 0;
-                               sniffState = SNF_WUPREQ;
+                               sniffState = SNF_ATQA;
+                               if (data[0] == 0x40) 
+                                       sniffState = SNF_MAGIC_WUPC2;
                        }
                        break;
                }
                        }
                        break;
                }
-               case SNF_WUPREQ:{
+               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);
                        if ((!reader) && (len == 2)) {          // ATQA from tag
                                memcpy(sniffATQA, data, 2);
-                               sniffState = SNF_ATQA;
+                               sniffState = SNF_UID1;
                        }
                        break;
                }
                        }
                        break;
                }
-               case SNF_ATQA:
                case SNF_UID1:{\r
                case SNF_UID1:{\r
-                       // SNF_ATQA\r
-                       if ((reader) && (len == 2) && (data[0] == 0x93) && (data[1] == 0x20)) { // Select ALL from reader
-                               sniffState = SNF_ANTICOL1;
-                       }\r
-                       \r
-                       // SNF_UID1
                        if ((reader) && (len == 9) && (data[0] == 0x93) && (data[1] == 0x70) && (CheckCrc14443(CRC_14443_A, data, 9))) {   // Select 4 Byte UID from reader\r
                                memcpy(sniffUID + 3, &data[2], 4);\r
                                sniffState = SNF_SAK;\r
                        }\r
                        break;
                }\r
                        if ((reader) && (len == 9) && (data[0] == 0x93) && (data[1] == 0x70) && (CheckCrc14443(CRC_14443_A, data, 9))) {   // Select 4 Byte UID from reader\r
                                memcpy(sniffUID + 3, &data[2], 4);\r
                                sniffState = SNF_SAK;\r
                        }\r
                        break;
                }\r
-               case SNF_ANTICOL1:{
-                       if ((!reader) && (len == 5) && ((data[0] ^ data[1] ^ data[2] ^ data[3]) == data[4])) {  // UID from tag (CL1) 
-                               memcpy(sniffUID + 3, data, 4);
-                               sniffState = SNF_UID1;
-                       }
-                       break;
-               }
                case SNF_SAK:{
                        if ((!reader) && (len == 3) && (CheckCrc14443(CRC_14443_A, data, 3))) { // SAK from card?
                                sniffSAK = data[0];
                case SNF_SAK:{
                        if ((!reader) && (len == 3) && (CheckCrc14443(CRC_14443_A, data, 3))) { // SAK from card?
                                sniffSAK = data[0];
@@ -104,18 +100,7 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
                        }
                        break;
                }
                        }
                        break;
                }
-               case SNF_ANTICOL2:{
-                       if ((!reader) && (len == 5) && ((data[0] ^ data[1] ^ data[2] ^ data[3]) == data[4])) { // CL2 UID 
-                               memcpy(sniffUID + 3, data, 4);\r
-                               sniffState = SNF_UID2;
-                       }
-                       break;
-               }
                case SNF_UID2:{\r
                case SNF_UID2:{\r
-                       if ((reader) && (len == 2) && (data[0] == 0x95) && (data[1] == 0x20)) {\r
-                               sniffState = SNF_ANTICOL2;\r
-                       }\r
-                       \r
                        if ((reader) && (len == 9) && (data[0] == 0x95) && (data[1] == 0x70) && (CheckCrc14443(CRC_14443_A, data, 9))) {\r
                                memcpy(sniffUID + 3, &data[2], 4);\r
                                sniffState = SNF_SAK;\r
                        if ((reader) && (len == 9) && (data[0] == 0x95) && (data[1] == 0x70) && (CheckCrc14443(CRC_14443_A, data, 9))) {\r
                                memcpy(sniffUID + 3, &data[2], 4);\r
                                sniffState = SNF_SAK;\r
@@ -130,11 +115,11 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
                        sniffBuf[11] = sniffSAK;
                        sniffBuf[12] = 0xFF;
                        sniffBuf[13] = 0xFF;
                        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:{     
                        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;
                }
                        timerData = GetTickCount();
                        break;
                }
@@ -145,14 +130,14 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
        }
 
 
        }
 
 
-       return FALSE;
+       return false;
 }
 
 bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) {
        if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) {
                return intMfSniffSend();
        }
 }
 
 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.
 }
 
 // internal sending function. not a RAMFUNC.
@@ -167,7 +152,7 @@ bool intMfSniffSend() {
        while (pckLen > 0) {
                pckSize = MIN(USB_CMD_DATA_SIZE, pckLen);
                LED_B_ON();
        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_OFF();
 
                pckLen -= pckSize;
@@ -175,10 +160,10 @@ bool intMfSniffSend() {
        }
 
        LED_B_ON();
        }
 
        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();
        
        LED_B_OFF();
 
        clear_trace();
        
-       return TRUE;
+       return true;
 }
 }
Impressum, Datenschutz