1 //-----------------------------------------------------------------------------
3 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
4 // at your option, any later version. See the LICENSE.txt file for the text of
6 //-----------------------------------------------------------------------------
7 // Low frequency T55xx commands
8 //-----------------------------------------------------------------------------
13 #include "proxmark3.h"
17 #include "cmdparser.h"
20 #include "cmdlft55xx.h"
24 #include "../common/crc.h"
25 #include "../common/iso14443crc.h"
28 // Default configuration
29 t55xx_conf_block_t config
= { .modulation
= DEMOD_ASK
, .inversed
= FALSE
, .offset
= 0x00, .block0
= 0x00};
31 int usage_t55xx_config(){
32 PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>]");
33 PrintAndLog("Options: ");
34 PrintAndLog(" h This help");
35 PrintAndLog(" d <FSK|ASK|PSK1|PSK2|NZ|BI> Set demodulation FSK / ASK / PSK / NZ / Biphase");
36 PrintAndLog(" i [1] Inverse data signal, defaults to normal");
37 PrintAndLog(" o [offset] Set offset, where data should start decode in bitstream");
39 PrintAndLog("Examples:");
40 PrintAndLog(" lf t55xx config d FSK - FSK demodulation");
41 PrintAndLog(" lf t55xx config d FSK i 1 - FSK demodulation, inverse data");
42 PrintAndLog(" lf t55xx config d FSK i 1 o 3 - FSK demodulation, inverse data, offset=3,start from bitpos 3 to decode data");
46 int usage_t55xx_read(){
47 PrintAndLog("Usage: lf t55xx read <block> <password>");
48 PrintAndLog(" <block>, block number to read. Between 0-7");
49 PrintAndLog(" <password>, OPTIONAL password (8 hex characters)");
51 PrintAndLog("Examples:");
52 PrintAndLog(" lf t55xx read 0 - read data from block 0");
53 PrintAndLog(" lf t55xx read 0 feedbeef - read data from block 0 password feedbeef");
57 int usage_t55xx_write(){
58 PrintAndLog("Usage: lf t55xx wr <block> <data> [password]");
59 PrintAndLog(" <block>, block number to read. Between 0-7");
60 PrintAndLog(" <data>, 4 bytes of data to write (8 hex characters)");
61 PrintAndLog(" [password], OPTIONAL password 4bytes (8 hex characters)");
63 PrintAndLog("Examples:");
64 PrintAndLog(" lf t55xx wd 3 11223344 - write 11223344 to block 3");
65 PrintAndLog(" lf t55xx wd 3 11223344 feedbeef - write 11223344 to block 3 password feedbeef");
69 int usage_t55xx_trace() {
70 PrintAndLog("Usage: lf t55xx trace [1]");
71 PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");
73 PrintAndLog("Examples:");
74 PrintAndLog(" lf t55xx trace");
75 PrintAndLog(" lf t55xx trace 1");
79 int usage_t55xx_info() {
80 PrintAndLog("Usage: lf t55xx info [1]");
81 PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");
83 PrintAndLog("Examples:");
84 PrintAndLog(" lf t55xx info");
85 PrintAndLog(" lf t55xx info 1");
89 int usage_t55xx_dump(){
90 PrintAndLog("Usage: lf t55xx dump <password>");
91 PrintAndLog(" <password>, OPTIONAL password 4bytes (8 hex symbols)");
93 PrintAndLog("Examples:");
94 PrintAndLog(" lf t55xx dump");
95 PrintAndLog(" lf t55xx dump feedbeef");
99 int usage_t55xx_detect(){
100 PrintAndLog("Usage: lf t55xx detect");
102 PrintAndLog("Examples:");
103 PrintAndLog(" lf t55xx detect");
104 PrintAndLog(" lf t55xx detect 1");
109 static int CmdHelp(const char *Cmd
);
111 int CmdT55xxSetConfig(const char *Cmd
){
116 char modulation
[5] = {0x00};
119 while(param_getchar(Cmd
, cmdp
) != 0x00 && !errors
)
121 tmp
= param_getchar(Cmd
, cmdp
);
126 return usage_t55xx_config();
128 param_getstr(Cmd
, cmdp
+1, modulation
);
131 if ( strcmp(modulation
, "FSK" ) == 0)
132 config
.modulation
= DEMOD_FSK
;
133 else if ( strcmp(modulation
, "ASK" ) == 0)
134 config
.modulation
= DEMOD_ASK
;
135 else if ( strcmp(modulation
, "NRZ" ) == 0)
136 config
.modulation
= DEMOD_NRZ
;
137 else if ( strcmp(modulation
, "PSK1" ) == 0)
138 config
.modulation
= DEMOD_PSK1
;
139 else if ( strcmp(modulation
, "PSK2" ) == 0)
140 config
.modulation
= DEMOD_PSK2
;
141 else if ( strcmp(modulation
, "BI" ) == 0)
142 config
.modulation
= DEMOD_BI
;
144 PrintAndLog("Unknown modulation '%s'", modulation
);
149 config
.inversed
= param_getchar(Cmd
,cmdp
+1) == '1';
153 errors
|= param_getdec(Cmd
, cmdp
+1,&offset
);
155 config
.offset
= offset
;
159 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd
, cmdp
));
167 printConfiguration( config
);
172 return usage_t55xx_config();
174 printConfiguration( config
);
178 int CmdT55xxReadBlock(const char *Cmd
)
181 int password
= 0xFFFFFFFF; //default to blank Block 7
183 char cmdp
= param_getchar(Cmd
, 0);
184 if (cmdp
== 'h' || cmdp
== 'H')
185 return usage_t55xx_read();
187 int res
= sscanf(Cmd
, "%d %x", &block
, &password
);
189 if ( res
< 1 || res
> 2 )
190 return usage_t55xx_read();
193 if ((block
< 0) | (block
> 7)) {
194 PrintAndLog("Block must be between 0 and 7");
198 UsbCommand c
= {CMD_T55XX_READ_BLOCK
, {0, block
, 0}};
199 c
.d
.asBytes
[0] = 0x0;
204 c
.d
.asBytes
[0] = 0x1;
208 if ( !WaitForResponseTimeout(CMD_ACK
,NULL
,2500) ) {
209 PrintAndLog("command execution time out");
214 GetFromBigBuf(got
,sizeof(got
),0);
215 WaitForResponse(CMD_ACK
,NULL
);
216 setGraphBuf(got
, 12000);
223 void DecodeT55xxBlock(){
225 char buf
[8] = {0x00};
228 // clearing the DemodBuffer.
229 DemodBufferLen
= 0x00;
231 // use the configuration
232 switch( config
.modulation
){
234 sprintf(cmdStr
,"0 %d", config
.inversed
);
235 FSKrawDemod(cmdStr
, FALSE
);
238 sprintf(cmdStr
,"0 %d 1", config
.inversed
);
239 ASKmanDemod(cmdStr
, FALSE
, FALSE
);
242 sprintf(cmdStr
,"0 %d 1", config
.inversed
);
243 PSKDemod(cmdStr
, FALSE
);
246 sprintf(cmdStr
,"0 %d 1", config
.inversed
);
247 PSKDemod(cmdStr
, FALSE
);
248 psk1TOpsk2(DemodBuffer
, DemodBufferLen
);
251 sprintf(cmdStr
,"0 %d 1", config
.inversed
);
252 PSKDemod(cmdStr
, FALSE
);
253 psk1TOpsk2(DemodBuffer
, DemodBufferLen
);
256 sprintf(cmdStr
,"0 %d 1", config
.inversed
);
257 NRZrawDemod(cmdStr
, FALSE
);
260 sprintf(cmdStr
,"0 0 %d 1", config
.inversed
);
261 // DEPENDS ON NEW CODE IN MARSHMELLOWS PULL REQUEST
262 //ASKbiphDemod(cmdStr, FALSE);
269 int CmdT55xxDetect(const char *Cmd
){
270 char cmdp
= param_getchar(Cmd
, 0);
271 if (cmdp
== 'h' || cmdp
== 'H')
272 return usage_t55xx_detect();
274 // read block 0, Page 0. Configuration.
275 UsbCommand c
= {CMD_T55XX_READ_BLOCK
, {0, 0, 0}};
276 c
.d
.asBytes
[0] = 0x0;
280 // c.arg[2] = password;
281 // c.d.asBytes[0] = 0x1;
285 if ( !WaitForResponseTimeout(CMD_ACK
,NULL
,2500) ) {
286 PrintAndLog("command execution time out");
291 GetFromBigBuf(got
,sizeof(got
),0);
292 WaitForResponse(CMD_ACK
,NULL
);
293 setGraphBuf(got
, 12000);
295 if ( !tryDetectModulation() ){
296 PrintAndLog("Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");
301 // detect configuration?
302 bool tryDetectModulation(){
305 t55xx_conf_block_t tests
[11];
307 if (GetFskClock("", FALSE
, FALSE
)){
308 if ( FSKrawDemod("0 0", FALSE
) && test(DEMOD_FSK
, &tests
[hits
].offset
)){
309 tests
[hits
].modulation
= DEMOD_FSK
;
310 tests
[hits
].inversed
= FALSE
;
313 if ( FSKrawDemod("0 1", FALSE
) && test(DEMOD_FSK
, &tests
[hits
].offset
)) {
314 tests
[hits
].modulation
= DEMOD_FSK
;
315 tests
[hits
].inversed
= TRUE
;
319 if ( ASKmanDemod("0 0 1", FALSE
, FALSE
) && test(DEMOD_ASK
, &tests
[hits
].offset
)) {
320 tests
[hits
].modulation
= DEMOD_ASK
;
321 tests
[hits
].inversed
= FALSE
;
325 if ( ASKmanDemod("0 1 1", FALSE
, FALSE
) && test(DEMOD_ASK
, &tests
[hits
].offset
)) {
326 tests
[hits
].modulation
= DEMOD_ASK
;
327 tests
[hits
].inversed
= TRUE
;
331 if ( NRZrawDemod("0 0 1", FALSE
) && test(DEMOD_NRZ
, &tests
[hits
].offset
)) {
332 tests
[hits
].modulation
= DEMOD_NRZ
;
333 tests
[hits
].inversed
= FALSE
;
337 if ( NRZrawDemod("0 1 1", FALSE
) && test(DEMOD_NRZ
, &tests
[hits
].offset
)) {
338 tests
[hits
].modulation
= DEMOD_NRZ
;
339 tests
[hits
].inversed
= TRUE
;
343 if ( PSKDemod("0 0 1", FALSE
) && test(DEMOD_PSK1
, &tests
[hits
].offset
)) {
344 tests
[hits
].modulation
= DEMOD_PSK1
;
345 tests
[hits
].inversed
= FALSE
;
349 if ( PSKDemod("0 1 1", FALSE
) && test(DEMOD_PSK1
, &tests
[hits
].offset
)) {
350 tests
[hits
].modulation
= DEMOD_PSK1
;
351 tests
[hits
].inversed
= TRUE
;
356 if ( PSKDemod("0 0 1", FALSE
)) {
357 psk1TOpsk2(DemodBuffer
, DemodBufferLen
);
358 if (test(DEMOD_PSK2
, &tests
[hits
].offset
)){
359 tests
[hits
].modulation
= DEMOD_PSK2
;
360 tests
[hits
].inversed
= FALSE
;
364 if ( PSKDemod("0 1 1", FALSE
)) {
365 psk1TOpsk2(DemodBuffer
, DemodBufferLen
);
366 if (test(DEMOD_PSK2
, &tests
[hits
].offset
)){
367 tests
[hits
].modulation
= DEMOD_PSK2
;
368 tests
[hits
].inversed
= TRUE
;
373 /* DEPENDANT ON NEW CODE IN MARSHMELLOWS pull request
374 //biphase //offset, clock, invert, maxErr
375 if ( ASKbiphaseDemod("0 0 0 1", FALSE) && test(DEMOD_BI, &tests[hits].offset) ) {
376 tests[hits].modulation = DEMOD_BI;
377 tests[hits].inversed = FALSE;
380 if ( ASKbiphaseDemod("0 0 1 1", FALSE) && test(DEMOD_BI, &tests[hits].offset) ) {
381 tests[hits].modulation = DEMOD_BI;
382 tests[hits].inversed = TRUE;
388 config
.modulation
= tests
[0].modulation
;
389 config
.inversed
= tests
[0].inversed
;
390 config
.offset
= tests
[0].offset
;
391 printConfiguration( config
);
396 PrintAndLog("Found [%d] possible matches for modulation.",hits
);
397 for(int i
=0; i
<hits
; ++i
){
398 PrintAndLog("--[%d]---------------", i
+1);
399 printConfiguration( tests
[i
] );
405 bool testModulation(uint8_t mode
, uint8_t modread
){
408 if (modread
> 3 && modread
< 8) return TRUE
;
411 if (modread
== 8) return TRUE
;
414 if (modread
== 1) return TRUE
;
417 if (modread
== 2) return TRUE
;
420 if (modread
== 3) return TRUE
;
423 if (!modread
) return TRUE
;
426 if (modread
== 16) return TRUE
;
434 bool test(uint8_t mode
, uint8_t *offset
){
436 if ( !DemodBufferLen
)
438 if ( PackBits(0, 32, DemodBuffer
) == 0x00 )
440 for (uint8_t idx
=1; idx
<33; idx
++){
442 uint8_t safer
= PackBits(si
, 4, DemodBuffer
); si
+= 4; //master key
443 uint8_t resv
= PackBits(si
, 4, DemodBuffer
); si
+= 4; //was 7 & +=7+3 //should be only 4 bits if extended mode
444 uint8_t xtRate
= PackBits(si
, 3, DemodBuffer
); si
+= 3+3; //new
445 //uint8_t bitRate = PackBits(si, 3, DemodBuffer); si += 3; //new could check bit rate
446 uint8_t extend
= PackBits(si
, 1, DemodBuffer
); si
+= 1; //bit 15 extended mode
447 uint8_t modread
= PackBits(si
, 5, DemodBuffer
); si
+= 5+2+1; //new
448 //uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2+1; //new could check psk cr
449 uint8_t nml01
= PackBits(si
, 1, DemodBuffer
); si
+= 1+5; //bit 24 , 30, 31 could be tested for 0 if not extended mode
450 uint8_t nml02
= PackBits(si
, 2, DemodBuffer
); si
+= 2;
452 bool extMode
= FALSE
;
454 //PrintAndLog("test: %X %X %X ", safer, resv, extend);
456 // 2nibble must be zeroed.
457 if ( resv
> 0x00) continue;
460 if ( (safer
== 0x6 || safer
== 0x9) && extend
) extMode
= TRUE
;
463 if (nml01
|| nml02
|| xtRate
) continue;
467 if (!testModulation(mode
, modread
)) continue;
474 void printT55xxBlock(const char *demodStr
){
476 uint32_t blockData
= 0;
477 uint8_t bits
[64] = {0x00};
479 if ( !DemodBufferLen
)
482 if ( config
.offset
+ 32 > DemodBufferLen
){
483 PrintAndLog("The configured offset is too big. (%d > %d)", config
.offset
, DemodBufferLen
);
487 int i
= config
.offset
;
488 int pos
= 32 + config
.offset
;
490 bits
[i
- config
.offset
]=DemodBuffer
[i
];
492 blockData
= PackBits(0, 32, bits
);
493 PrintAndLog("0x%08X %s [%s]", blockData
, sprint_bin(bits
,32), demodStr
);
496 int special(const char *Cmd
) {
497 uint32_t blockData
= 0;
498 uint8_t bits
[32] = {0x00};
500 PrintAndLog("[OFFSET] [DATA] [BINARY]");
501 PrintAndLog("----------------------------------------------------");
503 for (; j
< 128; ++j
){
505 for (i
= 0; i
< 32; ++i
)
506 bits
[i
]=DemodBuffer
[j
+i
];
508 blockData
= PackBits(0, 32, bits
);
509 PrintAndLog("[%d] 0x%08X %s",j
, blockData
, sprint_bin(bits
,32));
515 void printConfiguration( t55xx_conf_block_t b
){
516 PrintAndLog("Modulation : %s", GetSelectedModulationStr(b
.modulation
) );
517 PrintAndLog("Inverted : %s", (b
.inversed
) ? "Yes" : "No" );
518 PrintAndLog("Offset : %d", b
.offset
);
519 PrintAndLog("Block0 : %08X", b
.block0
);
523 int CmdT55xxWriteBlock(const char *Cmd
)
525 int block
= 8; //default to invalid block
526 int data
= 0xFFFFFFFF; //default to blank Block
527 int password
= 0xFFFFFFFF; //default to blank Block 7
529 char cmdp
= param_getchar(Cmd
, 0);
530 if (cmdp
== 'h' || cmdp
== 'H') {
535 int res
= sscanf(Cmd
, "%d %x %x",&block
, &data
, &password
);
537 if ( res
< 2 || res
> 3) {
543 PrintAndLog("Block must be between 0 and 7");
547 UsbCommand c
= {CMD_T55XX_WRITE_BLOCK
, {data
, block
, 0}};
548 c
.d
.asBytes
[0] = 0x0;
550 PrintAndLog("Writing to T55x7");
551 PrintAndLog("block : %d", block
);
552 PrintAndLog("data : 0x%08X", data
);
557 c
.d
.asBytes
[0] = 0x1;
558 PrintAndLog("pwd : 0x%08X", password
);
564 int CmdT55xxReadTrace(const char *Cmd
)
566 char cmdp
= param_getchar(Cmd
, 0);
568 if (strlen(Cmd
) > 1 || cmdp
== 'h' || cmdp
== 'H')
569 return usage_t55xx_trace();
571 if ( strlen(Cmd
)==0){
573 UsbCommand c
= {CMD_T55XX_READ_TRACE
, {0, 0, 0}};
575 if ( !WaitForResponseTimeout(CMD_ACK
,NULL
,2500) ) {
576 PrintAndLog("command execution time out");
581 GetFromBigBuf(got
,sizeof(got
),0);
582 WaitForResponse(CMD_ACK
,NULL
);
583 setGraphBuf(got
, 12000);
588 if ( !DemodBufferLen
)
591 RepaintGraphWindow();
593 if (config
.offset
> 5) repeat
= 32;
594 uint8_t si
= config
.offset
+repeat
;
595 uint32_t bl0
= PackBits(si
, 32, DemodBuffer
);
596 uint32_t bl1
= PackBits(si
+32, 32, DemodBuffer
);
598 uint32_t acl
= PackBits(si
, 8, DemodBuffer
); si
+= 8;
599 uint32_t mfc
= PackBits(si
, 8, DemodBuffer
); si
+= 8;
600 uint32_t cid
= PackBits(si
, 5, DemodBuffer
); si
+= 5;
601 uint32_t icr
= PackBits(si
, 3, DemodBuffer
); si
+= 3;
602 uint32_t year
= PackBits(si
, 4, DemodBuffer
); si
+= 4;
603 uint32_t quarter
= PackBits(si
, 2, DemodBuffer
); si
+= 2;
604 uint32_t lotid
= PackBits(si
, 12, DemodBuffer
); si
+= 12;
605 uint32_t wafer
= PackBits(si
, 5, DemodBuffer
); si
+= 5;
606 uint32_t dw
= PackBits(si
, 15, DemodBuffer
);
611 PrintAndLog("-- T55xx Trace Information ----------------------------------");
612 PrintAndLog("-------------------------------------------------------------");
613 PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", acl
, acl
);
614 PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d) - %s", mfc
, mfc
, getTagInfo(mfc
));
615 PrintAndLog(" CID : 0x%02X (%d) - %s", cid
, cid
, GetModelStrFromCID(cid
));
616 PrintAndLog(" ICR IC Revision : %d",icr
);
617 PrintAndLog(" Manufactured");
618 PrintAndLog(" Year/Quarter : %d/%d",year
, quarter
);
619 PrintAndLog(" Lot ID : %d", lotid
);
620 PrintAndLog(" Wafer number : %d", wafer
);
621 PrintAndLog(" Die Number : %d", dw
);
622 PrintAndLog("-------------------------------------------------------------");
623 PrintAndLog(" Raw Data - Page 1");
624 PrintAndLog(" Block 0 : 0x%08X %s", bl0
, sprint_bin(DemodBuffer
+config
.offset
+repeat
,32) );
625 PrintAndLog(" Block 1 : 0x%08X %s", bl1
, sprint_bin(DemodBuffer
+config
.offset
+repeat
+32,32) );
626 PrintAndLog("-------------------------------------------------------------");
630 1-8 ACL Allocation class (ISO/IEC 15963-1) 0xE0
631 9-16 MFC Manufacturer ID (ISO/IEC 7816-6) 0x15 Atmel Corporation
632 17-21 CID 0x1 = Atmel ATA5577M1 0x2 = Atmel ATA5577M2
633 22-24 ICR IC revision
634 25-28 YEAR (BCD encoded) 9 (= 2009)
635 29-30 QUARTER 1,2,3,4
641 18-32 DW, die number sequential
647 int CmdT55xxInfo(const char *Cmd
){
649 Page 0 Block 0 Configuration data.
653 char cmdp
= param_getchar(Cmd
, 0);
655 if (cmdp
== 'h' || cmdp
== 'H')
656 return usage_t55xx_info();
660 // read block 0, Page 0. Configuration.
661 UsbCommand c
= {CMD_T55XX_READ_BLOCK
, {0, 0, 0}};
662 c
.d
.asBytes
[0] = 0x0;
666 // c.arg[2] = password;
667 // c.d.asBytes[0] = 0x1;
671 if ( !WaitForResponseTimeout(CMD_ACK
,NULL
,2500) ) {
672 PrintAndLog("command execution time out");
677 GetFromBigBuf(got
,sizeof(got
),0);
678 WaitForResponse(CMD_ACK
,NULL
);
679 setGraphBuf(got
, 12000);
684 if ( !DemodBufferLen
)
688 uint8_t si
= config
.offset
;
689 uint32_t bl0
= PackBits(si
, 32, DemodBuffer
);
691 uint32_t safer
= PackBits(si
, 4, DemodBuffer
); si
+= 4;
692 uint32_t resv
= PackBits(si
, 7, DemodBuffer
); si
+= 7;
693 uint32_t dbr
= PackBits(si
, 3, DemodBuffer
); si
+= 3;
694 uint32_t extend
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
695 uint32_t datamod
= PackBits(si
, 5, DemodBuffer
); si
+= 5;
696 uint32_t pskcf
= PackBits(si
, 2, DemodBuffer
); si
+= 2;
697 uint32_t aor
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
698 uint32_t otp
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
699 uint32_t maxblk
= PackBits(si
, 3, DemodBuffer
); si
+= 3;
700 uint32_t pwd
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
701 uint32_t sst
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
702 uint32_t fw
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
703 uint32_t inv
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
704 uint32_t por
= PackBits(si
, 1, DemodBuffer
); si
+= 1;
707 PrintAndLog("-- T55xx Configuration & Tag Information --------------------");
708 PrintAndLog("-------------------------------------------------------------");
709 PrintAndLog(" Safer key : %s", GetSaferStr(safer
));
710 PrintAndLog(" reserved : %d", resv
);
711 PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr
));
712 PrintAndLog(" eXtended mode : %s", (extend
) ? "Yes - Warning":"No");
713 PrintAndLog(" Modulation : %s", GetModulationStr(datamod
));
714 PrintAndLog(" PSK clock freq : %d", pskcf
);
715 PrintAndLog(" AOR - Answer on Request : %s", (aor
) ? "Yes":"No");
716 PrintAndLog(" OTP - One Time Pad : %s", (otp
) ? "Yes - Warning":"No" );
717 PrintAndLog(" Max block : %d", maxblk
);
718 PrintAndLog(" Password mode : %s", (pwd
) ? "Yes":"No");
719 PrintAndLog(" Sequence Start Terminator : %s", (sst
) ? "Yes":"No");
720 PrintAndLog(" Fast Write : %s", (fw
) ? "Yes":"No");
721 PrintAndLog(" Inverse data : %s", (inv
) ? "Yes":"No");
722 PrintAndLog(" POR-Delay : %s", (por
) ? "Yes":"No");
723 PrintAndLog("-------------------------------------------------------------");
724 PrintAndLog(" Raw Data - Page 0");
725 PrintAndLog(" Block 0 : 0x%08X %s", bl0
, sprint_bin(DemodBuffer
+config
.offset
,32) );
726 PrintAndLog("-------------------------------------------------------------");
731 int CmdT55xxDump(const char *Cmd
){
734 uint8_t pwd
[4] = {0x00};
736 char cmdp
= param_getchar(Cmd
, 0);
737 if ( cmdp
== 'h' || cmdp
== 'H') {
742 bool hasPwd
= ( strlen(Cmd
) > 0);
744 if (param_gethex(Cmd
, 0, pwd
, 8)) {
745 PrintAndLog("password must include 8 HEX symbols");
750 for ( int i
= 0; i
<8; ++i
){
751 memset(s
,0,sizeof(s
));
753 sprintf(s
,"%d %02x%02x%02x%02x", i
, pwd
[0],pwd
[1],pwd
[2],pwd
[3]);
757 CmdT55xxReadBlock(s
);
762 char * GetBitRateStr(uint32_t id
){
767 sprintf(retStr
,"%d - RF/8",id
);
770 sprintf(retStr
,"%d - RF/16",id
);
773 sprintf(retStr
,"%d - RF/32",id
);
776 sprintf(retStr
,"%d - RF/40",id
);
779 sprintf(retStr
,"%d - RF/50",id
);
782 sprintf(retStr
,"%d - RF/64",id
);
785 sprintf(retStr
,"%d - RF/100",id
);
788 sprintf(retStr
,"%d - RF/128",id
);
791 sprintf(retStr
,"%d - (Unknown)",id
);
798 char * GetSaferStr(uint32_t id
){
802 sprintf(retStr
,"%d",id
);
804 sprintf(retStr
,"%d - passwd",id
);
807 sprintf(retStr
,"%d - testmode",id
);
812 char * GetModulationStr( uint32_t id
){
818 sprintf(retStr
,"%d - DIRECT (ASK/NRZ)",id
);
821 sprintf(retStr
,"%d - PSK 1 phase change when input changes",id
);
824 sprintf(retStr
,"%d - PSK 2 phase change on bitclk if input high",id
);
827 sprintf(retStr
,"%d - PSK 3 phase change on rising edge of input",id
);
830 sprintf(retStr
,"%d - FSK 1 RF/8 RF/5",id
);
833 sprintf(retStr
,"%d - FSK 2 RF/8 RF/10",id
);
836 sprintf(retStr
,"%d - FSK 1a RF/5 RF/8",id
);
839 sprintf(retStr
,"%d - FSK 2a RF/10 RF/8",id
);
842 sprintf(retStr
,"%d - Manschester",id
);
845 sprintf(retStr
,"%d - Biphase",id
);
848 sprintf(retStr
,"%d - Reserved",id
);
851 sprintf(retStr
,"0x%02X (Unknown)",id
);
857 char * GetModelStrFromCID(uint32_t cid
){
862 if (cid
== 1) sprintf(retStr
,"ATA5577M1");
863 if (cid
== 2) sprintf(retStr
,"ATA5577M2");
867 char * GetSelectedModulationStr( uint8_t id
){
874 sprintf(retStr
,"FSK (%d)",id
);
877 sprintf(retStr
,"ASK (%d)",id
);
880 sprintf(retStr
,"DIRECT/NRZ (%d)",id
);
883 sprintf(retStr
,"PSK1 (%d)",id
);
886 sprintf(retStr
,"PSK2 (%d)",id
);
889 sprintf(retStr
,"BIPHASE (%d)",id
);
892 sprintf(retStr
,"(Unknown)");
898 uint32_t PackBits(uint8_t start
, uint8_t len
, uint8_t* bits
){
906 for (; j
>= 0; --j
, ++i
){
912 static command_t CommandTable
[] =
914 {"help", CmdHelp
, 1, "This help"},
915 {"config", CmdT55xxSetConfig
, 1, "Set T55XX config for modulation, inversed data"},
916 {"detect", CmdT55xxDetect
, 0, "Try detecting the tag modulation from reading the configuration block."},
917 {"read", CmdT55xxReadBlock
, 0, "<block> [password] -- Read T55xx block data (page 0) [optional password]"},
918 {"write", CmdT55xxWriteBlock
,0, "<block> <data> [password] -- Write T55xx block data (page 0) [optional password]"},
919 {"trace", CmdT55xxReadTrace
, 0, "[1] Show T55xx traceability data (page 1/ blk 0-1)"},
920 {"info", CmdT55xxInfo
, 0, "[1] Show T55xx configuration data (page 0/ blk 0)"},
921 {"dump", CmdT55xxDump
, 0, "[password] Dump T55xx card block 0-7. [optional password]"},
922 {"special", special
, 0, "Shows how a datablock changes with 32 different offsets"},
923 {NULL
, NULL
, 0, NULL
}
926 int CmdLFT55XX(const char *Cmd
)
928 CmdsParse(CommandTable
, Cmd
);
932 int CmdHelp(const char *Cmd
)
934 CmdsHelp(CommandTable
);