X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/ac2df3460ab2ab2d39fe93350018701699d8327b..b87f99f4bbca6ed29ebeaa78b0165e70941e934d:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 1cadfe7a..3b56881b 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -28,6 +28,7 @@ #define CONFIGURATION_BLOCK 0x00 #define TRACE_BLOCK 0x01 +#define T55x7_PWD 0x00000010 // Default configuration t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00}; @@ -235,8 +236,20 @@ int CmdT55xxReadBlock(const char *Cmd) { //Password mode if ( res == 2 ) { - c.arg[2] = password; - c.d.asBytes[0] = 0x1; + + // try reading the config block and verify that PWD bit is set before doing this! + AquireData( CONFIGURATION_BLOCK ); + if ( !tryDetectModulation() ) { + PrintAndLog("Could not detect is PWD bit is set in config block. Exits."); + return 1; + } + //if PWD bit is set, allow to execute read command with password. + if (( config.block0 & T55x7_PWD ) == 1) { + c.arg[2] = password; + c.d.asBytes[0] = 0x1; + } else { + PrintAndLog("PWD bit is NOT set in config block. Reading without password..."); + } } clearCommandBuffer(); @@ -249,8 +262,8 @@ int CmdT55xxReadBlock(const char *Cmd) { uint8_t got[12000]; GetFromBigBuf(got,sizeof(got),0); WaitForResponse(CMD_ACK,NULL); - setGraphBuf(got, 12000); - DemodBufferLen=0; + setGraphBuf(got, sizeof(got)); + //DemodBufferLen=0; if (!DecodeT55xxBlock()) return 3; char blk[10]={0}; sprintf(blk,"%d", block); @@ -667,8 +680,8 @@ int CmdT55xxWriteBlock(const char *Cmd) return 1; } - UsbCommand resp; UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}}; + UsbCommand resp; c.d.asBytes[0] = 0x0; PrintAndLog("Writing to block: %d data : 0x%08X", block, data);