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