X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/fbceacc5b80254eb4381102d44e78aad7490876f..081151eabb3728d4db4e5cca0cab2b2e397e3851:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 9206fd2a..5804fbc7 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -28,10 +28,7 @@ static int CmdHelp(const char *Cmd); int CmdReadBlk(const char *Cmd) { - //default to invalid block int Block = -1; - UsbCommand c; - sscanf(Cmd, "%d", &Block); if ((Block > 7) | (Block < 0)) { @@ -39,10 +36,7 @@ int CmdReadBlk(const char *Cmd) return 1; } - //PrintAndLog(" Reading page 0 block : %d", Block); - - // this command fills up BigBuff - // + UsbCommand c; c.cmd = CMD_T55XX_READ_BLOCK; c.d.asBytes[0] = 0x00; c.arg[0] = 0; @@ -51,17 +45,18 @@ int CmdReadBlk(const char *Cmd) SendCommand(&c); WaitForResponse(CMD_ACK, NULL); - uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; +// uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; - 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]) ; - } - GraphTraceLen = LF_TRACE_BUFF_SIZE; - CmdIceManchester(Cmd); - RepaintGraphWindow(); + // 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]; + // } + // GraphTraceLen = LF_TRACE_BUFF_SIZE; + CmdSamples("12000"); + ManchesterDemod(Block); + // RepaintGraphWindow(); return 0; } @@ -94,12 +89,10 @@ int CmdReadBlkPWD(const char *Cmd) WaitForResponseTimeout(CMD_ACK,NULL, 1500); for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { - GraphBuffer[j] = ((int)data[j]) - 128; + GraphBuffer[j] = ((int)data[j]); } GraphTraceLen = LF_TRACE_BUFF_SIZE; - - CmdIceManchester(Cmd); - + ManchesterDemod(Block); RepaintGraphWindow(); return 0; } @@ -161,8 +154,8 @@ int CmdReadTrace(const char *Cmd) PrintAndLog("Usage: lf t55xx trace [use data from Graphbuffer]"); PrintAndLog(" [use data from Graphbuffer], if not set, try reading data from tag."); PrintAndLog(""); - PrintAndLog(" sample: lf t55xx trace"); - PrintAndLog(" sample: lf t55xx trace 1"); + PrintAndLog(" sample: lf t55xx trace"); + PrintAndLog(" sample: lf t55xx trace 1"); return 0; } @@ -251,15 +244,14 @@ int CmdInfo(const char *Cmd){ PrintAndLog("Usage: lf t55xx info [use data from Graphbuffer]"); PrintAndLog(" [use data from Graphbuffer], if not set, try reading data from tag."); PrintAndLog(""); - PrintAndLog(" sample: lf t55xx info"); - PrintAndLog(" sample: lf t55xx info 1"); + PrintAndLog(" sample: lf t55xx info"); + PrintAndLog(" sample: lf t55xx info 1"); return 0; } if ( strlen(Cmd)==0){ CmdReadBlk("0"); - } - + } uint8_t bits[1000] = {0x00}; uint8_t * bitstream = bits; @@ -349,20 +341,26 @@ int CmdIceFsk(const char *Cmd){ return 0; } int CmdIceManchester(const char *Cmd){ + ManchesterDemod( -1); + return 0; +} +int ManchesterDemod(int block){ int blockNum = -1; + uint8_t sizebyte = 32; + uint8_t offset = 5; uint32_t blockData; uint8_t bits[1000] = {0x00}; uint8_t * bitstream = bits; manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); - blockData = PackBits(5, 32, bitstream); - sscanf(Cmd, "%d", &blockNum); - if ( blockNum > -1){ - PrintAndLog(" Block %d : 0x%08X %s", blockNum, blockData, sprint_bin(bitstream+5,32) ); - }else{ - PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bitstream+5,32) ); - } + blockData = PackBits(offset, sizebyte, bitstream); + + if ( blockNum < 0) + PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bitstream+offset,sizebyte) ); + else + PrintAndLog(" Block %d : 0x%08X %s", blockNum, blockData, sprint_bin(bitstream+offset,sizebyte) ); + return 0; } @@ -477,14 +475,14 @@ static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"}, {"rd", CmdReadBlk, 0, " -- Read T55xx block data (page 0)"}, - {"rdPWD", CmdReadBlkPWD, 0, " -- Read T55xx block data with password mode"}, + {"rdpwd", CmdReadBlkPWD, 0, " -- Read T55xx block data with password mode"}, {"wr", CmdWriteBlk, 0, " -- Write T55xx block data (page 0)"}, - {"wrPWD", CmdWriteBlkPWD, 0, " -- Write T55xx block data with password"}, + {"wrpwd", CmdWriteBlkPWD, 0, " -- Write T55xx block data with password"}, {"trace", CmdReadTrace, 0, "[1] Read T55xx traceability data (page 1 / blk 0-1) "}, {"info", CmdInfo, 0, "[1] Read T55xx configuration data (page0 /blk 0)"}, {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. optional with password"}, {"fsk", CmdIceFsk, 0, "FSK demod"}, - {"man", CmdIceManchester, 0, "Manchester demod"}, + {"man", CmdIceManchester, 0, "Manchester demod (with SST)"}, {NULL, NULL, 0, NULL} };