X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/7bd30f12ac6def96c82df20ed7d927160db289af..db297e69e116369d7f5cdadcff69a0425b4e61de:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 3820e590..31261a4f 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,14 +306,13 @@ 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') { + bool hasPwd = ( strlen(Cmd) > 0); + + if ( cmdp == 'h' || cmdp == 'H') { PrintAndLog("Usage: lf t55xx dump "); PrintAndLog(" sample: lf t55xx dump FFFFFFFF"); return 0; } - - bool hasPwd = ( strlen(Cmd) > 0); if ( hasPwd ){ if (param_gethex(Cmd, 0, pwd, 4)) { @@ -320,9 +322,9 @@ int CmdDump(const char *Cmd){ } for ( int i = 0; i <8; ++i){ - *s = 0; + memset(s,0,sizeof(s)); if ( hasPwd ) { - sprintf(s,"%d %d", i, pwd); + sprintf(s,"%d %s", i, sprint_hex(pwd,4)); CmdReadBlkPWD(s); } else { sprintf(s,"%d", i); @@ -333,13 +335,33 @@ int CmdDump(const char *Cmd){ } int CmdIceFsk(const char *Cmd){ - //uint8_t bits[1000] = {0x00}; - //uint8_t * bitstream = bits; 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]; @@ -452,13 +474,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"}, - {"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1 / blk 0-1)"}, - {"info", CmdInfo, 0, "Read T55xx configuration data (page0 /blk 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} };