X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/e98300f2455f72b64df737b3a81c072b6b3761e3..b44e523300b3fbe0a5d9b3081aaa588be3095b14:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 1fac5014..a002bf34 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -10,64 +10,122 @@ #include #include #include -#include "proxusb.h" +#include "proxmark3.h" #include "ui.h" #include "graph.h" +#include "cmdmain.h" #include "cmdparser.h" #include "cmddata.h" #include "cmdlf.h" #include "cmdlft55xx.h" +#include "util.h" +#include "data.h" +#define LF_TRACE_BUFF_SIZE 16000 static int CmdHelp(const char *Cmd); int CmdReadBlk(const char *Cmd) { - int Block = 8; //default to invalid block - UsbCommand c; - - sscanf(Cmd, "%d", &Block); - - if (Block > 7) { - PrintAndLog("Block must be between 0 and 7"); - return 1; - } - - PrintAndLog("Reading block %d", Block); - - c.cmd = CMD_T55XX_READ_BLOCK; - c.d.asBytes[0] = 0x0; //Normal mode - c.arg[0] = 0; - c.arg[1] = Block; - c.arg[2] = 0; - SendCommand(&c); + //default to invalid block + int Block = -1; + UsbCommand c; + + sscanf(Cmd, "%d", &Block); + + if ((Block > 7) | (Block < 0)) { + PrintAndLog("Block must be between 0 and 7"); + return 1; + } + + PrintAndLog(" Reading page 0 block : %d", Block); + + // this command fills up BigBuff + // + c.cmd = CMD_T55XX_READ_BLOCK; + c.d.asBytes[0] = 0x00; + c.arg[0] = 0; + c.arg[1] = Block; + c.arg[2] = 0; + SendCommand(&c); + WaitForResponse(CMD_ACK, NULL); + + uint8_t data[LF_TRACE_BUFF_SIZE]; + memset(data, 0x00, LF_TRACE_BUFF_SIZE); + + GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. + WaitForResponseTimeout(CMD_ACK,NULL, 1500); + + for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { + GraphBuffer[j] = ((int)data[j]) - 128; + } + GraphTraceLen = LF_TRACE_BUFF_SIZE; + + // BiDirectional + //CmdDirectionalThreshold("70 60"); + + // Askdemod + //Cmdaskdemod("1"); + + uint8_t bits[1000]; + uint8_t * bitstream = bits; + memset(bitstream, 0x00, sizeof(bits)); + + manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); + return 0; } + int CmdReadBlkPWD(const char *Cmd) { - int Block = 8; //default to invalid block - int Password = 0xFFFFFFFF; //default to blank Block 7 - UsbCommand c; - - sscanf(Cmd, "%d %x", &Block, &Password); - - if (Block > 7) { - PrintAndLog("Block must be between 0 and 7"); - return 1; - } - - PrintAndLog("Reading block %d with password %08X", Block, Password); - - c.cmd = CMD_T55XX_READ_BLOCK; - c.d.asBytes[0] = 0x1; //Password mode - c.arg[0] = 0; - c.arg[1] = Block; - c.arg[2] = Password; - SendCommand(&c); + int Block = -1; //default to invalid block + int Password = 0xFFFFFFFF; //default to blank Block 7 + UsbCommand c; + + sscanf(Cmd, "%d %x", &Block, &Password); + + if ((Block > 7) | (Block < 0)) { + PrintAndLog("Block must be between 0 and 7"); + return 1; + } + + PrintAndLog("Reading page 0 block %d pwd %08X", Block, Password); + + c.cmd = CMD_T55XX_READ_BLOCK; + c.d.asBytes[0] = 0x1; //Password mode + c.arg[0] = 0; + c.arg[1] = Block; + c.arg[2] = Password; + SendCommand(&c); + WaitForResponse(CMD_ACK, NULL); + + uint8_t data[LF_TRACE_BUFF_SIZE]; + memset(data, 0x00, LF_TRACE_BUFF_SIZE); + + GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. + WaitForResponseTimeout(CMD_ACK,NULL, 1500); + + for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { + GraphBuffer[j] = ((int)data[j]) - 128; + } + GraphTraceLen = LF_TRACE_BUFF_SIZE; + + // BiDirectional + //CmdDirectionalThreshold("70 -60"); + + // Askdemod + //Cmdaskdemod("1"); + + uint8_t bits[1000]; + uint8_t * bitstream = bits; + memset(bitstream, 0x00, sizeof(bits)); + + manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); return 0; } + int CmdWriteBlk(const char *Cmd) { int Block = 8; //default to invalid block @@ -119,22 +177,47 @@ int CmdWriteBlkPWD(const char *Cmd) int CmdReadTrace(const char *Cmd) { - - PrintAndLog("Reading traceability data"); + PrintAndLog(" Reading page 1 - tracedata"); UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}}; SendCommand(&c); + WaitForResponse(CMD_ACK, NULL); + + uint8_t data[LF_TRACE_BUFF_SIZE]; + memset(data, 0x00, LF_TRACE_BUFF_SIZE); + + GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. + WaitForResponseTimeout(CMD_ACK,NULL, 1500); + + for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { + GraphBuffer[j] = ((int)data[j]) - 128; + } + GraphTraceLen = LF_TRACE_BUFF_SIZE; + + // BiDirectional + //CmdDirectionalThreshold("70 -60"); + + // Askdemod + //Cmdaskdemod("1"); + + + uint8_t bits[1000]; + uint8_t * bitstream = bits; + memset(bitstream, 0x00, sizeof(bits)); + + manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); + return 0; } static command_t CommandTable[] = { - {"help", CmdHelp, 1, "This help"}, - {"readblock", CmdReadBlk, 1, " -- Read T55xx block data (page 0)"}, - {"readblockPWD", CmdReadBlkPWD, 1, " -- Read T55xx block data in password mode(page 0)"}, - {"writeblock", CmdWriteBlk, 1, " -- Write T55xx block data (page 0)"}, - {"writeblockPWD", CmdWriteBlkPWD, 1, " -- Write T55xx block data in password mode(page 0)"}, - {"readtrace", CmdReadTrace, 1, "Read T55xx traceability data (page 1)"}, + {"help", CmdHelp, 1, "This help"}, + {"rd", CmdReadBlk, 0, " -- Read T55xx block data (page 0)"}, + {"rdPWD", CmdReadBlkPWD, 0, " -- Read T55xx block data in password mode(page 0)"}, + {"wr", CmdWriteBlk, 0, " -- Write T55xx block data (page 0)"}, + {"wrPWD", CmdWriteBlkPWD, 0, " -- Write T55xx block data in password mode(page 0)"}, + {"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1)"}, {NULL, NULL, 0, NULL} };