return 0;\r
}\r
int usage_t55xx_read(){\r
- PrintAndLog("Usage: lf t55xx read b <block> p <password> <override_safety> <wakeup>");\r
+ PrintAndLog("Usage: lf t55xx read b <block> p <password> <override_safety>");\r
PrintAndLog("Options:");\r
PrintAndLog(" b <block>, block number to read. Between 0-7");\r
PrintAndLog(" p <password>, OPTIONAL password 4bytes (8 hex symbols)");\r
PrintAndLog(" o, OPTIONAL override safety check");\r
- PrintAndLog(" w, OPTIONAL wakeup");\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
}\r
\r
// No args\r
- if (cmdp == 0) {\r
- printConfiguration( config );\r
- return 0;\r
- }\r
+ if (cmdp == 0) return printConfiguration( config );\r
+\r
//Validations\r
- if (errors)\r
- return usage_t55xx_config();\r
+ if (errors) return usage_t55xx_config();\r
\r
config.block0 = 0;\r
- printConfiguration ( config );\r
- return 0;\r
+ return printConfiguration ( config );\r
}\r
\r
int CmdT55xxReadBlock(const char *Cmd) {\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
+ uint32_t password = 0; //default to blank Block 7\r
+ bool usepwd = FALSE;\r
+ bool override = FALSE; \r
+ bool errors = FALSE;\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
+ return usage_t55xx_read();\r
case 'b':\r
case 'B':\r
errors |= param_getdec(Cmd, cmdp+1, &block);\r
- cmdp+=2;\r
+ cmdp += 2;\r
break;\r
case 'o':\r
case 'O':\r
- override = 1;\r
+ override = TRUE;\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
+ password = param_get32ex(Cmd, cmdp+1, 0xFFFFFFFF, 16);\r
+ usepwd = TRUE;\r
+ cmdp += 2;\r
break;\r
default:\r
PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\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
+\r
+ if ( block > 7 ) {\r
PrintAndLog("Block must be between 0 and 7");\r
return 1;\r
} \r
UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, password}};\r
\r
//Password mode\r
- if ( usepwd || wake ) {\r
+ if ( usepwd ) {\r
+ \r
// try reading the config block and verify that PWD bit is set before doing this!\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
+ if ( !override ) {\r
AquireData( CONFIGURATION_BLOCK );\r
if ( !tryDetectModulation() ) {\r
PrintAndLog("Safety Check: Could not detect if PWD bit is set in config block. Exits.");\r
} else { \r
PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password..."); \r
}\r
+ } else { \r
+ PrintAndLog("Safety Check Overriden - proceeding despite risk");\r
+ c.arg[0] = usepwd;\r
}\r
}\r
\r
GetFromBigBuf(got,sizeof(got),0);\r
WaitForResponse(CMD_ACK,NULL);\r
setGraphBuf(got, sizeof(got));\r
- //DemodBufferLen=0;\r
+\r
if (!DecodeT55xxBlock()) return 3;\r
+ \r
char blk[10]={0};\r
- if ( wake ) {\r
- sprintf(blk,"wake");\r
- } else {\r
- sprintf(blk,"%d", block);\r
- }\r
+ sprintf(blk,"%d", block); \r
printT55xxBlock(blk);\r
return 0;\r
}\r
int CmdT55xxDetect(const char *Cmd){\r
\r
char cmdp = param_getchar(Cmd, 0);\r
- if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')\r
- return usage_t55xx_detect();\r
+ if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') return usage_t55xx_detect();\r
\r
if (strlen(Cmd)==0)\r
AquireData( CONFIGURATION_BLOCK );\r
}\r
\r
for (; i < endpos; ++i)\r
- bits[i - config.offset]=DemodBuffer[i];\r
+ bits[i - config.offset] = DemodBuffer[i];\r
\r
blockData = PackBits(0, 32, bits);\r
- PrintAndLog("[%s] 0x%08X %s", blockNum, blockData, sprint_bin(bits,32));\r
+ PrintAndLog("%s | %08X | %s", blockNum, blockData, sprint_bin(bits,32));\r
}\r
\r
int special(const char *Cmd) {\r
uint32_t blockData = 0;\r
uint8_t bits[32] = {0x00};\r
\r
- PrintAndLog("[OFFSET] [DATA] [BINARY]");\r
+ PrintAndLog("OFFSET | DATA | BINARY");\r
PrintAndLog("----------------------------------------------------");\r
int i,j = 0;\r
for (; j < 64; ++j){\r
\r
blockData = PackBits(0, 32, bits);\r
\r
- PrintAndLog("[%02d] 0x%08X %s",j , blockData, sprint_bin(bits,32)); \r
+ PrintAndLog("%02d | 0x%08X | %s",j , blockData, sprint_bin(bits,32)); \r
}\r
return 0;\r
}\r
\r
-void printConfiguration( t55xx_conf_block_t b){\r
+int printConfiguration( t55xx_conf_block_t b){\r
PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
PrintAndLog("Bit Rate : %s", GetBitRateStr(b.bitrate) );\r
PrintAndLog("Inverted : %s", (b.inverted) ? "Yes" : "No" );\r
PrintAndLog("Offset : %d", b.offset);\r
PrintAndLog("Block0 : 0x%08X", b.block0);\r
PrintAndLog("");\r
+ return 0;\r
}\r
\r
-int CmdT55xxWriteBlock(const char *Cmd)\r
-{\r
+int CmdT55xxWriteBlock(const char *Cmd) {\r
int block = 8; //default to invalid block\r
int data = 0xFFFFFFFF; //default to blank Block \r
int password = 0xFFFFFFFF; //default to blank Block 7\r
\r
char cmdp = param_getchar(Cmd, 0);\r
- if (cmdp == 'h' || cmdp == 'H') {\r
- usage_t55xx_write();\r
- return 0;\r
- }\r
- \r
+ if (cmdp == 'h' || cmdp == 'H') return usage_t55xx_write();\r
+ \r
int res = sscanf(Cmd, "%d %x %x",&block, &data, &password);\r
\r
if ( res < 2 || res > 3) {\r
return 0;\r
}\r
\r
-int CmdT55xxReadTrace(const char *Cmd)\r
-{\r
+int CmdT55xxReadTrace(const char *Cmd) {\r
char cmdp = param_getchar(Cmd, 0);\r
\r
- if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') \r
- return usage_t55xx_trace();\r
+ if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') return usage_t55xx_trace();\r
\r
if (strlen(Cmd)==0)\r
AquireData( TRACE_BLOCK );\r
*/\r
char cmdp = param_getchar(Cmd, 0);\r
\r
- if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')\r
- return usage_t55xx_info();\r
+ if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') return usage_t55xx_info();\r
\r
if (strlen(Cmd)==0)\r
AquireData( CONFIGURATION_BLOCK );\r
\r
char s[20] = {0x00};\r
uint8_t pwd[4] = {0x00};\r
-\r
char cmdp = param_getchar(Cmd, 0);\r
- if ( cmdp == 'h' || cmdp == 'H') {\r
- usage_t55xx_dump();\r
- return 0;\r
- }\r
+ if ( cmdp == 'h' || cmdp == 'H') return usage_t55xx_dump();\r
\r
bool hasPwd = ( strlen(Cmd) > 0); \r
if ( hasPwd ){\r
}\r
\r
int AquireData( uint8_t block ){\r
-\r
- UsbCommand c;\r
\r
- if ( block == CONFIGURATION_BLOCK ) \r
- c.cmd = CMD_T55XX_READ_BLOCK;\r
- else if (block == TRACE_BLOCK )\r
- c.cmd = CMD_T55XX_READ_TRACE;\r
- \r
- c.arg[0] = 0x00;\r
- c.arg[1] = 0x00;\r
- c.arg[2] = 0x00;\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
- // }\r
-\r
+ uint32_t password = 0;\r
+ UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, 0, password}};\r
+ \r
+ if ( block == CONFIGURATION_BLOCK ) {\r
+ c.arg[0] = 0x00 | 0x01;\r
+ }\r
+ else if (block == TRACE_BLOCK ) {\r
+ c.arg[0] = 0x02 | 0x01;\r
+ }\r
+ \r
clearCommandBuffer();\r
SendCommand(&c);\r
if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {\r
}\r
\r
int CmdT55xxWakeUp(const char *Cmd) {\r
- uint32_t password = 0xFFFFFFFF; //default to blank Block 7\r
+ uint32_t password = 0;\r
uint8_t cmdp = 0;\r
bool errors = false;\r
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {\r
return usage_t55xx_wakup();\r
case 'p':\r
case 'P':\r
- password = param_get32ex(Cmd, cmdp+1, 0, 10);\r
+ password = param_get32ex(Cmd, cmdp+1, 0xFFFFFFFF, 16);\r
cmdp+=2;\r
break;\r
default:\r
}\r
}\r
if (errors) return usage_t55xx_wakup();\r
- \r
- UsbCommand c = {CMD_T55XX_WAKEUP, {password, 0, 0}};\r
\r
+ UsbCommand c = {CMD_T55XX_WAKEUP, {password, 0, 0}};\r
clearCommandBuffer();\r
SendCommand(&c);\r
PrintAndLog("Wake up command sent. Try read now");\r