]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
add wake option to t55xx read command
authormarshmellow42 <marshmellowrf@gmail.com>
Sat, 17 Oct 2015 19:01:26 +0000 (15:01 -0400)
committermarshmellow42 <marshmellowrf@gmail.com>
Sat, 17 Oct 2015 19:01:26 +0000 (15:01 -0400)
CHANGELOG.md
armsrc/appmain.c
armsrc/apps.h
armsrc/lfops.c
client/cmdlft55xx.c

index 212920882e00f6112ae3b75902b81e45d3ada28b..67aec2c0eb9e6b51c4e9d525255d7c7a66555119 100644 (file)
@@ -5,6 +5,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
 ## [unreleased][unreleased]
 
 ### Added
+- `lf t55xx read w` added wake with password then read following stream option to standard t55xx read commands (marshmellow)
 - `hf iclass managekeys` to save, load and manage iclass keys.  (adjusted most commands to accept a loaded key in memory) (marshmellow)
 - `hf iclass readblk` to select, authenticate, and read 1 block from an iclass card (marshmellow)
 - `hf iclass writeblk` to select, authenticate, and write 1 block to an iclass card (or picopass) (marshmellow + others)
index 3a819edf518f2fe28541ccac6fcd3bb4d12e5302..bbb062c0a75934ebe408b558b81bbb2cc395260c 100644 (file)
@@ -975,7 +975,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        CopyIndala224toT55x7(c->d.asDwords[0], c->d.asDwords[1], c->d.asDwords[2], c->d.asDwords[3], c->d.asDwords[4], c->d.asDwords[5], c->d.asDwords[6]);
                        break;
                case CMD_T55XX_READ_BLOCK:
-                       T55xxReadBlock(c->arg[1], c->arg[2],c->d.asBytes[0]);
+                       T55xxReadBlock(c->arg[0], c->arg[1], c->arg[2]);
                        break;
                case CMD_T55XX_WRITE_BLOCK:
                        T55xxWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
index aaace18b308b0f272d9ac36dc57fb7d6869bcbc1..d0be7503f7f09997f9d9823fb01b6bff672fc38b 100644 (file)
@@ -80,7 +80,7 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
 void CopyIndala64toT55x7(int hi, int lo); // Clone Indala 64-bit tag by UID to T55x7
 void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int uid6, int uid7); // Clone Indala 224-bit tag by UID to T55x7
 void T55xxWriteBlock(uint32_t Data, uint32_t Block, uint32_t Pwd, uint8_t PwdMode);
-void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode );
+void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd);
 void T55xxReadTrace(void);
 void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode);
 void EM4xWriteWord(uint32_t Data, uint8_t Address, uint32_t Pwd, uint8_t PwdMode);
index cf04c31b627357860fa641c6df9a92b0e68319d2..b5647edd8393baed0e8b8db9020ba8f37df3520c 100644 (file)
@@ -1202,9 +1202,10 @@ void T55xxWriteBlock(uint32_t Data, uint32_t Block, uint32_t Pwd, uint8_t PwdMod
 }
 
 // Read one card block in page 0
