]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
hf search - prelim - re-use hf mfu GetTagType...
authormarshmellow42 <marshmellowrf@gmail.com>
Tue, 12 May 2015 04:19:44 +0000 (00:19 -0400)
committermarshmellow42 <marshmellowrf@gmail.com>
Tue, 12 May 2015 04:19:44 +0000 (00:19 -0400)
in hf 14a reader to identify UL(+)

still a work in progress.

client/cmdhf.c
client/cmdhf14a.c
client/cmdhfmfu.c
client/cmdhfmfu.h

index 020ea94cb18963871d4bda593a515b76e4a354bb..524d9c2e19f93a8fe74e40974d2d8c9eae30e611 100644 (file)
@@ -544,6 +544,21 @@ int CmdHFList(const char *Cmd)
        return 0;
 }
 
+int CmdHFSearch(const char *Cmd){
+       int ans = 0;
+       ans = CmdHF14AReader(Cmd);
+       if (ans > 0) return ans;
+
+       ans = CmdHF15Reader(Cmd);
+       //if (ans > 0) return ans;      
+
+       ans = CmdHF14BRead(Cmd);
+       //if (ans > 0) return ans;
+
+       ans = CmdHFiClassReader(Cmd);
+       //if (ans > 0) return ans;
+       return 0;
+}
 
 static command_t CommandTable[] = 
 {
@@ -554,10 +569,11 @@ static command_t CommandTable[] =
   {"epa",         CmdHFEPA,         1, "{ German Identification Card... }"},
   {"legic",       CmdHFLegic,       0, "{ LEGIC RFIDs... }"},
   {"iclass",      CmdHFiClass,      1, "{ ICLASS RFIDs... }"},
-  {"mf",               CmdHFMF,                1, "{ MIFARE RFIDs... }"},
-  {"mfu",                      CmdHFMFUltra,           1, "{ MIFARE Ultralight RFIDs... }"},
+  {"mf",          CmdHFMF,          1, "{ MIFARE RFIDs... }"},
+  {"mfu",         CmdHFMFUltra,     1, "{ MIFARE Ultralight RFIDs... }"},
   {"tune",        CmdHFTune,        0, "Continuously measure HF antenna tuning"},
-  {"list",       CmdHFList,         1, "List protocol data in trace buffer"},
+  {"list",        CmdHFList,        1, "List protocol data in trace buffer"},
+  {"search",      CmdHFSearch,      1, "Search for known HF tags"},
        {NULL, NULL, 0, NULL}
 };
 
index d4285eeab5df128444ef2cc0ab59761cfb041507..d1f8b36342c4feb2e3fe6b41379e1403e28aaa41 100644 (file)
@@ -23,6 +23,7 @@
 #include "common.h"
 #include "cmdmain.h"
 #include "mifare.h"
+#include "cmdhfmfu.h"
 
 static int CmdHelp(const char *Cmd);
 static void waitCmd(uint8_t iLen);
@@ -169,6 +170,42 @@ int CmdHF14AReader(const char *Cmd)
 
        switch (card.sak) {
                case 0x00: 
+
+                       //***************************************test****************
+                       // disconnect
+                       c.arg[0] = 0;
+                       c.arg[1] = 0;
+                       c.arg[2] = 0;
+                       SendCommand(&c);
+                       
+                       uint16_t tagT = GetHF14AMfU_Type();
+                       ul_print_type(tagT, 0);
+
+                       //reconnect for further tests
+                       c.arg[0] = ISO14A_CONNECT | ISO14A_NO_DISCONNECT;
+                       c.arg[1] = 0;
+                       c.arg[2] = 0;
+
+                       SendCommand(&c);
+
+                       UsbCommand resp;
+                       WaitForResponse(CMD_ACK,&resp);
+                       
+                       memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_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");
+                               // disconnect
+                               c.arg[0] = 0;
+                               c.arg[1] = 0;
+                               c.arg[2] = 0;
+                               SendCommand(&c);
+                               return 0;
+                       }
+
+                       /*  orig
                        // check if the tag answers to GETVERSION (0x60)
                        c.arg[0] = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT;
                        c.arg[1] = 1;
@@ -187,7 +224,7 @@ int CmdHF14AReader(const char *Cmd)
                                case 0x01:PrintAndLog("TYPE : NXP MIFARE Ultralight C");break;
                                case 0x00:PrintAndLog("TYPE : NXP MIFARE Ultralight");break;    
                        }
-
+                       */
                        break;
                case 0x01: PrintAndLog("TYPE : NXP TNP3xxx Activision Game Appliance"); break;
                case 0x04: PrintAndLog("TYPE : NXP MIFARE (various !DESFire !DESFire EV1)"); break;
