]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhf14a.c
Revert "Comms refactor (prerequisite of libproxmark work) (#371)"
[proxmark3-svn] / client / cmdhf14a.c
index fc6dcff7eefbf25e0889c62d7b8d1c2c56c126e1..e3f1a5f17cf7d4cf7a2546149f62507a289899b0 100644 (file)
@@ -15,6 +15,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "util.h"
 #include <string.h>
 #include <unistd.h>
 #include "util.h"
+#include "util_posix.h"
 #include "iso14443crc.h"
 #include "data.h"
 #include "proxmark3.h"
 #include "iso14443crc.h"
 #include "data.h"
 #include "proxmark3.h"
@@ -25,6 +26,7 @@
 #include "cmdmain.h"
 #include "mifare.h"
 #include "cmdhfmfu.h"
 #include "cmdmain.h"
 #include "mifare.h"
 #include "cmdhfmfu.h"
+#include "mifarehost.h"
 
 static int CmdHelp(const char *Cmd);
 static void waitCmd(uint8_t iLen);
 
 static int CmdHelp(const char *Cmd);
 static void waitCmd(uint8_t iLen);
@@ -403,22 +405,8 @@ int CmdHF14AReader(const char *Cmd)
 
        
        // try to see if card responses to "chinese magic backdoor" commands.
 
        
        // 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") );
+       mfCIdentify();
        
        
-       // disconnect
-       c.cmd = CMD_READER_ISO_14443a;
-       c.arg[0] = 0;
-       c.arg[1] = 0;
-       c.arg[2] = 0;
-       SendCommand(&c);
-
        return select_status;
 }
 
        return select_status;
 }
 
@@ -435,7 +423,7 @@ int CmdHF14ACUIDs(const char *Cmd)
        // repeat n times
        for (int i = 0; i < n; i++) {
                // execute anticollision procedure
        // repeat n times
        for (int i = 0; i < n; i++) {
                // execute anticollision procedure
-               UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}};
+               UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}};
                SendCommand(&c);
     
                UsbCommand resp;
                SendCommand(&c);
     
                UsbCommand resp;
@@ -574,6 +562,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
        bool power = false;
        bool active = false;
        bool active_select = false;
        bool power = false;
        bool active = false;
        bool active_select = false;
+       bool no_rats = false;
        uint16_t numbits = 0;
        bool bTimeout = false;
        uint32_t timeout = 0;
        uint16_t numbits = 0;
        bool bTimeout = false;
        uint32_t timeout = 0;
@@ -594,6 +583,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
                PrintAndLog("       -b    number of bits to send. Useful for send partial byte");
                PrintAndLog("       -t    timeout in ms");
                PrintAndLog("       -T    use Topaz protocol to send command");
                PrintAndLog("       -b    number of bits to send. Useful for send partial byte");
                PrintAndLog("       -t    timeout in ms");
                PrintAndLog("       -T    use Topaz protocol to send command");
+               PrintAndLog("       -3    ISO14443-3 select only (skip RATS)");
                return 0;
        }
 
                return 0;
        }
 
@@ -638,6 +628,9 @@ int CmdHF14ACmdRaw(const char *cmd) {
                                case 'T':
                                        topazmode = true;
                                        break;
                                case 'T':
                                        topazmode = true;
                                        break;
+                               case '3':
+                                       no_rats = true;
+                                       break;
                                default:
                                        PrintAndLog("Invalid option");
                                        return 0;
                                default:
                                        PrintAndLog("Invalid option");
                                        return 0;
@@ -661,7 +654,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
                                                PrintAndLog("Buffer is full, we can't add CRC to your data");
                                        break;
                                } else {
                                                PrintAndLog("Buffer is full, we can't add CRC to your data");
                                        break;
                                } else {
-                                       datalen++
+                                       datalen++;
                                }
                        }
                        continue;
                                }
                        }
                        continue;
@@ -711,6 +704,10 @@ int CmdHF14ACmdRaw(const char *cmd) {
                c.arg[0] |= ISO14A_TOPAZMODE;
        }
 
                c.arg[0] |= ISO14A_TOPAZMODE;
        }
 
+       if(no_rats) {
+               c.arg[0] |= ISO14A_NO_RATS;
+       }
+
        // Max buffer is USB_CMD_DATA_SIZE (512)
        c.arg[1] = (datalen & 0xFFFF) | ((uint32_t)numbits << 16);
        memcpy(c.d.asBytes,data,datalen);
        // Max buffer is USB_CMD_DATA_SIZE (512)
        c.arg[1] = (datalen & 0xFFFF) | ((uint32_t)numbits << 16);
        memcpy(c.d.asBytes,data,datalen);
Impressum, Datenschutz