uint8_t modulation;\r
bool inversed;\r
uint32_t block0;\r
-} t55xx_conf_block;\r
+} t55xx_conf_block_t;\r
\r
// Default configuration: FSK, not inversed.\r
-t55xx_conf_block config = {0x00, FALSE, 0x00};\r
-\r
- // FSK\r
- // FSK inverted\r
- //FSKrawDemod("", FALSE)\r
- //FSKrawDemod("1", FALSE)\r
-\r
- // ASK/MAN\r
- // ASK/MAN inverted\r
- //ASKmanDemod("", FALSE, FALSE)\r
- \r
- // NZR (autoclock, normal, maxerrors 1)\r
- // NZR (autoclock, inverse, maxerrors 1)\r
- //NRZrawDemod("0 0 1", FALSE) ) {\r
- \r
- // PSK (autoclock, normal, maxerrors 1)\r
- // PSK (autoclock, inverse, maxerrors 1)\r
- //PSKDemod("0 0 1", FALSE)\r
+t55xx_conf_block_t config = { .modulation = 0, .inversed = FALSE, .block0 = 0x00};\r
\r
int usage_t55xx_config(){\r
- PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 0|1]");\r
+ PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1]");\r
PrintAndLog("Options: ");\r
- PrintAndLog(" h This help");\r
- PrintAndLog(" d <> Set demodulation FSK / ASK / PSK / NZR");\r
- PrintAndLog(" i [0|1] Inverse data signal, Default: 0");\r
+ PrintAndLog(" h This help");\r
+ PrintAndLog(" d <FSK|ASK|PSK|NZ|BI> Set demodulation FSK / ASK / PSK / NZ / Biphase");\r
+ PrintAndLog(" i [1] Inverse data signal, defaults to normal");\r
+ PrintAndLog("");\r
PrintAndLog("Examples:");\r
- PrintAndLog(" lf t55xx config d FSK ");\r
- PrintAndLog(" FSK demodulation");\r
- PrintAndLog(" lf t55xx config d FSK i 1");\r
- PrintAndLog(" FSK demodulation, inverse data");\r
- PrintAndLog(" lf dump");\r
- PrintAndLog(" Dumps all block from tag");\r
- PrintAndLog(" lf trace");\r
- PrintAndLog(" Read trace block and decode it");\r
- PrintAndLog(" lf info");\r
- PrintAndLog(" Read configuration and decode it");\r
+ PrintAndLog(" lf t55xx config d FSK - FSK demodulation");\r
+ PrintAndLog(" lf t55xx config d FSK i 1 - FSK demodulation, inverse data");\r
+ PrintAndLog("");\r
return 0;\r
}\r
int usage_t55xx_read(){\r
PrintAndLog(" <block>, block number to read. Between 0-7");\r
PrintAndLog(" <password>, OPTIONAL password (8 hex characters)");\r
PrintAndLog("");\r
- PrintAndLog(" sample: lf t55xx read 0 = try reading data from block 0");\r
- PrintAndLog(" : lf t55xx read 0 feedbeef = try reading data from block 0 using password");\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("");\r
return 0;\r
}\r
PrintAndLog(" <data>, 4 bytes of data to write (8 hex characters)");\r
PrintAndLog(" [password], OPTIONAL password 4bytes (8 hex characters)");\r
PrintAndLog("");\r
- PrintAndLog(" sample: lf t55xx wd 3 11223344 = try writing data 11223344 to block 3");\r
- PrintAndLog(" : lf t55xx wd 3 11223344 feedbeef = try writing data 11223344 to block 3 using password feedbeef");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx wd 3 11223344 - write 11223344 to block 3");\r
+ PrintAndLog(" lf t55xx wd 3 11223344 feedbeef - write 11223344 to block 3 password feedbeef");\r
PrintAndLog("");\r
return 0;\r
}\r
int usage_t55xx_trace() {\r
- PrintAndLog("Usage: lf t55xx trace [graph buffer data]");\r
+ PrintAndLog("Usage: lf t55xx trace [1]");\r
PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r
PrintAndLog("");\r
- PrintAndLog(" sample: lf t55xx trace");\r
- PrintAndLog(" : lf t55xx trace 1");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx trace");\r
+ PrintAndLog(" lf t55xx trace 1");\r
PrintAndLog("");\r
return 0;\r
}\r
int usage_t55xx_info() {\r
- PrintAndLog("Usage: lf t55xx info [graph buffer data]");\r
+ PrintAndLog("Usage: lf t55xx info [1]");\r
PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r
PrintAndLog("");\r
- PrintAndLog(" sample: lf t55xx info");\r
- PrintAndLog(" : lf t55xx info 1");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx info");\r
+ PrintAndLog(" lf t55xx info 1");\r
PrintAndLog("");\r
return 0;\r
}\r
int usage_t55xx_dump(){\r
PrintAndLog("Usage: lf t55xx dump <password>");\r
- PrintAndLog(" <password>, OPTIONAL password 4bytes (8 hex characters)");\r
+ PrintAndLog(" <password>, OPTIONAL password 4bytes (8 hex symbols)");\r
PrintAndLog("");\r
- PrintAndLog(" sample: lf t55xx dump");\r
- PrintAndLog(" : lf t55xx dump feedbeef");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx dump");\r
+ PrintAndLog(" lf t55xx dump feedbeef");\r
PrintAndLog("");\r
return 0;\r
}\r
static int CmdHelp(const char *Cmd);\r
\r
int CmdT55xxSetConfig(const char *Cmd){\r
+\r
+ int len;\r
+ bool inverse;\r
+ bool errors = FALSE;\r
+ uint8_t cmdp = 0;\r
+ char modulation[4] = {0x00};\r
\r
- uint8_t paramNum =0;\r
- if(param_getchar(Cmd, paramNum) == 'h')\r
+ while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
{\r
- return usage_t55xx_config();\r
+ switch(param_getchar(Cmd, cmdp))\r
+ {\r
+ case 'h':\r
+ case 'H':\r
+ return usage_t55xx_config();\r
+ case 'd':\r
+ len = param_getstr(Cmd, cmdp+1, modulation);\r
+ cmdp+= len+1;\r
+ //FSK|ASK|PSK|NZ|BI\r
+ if ( strcmp(modulation, "FSK" ) == 0)\r
+ len = 1;\r
+ else if ( strcmp(modulation, "ASK" ) == 0)\r
+ len = 2;\r
+ else if ( strcmp(modulation, "PSK" ) == 0)\r
+ len = 3;\r
+ else if ( strcmp(modulation, "NZ" ) == 0)\r
+ len = 4;\r
+ else if ( strcmp(modulation, "BI" ) == 0)\r
+ len = 5;\r
+ else {\r
+ PrintAndLog("Unknown modulation '%s'", modulation);\r
+ errors = TRUE;\r
+ }\r
+ break;\r
+ case 'i':\r
+ inverse = param_getchar(Cmd,cmdp+1) == '1';\r
+ cmdp+=2;\r
+ break;\r
+ default:\r
+ PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
+ errors = TRUE;\r
+ break;\r
+ }\r
}\r
-\r
- uint8_t buff[] = { 0x01, 0x01, 0x01, 0x01,\r
- 0x01, 0x01, 0x01, 0x01,\r
- 0x01, 0x40, 0x01, 0x01, 0x04 };\r
- PrintAndLog("CRC-8: %x",CRC8Maxim(buff, 13));\r
-\r
- //config = { 0, FALSE};\r
+ // No args\r
+ if (cmdp == 0) {\r
+ PrintAndLog("Modulation: %d", config.modulation);\r
+ PrintAndLog("Invert : %d", config.inversed);\r
+ PrintAndLog("Block0 : %08X", config.block0);\r
+ return 0;\r
+ }\r
+ //Validations\r
+ if (errors)\r
+ return usage_t55xx_config();\r
+ \r
+ config.modulation = len;\r
+ config.inversed = inverse;\r
+ config.block0 = 0;\r
return 0;\r
}\r
-\r
// detect configuration?\r
\r
int CmdReadBlk(const char *Cmd)\r
setGraphBuf(got, 12000);\r
\r
if (block == 0){\r
- // try a detection.\r
- \r
+ // try a detection. \r
}\r
\r
if (CmdDetectClockRate("f")){ //wave is almost certainly FSK\r
- //call FSK DEMOD\r
// FSK\r
- if ( FSKrawDemod("", FALSE))\r
+ if ( FSKrawDemod("0 0", FALSE) && test())\r
printT55xx("FSK");\r
// FSK inverted\r
- if ( FSKrawDemod("1", FALSE)) \r
+ if ( FSKrawDemod("0 1", FALSE) && test()) \r
printT55xx("FSK inv");\r
} else {\r
// ASK/MAN (autoclock, normal, maxerrors 1)\r
- if ( ASKmanDemod("0 0 1", FALSE, FALSE) )\r
+ if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) \r
printT55xx("ASK/MAN");\r
\r
// ASK/MAN (autoclock, inverted, maxerrors 1)\r
- if ( ASKmanDemod("0 1 1", FALSE, FALSE) )\r
+ if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test()) \r
printT55xx("ASK/MAN Inv");\r
\r
// NZR (autoclock, normal, maxerrors 1)\r
- if ( NRZrawDemod("0 0 1", FALSE) )\r
+ if ( NRZrawDemod("0 0 1", FALSE) && test()) \r
printT55xx("NZR");\r
// NZR (autoclock, inverted, maxerrors 1)\r
- if ( NRZrawDemod("0 1 1", FALSE) )\r
+ if ( NRZrawDemod("0 1 1", FALSE) && test()) \r
printT55xx("NZR inv");\r
\r
// PSK (autoclock, normal, maxerrors 1)\r
- if (!PSKDemod("0 0 1", FALSE))\r
+ if ( PSKDemod("0 0 1", FALSE) && test()) \r
printT55xx("PSK");\r
\r
// PSK (autoclock, inverted, maxerrors 1)\r
- if (!PSKDemod("0 1 1", FALSE))\r
+ if ( PSKDemod("0 1 1", FALSE) && test()) \r
printT55xx("PSK inv");\r
+ \r
+ //PSK2?\r
+ \r
+ // if (!BiphaseRawDecode("0",FALSE) && test()) \r
+ // printT55xx("BIPHASE");\r
+ \r
+ // if (!BiphaseRawDecode("1",FALSE) && test()) \r
+ // printT55xx("BIPHASE inv");\r
}\r
return 0;\r
}\r
+bool test(){\r
+\r
+ if ( !DemodBufferLen) \r
+ return false;\r
+ \r
+ uint8_t si = 1;\r
+ uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r
+ uint8_t resv = PackBits(si, 7, DemodBuffer); si += 7+3;\r
+ uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1;\r
+\r
+ //PrintAndLog("test: %X %X %X ", safer, resv, extend);\r
+ \r
+ // 2nibble must be zeroed.\r
+ if ( resv > 0x00) return FALSE;\r
+\r
+ if ( safer == 0x6 || safer == 0x9){\r
+ if ( extend == 0x00)\r
+ return TRUE;\r
+ }\r
+ if ( resv== 0x00) return TRUE;\r
+ return FALSE;\r
+}\r
\r
void printT55xx(const char *demodStr){\r
\r
uint32_t resv = PackBits(si, 7, bits); si += 7;\r
uint32_t dbr = PackBits(si, 3, bits); si += 3;\r
uint32_t extend = PackBits(si, 1, bits); si += 1;\r
- uint32_t datamodulation = PackBits(si, 5, bits); si += 5;\r
+ uint32_t datamod = PackBits(si, 5, bits); si += 5;\r
uint32_t pskcf = PackBits(si, 2, bits); si += 2;\r
uint32_t aor = PackBits(si, 1, bits); si += 1; \r
uint32_t otp = PackBits(si, 1, bits); si += 1; \r
PrintAndLog(" reserved : %d", resv);\r
PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));\r
PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");\r
- PrintAndLog(" Modulation : %s", GetModulationStr(datamodulation) );\r
+ PrintAndLog(" Modulation : %s", GetModulationStr(datamod));\r
PrintAndLog(" PSK clock freq : %d", pskcf);\r
PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");\r
PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );\r
PrintAndLog(" Max block : %d", maxblk);\r
PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");\r
PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");\r
- PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");\r
+ PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");\r
PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");\r
PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");\r
PrintAndLog("-------------------------------------------------------------");\r
\r
sprintf(retStr,"%d",id);\r
if (id == 6) {\r
- sprintf(retStr,"%d - pasdwd",id);\r
+ sprintf(retStr,"%d - passwd",id);\r
}\r
if (id == 9 ){\r
- sprintf(retStr,"%d - testmode ",id);\r
+ sprintf(retStr,"%d - testmode",id);\r
}\r
\r
return buf;\r