]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhficlass.c
Some work on iclass dump and iclass list, now the dumping is a lot more stable. I...
[proxmark3-svn] / client / cmdhficlass.c
index 583d518e6d4a3e85a1198d3015303bc1dbf24674..f6261f332120869c145d07bee01b63c86bb9d30a 100644 (file)
@@ -42,6 +42,42 @@ int xorbits_8(uint8_t val)
     return res & 1;
 }
 
+#define ICLASS_CMD_ACTALL 0x0A
+#define ICLASS_CMD_IDENTIFY 0x0C
+#define ICLASS_CMD_READ 0x0C
+
+#define ICLASS_CMD_SELECT 0x81
+#define ICLASS_CMD_PAGESEL 0x84
+#define ICLASS_CMD_READCHECK 0x88
+#define ICLASS_CMD_CHECK 0x05
+#define ICLASS_CMD_SOF 0x0F
+#define ICLASS_CMD_HALT 0x00
+
+
+void explain(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
+{
+
+       if(cmdsize > 1 && cmd[0] == ICLASS_CMD_READ)
+       {
+                 snprintf(exp,size,"READ(%d)",cmd[1]);
+                 return;
+       }
+
+    switch(cmd[0])
+    {
+       case ICLASS_CMD_ACTALL:            snprintf(exp,size,"ACTALL"); break;
+       case ICLASS_CMD_IDENTIFY:    snprintf(exp,size,"IDENTIFY"); break;
+       case ICLASS_CMD_SELECT:         snprintf(exp,size,"SELECT"); break;
+       case ICLASS_CMD_PAGESEL:         snprintf(exp,size,"PAGESEL"); break;
+       case ICLASS_CMD_READCHECK:         snprintf(exp,size,"READCHECK"); break;
+       case ICLASS_CMD_CHECK:         snprintf(exp,size,"CHECK"); break;
+       case ICLASS_CMD_SOF:            snprintf(exp,size,"SOF"); break;
+       case ICLASS_CMD_HALT:            snprintf(exp,size,"HALT"); break;
+       default:                        snprintf(exp,size,"?"); break;
+    }
+    return;
+}
+
 int CmdHFiClassList(const char *Cmd)
 {
        bool ShowWaitCycles = false;
@@ -67,8 +103,8 @@ int CmdHFiClassList(const char *Cmd)
        PrintAndLog("Start = Start of Start Bit, End = End of last modulation. Src = Source of Transfer");
        PrintAndLog("All times are in carrier periods (1/13.56Mhz)");
        PrintAndLog("");
-       PrintAndLog("     Start |       End | Src | Data (! denotes parity error)                                   | CRC ");
-       PrintAndLog("-----------|-----------|-----|-----------------------------------------------------------------------");
+    PrintAndLog("     Start |       End | Src | Data (! denotes parity error)                                   | CRC | Explanation|");
+    PrintAndLog("-----------|-----------|-----|-------------------------------------------------------------------------------------");
 
        uint16_t tracepos = 0;
        uint16_t duration;
@@ -78,7 +114,7 @@ int CmdHFiClassList(const char *Cmd)
        uint32_t timestamp;
        uint32_t first_timestamp;
        uint32_t EndOfTransmissionTimestamp;
-       
+    char explanation[20] = {0};
        for (;;) {
 
                if(tracepos >= TRACE_SIZE) {
@@ -135,7 +171,7 @@ int CmdHFiClassList(const char *Cmd)
 
                }
 
-               char *crc = ""; 
+        char *crc = "    ";
                if (data_len > 2) {
                        uint8_t b1, b2;
                        if(!isResponse && data_len == 4 ) {
@@ -156,20 +192,21 @@ int CmdHFiClassList(const char *Cmd)
                }
 
                EndOfTransmissionTimestamp = timestamp + duration;
-               
+        explain(explanation,sizeof(explanation),frame,data_len);
                int num_lines = (data_len - 1)/16 + 1;
                for (int j = 0; j < num_lines; j++) {
                        if (j == 0) {
-                               PrintAndLog(" %9d | %9d | %s | %-64s| %s",
+                PrintAndLog(" %9d | %9d | %s | %-64s| %s| %s",
                                        (timestamp - first_timestamp),
                                        (EndOfTransmissionTimestamp - first_timestamp),
                                        (isResponse ? "Tag" : "Rdr"),
                                        line[j], 
-                                       (j == num_lines-1)?crc:"");
+                    (j == num_lines-1)?crc:"    ",
+                        explanation);
                        } else {
                                PrintAndLog("           |           |     | %-64s| %s",
                                        line[j], 
-                                       (j == num_lines-1)?crc:"");
+                    (j == num_lines-1)?crc:"    ");
                        }
                }                               
 
@@ -322,7 +359,11 @@ int CmdHFiClassReader(const char *Cmd)
             uint8_t * data  = resp.d.asBytes;
 
             PrintAndLog("isOk:%02x", isOK);
-
+            if( isOK == 0){
+                //Aborted
+                PrintAndLog("Quitting...");
+                return 0;
+            }
             if(isOK > 0)
             {
                 PrintAndLog("CSN: %s",sprint_hex(data,8));
@@ -425,7 +466,7 @@ int CmdHFiClassReader_Dump(const char *Cmd)
 
 
   UsbCommand c = {CMD_READER_ICLASS, {0}};
-  c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE;
+  c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE| FLAG_ICLASS_READER_GET_CC;
   if(!fake_dummy_test)   
     SendCommand(&c);
   
Impressum, Datenschutz