]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfem4x.c
Inital test for the "lf em4x 410xsim / lf em4x 410xwatch" which I try to verify that...
[proxmark3-svn] / client / cmdlfem4x.c
index 0449e34ab4333c88ba02bb7c730091060ebeaaf7..aa87132e7f6decf57bef6542a4194d9d69d921cd 100644 (file)
@@ -1,4 +1,4 @@
-//-----------------------------------------------------------------------------
+ //-----------------------------------------------------------------------------
 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
 //
 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
@@ -22,6 +22,7 @@
 #include "util.h"
 #include "data.h"
 #define LF_TRACE_BUFF_SIZE 12000
+#define LF_BITSSTREAM_LEN 1000
 
 char *global_em410xId;
 
@@ -194,9 +195,27 @@ retest:
  *   0                     <-- stop bit, end of tag
  */
 int CmdEM410xSim(const char *Cmd)
-{
-  int i, n, j, h, binary[4], parity[4];
+{      
+       int i, n, j, h, binary[4], parity[4];
+
+       char cmdp = param_getchar(Cmd, 0);
+       uint8_t uid[5] = {0x00};
+
+       if (cmdp == 'h' || cmdp == 'H') {
+               PrintAndLog("Usage:  lf em4x sim <UID>");
+               PrintAndLog("");
+               PrintAndLog("     sample: lf em4x sim 0F0368568B");
+               return 0;
+       }
 
+       if (param_gethex(Cmd, 0, uid, 10)) {
+               PrintAndLog("UID must include 10 HEX symbols");
+               return 0;
+       }
+       
+       PrintAndLog("Starting simulating with UID %02X %02X %02X %02X %02X", uid[0],uid[1],uid[2],uid[3],uid[4]);
+       
+  
   /* clock is 64 in EM410x tags */
   int clock = 64;
 
@@ -270,10 +289,16 @@ int CmdEM410xWatch(const char *Cmd)
        int read_h = (*Cmd == 'h');
        do
        {
+               if (ukbhit()) {
+                       printf("\naborted via keyboard!\n");
+                       break;
+               }
+               
                CmdLFRead(read_h ? "h" : "");
-               CmdSamples("16000");    
+               CmdSamples("16000");
+               
        } while (
-               !CmdEM410xRead("") 
+               !CmdEM410xRead("64") 
        );
        return 0;
 }
@@ -530,9 +555,9 @@ int CmdReadWord(const char *Cmd)
        }
        GraphTraceLen = LF_TRACE_BUFF_SIZE;
        
-       uint8_t bits[1000] = {0x00};
+       uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};
        uint8_t * bitstream = bits;
-       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);
+       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream,LF_BITSSTREAM_LEN);
        RepaintGraphWindow();
   return 0;
 }
@@ -570,10 +595,9 @@ int CmdReadWordPWD(const char *Cmd)
        }
        GraphTraceLen = LF_TRACE_BUFF_SIZE;
        
-       uint8_t bits[1000] = {0x00};
-       uint8_t * bitstream = bits;
-       
-       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);
+       uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};
+       uint8_t * bitstream = bits;     
+       manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);
        RepaintGraphWindow();
   return 0;
 }
Impressum, Datenschutz