From 952a812c008767518e2357e420e1b54dcdf5e2b2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 15 Oct 2015 19:17:20 +0200 Subject: [PATCH] FIX: a suggested fix for #136 where the "lf t55x7 read" command when called with a password. The call will now try loading the config block, decode it and see if PWD is set. If PWD Bit is set, the call will be allowed to execute. If PWD Bit is NOT set, the call will print a message and excute the call but without sending the password. If config block is not being able to read or decode, the call with print a warning message and exit the call. --- client/cmdlft55xx.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 1cadfe7a..e652c788 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(); -- 2.39.2