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);
}
// 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
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);
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
}\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
//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