]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfhitag.c
FIX: introduced a bug in luascripts when adding the "safe ascii chars" to ConvertHex...
[proxmark3-svn] / client / cmdlfhitag.c
index a5c3b8eb29bfce37f859930f55d0c561a9ab1c03..b32990cdd340c857c3b2c333c2fcc5f6279ac825 100644 (file)
@@ -195,9 +195,9 @@ int CmdLFHitagSim(const char *Cmd) {
 
 int CmdLFHitagReader(const char *Cmd) {
        
-       UsbCommand c = {CMD_READER_HITAG};//, {param_get32ex(Cmd,0,0,10),param_get32ex(Cmd,1,0,16),param_get32ex(Cmd,2,0,16),param_get32ex(Cmd,3,0,16)}};
+       UsbCommand c = {CMD_READER_HITAG, {0,0,0} };//, {param_get32ex(Cmd,0,0,10),param_get32ex(Cmd,1,0,16),param_get32ex(Cmd,2,0,16),param_get32ex(Cmd,3,0,16)}};
        hitag_data* htd = (hitag_data*)c.d.asBytes;
-       hitag_function htf = param_get32ex(Cmd,0,0,10);
+       hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
        
        switch (htf) {
                case 01: { //RHTSF_CHALLENGE
@@ -222,9 +222,14 @@ int CmdLFHitagReader(const char *Cmd) {
                case RHT2F_TEST_AUTH_ATTEMPTS: {
                        // No additional parameters needed
                } break;
+               case RHT2F_UID_ONLY: {
+                       // No additional parameters needed
+               } break;
                default: {
-                       PrintAndLog("Error: unkown reader function %d",htf);
-                       PrintAndLog("Hitag reader functions");
+                       PrintAndLog("\nError: unkown reader function %d",htf);
+                       PrintAndLog("");
+                       PrintAndLog("Usage: hitag reader <Reader Function #>");
+                       PrintAndLog("Reader Functions:");
                        PrintAndLog(" HitagS (0*)");
                        PrintAndLog("  01 <nr> <ar> (Challenge) read all pages from a Hitag S tag");
                        PrintAndLog("  02 <key> (set to 0 if no authentication is needed) read all pages from a Hitag S tag");
@@ -234,6 +239,7 @@ int CmdLFHitagReader(const char *Cmd) {
                        PrintAndLog("  22 <nr> <ar> (authentication)");
                        PrintAndLog("  23 <key> (authentication) key is in format: ISK high + ISK low");
                        PrintAndLog("  25 (test recorded authentications)");
+                       PrintAndLog("  26 just read UID");
                        return 1;
                } break;
        }
@@ -243,26 +249,30 @@ int CmdLFHitagReader(const char *Cmd) {
        clearCommandBuffer();
        SendCommand(&c);
        UsbCommand resp;
-       WaitForResponse(CMD_ACK,&resp);
+       WaitForResponse(CMD_ACK, &resp);
 
        // Check the return status, stored in the first argument
        if (resp.arg[0] == false) return 1;
 
        uint32_t id = bytes_to_num(resp.d.asBytes,4);
 
-       char filename[FILE_PATH_SIZE];
-       FILE* f = NULL;
-       sprintf(filename,"%08x_%04x.ht2",id,(rand() & 0xffff));
-       f = fopen(filename,"wb");
-       if (!f) {
-               PrintAndLog("Error: Could not open file [%s]",filename);
-               return 1;
-       }
+       if (htf == RHT2F_UID_ONLY){
+               PrintAndLog("Valid Hitag2 tag found - UID: %08x",id);
+       } else {
+               char filename[FILE_PATH_SIZE];
+               FILE* f = NULL;
+               sprintf(filename,"%08x_%04x.ht2",id,(rand() & 0xffff));
+               f = fopen(filename,"wb");
+               if (!f) {
+                       PrintAndLog("Error: Could not open file [%s]",filename);
+                       return 1;
+               }
 
-       // Write the 48 tag memory bytes to file and finalize
-       fwrite(resp.d.asBytes, 1, 48, f);
-       fclose(f);
-       PrintAndLog("Succesfully saved tag memory to [%s]",filename);
+               // Write the 48 tag memory bytes to file and finalize
+               fwrite(resp.d.asBytes, 1, 48, f);
+               fclose(f);
+               PrintAndLog("Succesfully saved tag memory to [%s]",filename);
+       }
        return 0;
 }
 
Impressum, Datenschutz