#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
- UsbCommand c;\r
-\r
- sscanf(Cmd, "%d", &Block);\r
-\r
- if (Block > 7) {\r
- PrintAndLog("Block must be between 0 and 7");\r
- return 1;\r
- } \r
-\r
- PrintAndLog("Reading block %d", Block);\r
-\r
- c.cmd = CMD_T55XX_READ_BLOCK;\r
- c.d.asBytes[0] = 0x0; //Normal mode\r
- c.arg[0] = 0;\r
- c.arg[1] = Block;\r
- c.arg[2] = 0;\r
- SendCommand(&c);\r
+ //default to invalid block\r
+ int Block = -1;\r
+ UsbCommand c;\r
+\r
+ sscanf(Cmd, "%d", &Block);\r
+\r
+ if ((Block > 7) | (Block < 0)) {\r
+ PrintAndLog("Block must be between 0 and 7");\r
+ return 1;\r
+ } \r
+\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] = 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
+ memset(bitstream, 0x00, sizeof(bits));\r
+ \r
+ manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);\r
+ \r
return 0;\r
}\r
\r
+\r
int CmdReadBlkPWD(const char *Cmd)\r
{\r
- int Block = 8; //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
- PrintAndLog("Block must be between 0 and 7");\r
- return 1;\r
- } \r
-\r
- PrintAndLog("Reading block %d with password %08X", Block, Password);\r
-\r
- c.cmd = CMD_T55XX_READ_BLOCK;\r
- c.d.asBytes[0] = 0x1; //Password mode\r
- c.arg[0] = 0;\r
- c.arg[1] = Block;\r
- c.arg[2] = Password;\r
- SendCommand(&c);\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) | (Block < 0)) {\r
+ PrintAndLog("Block must be between 0 and 7");\r
+ return 1;\r
+ } \r
+\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
+ c.arg[0] = 0;\r
+ 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 * bitstream = bits;\r
+ memset(bitstream, 0x00, sizeof(bits));\r
+ \r
+ manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);\r
return 0;\r
}\r
\r
+\r
int CmdWriteBlk(const char *Cmd)\r
{\r
int Block = 8; //default to invalid block\r
\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
+\r
+ uint8_t bits[1000];\r
+ uint8_t * bitstream = bits;\r
+ memset(bitstream, 0x00, sizeof(bits));\r
+ \r
+ manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);\r
+ \r
return 0;\r
}\r
\r
static command_t CommandTable[] =\r
{\r
- {"help", CmdHelp, 1, "This help"},\r
- {"readblock", CmdReadBlk, 1, "<Block> -- Read T55xx block data (page 0)"},\r
- {"readblockPWD", CmdReadBlkPWD, 1, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},\r
- {"writeblock", CmdWriteBlk, 1, "<Data> <Block> -- Write T55xx block data (page 0)"},\r
- {"writeblockPWD", CmdWriteBlkPWD, 1, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},\r
- {"readtrace", CmdReadTrace, 1, "Read T55xx traceability data (page 1)"},\r
+ {"help", CmdHelp, 1, "This help"},\r
+ {"rd", CmdReadBlk, 0, "<Block> -- Read T55xx block data (page 0)"},\r
+ {"rdPWD", CmdReadBlkPWD, 0, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},\r
+ {"wr", CmdWriteBlk, 0, "<Data> <Block> -- Write T55xx block data (page 0)"},\r
+ {"wrPWD", CmdWriteBlkPWD, 0, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},\r
+ {"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1)"},\r
{NULL, NULL, 0, NULL}\r
};\r
\r