X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/773765774761e1463cadd979c1f74728b8b6fd31..72e930ef3206224ae0ff0696a8a146a0b26268f7:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 027f528a..8420465b 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -28,9 +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); @@ -39,10 +37,8 @@ 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; @@ -57,18 +53,10 @@ int CmdReadBlk(const char *Cmd) WaitForResponseTimeout(CMD_ACK,NULL, 1500); for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) { - GraphBuffer[j] = ((int)data[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) ); - + CmdIceManchester(Block); RepaintGraphWindow(); return 0; } @@ -105,15 +93,7 @@ int CmdReadBlkPWD(const char *Cmd) GraphBuffer[j] = ((int)data[j]) - 128; } 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) ); - + CmdIceManchester(Block); RepaintGraphWindow(); return 0; } @@ -169,20 +149,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 +239,22 @@ 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 +308,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 +324,6 @@ int CmdDump(const char *Cmd){ } } - for ( int i = 0; i <8; ++i){ *s = 0; if ( hasPwd ) { @@ -334,6 +337,33 @@ 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; + 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); + + 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) ); + } + 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} };