]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
`hf mf sniff` transfered parity from arm to decoding procedure
authorMerlokbr@gmail.com <Merlokbr@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 17 Jul 2012 15:19:15 +0000 (15:19 +0000)
committerMerlokbr@gmail.com <Merlokbr@gmail.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 17 Jul 2012 15:19:15 +0000 (15:19 +0000)
armsrc/iso14443a.c
armsrc/mifaresniff.c
armsrc/mifaresniff.h
client/cmdhfmf.c
client/mifarehost.c
client/mifarehost.h

index d2d79bda6695e85f851f1dcb7ab28dbeee4764cc..6b481df213b26b33793f902d5183da747e181678 100644 (file)
@@ -2455,7 +2455,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
                if(MillerDecoding((data[0] & 0xF0) >> 4)) {
                        LED_C_INV();
                        // check - if there is a short 7bit request from reader
-                       if (MfSniffLogic(receivedCmd, Uart.byteCnt, Uart.bitCnt, TRUE)) break;
+                       if (MfSniffLogic(receivedCmd, Uart.byteCnt, Uart.parityBits, Uart.bitCnt, TRUE)) break;
 
                        /* And ready to receive another command. */
                        Uart.state = STATE_UNSYNCD;
@@ -2467,7 +2467,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
                if(ManchesterDecoding(data[0] & 0x0F)) {
                        LED_C_INV();
 
-                       if (MfSniffLogic(receivedResponse, Demod.len, Uart.bitCnt, FALSE)) break;
+                       if (MfSniffLogic(receivedResponse, Demod.len, Demod.parityBits, Demod.bitCount, FALSE)) break;
 
                        // And ready to receive another response.
                        memset(&Demod, 0, sizeof(Demod));
index 31e0287ddcf41047caff6426929a6b2f4ee62caa..fc5156fdad27e4cdb4045868e08ca30cb6b25aa8 100644 (file)
@@ -40,7 +40,7 @@ int MfSniffEnd(void){
        return 0;\r
 }\r
 \r
-int RAMFUNC MfSniffLogic(const uint8_t * data, int len, int bitCnt, int reader) {\r
+int RAMFUNC MfSniffLogic(const uint8_t * data, int len, uint32_t parity, int bitCnt, int reader) {\r
 \r
        if ((len == 1) && (bitCnt = 9) && (data[0] > 0x0F)) { \r
                sniffState = SNF_INIT;\r
@@ -121,18 +121,18 @@ int RAMFUNC MfSniffLogic(const uint8_t * data, int len, int bitCnt, int reader)
                        sniffBuf[11] = sniffSAK;\r
                        sniffBuf[12] = 0xFF;\r
                        sniffBuf[13] = 0xFF;\r
-                       LogTrace(sniffBuf, 14, 0, 0, true);\r
+                       LogTrace(sniffBuf, 14, 0, parity, true);\r
                        timerData = GetTickCount();\r
                }\r
                case SNF_CARD_CMD:{\r
-                       LogTrace(data, len, 0, 0, true);\r
+                       LogTrace(data, len, 0, parity, true);\r
 \r
                        sniffState = SNF_CARD_RESP;\r
                        timerData = GetTickCount();\r
                        break;\r
                }\r
                case SNF_CARD_RESP:{\r
-                       LogTrace(data, len, 0, 0, false);\r
+                       LogTrace(data, len, 0, parity, false);\r
 \r
                        sniffState = SNF_CARD_CMD;\r
                        timerData = GetTickCount();\r
index 2012f9d74fdc8a27835d59a18859243860d1941d..db5af9a850305ddafab2f7c25237ac46a2ee5d97 100644 (file)
@@ -39,7 +39,7 @@
 #define SNF_UID_7                              0\r
 \r
 int MfSniffInit(void);\r
-int RAMFUNC MfSniffLogic(const uint8_t * data, int len, int bitCnt, int reader);\r
+int RAMFUNC MfSniffLogic(const uint8_t * data, int len, uint32_t parity, int bitCnt, int reader);\r
 int RAMFUNC MfSniffSend(int maxTimeoutMs);\r
 int intMfSniffSend();\r
 int MfSniffEnd(void);\r
index c7f51ed83b5b10b26b01f8be3ce705f47f0602aa..9624ce9ae762cd76f4058fc7c30a2ee624425102 100644 (file)
@@ -1558,6 +1558,7 @@ int CmdHF14AMfSniff(const char *Cmd){
        uint8_t atqa[2];\r
        uint8_t sak;\r
        bool isTag;\r
+       uint32_t parity;\r
        uint8_t buf[3000];\r
        uint8_t * bufPtr = buf;\r
        memset(buf, 0x00, 3000);\r
@@ -1625,7 +1626,9 @@ int CmdHF14AMfSniff(const char *Cmd){
                                num = 0;\r
                                while (bufPtr - buf + 9 < blockLen) {\r
                                  isTag = bufPtr[3] & 0x80 ? true:false;\r
-                                       bufPtr += 8;\r
+                                       bufPtr += 4;\r
+                                       parity = *((uint32_t *)(bufPtr));\r
+                                       bufPtr += 4;\r
                                        len = bufPtr[0];\r
                                        bufPtr++;\r
                                        if ((len == 14) && (bufPtr[0] = 0xff) && (bufPtr[1] = 0xff)) {\r
@@ -1642,7 +1645,7 @@ int CmdHF14AMfSniff(const char *Cmd){
                                        } else {\r
                                                PrintAndLog("%s(%d):%s", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len));\r
                                                if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);\r
-                                               if (wantDecrypt) mfTraceDecode(bufPtr, len, wantSaveToEmlFile);\r
+                                               if (wantDecrypt) mfTraceDecode(bufPtr, len, parity, wantSaveToEmlFile);\r
                                        }\r
                                        bufPtr += len;\r
                                        num++;\r
index 70d2413a856936ccd38f5f314589f1ec2de3e6fc..f34759df80b6343cd1be1de0cf7dc111a20cdcd4 100644 (file)
@@ -295,9 +295,12 @@ uint32_t ks3;
 \r
 uint32_t uid;     // serial number\r
 uint32_t nt;      // tag challenge\r
+uint32_t nt_par; \r
 uint32_t nr_enc;  // encrypted reader challenge\r
 uint32_t ar_enc;  // encrypted reader response\r
+uint32_t nr_ar_par; \r
 uint32_t at_enc;  // encrypted tag response\r
+uint32_t at_par; \r
 \r
 int isTraceCardEmpty(void) {\r
        return ((traceCard[0] == 0) && (traceCard[1] == 0) && (traceCard[2] == 0) && (traceCard[3] == 0));\r
@@ -401,7 +404,7 @@ void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool i
 }\r
 \r
 \r
-int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {\r
+int mfTraceDecode(uint8_t *data_src, int len, uint32_t parity, bool wantSaveToEmlFile) {\r
        uint8_t data[64];\r
 \r
        if (traceState == TRACE_ERROR) return 1;\r
@@ -504,6 +507,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_AUTH2;\r
 \r
                        nt = bytes_to_num(data, 4);\r
+                       nt_par = parity;\r
                        return 0;\r
                } else {\r
                        traceState = TRACE_ERROR;\r
@@ -517,6 +521,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
 \r
                        nr_enc = bytes_to_num(data, 4);\r
                        ar_enc = bytes_to_num(data + 4, 4);\r
+                       nr_ar_par = parity;\r
                        return 0;\r
                } else {\r
                        traceState = TRACE_ERROR;\r
@@ -529,6 +534,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_IDLE;\r
 \r
                        at_enc = bytes_to_num(data, 4);\r
+                       at_par = parity;\r
                        \r
                        //  decode key here)\r
                        if (!traceCrypto1) {\r
index d74f3f0e4aa2361b08d1766bd0b0a814913ff52b..a264002fd075b8ffcef2a1a29f35ea0a23e76bb5 100644 (file)
@@ -73,7 +73,7 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe, uint
 int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);\r
 \r
 int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);\r
-int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);\r
+int mfTraceDecode(uint8_t *data_src, int len, uint32_t parity, bool wantSaveToEmlFile);\r
 \r
 int isTraceCardEmpty(void);\r
 int isBlockEmpty(int blockN);\r
Impressum, Datenschutz