]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
HF Search - refactoring cmds to work with it
authormarshmellow42 <marshmellowrf@gmail.com>
Tue, 12 May 2015 20:45:48 +0000 (16:45 -0400)
committermarshmellow42 <marshmellowrf@gmail.com>
Tue, 12 May 2015 20:45:48 +0000 (16:45 -0400)
armsrc/iclass.c
client/cmdhf.c
client/cmdhf14a.c
client/cmdhf15.c
client/cmdhf15.h
client/cmdhficlass.c
client/cmdhficlass.h
include/usb_cmd.h

index 56bc29db5d760f4f631c51878635c486fe0d6de6..9139d3bd9f5a0734f4b2e651ca4b503e4b0a6485 100644 (file)
@@ -1677,7 +1677,7 @@ void ReaderIClass(uint8_t arg0) {
 
        uint8_t card_data[6 * 8]={0};
        memset(card_data, 0xFF, sizeof(card_data));
 
        uint8_t card_data[6 * 8]={0};
        memset(card_data, 0xFF, sizeof(card_data));
-    uint8_t last_csn[8]={0};
+       uint8_t last_csn[8]={0};
        
        //Read conf block CRC(0x01) => 0xfa 0x22
        uint8_t readConf[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x01, 0xfa, 0x22};
        
        //Read conf block CRC(0x01) => 0xfa 0x22
        uint8_t readConf[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x01, 0xfa, 0x22};
@@ -1685,16 +1685,18 @@ void ReaderIClass(uint8_t arg0) {
        uint8_t readAA[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x05, 0xde, 0x64};
 
 
        uint8_t readAA[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x05, 0xde, 0x64};
 
 
-    int read_status= 0;
+       int read_status= 0;
        uint8_t result_status = 0;
        uint8_t result_status = 0;
-    bool abort_after_read = arg0 & FLAG_ICLASS_READER_ONLY_ONCE;
-
+       bool abort_after_read = arg0 & FLAG_ICLASS_READER_ONLY_ONCE;
+       bool try_once = arg0 & FLAG_ICLASS_READER_ONE_TRY;
        set_tracing(TRUE);
        set_tracing(TRUE);
-    setupIclassReader();
+       setupIclassReader();
 
 
+       uint16_t tryCnt=0;
        while(!BUTTON_PRESS())
        while(!BUTTON_PRESS())
-    {
-
+       {
+               if (try_once && tryCnt > 5) break; 
+               tryCnt++;
                if(!tracing) {
                        DbpString("Trace full");
                        break;
                if(!tracing) {
                        DbpString("Trace full");
                        break;
@@ -1761,7 +1763,7 @@ void ReaderIClass(uint8_t arg0) {
 
                }
                LED_B_OFF();
 
                }
                LED_B_OFF();
-    }
+       }
     cmd_send(CMD_ACK,0,0,0,card_data, 0);
     LED_A_OFF();
 }
     cmd_send(CMD_ACK,0,0,0,card_data, 0);
     LED_A_OFF();
 }
index 524d9c2e19f93a8fe74e40974d2d8c9eae30e611..8853a7f3f3022f11c5ac773f53c9831d50268ba1 100644 (file)
@@ -87,7 +87,7 @@ void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
        case MIFARE_ULC_AUTH_2:         snprintf(exp,size,"AUTH_ANSW"); break;
        case MIFARE_ULEV1_AUTH:         snprintf(exp,size,"PWD-AUTH"); break;
        case MIFARE_ULEV1_FASTREAD:{
        case MIFARE_ULC_AUTH_2:         snprintf(exp,size,"AUTH_ANSW"); break;
        case MIFARE_ULEV1_AUTH:         snprintf(exp,size,"PWD-AUTH"); break;
        case MIFARE_ULEV1_FASTREAD:{
-               if ( cmdsize >=3 && cmd[2] < 0x21)
+               if ( cmdsize >=3 && cmd[2] <= 0xE6)
                        snprintf(exp,size,"READ RANGE (%d-%d)",cmd[1],cmd[2]); 
                else
                        snprintf(exp,size,"?");
                        snprintf(exp,size,"READ RANGE (%d-%d)",cmd[1],cmd[2]); 
                else
                        snprintf(exp,size,"?");
@@ -546,17 +546,28 @@ int CmdHFList(const char *Cmd)
 
 int CmdHFSearch(const char *Cmd){
        int ans = 0;
 
 int CmdHFSearch(const char *Cmd){
        int ans = 0;
-       ans = CmdHF14AReader(Cmd);
-       if (ans > 0) return ans;
+       PrintAndLog("");
+       ans = CmdHF14AReader("s");
+       if (ans > 0) {
+               PrintAndLog("\nValid ISO14443A Tag Found - Quiting Search\n");
+               return ans;
+       } 
+       ans = HFiClassReader("", false, false);
+       if (ans) {
+               PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n");
+               return ans;
+       }
+       ans = HF15Reader("", false);
+       if (ans) {
+               PrintAndLog("\nValid ISO15693 Tag Found - Quiting Search\n");
+               return ans;
+       }
 
 
-       ans = CmdHF15Reader(Cmd);
-       //if (ans > 0) return ans;      
 
 
-       ans = CmdHF14BRead(Cmd);
+       //14b has issues currently...
+       //ans = CmdHF14BRead(Cmd);
        //if (ans > 0) return ans;
 
        //if (ans > 0) return ans;
 
-       ans = CmdHFiClassReader(Cmd);
-       //if (ans > 0) return ans;
        return 0;
 }
 
        return 0;
 }
 
@@ -573,7 +584,7 @@ static command_t CommandTable[] =
   {"mfu",         CmdHFMFUltra,     1, "{ MIFARE Ultralight RFIDs... }"},
   {"tune",        CmdHFTune,        0, "Continuously measure HF antenna tuning"},
   {"list",        CmdHFList,        1, "List protocol data in trace buffer"},
   {"mfu",         CmdHFMFUltra,     1, "{ MIFARE Ultralight RFIDs... }"},
   {"tune",        CmdHFTune,        0, "Continuously measure HF antenna tuning"},
   {"list",        CmdHFList,        1, "List protocol data in trace buffer"},
-  {"search",      CmdHFSearch,      1, "Search for known HF tags"},
+  {"search",      CmdHFSearch,      1, "Search for known HF tags [preliminary]"},
        {NULL, NULL, 0, NULL}
 };
 
        {NULL, NULL, 0, NULL}
 };
 
index d1f8b36342c4feb2e3fe6b41379e1403e28aaa41..1973ff22259415a5523b9c1d67ceee0e5b347d60 100644 (file)
@@ -144,7 +144,7 @@ int CmdHF14AReader(const char *Cmd)
        uint64_t select_status = resp.arg[0];           // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
        
        if(select_status == 0) {
        uint64_t select_status = resp.arg[0];           // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
        
        if(select_status == 0) {
-               PrintAndLog("iso14443a card select failed");
+               if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed");
                // disconnect
                c.arg[0] = 0;
                c.arg[1] = 0;
                // disconnect
                c.arg[0] = 0;
                c.arg[1] = 0;
index c3ff7dd6d3976574b668ab5ec13fa5c0b398f8b3..8ddbea89bbab5cf8034ead823a6f6a2ea9c10f34 100644 (file)
@@ -374,6 +374,20 @@ int CmdHF15Record(const char *Cmd)
        return 0;
 }
 
        return 0;
 }
 
+int HF15Reader(const char *Cmd, bool verbose)
+{
+       uint8_t uid[8];
+
+       if (!getUID(uid)) {
+               if (verbose) PrintAndLog("No Tag found.");
+               return 0;
+       }
+
+       PrintAndLog("Tag UID : %s",sprintUID(NULL,uid));
+       PrintAndLog("Tag Info: %s",getTagInfo(uid));
+       return 1;
+}
+
 int CmdHF15Reader(const char *Cmd)
 {
        UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
 int CmdHF15Reader(const char *Cmd)
 {
        UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
@@ -469,7 +483,7 @@ int CmdHF15DumpMem(const char*Cmd) {
                                        // PrintAndLog("bn=%i",blocknum);
                                } else {
                                        PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); 
                                        // PrintAndLog("bn=%i",blocknum);
                                } else {
                                        PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); 
-                                       return 0;
+                                       return 1;
                                }
                        } // else PrintAndLog("crc");
                } // else PrintAndLog("r null");
                                }
                        } // else PrintAndLog("crc");
                } // else PrintAndLog("r null");
