]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlft55xx.c
Merge branch 'master' of https://github.com/Proxmark/proxmark3
[proxmark3-svn] / client / cmdlft55xx.c
index 9783370ce19c0980cfa698649b9d3aecf0c009b7..5a464ddb1e66aa0379629505650d2ac40f578985 100644 (file)
 #include <stdio.h>\r
 #include <string.h>\r
 #include <inttypes.h>\r
-//#include "proxusb.h"\r
 #include "proxmark3.h"\r
 #include "ui.h"\r
 #include "graph.h"\r
+#include "cmdmain.h"\r
 #include "cmdparser.h"\r
 #include "cmddata.h"\r
 #include "cmdlf.h"\r
 #include "cmdlft55xx.h"\r
+#include "util.h"\r
+#include "data.h"\r
 \r
+#define LF_TRACE_BUFF_SIZE 16000\r
 static int CmdHelp(const char *Cmd);\r
 \r
 \r
 int CmdReadBlk(const char *Cmd)\r
 {\r
-  int Block = 8; //default to invalid block\r
+       //default to invalid block\r
+       int Block = -1;\r
   UsbCommand c;\r
 \r
   sscanf(Cmd, "%d", &Block);\r
 \r
-  if (Block > 7) {\r
+       if ((Block > 7) | (Block < 0)) {\r
        PrintAndLog("Block must be between 0 and 7");\r
        return 1;\r
   }    \r
 \r
-  PrintAndLog("Reading block %d", Block);\r
+       PrintAndLog(" Reading page 0 block : %d", Block);\r
 \r
+       // this command fills up BigBuff\r
+       // \r
   c.cmd = CMD_T55XX_READ_BLOCK;\r
-  c.d.asBytes[0] = 0x0; //Normal mode\r
+       c.d.asBytes[0] = 0x00;\r
   c.arg[0] = 0;\r
   c.arg[1] = Block;\r
   c.arg[2] = 0;\r
   SendCommand(&c);\r
+       WaitForResponse(CMD_ACK, NULL);\r
+       \r
+       uint8_t data[LF_TRACE_BUFF_SIZE];\r
+       memset(data, 0x00, LF_TRACE_BUFF_SIZE);\r
+       \r
+       GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560);  //3560 -- should be offset..\r
+       WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r
+\r
+       for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r
+               GraphBuffer[j] = ((int)data[j]) - 128;\r
+       }\r
+       GraphTraceLen = LF_TRACE_BUFF_SIZE;\r
+         \r
+       // BiDirectional\r
+       CmdDirectionalThreshold("70 -60");      \r
+       \r
+       // Askdemod\r
+       Cmdaskdemod("1");\r
+       \r
+       uint8_t bits[1000];\r
+       uint8_t * bitstream = bits;\r
+       uint8_t len = 0;\r
+       len = manchester_decode(data, LF_TRACE_BUFF_SIZE, bitstream);\r
+       if ( len > 0 )\r
+               PrintPaddedManchester(bitstream, len, 32);\r
+\r
   return 0;\r
 }\r
 \r
+\r
 int CmdReadBlkPWD(const char *Cmd)\r
 {\r
-  int Block = 8; //default to invalid block\r
+       int Block = -1; //default to invalid block\r
   int Password = 0xFFFFFFFF; //default to blank Block 7\r
   UsbCommand c;\r
 \r
   sscanf(Cmd, "%d %x", &Block, &Password);\r
 \r
-  if (Block > 7) {\r
+       if ((Block > 7) | (Block < 0)) {\r
        PrintAndLog("Block must be between 0 and 7");\r
        return 1;\r
   }    \r
 \r
-  PrintAndLog("Reading block %d with password %08X", Block, Password);\r
+       PrintAndLog("Reading page 0 block %d pwd %08X", Block, Password);\r
 \r
   c.cmd = CMD_T55XX_READ_BLOCK;\r
   c.d.asBytes[0] = 0x1; //Password mode\r
@@ -66,9 +99,35 @@ int CmdReadBlkPWD(const char *Cmd)
   c.arg[1] = Block;\r
   c.arg[2] = Password;\r
   SendCommand(&c);\r
+       WaitForResponse(CMD_ACK, NULL);\r
+               \r
+       uint8_t data[LF_TRACE_BUFF_SIZE];\r
+       memset(data, 0x00, LF_TRACE_BUFF_SIZE);\r
+\r
+       GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560);  //3560 -- should be offset..\r
+       WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r
+\r
+       for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r
+               GraphBuffer[j] = ((int)data[j]) - 128;\r
+       }\r
+       GraphTraceLen = LF_TRACE_BUFF_SIZE;\r
+\r
+       // BiDirectional\r
+       CmdDirectionalThreshold("70 -60");      \r
+       \r
+       // Askdemod\r
+       Cmdaskdemod("1");\r
+               \r
+       uint8_t bits[1000];\r
+       uint8_t len = 0;\r
+       len = manchester_decode(data, LF_TRACE_BUFF_SIZE, bits);\r
+       if ( len > 0 )\r
+               PrintPaddedManchester(bits, len, 32);\r
+               \r
   return 0;\r
 }\r
 \r
+\r
 int CmdWriteBlk(const char *Cmd)\r
 {\r
   int Block = 8; //default to invalid block\r
@@ -120,11 +179,35 @@ int CmdWriteBlkPWD(const char *Cmd)
 \r
 int CmdReadTrace(const char *Cmd)\r
 {\r
-\r
-  PrintAndLog("Reading traceability data");\r
+       PrintAndLog(" Reading page 1 - tracedata");\r
 \r
   UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};\r
   SendCommand(&c);\r
+       WaitForResponse(CMD_ACK, NULL);\r
+\r
+       uint8_t data[LF_TRACE_BUFF_SIZE];\r
+       memset(data, 0x00, LF_TRACE_BUFF_SIZE);\r
+\r
+       GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560);  //3560 -- should be offset..\r
+       WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r
+\r
+       for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r
+               GraphBuffer[j] = ((int)data[j]) - 128;\r
+       }\r
+       GraphTraceLen = LF_TRACE_BUFF_SIZE;\r
+       \r
+       // BiDirectional\r
+       CmdDirectionalThreshold("70 -60");      \r
+       \r
+       // Askdemod\r
+       Cmdaskdemod("1");\r
+\r
+       uint8_t bits[512];\r
+       uint8_t len = 0;\r
+       len =  manchester_decode(data,LF_TRACE_BUFF_SIZE,bits);\r
+       if ( len > 0 )\r
+               PrintPaddedManchester(bits, len, 64);\r
+       \r
   return 0;\r
 }\r
 \r
Impressum, Datenschutz