index fec7a85ec9a21462cb50dd553ff5fb813d43df7b..884ed3ff8d4d323a304ff5670dbf04e6097ef436 100644 (file)
 #define MAX_NTAG_215      0x86
 #define MAX_NTAG_216      0xe6
 
-typedef enum TAGTYPE_UL {
-       UNKNOWN       = 0x0000,
-       UL            = 0x0001,
-       UL_C          = 0x0002,
-       UL_EV1_48     = 0x0004,
-       UL_EV1_128    = 0x0008,
-       NTAG          = 0x0010,
-       NTAG_213      = 0x0020,
-       NTAG_215      = 0x0040,
-       NTAG_216      = 0x0080,
-       MY_D          = 0x0100,
-       MY_D_NFC      = 0x0200,
-       MY_D_MOVE     = 0x0400,
-       MY_D_MOVE_NFC = 0x0800,
-       MAGIC         = 0x1000,
-       UL_MAGIC      = UL | MAGIC,
-       UL_C_MAGIC    = UL_C | MAGIC,
-       UL_ERROR      = 0xFFFF,
-} TagTypeUL_t;
-
 #define KEYS_3DES_COUNT 7
 uint8_t default_3des_keys[KEYS_3DES_COUNT][16] = {
                { 0x42,0x52,0x45,0x41,0x4b,0x4d,0x45,0x49,0x46,0x59,0x4f,0x55,0x43,0x41,0x4e,0x21 },// 3des std key
@@ -314,31 +294,35 @@ static int ntag_print_CC(uint8_t *data) {
        return 0;
 }
 
-static int ul_print_type(uint16_t tagtype){
+int ul_print_type(uint16_t tagtype, uint8_t spaces){
+       char spc[11] = "          ";
+       spc[10]=0x00;
+       char *spacer = spc + (10-spaces);
+
        if ( tagtype & UL )     
-               PrintAndLog("      TYPE : MIFARE Ultralight (MF0ICU1) %s [%x]", (tagtype & MAGIC)?"<magic>":"", tagtype);
+               PrintAndLog("%sTYPE : MIFARE Ultralight (MF0ICU1) %s [%x]", spacer, (tagtype & MAGIC)?"<magic>":"", tagtype);
        else if ( tagtype & UL_C)
-               PrintAndLog("      TYPE : MIFARE Ultralight C (MF0ULC) %s [%x]", (tagtype & MAGIC)?"<magic>":"", tagtype );
+               PrintAndLog("%sTYPE : MIFARE Ultralight C (MF0ULC) %s [%x]", spacer, (tagtype & MAGIC)?"<magic>":"", tagtype );
        else if ( tagtype & UL_EV1_48)
-               PrintAndLog("      TYPE : MIFARE Ultralight EV1 48bytes (MF0UL1101)"); 
+               PrintAndLog("%sTYPE : MIFARE Ultralight EV1 48bytes (MF0UL1101)", spacer); 
        else if ( tagtype & UL_EV1_128)
-               PrintAndLog("      TYPE : MIFARE Ultralight EV1 128bytes (MF0UL2101)");
+               PrintAndLog("%sTYPE : MIFARE Ultralight EV1 128bytes (MF0UL2101)", spacer);
        else if ( tagtype & NTAG_213 )
-               PrintAndLog("      TYPE : MIFARE NTAG 213 144bytes (NT2H1311G0DU)");
+               PrintAndLog("%sTYPE : MIFARE NTAG 213 144bytes (NT2H1311G0DU)", spacer);
        else if ( tagtype & NTAG_215 )
-               PrintAndLog("      TYPE : MIFARE NTAG 215 504bytes (NT2H1511G0DU)");
+               PrintAndLog("%sTYPE : MIFARE NTAG 215 504bytes (NT2H1511G0DU)", spacer);
        else if ( tagtype & NTAG_216 )
-               PrintAndLog("      TYPE : MIFARE NTAG 216 888bytes (NT2H1611G0DU)");
+               PrintAndLog("%sTYPE : MIFARE NTAG 216 888bytes (NT2H1611G0DU)", spacer);
        else if ( tagtype & MY_D )
-               PrintAndLog("      TYPE : INFINEON my-d\x99");
+               PrintAndLog("%sTYPE : INFINEON my-d\x99", spacer);
        else if ( tagtype & MY_D_NFC )
-               PrintAndLog("      TYPE : INFINEON my-d\x99 NFC");
+               PrintAndLog("%sTYPE : INFINEON my-d\x99 NFC", spacer);
        else if ( tagtype & MY_D_MOVE )
-               PrintAndLog("      TYPE : INFINEON my-d\x99 move");
+               PrintAndLog("%sTYPE : INFINEON my-d\x99 move", spacer);
        else if ( tagtype & MY_D_MOVE_NFC )
-               PrintAndLog("      TYPE : INFINEON my-d\x99 move NFC");
+               PrintAndLog("%sTYPE : INFINEON my-d\x99 move NFC", spacer);
        else
-               PrintAndLog("      TYPE : Unknown %04x",tagtype);
+               PrintAndLog("%sTYPE : Unknown %04x", spacer, tagtype);
        return 0;
 }
 
@@ -579,7 +563,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
 
        PrintAndLog("\n--- Tag Information ---------");
        PrintAndLog("-------------------------------------------------------------");
-       ul_print_type(tagtype);
+       ul_print_type(tagtype, 6);
 
        status = ul_select(&card);
        if ( status < 1 ){
index 8e96775cd51acae07a987375b60e61781b10b6a6..23f97cac37a22db5c34d94464d0d9072fed793ac 100644 (file)
@@ -20,9 +20,31 @@ void rol (uint8_t *data, const size_t len);
 uint8_t requestAuthentication( uint8_t *nonce);
 int try3DesAuthentication( uint8_t *key);
 uint16_t GetHF14AMfU_Type(void);
+int ul_print_type(uint16_t tagtype, uint8_t spacer);
 
 int usage_hf_mfu_dump(void);
 
 int CmdHFMFUltra(const char *Cmd);
 int CmdHF14AMfUInfo(const char *Cmd);
+
+typedef enum TAGTYPE_UL {
+       UNKNOWN       = 0x0000,
+       UL            = 0x0001,
+       UL_C          = 0x0002,
+       UL_EV1_48     = 0x0004,
+       UL_EV1_128    = 0x0008,
+       NTAG          = 0x0010,
+       NTAG_213      = 0x0020,
+       NTAG_215      = 0x0040,
+       NTAG_216      = 0x0080,
+       MY_D          = 0x0100,
+       MY_D_NFC      = 0x0200,
+       MY_D_MOVE     = 0x0400,
+       MY_D_MOVE_NFC = 0x0800,
+       MAGIC         = 0x1000,
+       UL_MAGIC      = UL | MAGIC,
+       UL_C_MAGIC    = UL_C | MAGIC,
+       UL_ERROR      = 0xFFFF,
+} TagTypeUL_t;
+
 #endif
Impressum, Datenschutz