-void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
+void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd) {
        LED_A_ON();
-
+       uint8_t PwdMode = arg0 & 0xFF;
+       uint8_t wake = arg0 >> 8;
        uint32_t i = 0;
 
        //clear buffer now so it does not interfere with timing later
@@ -1237,17 +1238,21 @@ void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
        T55xxWriteBit(1);
        T55xxWriteBit(0); //Page 0
 
-       if (PwdMode == 1){
+       if (PwdMode || wake){
                // Send Pwd
                for (i = 0x80000000; i != 0; i >>= 1)
                        T55xxWriteBit(Pwd & i);
        }
-       // Send a zero bit separation
-       T55xxWriteBit(0);
 
-       // Send Block number
-       for (i = 0x04; i != 0; i >>= 1)
-               T55xxWriteBit(Block & i);
+       // reading a block - send rest of read block cmd else skip for wake command
+       if (!wake) {
+               // Send a zero bit separation
+               T55xxWriteBit(0);
+
+               // Send Block number
+               for (i = 0x04; i != 0; i >>= 1)
+                       T55xxWriteBit(Block & i);               
+       }
 
        // Turn field on to read the response
        TurnReadLFOn(READ_GAP);
index 2297d249d41b2a0783405106ac68702599e9c902..efa6c22d2bdedad9b2f63e38ca8ea8db71fdd657 100644 (file)
@@ -121,12 +121,12 @@ static int CmdHelp(const char *Cmd);
 int CmdT55xxSetConfig(const char *Cmd) {\r
 \r
        uint8_t offset = 0;\r
-       bool errors = FALSE;\r
-       uint8_t cmdp = 0;\r
        char modulation[5] = {0x00};\r
        char tmp = 0x00;\r
        uint8_t bitRate = 0;\r
        uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};\r
+       uint8_t cmdp = 0;\r
+       bool errors = FALSE;\r
        while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
        {\r
                tmp = param_getchar(Cmd, cmdp);\r
@@ -220,39 +220,72 @@ int CmdT55xxSetConfig(const char *Cmd) {
 }\r
 \r
 int CmdT55xxReadBlock(const char *Cmd) {\r
-       int block = -1;\r
-       int password = 0xFFFFFFFF; //default to blank Block 7\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 %d", &block, &password, &override);\r
-\r
-       if ( res < 1 || res > 3 )\r
-               return usage_t55xx_read();\r
-\r
-       if ((block < 0) || (block > 7)) {\r
+       uint8_t block = 255;\r
+       uint8_t wake = 0;\r
+       uint8_t usepwd = 0;\r
+       uint32_t password = 0xFFFFFFFF; //default to blank Block 7\r
+       uint8_t override = 0;\r
+       uint8_t cmdp = 0;\r
+       bool errors = false;\r
+       while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {\r
+               switch(param_getchar(Cmd, cmdp)) {\r
+               case 'h':\r
+               case 'H':\r
+                       return usage_t55xx_read();\r
+               case 'b':\r
+               case 'B':\r
+                       errors |= param_getdec(Cmd, cmdp+1, &block);\r
+                       cmdp+=2;\r
+                       break;\r
+               case 'o':\r
+               case 'O':\r
+                       override = 1;\r
+                       cmdp++;\r
+                       break;\r
+               case 'p':\r
+               case 'P':\r
+                       password = param_get32ex(Cmd, cmdp+1, 0, 10);\r
+                       usepwd = 1;\r
+                       cmdp+=2;\r
+                       break;\r
+               case 'w':\r
+               case 'W':\r
+                       wake = 1;\r
+                       cmdp++;\r
+                       break;\r
+               default:\r
+                       PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
+                       errors = true;\r
+                       break;\r
+               }\r
+       }\r
+       if (errors) return usage_t55xx_read();\r
+       if (wake && !usepwd) {\r
+               PrintAndLog("Wake command must use a pwd");\r
+               return 1;\r
+       }\r
+       if ((block > 7) && !wake) {\r
                PrintAndLog("Block must be between 0 and 7");\r
                return 1;\r
        }\r
 \r
-       UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, 0}};\r
-       c.d.asBytes[0] = 0x0;\r
+       UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, password}};\r
 \r
        //Password mode\r
-       if ( res > 1 ) {\r
+       if ( usepwd || wake ) {\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
+               if ( wake || override ) {\r
+                       c.arg[0] = (wake<<8) & usepwd;\r
+                       if ( !wake && override )\r
+                               PrintAndLog("Safety Check Overriden - proceeding despite risk");\r
                } else {\r
-                       PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password...");   \r
+                       AquireData( CONFIGURATION_BLOCK );\r
+                       if ( !tryDetectModulation() ) {\r
+                               PrintAndLog("Safety Check: Could not detect if PWD bit is set in config block. Exits.");\r
+                               return 1;\r
+                       } else {\r
+                               PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password...");   \r
+                       }\r
                }\r
        }\r
 \r
@@ -270,7 +303,11 @@ int CmdT55xxReadBlock(const char *Cmd) {
        //DemodBufferLen=0;\r
        if (!DecodeT55xxBlock()) return 3;\r
        char blk[10]={0};\r
-       sprintf(blk,"%d", block);\r
+       if ( wake ) {\r
+               sprintf(blk,"wake");\r
+       } else {\r
+               sprintf(blk,"%d", block);\r
+       }\r
        printT55xxBlock(blk);\r
        return 0;\r
 }\r
Impressum, Datenschutz