]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhficlass.c
CHG: "hf mfu info" now always tries to read the NDEF CC. (was restricted to only...
[proxmark3-svn] / client / cmdhficlass.c
index 44b074b35cc8de0acb1ee65c42b25a9f93a0d442..d6c791656806f2540797b0facc30478bc658738d 100644 (file)
@@ -165,10 +165,12 @@ int CmdHFiClassSim(const char *Cmd)
        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}};
+       if (!loop) c.arg[0] |= FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_ONE_TRY;
        SendCommand(&c);
        UsbCommand resp;
        while(!ukbhit()){
@@ -176,23 +178,34 @@ int CmdHFiClassReader(const char *Cmd)
                        uint8_t readStatus    = resp.arg[0] & 0xff;
                        uint8_t * data  = resp.d.asBytes;
 
+                       if (verbose)
                        PrintAndLog("Readstatus:%02x", readStatus);
                        if( readStatus == 0){
                                //Aborted
-                               PrintAndLog("Quitting...");
+                               if (verbose) PrintAndLog("Quitting...");
                                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 (tagFound && !loop) return 1;
                } else {
-                       PrintAndLog("Command execute timeout");
+                       if (verbose) PrintAndLog("Command execute timeout");
                }
+               if (!loop) break;
        }
-
        return 0;
+
+}
+
+int CmdHFiClassReader(const char *Cmd)
+{
+       return HFiClassReader(Cmd, true, true);
 }
 
 int CmdHFiClassReader_Replay(const char *Cmd)
@@ -345,7 +358,7 @@ int CmdHFiClassReader_Dump(const char *Cmd)
                        if(dataLength > 0)
                        {
                                PrintAndLog("Got %d bytes data (total so far %d)" ,dataLength,iclass_datalen);
-                               memcpy(iclass_data, resp.d.asBytes,dataLength);
+                               memcpy(iclass_data+iclass_datalen, resp.d.asBytes,dataLength);
                                iclass_datalen += dataLength;
                        }else
                        {//Last transfer, datalength 0 means the dump is finished
Impressum, Datenschutz