X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/773765774761e1463cadd979c1f74728b8b6fd31..081151eabb3728d4db4e5cca0cab2b2e397e3851:/client/cmdlft55xx.c?ds=inline diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 027f528a..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,25 +45,18 @@ int CmdReadBlk(const char *Cmd) SendCommand(&c); WaitForResponse(CMD_ACK, NULL); - 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; - - uint8_t bits[1000] = {0x00}; - uint8_t * bitstream = bits; - - manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); - - uint32_t bl0 = PackBits(5, 32, bitstream); - PrintAndLog(" Block %d : 0x%08X %s", Block, bl0, sprint_bin(bitstream+5,32) ); +// uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; - 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; } @@ -102,18 +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; - - uint8_t bits[1000] = {0x00}; - uint8_t * bitstream = bits; - - manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); - - uint32_t bl0 = PackBits(5, 32, bitstream); - PrintAndLog(" Block %d : 0x%08X %s", Block, bl0, sprint_bin(bitstream+5,32) ); - + ManchesterDemod(Block); RepaintGraphWindow(); return 0; } @@ -169,20 +148,32 @@ int CmdWriteBlkPWD(const char *Cmd) int CmdReadTrace(const char *Cmd) { - UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}}; - SendCommand(&c); - WaitForResponse(CMD_ACK, NULL); + char cmdp = param_getchar(Cmd, 0); - uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00}; + if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') { + 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"); + return 0; + } - GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset.. - WaitForResponseTimeout(CMD_ACK,NULL, 1500); + if ( strlen(Cmd)==0){ + UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}}; + SendCommand(&c); + WaitForResponse(CMD_ACK, NULL); - for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { - GraphBuffer[j] = ((int)data[j]); - //GraphBuffer[j] = ((int)data[j]) - 128; + 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; } - GraphTraceLen = LF_TRACE_BUFF_SIZE; uint8_t bits[1000] = {0x00}; uint8_t * bitstream = bits; @@ -247,9 +238,21 @@ int CmdInfo(const char *Cmd){ Normal mode Extended mode */ - // läs block 0 - data finns i graphbuff - CmdReadBlk("0"); - + char cmdp = param_getchar(Cmd, 0); + + if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') { + 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"); + return 0; + } + + if ( strlen(Cmd)==0){ + CmdReadBlk("0"); + } + uint8_t bits[1000] = {0x00}; uint8_t * bitstream = bits; @@ -303,7 +306,6 @@ int CmdDump(const char *Cmd){ char cmdp = param_getchar(Cmd, 0); char s[20]; uint8_t pwd[4] = {0x00}; - if (strlen(Cmd)>1 || cmdp == 'h' || cmdp == 'H') { PrintAndLog("Usage: lf t55xx dump "); @@ -320,7 +322,6 @@ int CmdDump(const char *Cmd){ } } - for ( int i = 0; i <8; ++i){ *s = 0; if ( hasPwd ) { @@ -334,6 +335,35 @@ int CmdDump(const char *Cmd){ return 0; } +int CmdIceFsk(const char *Cmd){ + iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE); + RepaintGraphWindow(); + 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(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; +} + char * GetBitRateStr(uint32_t id){ static char buf[40]; char *retStr = buf; @@ -390,7 +420,7 @@ char * GetModulationStr( uint32_t id){ switch (id){ case 0: - sprintf(retStr,"%d - direct",id); + sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id); break; case 1: sprintf(retStr,"%d - PSK 1 phase change when input changes",id); @@ -444,13 +474,15 @@ uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){ 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 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)"}, - {"info", CmdInfo, 0, "Read T55xx configuration data (page 0 / block 0"}, - {"dump", CmdDump, 0, "Dump T55xx card block 0-7 (is possible)"}, + {"rd", CmdReadBlk, 0, " -- Read T55xx block data (page 0)"}, + {"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"}, + {"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 (with SST)"}, {NULL, NULL, 0, NULL} };