]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlft55xx.c
update changelog
[proxmark3-svn] / client / cmdlft55xx.c
1 //-----------------------------------------------------------------------------
2 //
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
5 // the license.
6 //-----------------------------------------------------------------------------
7 // Low frequency T55xx commands
8 //-----------------------------------------------------------------------------
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <inttypes.h>
13 #include <time.h>
14 #include "proxmark3.h"
15 #include "ui.h"
16 #include "graph.h"
17 #include "cmdmain.h"
18 #include "cmdparser.h"
19 #include "cmddata.h"
20 #include "cmdlf.h"
21 #include "cmdlft55xx.h"
22 #include "util.h"
23 #include "data.h"
24 #include "lfdemod.h"
25 #include "../common/crc.h"
26 #include "../common/iso14443crc.h"
27 #include "cmdhf14a.h"
28
29 #define CONFIGURATION_BLOCK 0x00
30 #define TRACE_BLOCK 0x01
31 #define REGULAR_READ_MODE_BLOCK 0xFF
32
33 // Default configuration
34 t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00};
35
36 int usage_t55xx_config(){
37 PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>]");
38 PrintAndLog("Options:");
39 PrintAndLog(" h This help");
40 PrintAndLog(" b <8|16|32|40|50|64|100|128> Set bitrate");
41 PrintAndLog(" d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa> Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");
42 PrintAndLog(" i [1] Invert data signal, defaults to normal");
43 PrintAndLog(" o [offset] Set offset, where data should start decode in bitstream");
44 PrintAndLog("");
45 PrintAndLog("Examples:");
46 PrintAndLog(" lf t55xx config d FSK - FSK demodulation");
47 PrintAndLog(" lf t55xx config d FSK i 1 - FSK demodulation, inverse data");
48 PrintAndLog(" lf t55xx config d FSK i 1 o 3 - FSK demodulation, inverse data, offset=3,start from position 3 to decode data");
49 PrintAndLog("");
50 return 0;
51 }
52 int usage_t55xx_read(){
53 PrintAndLog("Usage: lf t55xx read [b <block>] [p <password>] <override_safety> <page1>");
54 PrintAndLog("Options:");
55 PrintAndLog(" b <block> - block number to read. Between 0-7");
56 PrintAndLog(" p <password> - OPTIONAL password (8 hex characters)");
57 PrintAndLog(" o - OPTIONAL override safety check");
58 PrintAndLog(" 1 - OPTIONAL read Page 1 instead of Page 0");
59 PrintAndLog(" ****WARNING****");
60 PrintAndLog(" Use of read with password on a tag not configured for a pwd");
61 PrintAndLog(" can damage the tag");
62 PrintAndLog("");
63 PrintAndLog("Examples:");
64 PrintAndLog(" lf t55xx read b 0 - read data from block 0");
65 PrintAndLog(" lf t55xx read b 0 p feedbeef - read data from block 0 password feedbeef");
66 PrintAndLog(" lf t55xx read b 0 p feedbeef o - read data from block 0 password feedbeef safety check");
67 PrintAndLog("");
68 return 0;
69 }
70 int usage_t55xx_write(){
71 PrintAndLog("Usage: lf t55xx wr [b <block>] [d <data>] [p <password>] [1]");
72 PrintAndLog("Options:");
73 PrintAndLog(" b <block> - block number to write. Between 0-7");
74 PrintAndLog(" d <data> - 4 bytes of data to write (8 hex characters)");
75 PrintAndLog(" p <password> - OPTIONAL password 4bytes (8 hex characters)");
76 PrintAndLog(" 1 - OPTIONAL write Page 1 instead of Page 0");
77 PrintAndLog("");
78 PrintAndLog("Examples:");
79 PrintAndLog(" lf t55xx wr b 3 d 11223344 - write 11223344 to block 3");
80 PrintAndLog(" lf t55xx wr b 3 d 11223344 p feedbeef - write 11223344 to block 3 password feedbeef");
81 PrintAndLog("");
82 return 0;
83 }
84 int usage_t55xx_trace() {
85 PrintAndLog("Usage: lf t55xx trace [1]");
86 PrintAndLog("Options:");
87 PrintAndLog(" [graph buffer data] - if set, use Graphbuffer otherwise read data from tag.");
88 PrintAndLog("");
89 PrintAndLog("Examples:");
90 PrintAndLog(" lf t55xx trace");
91 PrintAndLog(" lf t55xx trace 1");
92 PrintAndLog("");
93 return 0;
94 }
95 int usage_t55xx_info() {
96 PrintAndLog("Usage: lf t55xx info [1]");
97 PrintAndLog("Options:");
98 PrintAndLog(" [graph buffer data] - if set, use Graphbuffer otherwise read data from tag.");
99 PrintAndLog("");
100 PrintAndLog("Examples:");
101 PrintAndLog(" lf t55xx info");
102 PrintAndLog(" lf t55xx info 1");
103 PrintAndLog("");
104 return 0;
105 }
106 int usage_t55xx_dump(){
107 PrintAndLog("Usage: lf t55xx dump <password> [o]");
108 PrintAndLog("Options:");
109 PrintAndLog(" <password> - OPTIONAL password 4bytes (8 hex symbols)");
110 PrintAndLog(" o - OPTIONAL override, force pwd read despite danger to card");
111 PrintAndLog("");
112 PrintAndLog("Examples:");
113 PrintAndLog(" lf t55xx dump");
114 PrintAndLog(" lf t55xx dump feedbeef o");
115 PrintAndLog("");
116 return 0;
117 }
118 int usage_t55xx_detect(){
119 PrintAndLog("Usage: lf t55xx detect [1]");
120 PrintAndLog("Options:");
121 PrintAndLog(" [graph buffer data] - if set, use Graphbuffer otherwise read data from tag.");
122 PrintAndLog("");
123 PrintAndLog("Examples:");
124 PrintAndLog(" lf t55xx detect");
125 PrintAndLog(" lf t55xx detect 1");
126 PrintAndLog("");
127 return 0;
128 }
129 int usage_t55xx_wakup(){
130 PrintAndLog("Usage: lf t55xx wakeup [h] p <password>");
131 PrintAndLog("This commands send the Answer-On-Request command and leaves the readerfield ON afterwards.");
132 PrintAndLog("Options:");
133 PrintAndLog(" h - this help");
134 PrintAndLog(" p <password> - password 4bytes (8 hex symbols)");
135 PrintAndLog("");
136 PrintAndLog("Examples:");
137 PrintAndLog(" lf t55xx wakeup p 11223344 - send wakeup password");
138 return 0;
139 }
140
141 static int CmdHelp(const char *Cmd);
142
143 int CmdT55xxSetConfig(const char *Cmd) {
144
145 uint8_t offset = 0;
146 char modulation[5] = {0x00};
147 char tmp = 0x00;
148 uint8_t bitRate = 0;
149 uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};
150 uint8_t cmdp = 0;
151 bool errors = FALSE;
152 while(param_getchar(Cmd, cmdp) != 0x00 && !errors)
153 {
154 tmp = param_getchar(Cmd, cmdp);
155 switch(tmp)
156 {
157 case 'h':
158 case 'H':
159 return usage_t55xx_config();
160 case 'b':
161 errors |= param_getdec(Cmd, cmdp+1, &bitRate);
162 if ( !errors){
163 uint8_t i = 0;
164 for (; i < 9; i++){
165 if (rates[i]==bitRate) {
166 config.bitrate = i;
167 break;
168 }
169 }
170 if (i==9) errors = TRUE;
171 }
172 cmdp+=2;
173 break;
174 case 'd':
175 param_getstr(Cmd, cmdp+1, modulation);
176 cmdp += 2;
177
178 if ( strcmp(modulation, "FSK" ) == 0) {
179 config.modulation = DEMOD_FSK;
180 } else if ( strcmp(modulation, "FSK1" ) == 0) {
181 config.modulation = DEMOD_FSK1;
182 config.inverted=1;
183 } else if ( strcmp(modulation, "FSK1a" ) == 0) {
184 config.modulation = DEMOD_FSK1a;
185 config.inverted=0;
186 } else if ( strcmp(modulation, "FSK2" ) == 0) {
187 config.modulation = DEMOD_FSK2;
188 config.inverted=0;
189 } else if ( strcmp(modulation, "FSK2a" ) == 0) {
190 config.modulation = DEMOD_FSK2a;
191 config.inverted=1;
192 } else if ( strcmp(modulation, "ASK" ) == 0) {
193 config.modulation = DEMOD_ASK;
194 } else if ( strcmp(modulation, "NRZ" ) == 0) {
195 config.modulation = DEMOD_NRZ;
196 } else if ( strcmp(modulation, "PSK1" ) == 0) {
197 config.modulation = DEMOD_PSK1;
198 } else if ( strcmp(modulation, "PSK2" ) == 0) {
199 config.modulation = DEMOD_PSK2;
200 } else if ( strcmp(modulation, "PSK3" ) == 0) {
201 config.modulation = DEMOD_PSK3;
202 } else if ( strcmp(modulation, "BIa" ) == 0) {
203 config.modulation = DEMOD_BIa;
204 config.inverted=1;
205 } else if ( strcmp(modulation, "BI" ) == 0) {
206 config.modulation = DEMOD_BI;
207 config.inverted=0;
208 } else {
209 PrintAndLog("Unknown modulation '%s'", modulation);
210 errors = TRUE;
211 }
212 break;
213 case 'i':
214 config.inverted = param_getchar(Cmd,cmdp+1) == '1';
215 cmdp+=2;
216 break;
217 case 'o':
218 errors |= param_getdec(Cmd, cmdp+1, &offset);
219 if ( !errors )
220 config.offset = offset;
221 cmdp+=2;
222 break;
223 default:
224 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
225 errors = TRUE;
226 break;
227 }
228 }
229
230 // No args
231 if (cmdp == 0) return printConfiguration( config );
232
233 //Validations
234 if (errors) return usage_t55xx_config();
235
236 config.block0 = 0;
237 return printConfiguration ( config );
238 }
239
240 int T55xxReadBlock(uint8_t block, bool page1, bool usepwd, bool override, uint32_t password){
241 //Password mode
242 if ( usepwd ) {
243 // try reading the config block and verify that PWD bit is set before doing this!
244 if ( !override ) {
245 if ( !AquireData(0, CONFIGURATION_BLOCK, false, 0 ) ) return 0;
246 if ( !tryDetectModulation() ) {
247 PrintAndLog("Safety Check: Could not detect if PWD bit is set in config block. Exits.");
248 return 0;
249 } else {
250 PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password...");
251 usepwd = false;
252 page1 = false;
253 }
254 } else {
255 PrintAndLog("Safety Check Overriden - proceeding despite risk");
256 }
257 }
258
259 if (!AquireData(page1, block, usepwd, password) ) return 0;
260 if (!DecodeT55xxBlock()) return 0;
261
262 char blk[10]={0};
263 sprintf(blk,"%d", block);
264 printT55xxBlock(blk);
265 return 1;
266 }
267
268 int CmdT55xxReadBlock(const char *Cmd) {
269 uint8_t block = REGULAR_READ_MODE_BLOCK;
270 uint32_t password = 0; //default to blank Block 7
271 bool usepwd = false;
272 bool override = false;
273 bool page1 = false;
274 bool errors = false;
275 uint8_t cmdp = 0;
276 while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
277 switch(param_getchar(Cmd, cmdp)) {
278 case 'h':
279 case 'H':
280 return usage_t55xx_read();
281 case 'b':
282 case 'B':
283 errors |= param_getdec(Cmd, cmdp+1, &block);
284 cmdp += 2;
285 break;
286 case 'o':
287 case 'O':
288 override = true;
289 cmdp++;
290 break;
291 case 'p':
292 case 'P':
293 password = param_get32ex(Cmd, cmdp+1, 0, 16);
294 usepwd = true;
295 cmdp += 2;
296 break;
297 case '1':
298 page1 = true;
299 cmdp++;
300 break;
301 default:
302 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
303 errors = true;
304 break;
305 }
306 }
307 if (errors) return usage_t55xx_read();
308
309 if (block > 7 && block != REGULAR_READ_MODE_BLOCK ) {
310 PrintAndLog("Block must be between 0 and 7");
311 return 0;
312 }
313 PrintAndLog("Reading Page %d:", page1);
314 PrintAndLog("blk | hex data | binary");
315 return T55xxReadBlock(block, page1, usepwd, override, password);
316 }
317
318 bool DecodeT55xxBlock(){
319
320 char buf[30] = {0x00};
321 char *cmdStr = buf;
322 int ans = 0;
323 uint8_t bitRate[8] = {8,16,32,40,50,64,100,128};
324 DemodBufferLen = 0x00;
325
326 switch( config.modulation ){
327 case DEMOD_FSK:
328 snprintf(cmdStr, sizeof(buf),"%d %d", bitRate[config.bitrate], config.inverted );
329 ans = FSKrawDemod(cmdStr, FALSE);
330 break;
331 case DEMOD_FSK1:
332 case DEMOD_FSK1a:
333 snprintf(cmdStr, sizeof(buf),"%d %d 8 5", bitRate[config.bitrate], config.inverted );
334 ans = FSKrawDemod(cmdStr, FALSE);
335 break;
336 case DEMOD_FSK2:
337 case DEMOD_FSK2a:
338 snprintf(cmdStr, sizeof(buf),"%d %d 10 8", bitRate[config.bitrate], config.inverted );
339 ans = FSKrawDemod(cmdStr, FALSE);
340 break;
341 case DEMOD_ASK:
342 snprintf(cmdStr, sizeof(buf),"%d %d 0", bitRate[config.bitrate], config.inverted );
343 ans = ASKDemod(cmdStr, FALSE, FALSE, 1);
344 break;
345 case DEMOD_PSK1:
346 snprintf(cmdStr, sizeof(buf),"%d %d 0", bitRate[config.bitrate], config.inverted );
347 ans = PSKDemod(cmdStr, FALSE);
348 break;
349 case DEMOD_PSK2: //inverted won't affect this
350 case DEMOD_PSK3: //not fully implemented
351 snprintf(cmdStr, sizeof(buf),"%d 0 1", bitRate[config.bitrate] );
352 ans = PSKDemod(cmdStr, FALSE);
353 psk1TOpsk2(DemodBuffer, DemodBufferLen);
354 break;
355 case DEMOD_NRZ:
356 snprintf(cmdStr, sizeof(buf),"%d %d 1", bitRate[config.bitrate], config.inverted );
357 ans = NRZrawDemod(cmdStr, FALSE);
358 break;
359 case DEMOD_BI:
360 case DEMOD_BIa:
361 snprintf(cmdStr, sizeof(buf),"0 %d %d 0", bitRate[config.bitrate], config.inverted );
362 ans = ASKbiphaseDemod(cmdStr, FALSE);
363 break;
364 default:
365 return FALSE;
366 }
367 return (bool) ans;
368 }
369
370 int CmdT55xxDetect(const char *Cmd){
371
372 char cmdp = param_getchar(Cmd, 0);
373 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')
374 return usage_t55xx_detect();
375
376 if (strlen(Cmd)==0)
377 if ( !AquireData(0, CONFIGURATION_BLOCK, false, 0) )
378 return 0;
379
380 if ( !tryDetectModulation() )
381 PrintAndLog("Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");
382
383 return 1;
384 }
385
386 // detect configuration?
387 bool tryDetectModulation(){
388 uint8_t hits = 0;
389 t55xx_conf_block_t tests[15];
390 int bitRate=0;
391 uint8_t fc1 = 0, fc2 = 0, clk=0;
392 save_restoreGB(1);
393 if (GetFskClock("", FALSE, FALSE)){
394 fskClocks(&fc1, &fc2, &clk, FALSE);
395 if ( FSKrawDemod("0 0", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate)){
396 tests[hits].modulation = DEMOD_FSK;
397 if (fc1==8 && fc2 == 5)
398 tests[hits].modulation = DEMOD_FSK1a;
399 else if (fc1==10 && fc2 == 8)
400 tests[hits].modulation = DEMOD_FSK2;
401 tests[hits].bitrate = bitRate;
402 tests[hits].inverted = FALSE;
403 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
404 ++hits;
405 }
406 if ( FSKrawDemod("0 1", FALSE) && test(DEMOD_FSK, &tests[hits].offset, &bitRate)) {
407 tests[hits].modulation = DEMOD_FSK;
408 if (fc1 == 8 && fc2 == 5)
409 tests[hits].modulation = DEMOD_FSK1;
410 else if (fc1 == 10 && fc2 == 8)
411 tests[hits].modulation = DEMOD_FSK2a;
412
413 tests[hits].bitrate = bitRate;
414 tests[hits].inverted = TRUE;
415 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
416 ++hits;
417 }
418 } else {
419 clk = GetAskClock("", FALSE, FALSE);
420 if (clk>0) {
421 if ( ASKDemod("0 0 0", FALSE, FALSE, 1) && test(DEMOD_ASK, &tests[hits].offset, &bitRate)) {
422 tests[hits].modulation = DEMOD_ASK;
423 tests[hits].bitrate = bitRate;
424 tests[hits].inverted = FALSE;
425 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
426 ++hits;
427 }
428 if ( ASKDemod("0 1 0", FALSE, FALSE, 1) && test(DEMOD_ASK, &tests[hits].offset, &bitRate)) {
429 tests[hits].modulation = DEMOD_ASK;
430 tests[hits].bitrate = bitRate;
431 tests[hits].inverted = TRUE;
432 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
433 ++hits;
434 }
435 if ( ASKbiphaseDemod("0 0 0 0", FALSE) && test(DEMOD_BI, &tests[hits].offset, &bitRate) ) {
436 tests[hits].modulation = DEMOD_BI;
437 tests[hits].bitrate = bitRate;
438 tests[hits].inverted = FALSE;
439 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
440 ++hits;
441 }
442 if ( ASKbiphaseDemod("0 0 1 0", FALSE) && test(DEMOD_BIa, &tests[hits].offset, &bitRate) ) {
443 tests[hits].modulation = DEMOD_BIa;
444 tests[hits].bitrate = bitRate;
445 tests[hits].inverted = TRUE;
446 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
447 ++hits;
448 }
449 }
450 //undo trim from ask
451 save_restoreGB(0);
452 clk = GetNrzClock("", FALSE, FALSE);
453 if (clk>0) {
454 if ( NRZrawDemod("0 0 1", FALSE) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate)) {
455 tests[hits].modulation = DEMOD_NRZ;
456 tests[hits].bitrate = bitRate;
457 tests[hits].inverted = FALSE;
458 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
459 ++hits;
460 }
461
462 if ( NRZrawDemod("0 1 1", FALSE) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate)) {
463 tests[hits].modulation = DEMOD_NRZ;
464 tests[hits].bitrate = bitRate;
465 tests[hits].inverted = TRUE;
466 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
467 ++hits;
468 }
469 }
470
471 //undo trim from nrz
472 save_restoreGB(0);
473 clk = GetPskClock("", FALSE, FALSE);
474 if (clk>0) {
475 if ( PSKDemod("0 0 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate)) {
476 tests[hits].modulation = DEMOD_PSK1;
477 tests[hits].bitrate = bitRate;
478 tests[hits].inverted = FALSE;
479 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
480 ++hits;
481 }
482 if ( PSKDemod("0 1 1", FALSE) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate)) {
483 tests[hits].modulation = DEMOD_PSK1;
484 tests[hits].bitrate = bitRate;
485 tests[hits].inverted = TRUE;
486 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
487 ++hits;
488 }
489 // PSK2 - needs a call to psk1TOpsk2.
490 if ( PSKDemod("0 0 1", FALSE)) {
491 psk1TOpsk2(DemodBuffer, DemodBufferLen);
492 if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate)){
493 tests[hits].modulation = DEMOD_PSK2;
494 tests[hits].bitrate = bitRate;
495 tests[hits].inverted = FALSE;
496 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
497 ++hits;
498 }
499 } // inverse waves does not affect this demod
500 // PSK3 - needs a call to psk1TOpsk2.
501 if ( PSKDemod("0 0 1", FALSE)) {
502 psk1TOpsk2(DemodBuffer, DemodBufferLen);
503 if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate)){
504 tests[hits].modulation = DEMOD_PSK3;
505 tests[hits].bitrate = bitRate;
506 tests[hits].inverted = FALSE;
507 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);
508 ++hits;
509 }
510 } // inverse waves does not affect this demod
511 }
512 }
513 if ( hits == 1) {
514 config.modulation = tests[0].modulation;
515 config.bitrate = tests[0].bitrate;
516 config.inverted = tests[0].inverted;
517 config.offset = tests[0].offset;
518 config.block0 = tests[0].block0;
519 printConfiguration( config );
520 return TRUE;
521 }
522
523 if ( hits > 1) {
524 PrintAndLog("Found [%d] possible matches for modulation.",hits);
525 for(int i=0; i<hits; ++i){
526 PrintAndLog("--[%d]---------------", i+1);
527 printConfiguration( tests[i] );
528 }
529 }
530 return FALSE;
531 }
532
533 bool testModulation(uint8_t mode, uint8_t modread){
534 switch( mode ){
535 case DEMOD_FSK:
536 if (modread > 3 && modread < 8) return TRUE;
537 break;
538 case DEMOD_ASK:
539 if (modread == DEMOD_ASK) return TRUE;
540 break;
541 case DEMOD_PSK1:
542 if (modread == DEMOD_PSK1) return TRUE;
543 break;
544 case DEMOD_PSK2:
545 if (modread == DEMOD_PSK2) return TRUE;
546 break;
547 case DEMOD_PSK3:
548 if (modread == DEMOD_PSK3) return TRUE;
549 break;
550 case DEMOD_NRZ:
551 if (modread == DEMOD_NRZ) return TRUE;
552 break;
553 case DEMOD_BI:
554 if (modread == DEMOD_BI) return TRUE;
555 break;
556 case DEMOD_BIa:
557 if (modread == DEMOD_BIa) return TRUE;
558 break;
559 default:
560 return FALSE;
561 }
562 return FALSE;
563 }
564
565 bool testBitRate(uint8_t readRate, uint8_t mod){
566 uint8_t expected[8] = {8, 16, 32, 40, 50, 64, 100, 128};
567 uint8_t detRate = 0;
568 switch( mod ){
569 case DEMOD_FSK:
570 case DEMOD_FSK1:
571 case DEMOD_FSK1a:
572 case DEMOD_FSK2:
573 case DEMOD_FSK2a:
574 detRate = GetFskClock("",FALSE, FALSE);
575 if (expected[readRate] == detRate)
576 return TRUE;
577 break;
578 case DEMOD_ASK:
579 case DEMOD_BI:
580 case DEMOD_BIa:
581 detRate = GetAskClock("",FALSE, FALSE);
582 if (expected[readRate] == detRate)
583 return TRUE;
584 break;
585 case DEMOD_PSK1:
586 case DEMOD_PSK2:
587 case DEMOD_PSK3:
588 detRate = GetPskClock("",FALSE, FALSE);
589 if (expected[readRate] == detRate)
590 return TRUE;
591 break;
592 case DEMOD_NRZ:
593 detRate = GetNrzClock("",FALSE, FALSE);
594 if (expected[readRate] == detRate)
595 return TRUE;
596 break;
597 default:
598 return FALSE;
599 }
600 return FALSE;
601 }
602
603 bool test(uint8_t mode, uint8_t *offset, int *fndBitRate){
604
605 if ( DemodBufferLen < 64 ) return FALSE;
606 uint8_t si = 0;
607 for (uint8_t idx = 0; idx < 64; idx++){
608 si = idx;
609 if ( PackBits(si, 32, DemodBuffer) == 0x00 ) continue;
610
611 uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; //master key
612 uint8_t resv = PackBits(si, 4, DemodBuffer); si += 4; //was 7 & +=7+3 //should be only 4 bits if extended mode
613 // 2nibble must be zeroed.
614 // moved test to here, since this gets most faults first.
615 if ( resv > 0x00) continue;
616
617 uint8_t xtRate = PackBits(si, 3, DemodBuffer); si += 3; //extended mode part of rate
618 int bitRate = PackBits(si, 3, DemodBuffer); si += 3; //bit rate
619 if (bitRate > 7) continue;
620 uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1; //bit 15 extended mode
621 uint8_t modread = PackBits(si, 5, DemodBuffer); si += 5+2+1;
622 //uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2+1; //could check psk cr
623 uint8_t nml01 = PackBits(si, 1, DemodBuffer); si += 1+5; //bit 24, 30, 31 could be tested for 0 if not extended mode
624 uint8_t nml02 = PackBits(si, 2, DemodBuffer); si += 2;
625
626 //if extended mode
627 bool extMode =( (safer == 0x6 || safer == 0x9) && extend) ? TRUE : FALSE;
628
629 if (!extMode){
630 if (nml01 || nml02 || xtRate) continue;
631 }
632 //test modulation
633 if (!testModulation(mode, modread)) continue;
634 if (!testBitRate(bitRate, mode)) continue;
635 *fndBitRate = bitRate;
636 *offset = idx;
637 return TRUE;
638 }
639 return FALSE;
640 }
641
642 void printT55xxBlock(const char *blockNum){
643
644 uint8_t i = config.offset;
645 uint8_t endpos = 32 + i;
646 uint32_t blockData = 0;
647 uint8_t bits[64] = {0x00};
648
649 if ( !DemodBufferLen) return;
650
651 if ( endpos > DemodBufferLen){
652 PrintAndLog("The configured offset %d is too big. Possible offset: %d)", i, DemodBufferLen-32);
653 return;
654 }
655
656 for (; i < endpos; ++i)
657 bits[i - config.offset]=DemodBuffer[i];
658
659 blockData = PackBits(0, 32, bits);
660 PrintAndLog(" %s | %08X | %s", blockNum, blockData, sprint_bin(bits,32));
661 }
662
663 int special(const char *Cmd) {
664 uint32_t blockData = 0;
665 uint8_t bits[32] = {0x00};
666
667 PrintAndLog("OFFSET | DATA | BINARY");
668 PrintAndLog("----------------------------------------------------");
669 int i,j = 0;
670 for (; j < 64; ++j){
671
672 for (i = 0; i < 32; ++i)
673 bits[i]=DemodBuffer[j+i];
674
675 blockData = PackBits(0, 32, bits);
676
677 PrintAndLog(" %02d | 0x%08X | %s",j , blockData, sprint_bin(bits,32));
678 }
679 return 0;
680 }
681
682 int printConfiguration( t55xx_conf_block_t b){
683 PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );
684 PrintAndLog("Bit Rate : %s", GetBitRateStr(b.bitrate) );
685 PrintAndLog("Inverted : %s", (b.inverted) ? "Yes" : "No" );
686 PrintAndLog("Offset : %d", b.offset);
687 PrintAndLog("Block0 : 0x%08X", b.block0);
688 PrintAndLog("");
689 return 0;
690 }
691
692 int CmdT55xxWakeUp(const char *Cmd) {
693 uint32_t password = 0;
694 uint8_t cmdp = 0;
695 bool errors = true;
696 while(param_getchar(Cmd, cmdp) != 0x00) {
697 switch(param_getchar(Cmd, cmdp)) {
698 case 'h':
699 case 'H':
700 return usage_t55xx_wakup();
701 case 'p':
702 case 'P':
703 password = param_get32ex(Cmd, cmdp+1, 0xFFFFFFFF, 16);
704 cmdp += 2;
705 errors = false;
706 break;
707 default:
708 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
709 errors = true;
710 break;
711 }
712 }
713 if (errors) return usage_t55xx_wakup();
714
715 UsbCommand c = {CMD_T55XX_WAKEUP, {password, 0, 0}};
716 clearCommandBuffer();
717 SendCommand(&c);
718 PrintAndLog("Wake up command sent. Try read now");
719 return 0;
720 }
721
722 int CmdT55xxWriteBlock(const char *Cmd) {
723 uint8_t block = 0xFF; //default to invalid block
724 uint32_t data = 0xFFFFFFFF; //default to blank Block
725 uint32_t password = 0xFFFFFFFF; //default to blank Block 7
726 bool usepwd = false;
727 bool page1 = false;
728 bool gotdata = false;
729 bool errors = false;
730 uint8_t cmdp = 0;
731 while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
732 switch(param_getchar(Cmd, cmdp)) {
733 case 'h':
734 case 'H':
735 return usage_t55xx_write();
736 case 'b':
737 case 'B':
738 errors |= param_getdec(Cmd, cmdp+1, &block);
739 cmdp += 2;
740 break;
741 case 'd':
742 case 'D':
743 data = param_get32ex(Cmd, cmdp+1, 0, 16);
744 gotdata = true;
745 cmdp += 2;
746 break;
747 case 'p':
748 case 'P':
749 password = param_get32ex(Cmd, cmdp+1, 0, 16);
750 usepwd = true;
751 cmdp += 2;
752 break;
753 case '1':
754 page1 = true;
755 cmdp++;
756 break;
757 default:
758 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
759 errors = true;
760 break;
761 }
762 }
763 if (errors || !gotdata) return usage_t55xx_write();
764
765 if (block > 7) {
766 PrintAndLog("Block number must be between 0 and 7");
767 return 0;
768 }
769
770 UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};
771 UsbCommand resp;
772 c.d.asBytes[0] = (page1) ? 0x2 : 0;
773
774 PrintAndLog("Writing to page: %d block: %d data : 0x%08X", page1, block, data);
775
776 //Password mode
777 if (usepwd) {
778 c.arg[2] = password;
779 c.d.asBytes[0] |= 0x1;
780 PrintAndLog("pwd : 0x%08X", password);
781 }
782 clearCommandBuffer();
783 SendCommand(&c);
784 if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)){
785 PrintAndLog("Error occurred, device did not ACK write operation. (May be due to old firmware)");
786 return 0;
787 }
788 return 1;
789 }
790
791 int CmdT55xxReadTrace(const char *Cmd) {
792 char cmdp = param_getchar(Cmd, 0);
793 bool pwdmode = false;
794 uint32_t password = 0;
795 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')
796 return usage_t55xx_trace();
797
798 if (strlen(Cmd)==0)
799 if ( !AquireData( TRACE_BLOCK, REGULAR_READ_MODE_BLOCK, pwdmode, password ) )
800 return 0;
801
802 if (!DecodeT55xxBlock()) return 0;
803
804 if ( !DemodBufferLen) return 0;
805
806 RepaintGraphWindow();
807 uint8_t repeat = 0;
808 if (config.offset > 5)
809 repeat = 32;
810 uint8_t si = config.offset+repeat;
811 uint32_t bl1 = PackBits(si, 32, DemodBuffer);
812 uint32_t bl2 = PackBits(si+32, 32, DemodBuffer);
813
814 uint32_t acl = PackBits(si, 8, DemodBuffer); si += 8;
815 uint32_t mfc = PackBits(si, 8, DemodBuffer); si += 8;
816 uint32_t cid = PackBits(si, 5, DemodBuffer); si += 5;
817 uint32_t icr = PackBits(si, 3, DemodBuffer); si += 3;
818 uint32_t year = PackBits(si, 4, DemodBuffer); si += 4;
819 uint32_t quarter = PackBits(si, 2, DemodBuffer); si += 2;
820 uint32_t lotid = PackBits(si, 14, DemodBuffer); si += 14;
821 uint32_t wafer = PackBits(si, 5, DemodBuffer); si += 5;
822 uint32_t dw = PackBits(si, 15, DemodBuffer);
823
824 time_t t = time(NULL);
825 struct tm tm = *localtime(&t);
826 if ( year > tm.tm_year-110)
827 year += 2000;
828 else
829 year += 2010;
830
831 if ( acl != 0xE0 ) {
832 PrintAndLog("The modulation is most likely wrong since the ACL is not 0xE0. ");
833 return 0;
834 }
835
836 PrintAndLog("");
837 PrintAndLog("-- T55xx Trace Information ----------------------------------");
838 PrintAndLog("-------------------------------------------------------------");
839 PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", acl, acl);
840 PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d) - %s", mfc, mfc, getTagInfo(mfc));
841 PrintAndLog(" CID : 0x%02X (%d) - %s", cid, cid, GetModelStrFromCID(cid));
842 PrintAndLog(" ICR IC Revision : %d",icr );
843 PrintAndLog(" Manufactured");
844 PrintAndLog(" Year/Quarter : %d/%d",year, quarter);
845 PrintAndLog(" Lot ID : %d", lotid );
846 PrintAndLog(" Wafer number : %d", wafer);
847 PrintAndLog(" Die Number : %d", dw);
848 PrintAndLog("-------------------------------------------------------------");
849 PrintAndLog(" Raw Data - Page 1");
850 PrintAndLog(" Block 1 : 0x%08X %s", bl1, sprint_bin(DemodBuffer+config.offset+repeat,32) );
851 PrintAndLog(" Block 2 : 0x%08X %s", bl2, sprint_bin(DemodBuffer+config.offset+repeat+32,32) );
852 PrintAndLog("-------------------------------------------------------------");
853
854 /*
855 TRACE - BLOCK O
856 Bits Definition HEX
857 1-8 ACL Allocation class (ISO/IEC 15963-1) 0xE0
858 9-16 MFC Manufacturer ID (ISO/IEC 7816-6) 0x15 Atmel Corporation
859 17-21 CID 0x1 = Atmel ATA5577M1 0x2 = Atmel ATA5577M2
860 22-24 ICR IC revision
861 25-28 YEAR (BCD encoded) 9 (= 2009)
862 29-30 QUARTER 1,2,3,4
863 31-32 LOT ID
864
865 TRACE - BLOCK 1
866 1-12 LOT ID
867 13-17 Wafer number
868 18-32 DW, die number sequential
869 */
870
871 return 0;
872 }
873
874 int CmdT55xxInfo(const char *Cmd){
875 /*
876 Page 0 Block 0 Configuration data.
877 Normal mode
878 Extended mode
879 */
880 bool pwdmode = false;
881 uint32_t password = 0;
882 char cmdp = param_getchar(Cmd, 0);
883
884 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')
885 return usage_t55xx_info();
886
887 if (strlen(Cmd)==0)
888 if ( !AquireData( 0, CONFIGURATION_BLOCK, pwdmode, password ) )
889 return 1;
890
891 if (!DecodeT55xxBlock()) return 1;
892
893 if ( DemodBufferLen < 32) return 1;
894
895 uint8_t si = config.offset;
896 uint32_t bl0 = PackBits(si, 32, DemodBuffer);
897
898 uint32_t safer = PackBits(si, 4, DemodBuffer); si += 4;
899 uint32_t resv = PackBits(si, 7, DemodBuffer); si += 7;
900 uint32_t dbr = PackBits(si, 3, DemodBuffer); si += 3;
901 uint32_t extend = PackBits(si, 1, DemodBuffer); si += 1;
902 uint32_t datamod = PackBits(si, 5, DemodBuffer); si += 5;
903 uint32_t pskcf = PackBits(si, 2, DemodBuffer); si += 2;
904 uint32_t aor = PackBits(si, 1, DemodBuffer); si += 1;
905 uint32_t otp = PackBits(si, 1, DemodBuffer); si += 1;
906 uint32_t maxblk = PackBits(si, 3, DemodBuffer); si += 3;
907 uint32_t pwd = PackBits(si, 1, DemodBuffer); si += 1;
908 uint32_t sst = PackBits(si, 1, DemodBuffer); si += 1;
909 uint32_t fw = PackBits(si, 1, DemodBuffer); si += 1;
910 uint32_t inv = PackBits(si, 1, DemodBuffer); si += 1;
911 uint32_t por = PackBits(si, 1, DemodBuffer); si += 1;
912
913 PrintAndLog("");
914 PrintAndLog("-- T55xx Configuration & Tag Information --------------------");
915 PrintAndLog("-------------------------------------------------------------");
916 PrintAndLog(" Safer key : %s", GetSaferStr(safer));
917 PrintAndLog(" reserved : %d", resv);
918 PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));
919 PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");
920 PrintAndLog(" Modulation : %s", GetModulationStr(datamod));
921 PrintAndLog(" PSK clock frequency : %d", pskcf);
922 PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");
923 PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );
924 PrintAndLog(" Max block : %d", maxblk);
925 PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");
926 PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");
927 PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");
928 PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");
929 PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");
930 PrintAndLog("-------------------------------------------------------------");
931 PrintAndLog(" Raw Data - Page 0");
932 PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(DemodBuffer+config.offset,32) );
933 PrintAndLog("-------------------------------------------------------------");
934
935 return 0;
936 }
937
938 int CmdT55xxDump(const char *Cmd){
939
940 uint32_t password = 0;
941 char cmdp = param_getchar(Cmd, 0);
942 bool override = false;
943 if ( cmdp == 'h' || cmdp == 'H') return usage_t55xx_dump();
944
945 bool usepwd = ( strlen(Cmd) > 0);
946 if ( usepwd ){
947 password = param_get32ex(Cmd, 0, 0, 16);
948 if (param_getchar(Cmd, 1) =='o' )
949 override = true;
950 }
951
952 PrintAndLog("Reading Page 0:");
953 PrintAndLog("blk | hex data | binary");
954 for ( uint8_t i = 0; i <8; ++i){
955 T55xxReadBlock(i, 0, usepwd, override, password);
956 /*memset(s,0,sizeof(s));
957 if ( hasPwd ) {
958 if ( override ) {
959 sprintf(s,"b %d p %02x%02x%02x%02x o", i, pwd[0],pwd[1],pwd[2],pwd[3]);
960 } else {
961 sprintf(s,"b %d p %02x%02x%02x%02x", i, pwd[0],pwd[1],pwd[2],pwd[3]);
962 }
963 } else {
964 sprintf(s,"b %d", i);
965 }
966 CmdT55xxReadBlock(s);*/
967 }
968 PrintAndLog("Reading Page 1:");
969 PrintAndLog("blk | hex data | binary");
970 for ( uint8_t i = 0; i<4; i++){
971 T55xxReadBlock(i, 1, usepwd, override, password);
972 }
973 return 1;
974 }
975
976 int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password ){
977
978 uint8_t arg0 = (page<<1) | pwdmode;
979 UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}};
980
981 clearCommandBuffer();
982 SendCommand(&c);
983 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
984 PrintAndLog("command execution time out");
985 return 0;
986 }
987
988 uint8_t got[12000];
989 GetFromBigBuf(got,sizeof(got),0);
990 WaitForResponse(CMD_ACK,NULL);
991 setGraphBuf(got, sizeof(got));
992 return 1;
993 }
994
995 char * GetBitRateStr(uint32_t id){
996 static char buf[25];
997
998 char *retStr = buf;
999 switch (id){
1000 case 0:
1001 snprintf(retStr,sizeof(buf),"%d - RF/8",id);
1002 break;
1003 case 1:
1004 snprintf(retStr,sizeof(buf),"%d - RF/16",id);
1005 break;
1006 case 2:
1007 snprintf(retStr,sizeof(buf),"%d - RF/32",id);
1008 break;
1009 case 3:
1010 snprintf(retStr,sizeof(buf),"%d - RF/40",id);
1011 break;
1012 case 4:
1013 snprintf(retStr,sizeof(buf),"%d - RF/50",id);
1014 break;
1015 case 5:
1016 snprintf(retStr,sizeof(buf),"%d - RF/64",id);
1017 break;
1018 case 6:
1019 snprintf(retStr,sizeof(buf),"%d - RF/100",id);
1020 break;
1021 case 7:
1022 snprintf(retStr,sizeof(buf),"%d - RF/128",id);
1023 break;
1024 default:
1025 snprintf(retStr,sizeof(buf),"%d - (Unknown)",id);
1026 break;
1027 }
1028
1029 return buf;
1030 }
1031
1032 char * GetSaferStr(uint32_t id){
1033 static char buf[40];
1034 char *retStr = buf;
1035
1036 snprintf(retStr,sizeof(buf),"%d",id);
1037 if (id == 6) {
1038 snprintf(retStr,sizeof(buf),"%d - passwd",id);
1039 }
1040 if (id == 9 ){
1041 snprintf(retStr,sizeof(buf),"%d - testmode",id);
1042 }
1043
1044 return buf;
1045 }
1046
1047 char * GetModulationStr( uint32_t id){
1048 static char buf[60];
1049 char *retStr = buf;
1050
1051 switch (id){
1052 case 0:
1053 snprintf(retStr,sizeof(buf),"%d - DIRECT (ASK/NRZ)",id);
1054 break;
1055 case 1:
1056 snprintf(retStr,sizeof(buf),"%d - PSK 1 phase change when input changes",id);
1057 break;
1058 case 2:
1059 snprintf(retStr,sizeof(buf),"%d - PSK 2 phase change on bitclk if input high",id);
1060 break;
1061 case 3:
1062 snprintf(retStr,sizeof(buf),"%d - PSK 3 phase change on rising edge of input",id);
1063 break;
1064 case 4:
1065 snprintf(retStr,sizeof(buf),"%d - FSK 1 RF/8 RF/5",id);
1066 break;
1067 case 5:
1068 snprintf(retStr,sizeof(buf),"%d - FSK 2 RF/8 RF/10",id);
1069 break;
1070 case 6:
1071 snprintf(retStr,sizeof(buf),"%d - FSK 1a RF/5 RF/8",id);
1072 break;
1073 case 7:
1074 snprintf(retStr,sizeof(buf),"%d - FSK 2a RF/10 RF/8",id);
1075 break;
1076 case 8:
1077 snprintf(retStr,sizeof(buf),"%d - Manchester",id);
1078 break;
1079 case 16:
1080 snprintf(retStr,sizeof(buf),"%d - Biphase",id);
1081 break;
1082 case 0x18:
1083 snprintf(retStr,sizeof(buf),"%d - Biphase a - AKA Conditional Dephase Encoding(CDP)",id);
1084 break;
1085 case 17:
1086 snprintf(retStr,sizeof(buf),"%d - Reserved",id);
1087 break;
1088 default:
1089 snprintf(retStr,sizeof(buf),"0x%02X (Unknown)",id);
1090 break;
1091 }
1092 return buf;
1093 }
1094
1095 char * GetModelStrFromCID(uint32_t cid){
1096
1097 static char buf[10];
1098 char *retStr = buf;
1099
1100 if (cid == 1) snprintf(retStr, sizeof(buf),"ATA5577M1");
1101 if (cid == 2) snprintf(retStr, sizeof(buf),"ATA5577M2");
1102 return buf;
1103 }
1104
1105 char * GetSelectedModulationStr( uint8_t id){
1106
1107 static char buf[20];
1108 char *retStr = buf;
1109
1110 switch (id){
1111 case DEMOD_FSK:
1112 snprintf(retStr,sizeof(buf),"FSK");
1113 break;
1114 case DEMOD_FSK1:
1115 snprintf(retStr,sizeof(buf),"FSK1");
1116 break;
1117 case DEMOD_FSK1a:
1118 snprintf(retStr,sizeof(buf),"FSK1a");
1119 break;
1120 case DEMOD_FSK2:
1121 snprintf(retStr,sizeof(buf),"FSK2");
1122 break;
1123 case DEMOD_FSK2a:
1124 snprintf(retStr,sizeof(buf),"FSK2a");
1125 break;
1126 case DEMOD_ASK:
1127 snprintf(retStr,sizeof(buf),"ASK");
1128 break;
1129 case DEMOD_NRZ:
1130 snprintf(retStr,sizeof(buf),"DIRECT/NRZ");
1131 break;
1132 case DEMOD_PSK1:
1133 snprintf(retStr,sizeof(buf),"PSK1");
1134 break;
1135 case DEMOD_PSK2:
1136 snprintf(retStr,sizeof(buf),"PSK2");
1137 break;
1138 case DEMOD_PSK3:
1139 snprintf(retStr,sizeof(buf),"PSK3");
1140 break;
1141 case DEMOD_BI:
1142 snprintf(retStr,sizeof(buf),"BIPHASE");
1143 break;
1144 case DEMOD_BIa:
1145 snprintf(retStr,sizeof(buf),"BIPHASEa - (CDP)");
1146 break;
1147 default:
1148 snprintf(retStr,sizeof(buf),"(Unknown)");
1149 break;
1150 }
1151 return buf;
1152 }
1153
1154 uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){
1155
1156 int i = start;
1157 int j = len-1;
1158
1159 if (len > 32) return 0;
1160
1161 uint32_t tmp = 0;
1162 for (; j >= 0; --j, ++i)
1163 tmp |= bits[i] << j;
1164
1165 return tmp;
1166 }
1167
1168 int CmdResetRead(const char *Cmd) {
1169 UsbCommand c = {CMD_T55XX_RESET_READ, {0,0,0}};
1170
1171 clearCommandBuffer();
1172 SendCommand(&c);
1173 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
1174 PrintAndLog("command execution time out");
1175 return 0;
1176 }
1177
1178 uint8_t got[39999];
1179 GetFromBigBuf(got,sizeof(got),0);
1180 WaitForResponse(CMD_ACK,NULL);
1181 setGraphBuf(got, sizeof(got));
1182 return 1;
1183 }
1184
1185 static command_t CommandTable[] =
1186 {
1187 {"help", CmdHelp, 1, "This help"},
1188 {"config", CmdT55xxSetConfig, 1, "Set/Get T55XX configuration (modulation, inverted, offset, rate)"},
1189 {"detect", CmdT55xxDetect, 0, "[1] Try detecting the tag modulation from reading the configuration block."},
1190 {"read", CmdT55xxReadBlock, 0, "b <block> p [password] [o] [1] -- Read T55xx block data (page 0) [optional password]"},
1191 {"resetread",CmdResetRead, 0, "Send Reset Cmd then lf read the stream to attempt to identify the start of it (needs a demod and/or plot after)"},
1192 {"write", CmdT55xxWriteBlock,0, "b <block> d <data> p [password] [1] -- Write T55xx block data (page 0) [optional password]"},
1193 {"trace", CmdT55xxReadTrace, 0, "[1] Show T55xx traceability data (page 1/ blk 0-1)"},
1194 {"info", CmdT55xxInfo, 0, "[1] Show T55xx configuration data (page 0/ blk 0)"},
1195 {"dump", CmdT55xxDump, 0, "[password] [o] Dump T55xx card block 0-7. [optional password]"},
1196 {"special", special, 0, "Show block changes with 64 different offsets"},
1197 {"wakeup", CmdT55xxWakeUp, 0, "Send AOR wakeup command"},
1198 {NULL, NULL, 0, NULL}
1199 };
1200
1201 int CmdLFT55XX(const char *Cmd)
1202 {
1203 CmdsParse(CommandTable, Cmd);
1204 return 0;
1205 }
1206
1207 int CmdHelp(const char *Cmd)
1208 {
1209 CmdsHelp(CommandTable);
1210 return 0;
1211 }
Impressum, Datenschutz