]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
add lf t5 read w/pwd warning and checks
authormarshmellow42 <marshmellowrf@gmail.com>
Fri, 16 Oct 2015 01:26:23 +0000 (21:26 -0400)
committermarshmellow42 <marshmellowrf@gmail.com>
Fri, 16 Oct 2015 01:26:23 +0000 (21:26 -0400)
ideas from @iceman1001 for issue #136

client/cmdlft55xx.c

index 5a86d612ef69f2691584eb8f4e4c7bfce9a149a9..2297d249d41b2a0783405106ac68702599e9c902 100644 (file)
@@ -49,13 +49,18 @@ int usage_t55xx_config(){
        return 0;\r
 }\r
 int usage_t55xx_read(){\r
-       PrintAndLog("Usage:  lf t55xx read <block> <password>");\r
+       PrintAndLog("Usage:  lf t55xx read <block> <password> <override_safety>");\r
        PrintAndLog("     <block>, block number to read. Between 0-7");\r
        PrintAndLog("     <password>, OPTIONAL password (8 hex characters)");\r
+       PrintAndLog("     <override_safety>, OPTIONAL override safety check = 1");\r
+       PrintAndLog("     ****WARNING****");\r
+       PrintAndLog("     Use of read with password on a tag not configured for a pwd");\r
+       PrintAndLog("     can damage the tag");\r
        PrintAndLog("");\r
        PrintAndLog("Examples:");\r
-       PrintAndLog("      lf t55xx read 0           - read data from block 0");\r
-       PrintAndLog("      lf t55xx read 0 feedbeef  - read data from block 0 password feedbeef");\r
+       PrintAndLog("      lf t55xx read 0            - read data from block 0");\r
+       PrintAndLog("      lf t55xx read 0 feedbeef   - read data from block 0 password feedbeef");\r
+       PrintAndLog("      lf t55xx read 0 feedbeef 1 - read data from block 0 password feedbeef safety check");\r
        PrintAndLog("");\r
        return 0;\r
 }\r
@@ -217,29 +222,38 @@ int CmdT55xxSetConfig(const char *Cmd) {
 int CmdT55xxReadBlock(const char *Cmd) {\r
        int block = -1;\r
        int password = 0xFFFFFFFF; //default to blank Block 7\r
-\r
+       int override = 0;\r
        char cmdp = param_getchar(Cmd, 0);\r
        if (cmdp == 'h' || cmdp == 'H')\r
                return usage_t55xx_read();\r
 \r
-       int res = sscanf(Cmd, "%d %x", &block, &password);\r
+       int res = sscanf(Cmd, "%d %x %d", &block, &password, &override);\r
 \r
-       if ( res < 1 || res > 2 )\r
+       if ( res < 1 || res > 3 )\r
                return usage_t55xx_read();\r
 \r
-       \r
-       if ((block < 0) | (block > 7)) {\r
+       if ((block < 0) || (block > 7)) {\r
                PrintAndLog("Block must be between 0 and 7");\r
                return 1;\r
-       }       \r
+       }\r
 \r
        UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, 0}};\r
-       c.d.asBytes[0] = 0x0; \r
+       c.d.asBytes[0] = 0x0;\r
 \r
        //Password mode\r
-       if ( res == 2 ) {\r
-               c.arg[2] = password;\r
-               c.d.asBytes[0] = 0x1; \r
+       if ( res > 1 ) {\r
+               // try reading the config block and verify that PWD bit is set before doing this!\r
+               AquireData( CONFIGURATION_BLOCK );\r
+               if ( !tryDetectModulation() && !override) {\r
+                       PrintAndLog("Safety Check: Could not detect if PWD bit is set in config block. Exits.");\r
+                       return 1;\r
+               } else if (override) {\r
+                       PrintAndLog("Safety Check Overriden - proceeding despite risk");\r
+                       c.arg[2] = password;\r
+                       c.d.asBytes[0] = 0x1;\r
+               } else {\r
+                       PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password...");   \r
+               }\r
        }\r
 \r
        clearCommandBuffer();\r
Impressum, Datenschutz