]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: HF 14A READER is now able to see if a presented card responses to the chinese...
authoriceman1001 <iceman@iuse.se>
Fri, 26 Dec 2014 20:32:58 +0000 (21:32 +0100)
committericeman1001 <iceman@iuse.se>
Fri, 26 Dec 2014 20:32:58 +0000 (21:32 +0100)
FIX: simple namechange of some defines where it hinted it was related to "eml" when it wasn't.

armsrc/appmain.c
armsrc/apps.h
armsrc/mifarecmd.c
armsrc/mifaredesfire.c
client/cmdhf14a.c
include/usb_cmd.h

index c3cf3999dc91e66be18438661228d255a36807b4..33944c1d72623cd9e496c4ba908561af646a3e17 100644 (file)
@@ -854,12 +854,15 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        break;
                        
                // Work with "magic Chinese" card
-               case CMD_MIFARE_EML_CSETBLOCK:
+               case CMD_MIFARE_CSETBLOCK:
                        MifareCSetBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
                        break;
-               case CMD_MIFARE_EML_CGETBLOCK:
+               case CMD_MIFARE_CGETBLOCK:
                        MifareCGetBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
                        break;
+               case CMD_MIFARE_CIDENT:
+                       MifareCIdent();
+                       break;
                        
                // mifare sniffer
                case CMD_MIFARE_SNIFFER:
index 6725741f109a14e884c016db815c59a27f66bb1d..5e1926f965d79d2eef12b90dd8f9e309633a1b91 100644 (file)
@@ -211,6 +211,7 @@ void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
 void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
 void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);  // Work with "magic Chinese" card
 void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
+void MifareCIdent();  // is "magic chinese" card?
 
 // mifaredesfire.h
 bool   InitDesfireCard();
index 1352215e2314df9488cfb8e64eecb1f62b7bbeaf..ee2132ef34cbbaf5bb02b5901673830409866373 100644 (file)
@@ -937,29 +937,22 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        \r
        // variables\r
        byte_t isOK = 0;\r
-       uint8_t uid[10];\r
-       uint8_t d_block[18];\r
+       uint8_t uid[10] = {0x00};\r
+       uint8_t d_block[18] = {0x00};\r
        uint32_t cuid;\r
        \r
-       memset(uid, 0x00, 10);\r
        uint8_t* receivedAnswer = get_bigbufptr_recvrespbuf();\r
        uint8_t *receivedAnswerPar = receivedAnswer + MAX_FRAME_SIZE;\r
        \r
        // reset FPGA and LED\r
        if (workFlags & 0x08) {\r
-               iso14a_clear_trace();\r
-               iso14a_set_tracing(TRUE);\r
-\r
-               iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
-\r
                LED_A_ON();\r
                LED_B_OFF();\r
                LED_C_OFF();\r
-       \r
-               //SpinDelay(300);\r
-               //FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-               //SpinDelay(100);\r
-               //FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
+               \r
+               iso14a_clear_trace();\r
+               iso14a_set_tracing(TRUE);\r
+               iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
        }\r
 \r
        while (true) {\r
@@ -967,7 +960,6 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
                // get UID from chip\r
                if (workFlags & 0x01) {\r
                        if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
-                               Dbprintf("ICE");\r
                                if (MF_DBGLEVEL >= 1)   Dbprintf("Can't select card");\r
                                break;\r
                        };\r
@@ -1065,28 +1057,20 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        \r
        // variables\r
        byte_t isOK = 0;\r
-       uint8_t data[18];\r
+       uint8_t data[18] = {0x00};\r
        uint32_t cuid = 0;\r
        \r
-       memset(data, 0x00, 18);\r
        uint8_t* receivedAnswer = get_bigbufptr_recvrespbuf();\r
        uint8_t *receivedAnswerPar = receivedAnswer + MAX_FRAME_SIZE;\r
        \r
        if (workFlags & 0x08) {\r
-               // clear trace\r
-               iso14a_clear_trace();\r
-               iso14a_set_tracing(TRUE);\r
-\r
-               iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
-\r
                LED_A_ON();\r
                LED_B_OFF();\r
                LED_C_OFF();\r
-       \r
-               // SpinDelay(300);\r
-               // FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-               // SpinDelay(100);\r
-               // FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);\r
+\r
+               iso14a_clear_trace();\r
+               iso14a_set_tracing(TRUE);\r
+               iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
        }\r
 \r
        while (true) {\r
@@ -1132,3 +1116,35 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        }\r
 }\r
 \r