@@ -481,7 +495,7 @@ int CmdHF15DumpMem(const char*Cmd) {
 //             PrintAndLog("CRC Failed");
 //     else 
 //             PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); 
 //             PrintAndLog("CRC Failed");
 //     else 
 //             PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1])); 
-       return 0;
+       return 1;
 }
 
 
 }
 
 
index 8d78e13f1c60fd30d63d27290bd135bc2d955257..c6264604670d1980b9f3d943d6088d32535fbeb6 100644 (file)
@@ -15,6 +15,7 @@ int CmdHF15(const char *Cmd);
 
 int CmdHF15Demod(const char *Cmd);
 int CmdHF15Read(const char *Cmd);
 
 int CmdHF15Demod(const char *Cmd);
 int CmdHF15Read(const char *Cmd);
+int HF15Reader(const char *Cmd, bool verbose);
 int CmdHF15Reader(const char *Cmd);
 int CmdHF15Sim(const char *Cmd);
 int CmdHF15Record(const char *Cmd);
 int CmdHF15Reader(const char *Cmd);
 int CmdHF15Sim(const char *Cmd);
 int CmdHF15Record(const char *Cmd);
index b83371960d007958e6ae5c1a7d6f1d861693a9de..824aaa3674cc1bd5cf84d38174968d0e3fbd468e 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)) {
-                       uint8_t readStatus    = resp.arg[0] & 0xff;
-                       uint8_t * data  = resp.d.asBytes;
+               if (WaitForResponseTimeout(CMD_ACK,&resp, 4500)) {
+                       uint8_t readStatus = resp.arg[0] & 0xff;
+                       uint8_t *data = resp.d.asBytes;
 
 
-                       PrintAndLog("Readstatus:%02x", readStatus);
+                       if (verbose)
+                               PrintAndLog("Readstatus:%02x", readStatus);
                        if( readStatus == 0){
                                //Aborted
                        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)
index e4048eb170092b4f6cbfa5266830405ba70f406b..30c6a8a7b1907f2bedf6f121b79ffad46293c9a1 100644 (file)
@@ -17,6 +17,7 @@ int CmdHFiClass(const char *Cmd);
 int CmdHFiClassSnoop(const char *Cmd);
 int CmdHFiClassSim(const char *Cmd);
 int CmdHFiClassList(const char *Cmd);
 int CmdHFiClassSnoop(const char *Cmd);
 int CmdHFiClassSim(const char *Cmd);
 int CmdHFiClassList(const char *Cmd);
+int HFiClassReader(const char *Cmd, bool loop, bool verbose);
 int CmdHFiClassReader(const char *Cmd);
 int CmdHFiClassReader_Replay(const char *Cmd);
 
 int CmdHFiClassReader(const char *Cmd);
 int CmdHFiClassReader_Replay(const char *Cmd);
 
index 31498e2a450e88ba94d1a005ca91faaa9200402c..f67eac580d35976c207c8520867ff346e2665841 100644 (file)
@@ -201,10 +201,11 @@ typedef struct{
 
 //Iclass reader flags
 #define FLAG_ICLASS_READER_ONLY_ONCE    0x01
 
 //Iclass reader flags
 #define FLAG_ICLASS_READER_ONLY_ONCE    0x01
-#define FLAG_ICLASS_READER_CC       0x02
-#define FLAG_ICLASS_READER_CSN         0x04
-#define FLAG_ICLASS_READER_CONF                0x08
-#define FLAG_ICLASS_READER_AA          0x10
+#define FLAG_ICLASS_READER_CC           0x02
+#define FLAG_ICLASS_READER_CSN          0x04
+#define FLAG_ICLASS_READER_CONF         0x08
+#define FLAG_ICLASS_READER_AA           0x10
+#define FLAG_ICLASS_READER_ONE_TRY      0x20
 
 
 
 
 
 
Impressum, Datenschutz