]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifarecmd.c
magic Chinese card fully supported. Added commands:csetuid-set card uid and wipe...
[proxmark3-svn] / armsrc / mifarecmd.c
index 848207309783a82a5e156e1bdc8902c7c8029865..4f4ce64d96dd2f0791ba9748be835a8f29900dcd 100644 (file)
@@ -735,7 +735,12 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
   \r
   // params\r
        uint8_t needWipe = arg0;\r
-       uint8_t needGetUID = arg1;\r
+       // bit 0 - need get UID\r
+       // bit 1 - need wupC\r
+       // bit 2 - need HALT after sequence\r
+       // bit 3 - need init FPGA and field before sequence\r
+       // bit 4 - need reset FPGA and LED\r
+       uint8_t workFlags = arg1;\r
        uint8_t blockNo = arg2;\r
        \r
        // card commands\r
@@ -752,24 +757,26 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        memset(uid, 0x00, 8);\r
        uint8_t* receivedAnswer = mifare_get_bigbufptr();\r
        \r
-       // clear trace\r
-       iso14a_clear_tracelen();\r
-  iso14a_set_tracing(TRUE);\r
+       if (workFlags & 0x08) {\r
+               // clear trace\r
+               iso14a_clear_tracelen();\r
+               iso14a_set_tracing(TRUE);\r
 \r
-       iso14443a_setup();\r
+               iso14443a_setup();\r
 \r
-       LED_A_ON();\r
-       LED_B_OFF();\r
-       LED_C_OFF();\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
+               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
 \r
        while (true) {\r
                // get UID from chip\r
-               if (needGetUID) {\r
+               if (workFlags & 0x01) {\r
                        if(!iso14443a_select_card(uid, NULL, &cuid)) {\r
                                if (MF_DBGLEVEL >= 1)   Dbprintf("Can't select card");\r
                                break;\r
@@ -802,17 +809,19 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
                };      \r
 \r
                // write UID block\r
-               ReaderTransmitShort(wupC1);\r
-               if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) {\r
-                       if (MF_DBGLEVEL >= 1)   Dbprintf("wupC1 error");\r
-                       break;\r
-               };\r
+               if (workFlags & 0x02) {\r
+                       ReaderTransmitShort(wupC1);\r
+                       if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) {\r
+                               if (MF_DBGLEVEL >= 1)   Dbprintf("wupC1 error");\r
+                               break;\r
+                       };\r
 \r
-               ReaderTransmit(wupC2, sizeof(wupC2));\r
-               if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) {\r
-                       if (MF_DBGLEVEL >= 1)   Dbprintf("wupC2 error");\r
-                       break;\r
-               };\r
+                       ReaderTransmit(wupC2, sizeof(wupC2));\r
+                       if(!ReaderReceive(receivedAnswer) || (receivedAnswer[0] != 0x0a)) {\r
+                               if (MF_DBGLEVEL >= 1)   Dbprintf("wupC2 error");\r
+                               break;\r
+                       };\r
+               }\r
 \r
                if ((mifare_sendcmd_short(NULL, 0, 0xA0, blockNo, receivedAnswer) != 1) || (receivedAnswer[0] != 0x0a)) {\r
                        if (MF_DBGLEVEL >= 1)   Dbprintf("write block send command error");\r
@@ -828,10 +837,12 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
                        break;\r
                };      \r
        \r
-               if(mifare_classic_halt(NULL, cuid)) {\r
-                       if (MF_DBGLEVEL >= 1)   Dbprintf("Halt error");\r
-                       break;\r
-               };\r
+               if (workFlags & 0x04) {\r
+                       if (mifare_classic_halt(NULL, cuid)) {\r
+                               if (MF_DBGLEVEL >= 1)   Dbprintf("Halt error");\r
+                               break;\r
+                       };\r
+               }\r
                \r
                isOK = 1;\r
                break;\r
@@ -848,7 +859,9 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
        UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));\r
        LED_B_OFF();\r
 \r
-  // Thats it...\r
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
-       LEDsoff();\r
+       if (workFlags & 0x10) {\r
+               // Thats it...\r
+               FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);\r
+               LEDsoff();\r
+       }\r
 }\r
Impressum, Datenschutz