+void MifareCIdent(){\r
+  \r
+       // card commands\r
+       uint8_t wupC1[]       = { 0x40 }; \r
+       uint8_t wupC2[]       = { 0x43 }; \r
+       \r
+       // variables\r
+       byte_t isOK = 1;\r
+       \r
+       uint8_t* receivedAnswer = get_bigbufptr_recvrespbuf();\r
+       uint8_t *receivedAnswerPar = receivedAnswer + MAX_FRAME_SIZE;\r
+       \r
+       iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);\r
+       \r
+       ReaderTransmitBitsPar(wupC1,7,0, NULL);\r
+       if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {\r
+               isOK = 0;\r
+       };\r
+\r
+       ReaderTransmit(wupC2, sizeof(wupC2), NULL);\r
+       if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) {\r
+               isOK = 0;\r
+       };\r
+\r
+       if (mifare_classic_halt(NULL, 0)) {\r
+               isOK = 0;\r
+       };\r
+\r
+       cmd_send(CMD_ACK,isOK,0,0,0,0);\r
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+}\r
+\r
index 56166777bc62d6e2806546c0b1ed22211cf0351d..7511932264815e4574e8b95b5f4ef35517b83278 100644 (file)
@@ -24,11 +24,11 @@ bool InitDesfireCard(){
        
        byte_t cardbuf[USB_CMD_DATA_SIZE];
        memset(cardbuf,0,sizeof(cardbuf));
+       iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
        
        iso14a_set_tracing(TRUE);
        iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
        
-       iso14a_card_select_t *card = (iso14a_card_select_t*)cardbuf;
        int len = iso14443a_select_card(NULL,card,NULL);
 
        if (!len) {
@@ -350,7 +350,7 @@ size_t CreateAPDU( uint8_t *datain, size_t len, uint8_t *dataout){
        
        cmd[0] = 0x0A;  //  0x0A = skicka cid,  0x02 = ingen cid. Särskilda bitar //
        cmd[0] |= pcb_blocknum; // OR the block number into the PCB     
-       cmd[1] = 0x00;  //  CID: 0x00 //FIXME: allow multiple selected cards
+       cmd[1] = 0x00;  //  CID: 0x00 //TODO: allow multiple selected cards
        
        memcpy(cmd+2, datain, len);
        AppendCrc14443a(cmd, len+2);
index f09c555b96e1c2d8c4c863fa794bac47ee32e508..27f0ac3657b9ab7f13f3f3f04d563d37b397d82e 100644 (file)
@@ -225,12 +225,6 @@ int CmdHF14AReader(const char *Cmd)
            memcpy(&card.ats, resp.d.asBytes, resp.arg[0]);
                card.ats_len = resp.arg[0];                             // note: ats_len includes CRC Bytes
        } 
-
-       // disconnect
-       c.arg[0] = 0;
-       c.arg[1] = 0;
-       c.arg[2] = 0;
-       SendCommand(&c);
        
        if(card.ats_len >= 3) {                 // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
                bool ta1 = 0, tb1 = 0, tc1 = 0;
@@ -370,6 +364,23 @@ int CmdHF14AReader(const char *Cmd)
                PrintAndLog("proprietary non iso14443-4 card found, RATS not supported");
        }
 
+       
+       // try to see if card responses to "chinese magic backdoor" commands.
+       c.cmd = CMD_MIFARE_CIDENT;
+       c.arg[0] = 0;
+       c.arg[1] = 0;
+       c.arg[2] = 0;   
+       SendCommand(&c);
+       WaitForResponse(CMD_ACK,&resp);
+       uint8_t isOK  = resp.arg[0] & 0xff;
+       PrintAndLog(" Answers to chinese magic backdoor commands: %s", (isOK ? "YES" : "NO") );
+       
+       // disconnect
+       c.arg[0] = 0;
+       c.arg[1] = 0;
+       c.arg[2] = 0;
+       SendCommand(&c);
+       
        return select_status;
 }
 
index 55df18f441b1eee54b01172e91d68eca1256902e..65631d98e59a0a00cf8430522da181f802891fd5 100644 (file)
@@ -137,8 +137,11 @@ typedef struct {
 #define CMD_MIFARE_EML_MEMSET                                             0x0602
 #define CMD_MIFARE_EML_MEMGET                                             0x0603
 #define CMD_MIFARE_EML_CARDLOAD                                           0x0604
-#define CMD_MIFARE_EML_CSETBLOCK                                          0x0605
-#define CMD_MIFARE_EML_CGETBLOCK                                          0x0606
+
+// magic chinese card commands
+#define CMD_MIFARE_CSETBLOCK                                              0x0605
+#define CMD_MIFARE_CGETBLOCK                                              0x0606
+#define CMD_MIFARE_CIDENT                                                 0x0607
 
 #define CMD_SIMULATE_MIFARE_CARD                                          0x0610
 
Impressum, Datenschutz