]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhficlass.c
ADD: using @holiman's "ubs_poll_validate_length() function in some device-side...
[proxmark3-svn] / client / cmdhficlass.c
index b83371960d007958e6ae5c1a7d6f1d861693a9de..e8ba68f18467c2c221bd40cb24a63fc9b57a1a8c 100644 (file)
@@ -165,34 +165,47 @@ int CmdHFiClassSim(const char *Cmd)
        return 0;
 }
 
        return 0;
 }
 
-int CmdHFiClassReader(const char *Cmd)
+int HFiClassReader(const char *Cmd, bool loop, bool verbose)
 {
 {
+       bool tagFound = false;
        UsbCommand c = {CMD_READER_ICLASS, {FLAG_ICLASS_READER_CSN|
                                        FLAG_ICLASS_READER_CONF|FLAG_ICLASS_READER_AA}};
        UsbCommand c = {CMD_READER_ICLASS, {FLAG_ICLASS_READER_CSN|
                                        FLAG_ICLASS_READER_CONF|FLAG_ICLASS_READER_AA}};
+       if (!loop) c.arg[0] |= FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_ONE_TRY;
        SendCommand(&c);
        UsbCommand resp;
        while(!ukbhit()){
        SendCommand(&c);
        UsbCommand resp;
        while(!ukbhit()){
-               if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
+               if (WaitForResponseTimeout(CMD_ACK,&resp, 4500)) {
                        uint8_t readStatus    = resp.arg[0] & 0xff;
                        uint8_t readStatus    = resp.arg[0] & 0xff;
-                       uint8_t * data  = resp.d.asBytes;
+                       uint8_t *data = resp.d.asBytes;
 
 
+                       if (verbose)
                        PrintAndLog("Readstatus:%02x", readStatus);
                        if( readStatus == 0){
                                //Aborted
                        PrintAndLog("Readstatus:%02x", readStatus);
                        if( readStatus == 0){
                                //Aborted
-                               PrintAndLog("Quitting...");
+                               if (verbose) PrintAndLog("Quitting...");
                                return 0;
                        }
                                return 0;
                        }
-                       if( readStatus & FLAG_ICLASS_READER_CSN) PrintAndLog("CSN: %s",sprint_hex(data,8));
+                       if( readStatus & FLAG_ICLASS_READER_CSN){
+                               PrintAndLog("CSN: %s",sprint_hex(data,8));
+                               tagFound = true;
+                       }
                        if( readStatus & FLAG_ICLASS_READER_CC)  PrintAndLog("CC: %s",sprint_hex(data+16,8));
                        if( readStatus & FLAG_ICLASS_READER_CONF){
                                printIclassDumpInfo(data);
                        }
                        if( readStatus & FLAG_ICLASS_READER_CC)  PrintAndLog("CC: %s",sprint_hex(data+16,8));
                        if( readStatus & FLAG_ICLASS_READER_CONF){
                                printIclassDumpInfo(data);
                        }
+                       if (tagFound && !loop) return 1;
                } else {
                } else {
-                       PrintAndLog("Command execute timeout");
+                       if (verbose) PrintAndLog("Command execute timeout");
                }
                }
+               if (!loop) break;
        }
        }
-
        return 0;
        return 0;
+
+}
+
+int CmdHFiClassReader(const char *Cmd)
+{
+       return HFiClassReader(Cmd, true, true);
 }
 
 int CmdHFiClassReader_Replay(const char *Cmd)
 }
 
 int CmdHFiClassReader_Replay(const char *Cmd)
Impressum, Datenschutz