+#define T55x7_CONFIGURATION_BLOCK 0x00\r
+#define T55x7_PAGE0 0x00\r
+#define T55x7_PAGE1 0x01\r
+#define T55x7_PWD 0x00000010\r
+#define REGULAR_READ_MODE_BLOCK 0xFF\r
+\r
+// Default configuration\r
+t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00, .Q5 = FALSE };\r
+\r
+t55xx_conf_block_t Get_t55xx_Config(){\r
+ return config;\r
+}\r
+void Set_t55xx_Config(t55xx_conf_block_t conf){\r
+ config = conf;\r
+}\r
+\r
+int usage_t55xx_config(){\r
+ PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>] [Q5]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" h - This help");\r
+ PrintAndLog(" b <8|16|32|40|50|64|100|128> - Set bitrate");\r
+ PrintAndLog(" d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa> - Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");\r
+ PrintAndLog(" i [1] - Invert data signal, defaults to normal");\r
+ PrintAndLog(" o [offset] - Set offset, where data should start decode in bitstream");\r
+ PrintAndLog(" Q5 - Set as Q5(T5555) chip instead of T55x7");\r
+ PrintAndLog(" ST - Set Sequence Terminator on");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx config d FSK - FSK demodulation");\r
+ PrintAndLog(" lf t55xx config d FSK i 1 - FSK demodulation, inverse data");\r
+ PrintAndLog(" lf t55xx config d FSK i 1 o 3 - FSK demodulation, inverse data, offset=3,start from position 3 to decode data");\r
+ PrintAndLog("");\r
+ return 0;\r
+}\r
+int usage_t55xx_read(){\r
+ PrintAndLog("Usage: lf t55xx read [b <block>] [p <password>] <override_safety> <page1>");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" b <block> - block number to read. Between 0-7");\r
+ PrintAndLog(" p <password> - OPTIONAL password (8 hex characters)");\r
+ PrintAndLog(" o - OPTIONAL override safety check");\r
+ PrintAndLog(" 1 - OPTIONAL read Page 1 instead of Page 0");\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 b 0 - read data from block 0");\r
+ PrintAndLog(" lf t55xx read b 0 p feedbeef - read data from block 0 password feedbeef");\r
+ PrintAndLog(" lf t55xx read b 0 p feedbeef o - read data from block 0 password feedbeef safety check");\r
+ PrintAndLog("");\r
+ return 0;\r
+}\r
+int usage_t55xx_write(){\r
+ PrintAndLog("Usage: lf t55xx wr [b <block>] [d <data>] [p <password>] [1]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" b <block> - block number to write. Between 0-7");\r
+ PrintAndLog(" d <data> - 4 bytes of data to write (8 hex characters)");\r
+ PrintAndLog(" p <password> - OPTIONAL password 4bytes (8 hex characters)");\r
+ PrintAndLog(" 1 - OPTIONAL write Page 1 instead of Page 0");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx write b 3 d 11223344 - write 11223344 to block 3");\r
+ PrintAndLog(" lf t55xx write b 3 d 11223344 p 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 [1]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" 1 - if set, use Graphbuffer otherwise read data from tag.");\r
+ PrintAndLog("");\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 [1]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" 1 - if set, use Graphbuffer otherwise read data from tag.");\r
+ PrintAndLog("");\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> [o]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" <password> - OPTIONAL password 4bytes (8 hex symbols)");\r
+ PrintAndLog(" o - OPTIONAL override, force pwd read despite danger to card");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx dump");\r
+ PrintAndLog(" lf t55xx dump feedbeef o");\r
+ PrintAndLog("");\r
+ return 0;\r
+}\r
+int usage_t55xx_detect(){\r
+ PrintAndLog("Usage: lf t55xx detect [1] [p <password>]");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" 1 - if set, use Graphbuffer otherwise read data from tag.");\r
+ PrintAndLog(" p <password> - OPTIONAL password (8 hex characters)");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx detect");\r
+ PrintAndLog(" lf t55xx detect 1");\r
+ PrintAndLog(" lf t55xx detect p 11223344");\r
+ PrintAndLog("");\r
+ return 0;\r
+}\r
+int usage_t55xx_wakup(){\r
+ PrintAndLog("Usage: lf t55xx wakeup [h] p <password>");\r
+ PrintAndLog("This commands send the Answer-On-Request command and leaves the readerfield ON afterwards.");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" h - this help");\r
+ PrintAndLog(" p <password> - password 4bytes (8 hex symbols)");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx wakeup p 11223344 - send wakeup password");\r
+ return 0;\r
+}\r
+int usage_t55xx_bruteforce(){\r
+ PrintAndLog("This command uses A) bruteforce to scan a number range");\r
+ PrintAndLog(" B) a dictionary attack");\r
+ PrintAndLog("Usage: lf t55xx bruteforce [h] <start password> <end password> [i <*.dic>]");\r
+ PrintAndLog(" password must be 4 bytes (8 hex symbols)");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" h - this help");\r
+ PrintAndLog(" <start_pwd> - 4 byte hex value to start pwd search at");\r
+ PrintAndLog(" <end_pwd> - 4 byte hex value to end pwd search at");\r
+ PrintAndLog(" i <*.dic> - loads a default keys dictionary file <*.dic>");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx bruteforce aaaaaaaa bbbbbbbb");\r
+ PrintAndLog(" lf t55xx bruteforce i default_pwd.dic");\r
+ PrintAndLog("");\r
+ return 0;\r
+}\r
+int usage_t55xx_recoverpw(){\r
+ PrintAndLog("This command uses a few tricks to try to recover mangled password");\r
+ PrintAndLog("WARNING: this may brick non-password protected chips!");\r
+ PrintAndLog("Usage: lf t55xx recoverpw [password]");\r
+ PrintAndLog(" password must be 4 bytes (8 hex symbols)");\r
+ PrintAndLog(" default password is 51243648, used by many cloners");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" h - this help");\r
+ PrintAndLog(" [password] - 4 byte hex value of password written by cloner");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx recoverpw");\r
+ PrintAndLog(" lf t55xx recoverpw 51243648");\r
+ PrintAndLog("");\r
+ return 0;\r
+}int usage_t55xx_wipe(){\r
+ PrintAndLog("Usage: lf t55xx wipe [h] [Q5]");\r
+ PrintAndLog("This commands wipes a tag, fills blocks 1-7 with zeros and a default configuration block");\r
+ PrintAndLog("Options:");\r
+ PrintAndLog(" h - this help");\r
+ PrintAndLog(" Q5 - indicates to use the T5555 (Q5) default configuration block");\r
+ PrintAndLog("");\r
+ PrintAndLog("Examples:");\r
+ PrintAndLog(" lf t55xx wipe - wipes a t55x7 tag, config block 0x000880E0");\r
+ PrintAndLog(" lf t55xx wipe Q5 - wipes a t5555 Q5 tag, config block 0x6001F004");\r
+ return 0;\r
+}\r