]> cvs.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/cmdlft55xx.c
Client code cleanup:
[proxmark3-svn] / client / cmdlft55xx.c
... / ...
CommitLineData
1//-----------------------------------------------------------------------------\r
2//\r
3// This code is licensed to you under the terms of the GNU GPL, version 2 or,\r
4// at your option, any later version. See the LICENSE.txt file for the text of\r
5// the license.\r
6//-----------------------------------------------------------------------------\r
7// Low frequency T55xx commands\r
8//-----------------------------------------------------------------------------\r
9\r
10#include <stdio.h>\r
11#include <string.h>\r
12#include <inttypes.h>\r
13#include "proxmark3.h"\r
14#include "ui.h"\r
15#include "graph.h"\r
16#include "cmdmain.h"\r
17#include "cmdparser.h"\r
18#include "cmddata.h"\r
19#include "cmdlf.h"\r
20#include "cmdlft55xx.h"\r
21#include "util.h"\r
22#include "data.h"\r
23#include "lfdemod.h"\r
24#include "cmdhf14a.h" //for getTagInfo\r
25\r
26#define T55x7_CONFIGURATION_BLOCK 0x00\r
27#define T55x7_PAGE0 0x00\r
28#define T55x7_PAGE1 0x01\r
29//#define T55x7_PWD 0x00000010\r
30#define REGULAR_READ_MODE_BLOCK 0xFF\r
31\r
32// Default configuration\r
33t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = false, .offset = 0x00, .block0 = 0x00, .Q5 = false };\r
34\r
35t55xx_conf_block_t Get_t55xx_Config(){\r
36 return config;\r
37}\r
38void Set_t55xx_Config(t55xx_conf_block_t conf){\r
39 config = conf;\r
40}\r
41\r
42int usage_t55xx_config(){\r
43 PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>] [Q5]");\r
44 PrintAndLog("Options:");\r
45 PrintAndLog(" h This help");\r
46 PrintAndLog(" b <8|16|32|40|50|64|100|128> Set bitrate");\r
47 PrintAndLog(" d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa> Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");\r
48 PrintAndLog(" i [1] Invert data signal, defaults to normal");\r
49 PrintAndLog(" o [offset] Set offset, where data should start decode in bitstream");\r
50 PrintAndLog(" Q5 Set as Q5(T5555) chip instead of T55x7");\r
51 PrintAndLog(" ST Set Sequence Terminator on");\r
52 PrintAndLog("");\r
53 PrintAndLog("Examples:");\r
54 PrintAndLog(" lf t55xx config d FSK - FSK demodulation");\r
55 PrintAndLog(" lf t55xx config d FSK i 1 - FSK demodulation, inverse data");\r
56 PrintAndLog(" lf t55xx config d FSK i 1 o 3 - FSK demodulation, inverse data, offset=3,start from position 3 to decode data");\r
57 PrintAndLog("");\r
58 return 0;\r
59}\r
60int usage_t55xx_read(){\r
61 PrintAndLog("Usage: lf t55xx read [b <block>] [p <password>] <override_safety> <page1>");\r
62 PrintAndLog("Options:");\r
63 PrintAndLog(" b <block> - block number to read. Between 0-7");\r
64 PrintAndLog(" p <password> - OPTIONAL password (8 hex characters)");\r
65 PrintAndLog(" o - OPTIONAL override safety check");\r
66 PrintAndLog(" 1 - OPTIONAL read Page 1 instead of Page 0");\r
67 PrintAndLog(" ****WARNING****");\r
68 PrintAndLog(" Use of read with password on a tag not configured for a pwd");\r
69 PrintAndLog(" can damage the tag");\r
70 PrintAndLog("");\r
71 PrintAndLog("Examples:");\r
72 PrintAndLog(" lf t55xx read b 0 - read data from block 0");\r
73 PrintAndLog(" lf t55xx read b 0 p feedbeef - read data from block 0 password feedbeef");\r
74 PrintAndLog(" lf t55xx read b 0 p feedbeef o - read data from block 0 password feedbeef safety check");\r
75 PrintAndLog("");\r
76 return 0;\r
77}\r
78int usage_t55xx_write(){\r
79 PrintAndLog("Usage: lf t55xx write [b <block>] [d <data>] [p <password>] [1]");\r
80 PrintAndLog("Options:");\r
81 PrintAndLog(" b <block> - block number to write. Between 0-7");\r
82 PrintAndLog(" d <data> - 4 bytes of data to write (8 hex characters)");\r
83 PrintAndLog(" p <password> - OPTIONAL password 4bytes (8 hex characters)");\r
84 PrintAndLog(" 1 - OPTIONAL write Page 1 instead of Page 0");\r
85 PrintAndLog("");\r
86 PrintAndLog("Examples:");\r
87 PrintAndLog(" lf t55xx write b 3 d 11223344 - write 11223344 to block 3");\r
88 PrintAndLog(" lf t55xx write b 3 d 11223344 p feedbeef - write 11223344 to block 3 password feedbeef");\r
89 PrintAndLog("");\r
90 return 0;\r
91}\r
92int usage_t55xx_trace() {\r
93 PrintAndLog("Usage: lf t55xx trace [1]");\r
94 PrintAndLog("Options:");\r
95 PrintAndLog(" [graph buffer data] - if set, use Graphbuffer otherwise read data from tag.");\r
96 PrintAndLog("");\r
97 PrintAndLog("Examples:");\r
98 PrintAndLog(" lf t55xx trace");\r
99 PrintAndLog(" lf t55xx trace 1");\r
100 PrintAndLog("");\r
101 return 0;\r
102}\r
103int usage_t55xx_info() {\r
104 PrintAndLog("Usage: lf t55xx info [1]");\r
105 PrintAndLog("Options:");\r
106 PrintAndLog(" [graph buffer data] - if set, use Graphbuffer otherwise read data from tag.");\r
107 PrintAndLog("");\r
108 PrintAndLog("Examples:");\r
109 PrintAndLog(" lf t55xx info");\r
110 PrintAndLog(" lf t55xx info 1");\r
111 PrintAndLog("");\r
112 return 0;\r
113}\r
114int usage_t55xx_dump(){\r
115 PrintAndLog("Usage: lf t55xx dump <password> [o]");\r
116 PrintAndLog("Options:");\r
117 PrintAndLog(" <password> - OPTIONAL password 4bytes (8 hex symbols)");\r
118 PrintAndLog(" o - OPTIONAL override, force pwd read despite danger to card");\r
119 PrintAndLog("");\r
120 PrintAndLog("Examples:");\r
121 PrintAndLog(" lf t55xx dump");\r
122 PrintAndLog(" lf t55xx dump feedbeef o");\r
123 PrintAndLog("");\r
124 return 0;\r
125}\r
126int usage_t55xx_detect(){\r
127 PrintAndLog("Usage: lf t55xx detect [1] [p <password>]");\r
128 PrintAndLog("Options:");\r
129 PrintAndLog(" 1 - if set, use Graphbuffer otherwise read data from tag.");\r
130 PrintAndLog(" p <password> - OPTIONAL password (8 hex characters)");\r
131 PrintAndLog("");\r
132 PrintAndLog("Examples:");\r
133 PrintAndLog(" lf t55xx detect");\r
134 PrintAndLog(" lf t55xx detect 1");\r
135 PrintAndLog(" lf t55xx detect p 11223344");\r
136 PrintAndLog("");\r
137 return 0;\r
138}\r
139int usage_t55xx_wakup(){\r
140 PrintAndLog("Usage: lf t55xx wakeup [h] p <password>");\r
141 PrintAndLog("This commands send the Answer-On-Request command and leaves the readerfield ON afterwards.");\r
142 PrintAndLog("Options:");\r
143 PrintAndLog(" h - this help");\r
144 PrintAndLog(" p <password> - password 4bytes (8 hex symbols)");\r
145 PrintAndLog("");\r
146 PrintAndLog("Examples:");\r
147 PrintAndLog(" lf t55xx wakeup p 11223344 - send wakeup password");\r
148 return 0;\r
149}\r
150int usage_t55xx_bruteforce(){\r
151 PrintAndLog("This command uses A) bruteforce to scan a number range");\r
152 PrintAndLog(" B) a dictionary attack");\r
153 PrintAndLog("Usage: lf t55xx bruteforce <start password> <end password> [i <*.dic>]");\r
154 PrintAndLog(" password must be 4 bytes (8 hex symbols)");\r
155 PrintAndLog("Options:");\r
156 PrintAndLog(" h - this help");\r
157 PrintAndLog(" <start_pwd> - 4 byte hex value to start pwd search at");\r
158 PrintAndLog(" <end_pwd> - 4 byte hex value to end pwd search at");\r
159 PrintAndLog(" i <*.dic> - loads a default keys dictionary file <*.dic>");\r
160 PrintAndLog("");\r
161 PrintAndLog("Examples:");\r
162 PrintAndLog(" lf t55xx bruteforce aaaaaaaa bbbbbbbb");\r
163 PrintAndLog(" lf t55xx bruteforce i default_pwd.dic");\r
164 PrintAndLog("");\r
165 return 0;\r
166}\r
167int usage_t55xx_wipe(){\r
168 PrintAndLog("Usage: lf t55xx wipe [h] [Q5]");\r
169 PrintAndLog("This commands wipes a tag, fills blocks 1-7 with zeros and a default configuration block");\r
170 PrintAndLog("Options:");\r
171 PrintAndLog(" h - this help");\r
172 PrintAndLog(" Q5 - indicates to use the T5555 (Q5) default configuration block");\r
173 PrintAndLog("");\r
174 PrintAndLog("Examples:");\r
175 PrintAndLog(" lf t55xx wipe - wipes a t55x7 tag, config block 0x000880E0");\r
176 PrintAndLog(" lf t55xx wipe Q5 - wipes a t5555 Q5 tag, config block 0x6001F004");\r
177 return 0;\r
178}\r
179\r
180\r
181static int CmdHelp(const char *Cmd);\r
182\r
183void printT5xxHeader(uint8_t page){\r
184 PrintAndLog("Reading Page %d:", page);\r
185 PrintAndLog("blk | hex data | binary");\r
186 PrintAndLog("----+----------+---------------------------------"); \r
187}\r
188\r
189int CmdT55xxSetConfig(const char *Cmd) {\r
190\r
191 uint8_t offset = 0;\r
192 char modulation[5] = {0x00};\r
193 char tmp = 0x00;\r
194 uint8_t bitRate = 0;\r
195 uint8_t rates[9] = {8,16,32,40,50,64,100,128,0};\r
196 uint8_t cmdp = 0;\r
197 bool errors = false;\r
198 while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
199 {\r
200 tmp = param_getchar(Cmd, cmdp);\r
201 switch(tmp)\r
202 {\r
203 case 'h':\r
204 case 'H':\r
205 return usage_t55xx_config();\r
206 case 'b':\r
207 errors |= param_getdec(Cmd, cmdp+1, &bitRate);\r
208 if ( !errors){\r
209 uint8_t i = 0;\r
210 for (; i < 9; i++){\r
211 if (rates[i]==bitRate) {\r
212 config.bitrate = i;\r
213 break;\r
214 }\r
215 }\r
216 if (i==9) errors = true;\r
217 }\r
218 cmdp+=2;\r
219 break;\r
220 case 'd':\r
221 param_getstr(Cmd, cmdp+1, modulation);\r
222 cmdp += 2;\r
223\r
224 if ( strcmp(modulation, "FSK" ) == 0) {\r
225 config.modulation = DEMOD_FSK;\r
226 } else if ( strcmp(modulation, "FSK1" ) == 0) {\r
227 config.modulation = DEMOD_FSK1;\r
228 config.inverted=1;\r
229 } else if ( strcmp(modulation, "FSK1a" ) == 0) {\r
230 config.modulation = DEMOD_FSK1a;\r
231 config.inverted=0;\r
232 } else if ( strcmp(modulation, "FSK2" ) == 0) {\r
233 config.modulation = DEMOD_FSK2;\r
234 config.inverted=0;\r
235 } else if ( strcmp(modulation, "FSK2a" ) == 0) {\r
236 config.modulation = DEMOD_FSK2a;\r
237 config.inverted=1;\r
238 } else if ( strcmp(modulation, "ASK" ) == 0) {\r
239 config.modulation = DEMOD_ASK;\r
240 } else if ( strcmp(modulation, "NRZ" ) == 0) {\r
241 config.modulation = DEMOD_NRZ;\r
242 } else if ( strcmp(modulation, "PSK1" ) == 0) {\r
243 config.modulation = DEMOD_PSK1;\r
244 } else if ( strcmp(modulation, "PSK2" ) == 0) {\r
245 config.modulation = DEMOD_PSK2;\r
246 } else if ( strcmp(modulation, "PSK3" ) == 0) {\r
247 config.modulation = DEMOD_PSK3;\r
248 } else if ( strcmp(modulation, "BIa" ) == 0) {\r
249 config.modulation = DEMOD_BIa;\r
250 config.inverted=1;\r
251 } else if ( strcmp(modulation, "BI" ) == 0) {\r
252 config.modulation = DEMOD_BI;\r
253 config.inverted=0;\r
254 } else {\r
255 PrintAndLog("Unknown modulation '%s'", modulation);\r
256 errors = true;\r
257 }\r
258 break;\r
259 case 'i':\r
260 config.inverted = param_getchar(Cmd,cmdp+1) == '1';\r
261 cmdp+=2;\r
262 break;\r
263 case 'o':\r
264 errors |= param_getdec(Cmd, cmdp+1, &offset);\r
265 if ( !errors )\r
266 config.offset = offset;\r
267 cmdp+=2;\r
268 break;\r
269 case 'Q':\r
270 case 'q': \r
271 config.Q5 = true;\r
272 cmdp++;\r
273 break;\r
274 case 'S':\r
275 case 's': \r
276 config.ST = true;\r
277 cmdp++;\r
278 break;\r
279 default:\r
280 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
281 errors = true;\r
282 break;\r
283 }\r
284 }\r
285\r
286 // No args\r
287 if (cmdp == 0) return printConfiguration( config );\r
288\r
289 //Validations\r
290 if (errors) return usage_t55xx_config();\r
291\r
292 config.block0 = 0;\r
293 return printConfiguration ( config );\r
294}\r
295\r
296int T55xxReadBlock(uint8_t block, bool page1, bool usepwd, bool override, uint32_t password){\r
297 //Password mode\r
298 if ( usepwd ) {\r
299 // try reading the config block and verify that PWD bit is set before doing this!\r
300 if ( !override ) {\r
301 if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, false, 0 ) ) return 0;\r
302 if ( !tryDetectModulation() ) {\r
303 PrintAndLog("Safety Check: Could not detect if PWD bit is set in config block. Exits.");\r
304 return 0;\r
305 } else {\r
306 PrintAndLog("Safety Check: PWD bit is NOT set in config block. Reading without password..."); \r
307 usepwd = false;\r
308 page1 = false;\r
309 }\r
310 } else {\r
311 PrintAndLog("Safety Check Overriden - proceeding despite risk");\r
312 }\r
313 }\r
314\r
315 if (!AquireData(page1, block, usepwd, password) ) return 0;\r
316 if (!DecodeT55xxBlock()) return 0;\r
317\r
318 char blk[10]={0};\r
319 sprintf(blk,"%d", block);\r
320 printT55xxBlock(blk); \r
321 return 1;\r
322}\r
323\r
324int CmdT55xxReadBlock(const char *Cmd) {\r
325 uint8_t block = REGULAR_READ_MODE_BLOCK;\r
326 uint32_t password = 0; //default to blank Block 7\r
327 bool usepwd = false;\r
328 bool override = false;\r
329 bool page1 = false;\r
330 bool errors = false;\r
331 uint8_t cmdp = 0;\r
332 while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {\r
333 switch(param_getchar(Cmd, cmdp)) {\r
334 case 'h':\r
335 case 'H':\r
336 return usage_t55xx_read();\r
337 case 'b':\r
338 case 'B':\r
339 errors |= param_getdec(Cmd, cmdp+1, &block);\r
340 cmdp += 2;\r
341 break;\r
342 case 'o':\r
343 case 'O':\r
344 override = true;\r
345 cmdp++;\r
346 break;\r
347 case 'p':\r
348 case 'P':\r
349 password = param_get32ex(Cmd, cmdp+1, 0, 16);\r
350 usepwd = true;\r
351 cmdp += 2;\r
352 break;\r
353 case '1':\r
354 page1 = true;\r
355 cmdp++;\r
356 break;\r
357 default:\r
358 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
359 errors = true;\r
360 break;\r
361 }\r
362 }\r
363 if (errors) return usage_t55xx_read();\r
364\r
365 if (block > 7 && block != REGULAR_READ_MODE_BLOCK ) {\r
366 PrintAndLog("Block must be between 0 and 7");\r
367 return 0;\r
368 }\r
369\r
370 printT5xxHeader(page1);\r
371 return T55xxReadBlock(block, page1, usepwd, override, password);\r
372}\r
373\r
374bool DecodeT55xxBlock(){\r
375 \r
376 char buf[30] = {0x00};\r
377 char *cmdStr = buf;\r
378 int ans = 0;\r
379 bool ST = config.ST;\r
380 uint8_t bitRate[8] = {8,16,32,40,50,64,100,128};\r
381 DemodBufferLen = 0x00;\r
382\r
383 switch( config.modulation ){\r
384 case DEMOD_FSK:\r
385 snprintf(cmdStr, sizeof(buf),"%d %d", bitRate[config.bitrate], config.inverted );\r
386 ans = FSKrawDemod(cmdStr, false);\r
387 break;\r
388 case DEMOD_FSK1:\r
389 case DEMOD_FSK1a:\r
390 snprintf(cmdStr, sizeof(buf),"%d %d 8 5", bitRate[config.bitrate], config.inverted );\r
391 ans = FSKrawDemod(cmdStr, false);\r
392 break;\r
393 case DEMOD_FSK2:\r
394 case DEMOD_FSK2a:\r
395 snprintf(cmdStr, sizeof(buf),"%d %d 10 8", bitRate[config.bitrate], config.inverted );\r
396 ans = FSKrawDemod(cmdStr, false);\r
397 break;\r
398 case DEMOD_ASK:\r
399 snprintf(cmdStr, sizeof(buf),"%d %d 1", bitRate[config.bitrate], config.inverted );\r
400 ans = ASKDemod_ext(cmdStr, false, false, 1, &ST);\r
401 break;\r
402 case DEMOD_PSK1:\r
403 // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
404 save_restoreGB(1);\r
405 CmdLtrim("160");\r
406 snprintf(cmdStr, sizeof(buf),"%d %d 6", bitRate[config.bitrate], config.inverted );\r
407 ans = PSKDemod(cmdStr, false);\r
408 //undo trim samples\r
409 save_restoreGB(0);\r
410 break;\r
411 case DEMOD_PSK2: //inverted won't affect this\r
412 case DEMOD_PSK3: //not fully implemented\r
413 // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
414 save_restoreGB(1);\r
415 CmdLtrim("160");\r
416 snprintf(cmdStr, sizeof(buf),"%d 0 6", bitRate[config.bitrate] );\r
417 ans = PSKDemod(cmdStr, false);\r
418 psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
419 //undo trim samples\r
420 save_restoreGB(0);\r
421 break;\r
422 case DEMOD_NRZ:\r
423 snprintf(cmdStr, sizeof(buf),"%d %d 1", bitRate[config.bitrate], config.inverted );\r
424 ans = NRZrawDemod(cmdStr, false);\r
425 break;\r
426 case DEMOD_BI:\r
427 case DEMOD_BIa:\r
428 snprintf(cmdStr, sizeof(buf),"0 %d %d 1", bitRate[config.bitrate], config.inverted );\r
429 ans = ASKbiphaseDemod(cmdStr, false);\r
430 break;\r
431 default:\r
432 return false;\r
433 }\r
434 return (bool) ans;\r
435}\r
436\r
437bool DecodeT5555TraceBlock() {\r
438 DemodBufferLen = 0x00;\r
439 \r
440 // According to datasheet. Always: RF/64, not inverted, Manchester\r
441 return (bool) ASKDemod("64 0 1", false, false, 1);\r
442}\r
443\r
444int CmdT55xxDetect(const char *Cmd){\r
445 bool errors = false;\r
446 bool useGB = false;\r
447 bool usepwd = false;\r
448 uint32_t password = 0;\r
449 uint8_t cmdp = 0;\r
450\r
451 while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {\r
452 switch(param_getchar(Cmd, cmdp)) {\r
453 case 'h':\r
454 case 'H':\r
455 return usage_t55xx_detect();\r
456 case 'p':\r
457 case 'P':\r
458 password = param_get32ex(Cmd, cmdp+1, 0, 16);\r
459 usepwd = true;\r
460 cmdp += 2;\r
461 break;\r
462 case '1':\r
463 // use Graphbuffer data\r
464 useGB = true;\r
465 cmdp++;\r
466 break;\r
467 default:\r
468 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
469 errors = true;\r
470 break;\r
471 }\r
472 }\r
473 if (errors) return usage_t55xx_detect();\r
474 \r
475 if ( !useGB) {\r
476 if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, usepwd, password) )\r
477 return 0;\r
478 }\r
479 \r
480 if ( !tryDetectModulation() )\r
481 PrintAndLog("Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");\r
482\r
483 return 1;\r
484}\r
485\r
486// detect configuration?\r
487bool tryDetectModulation(){\r
488 uint8_t hits = 0;\r
489 t55xx_conf_block_t tests[15];\r
490 int bitRate=0;\r
491 uint8_t fc1 = 0, fc2 = 0, clk=0;\r
492 if (GetFskClock("", false, false)){ \r
493 fskClocks(&fc1, &fc2, &clk, false);\r
494 if ( FSKrawDemod("0 0", false) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
495 tests[hits].modulation = DEMOD_FSK;\r
496 if (fc1==8 && fc2 == 5)\r
497 tests[hits].modulation = DEMOD_FSK1a;\r
498 else if (fc1==10 && fc2 == 8)\r
499 tests[hits].modulation = DEMOD_FSK2;\r
500 tests[hits].bitrate = bitRate;\r
501 tests[hits].inverted = false;\r
502 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
503 tests[hits].ST = false;\r
504 ++hits;\r
505 }\r
506 if ( FSKrawDemod("0 1", false) && test(DEMOD_FSK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
507 tests[hits].modulation = DEMOD_FSK;\r
508 if (fc1 == 8 && fc2 == 5)\r
509 tests[hits].modulation = DEMOD_FSK1;\r
510 else if (fc1 == 10 && fc2 == 8)\r
511 tests[hits].modulation = DEMOD_FSK2a;\r
512 tests[hits].bitrate = bitRate;\r
513 tests[hits].inverted = true;\r
514 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
515 tests[hits].ST = false;\r
516 ++hits;\r
517 }\r
518 } else {\r
519 clk = GetAskClock("", false, false);\r
520 if (clk>0) {\r
521 tests[hits].ST = true;\r
522 if ( ASKDemod_ext("0 0 1", false, false, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
523 tests[hits].modulation = DEMOD_ASK;\r
524 tests[hits].bitrate = bitRate;\r
525 tests[hits].inverted = false;\r
526 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
527 ++hits;\r
528 }\r
529 tests[hits].ST = true;\r
530 if ( ASKDemod_ext("0 1 1", false, false, 1, &tests[hits].ST) && test(DEMOD_ASK, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
531 tests[hits].modulation = DEMOD_ASK;\r
532 tests[hits].bitrate = bitRate;\r
533 tests[hits].inverted = true;\r
534 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
535 ++hits;\r
536 }\r
537 if ( ASKbiphaseDemod("0 0 0 2", false) && test(DEMOD_BI, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5) ) {\r
538 tests[hits].modulation = DEMOD_BI;\r
539 tests[hits].bitrate = bitRate;\r
540 tests[hits].inverted = false;\r
541 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
542 tests[hits].ST = false;\r
543 ++hits;\r
544 }\r
545 if ( ASKbiphaseDemod("0 0 1 2", false) && test(DEMOD_BIa, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5) ) {\r
546 tests[hits].modulation = DEMOD_BIa;\r
547 tests[hits].bitrate = bitRate;\r
548 tests[hits].inverted = true;\r
549 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
550 tests[hits].ST = false;\r
551 ++hits;\r
552 }\r
553 }\r
554 //undo trim from ask\r
555 //save_restoreGB(0);\r
556 clk = GetNrzClock("", false, false);\r
557 if (clk>0) {\r
558 if ( NRZrawDemod("0 0 1", false) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
559 tests[hits].modulation = DEMOD_NRZ;\r
560 tests[hits].bitrate = bitRate;\r
561 tests[hits].inverted = false;\r
562 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
563 tests[hits].ST = false;\r
564 ++hits;\r
565 }\r
566\r
567 if ( NRZrawDemod("0 1 1", false) && test(DEMOD_NRZ, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
568 tests[hits].modulation = DEMOD_NRZ;\r
569 tests[hits].bitrate = bitRate;\r
570 tests[hits].inverted = true;\r
571 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
572 tests[hits].ST = false;\r
573 ++hits;\r
574 }\r
575 }\r
576 \r
577 // allow undo\r
578 // skip first 160 samples to allow antenna to settle in (psk gets inverted occasionally otherwise)\r
579 save_restoreGB(1);\r
580 CmdLtrim("160");\r
581 clk = GetPskClock("", false, false);\r
582 if (clk>0) {\r
583 if ( PSKDemod("0 0 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
584 tests[hits].modulation = DEMOD_PSK1;\r
585 tests[hits].bitrate = bitRate;\r
586 tests[hits].inverted = false;\r
587 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
588 tests[hits].ST = false;\r
589 ++hits;\r
590 }\r
591 if ( PSKDemod("0 1 6", false) && test(DEMOD_PSK1, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)) {\r
592 tests[hits].modulation = DEMOD_PSK1;\r
593 tests[hits].bitrate = bitRate;\r
594 tests[hits].inverted = true;\r
595 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
596 tests[hits].ST = false;\r
597 ++hits;\r
598 }\r
599 // PSK2 - needs a call to psk1TOpsk2.\r
600 if ( PSKDemod("0 0 6", false)) {\r
601 psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
602 if (test(DEMOD_PSK2, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
603 tests[hits].modulation = DEMOD_PSK2;\r
604 tests[hits].bitrate = bitRate;\r
605 tests[hits].inverted = false;\r
606 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
607 tests[hits].ST = false;\r
608 ++hits;\r
609 }\r
610 } // inverse waves does not affect this demod\r
611 // PSK3 - needs a call to psk1TOpsk2.\r
612 if ( PSKDemod("0 0 6", false)) {\r
613 psk1TOpsk2(DemodBuffer, DemodBufferLen);\r
614 if (test(DEMOD_PSK3, &tests[hits].offset, &bitRate, clk, &tests[hits].Q5)){\r
615 tests[hits].modulation = DEMOD_PSK3;\r
616 tests[hits].bitrate = bitRate;\r
617 tests[hits].inverted = false;\r
618 tests[hits].block0 = PackBits(tests[hits].offset, 32, DemodBuffer);\r
619 tests[hits].ST = false;\r
620 ++hits;\r
621 }\r
622 } // inverse waves does not affect this demod\r
623 }\r
624 //undo trim samples\r
625 save_restoreGB(0);\r
626 } \r
627 if ( hits == 1) {\r
628 config.modulation = tests[0].modulation;\r
629 config.bitrate = tests[0].bitrate;\r
630 config.inverted = tests[0].inverted;\r
631 config.offset = tests[0].offset;\r
632 config.block0 = tests[0].block0;\r
633 config.Q5 = tests[0].Q5;\r
634 config.ST = tests[0].ST;\r
635 printConfiguration( config );\r
636 return true;\r
637 }\r
638 \r
639 if ( hits > 1) {\r
640 PrintAndLog("Found [%d] possible matches for modulation.",hits);\r
641 for(int i=0; i<hits; ++i){\r
642 PrintAndLog("--[%d]---------------", i+1);\r
643 printConfiguration( tests[i] );\r
644 }\r
645 }\r
646 return false;\r
647}\r
648\r
649bool testModulation(uint8_t mode, uint8_t modread){\r
650 switch( mode ){\r
651 case DEMOD_FSK:\r
652 if (modread >= DEMOD_FSK1 && modread <= DEMOD_FSK2a) return true;\r
653 break;\r
654 case DEMOD_ASK:\r
655 if (modread == DEMOD_ASK) return true;\r
656 break;\r
657 case DEMOD_PSK1:\r
658 if (modread == DEMOD_PSK1) return true;\r
659 break;\r
660 case DEMOD_PSK2:\r
661 if (modread == DEMOD_PSK2) return true;\r
662 break;\r
663 case DEMOD_PSK3:\r
664 if (modread == DEMOD_PSK3) return true;\r
665 break;\r
666 case DEMOD_NRZ:\r
667 if (modread == DEMOD_NRZ) return true;\r
668 break;\r
669 case DEMOD_BI:\r
670 if (modread == DEMOD_BI) return true;\r
671 break;\r
672 case DEMOD_BIa:\r
673 if (modread == DEMOD_BIa) return true;\r
674 break; \r
675 default:\r
676 return false;\r
677 }\r
678 return false;\r
679}\r
680\r
681bool testQ5Modulation(uint8_t mode, uint8_t modread){\r
682 switch( mode ){\r
683 case DEMOD_FSK:\r
684 if (modread >= 4 && modread <= 5) return true;\r
685 break;\r
686 case DEMOD_ASK:\r
687 if (modread == 0) return true;\r
688 break;\r
689 case DEMOD_PSK1:\r
690 if (modread == 1) return true;\r
691 break;\r
692 case DEMOD_PSK2:\r
693 if (modread == 2) return true;\r
694 break;\r
695 case DEMOD_PSK3:\r
696 if (modread == 3) return true;\r
697 break;\r
698 case DEMOD_NRZ:\r
699 if (modread == 7) return true;\r
700 break;\r
701 case DEMOD_BI:\r
702 if (modread == 6) return true;\r
703 break;\r
704 default:\r
705 return false;\r
706 }\r
707 return false;\r
708}\r
709\r
710int convertQ5bitRate(uint8_t bitRateRead) {\r
711 uint8_t expected[] = {8, 16, 32, 40, 50, 64, 100, 128};\r
712 for (int i=0; i<8; i++)\r
713 if (expected[i] == bitRateRead)\r
714 return i;\r
715\r
716 return -1;\r
717}\r
718\r
719bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk){\r
720\r
721 if ( DemodBufferLen < 64 ) return false;\r
722 uint8_t si = 0;\r
723 for (uint8_t idx = 28; idx < 64; idx++){\r
724 si = idx;\r
725 if ( PackBits(si, 28, DemodBuffer) == 0x00 ) continue;\r
726\r
727 uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; //master key\r
728 uint8_t resv = PackBits(si, 8, DemodBuffer); si += 8;\r
729 // 2nibble must be zeroed.\r
730 if (safer != 0x6 && safer != 0x9) continue;\r
731 if ( resv > 0x00) continue;\r
732 //uint8_t pageSel = PackBits(si, 1, DemodBuffer); si += 1;\r
733 //uint8_t fastWrite = PackBits(si, 1, DemodBuffer); si += 1;\r
734 si += 1+1;\r
735 int bitRate = PackBits(si, 6, DemodBuffer)*2 + 2; si += 6; //bit rate\r
736 if (bitRate > 128 || bitRate < 8) continue;\r
737\r
738 //uint8_t AOR = PackBits(si, 1, DemodBuffer); si += 1; \r
739 //uint8_t PWD = PackBits(si, 1, DemodBuffer); si += 1; \r
740 //uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2; //could check psk cr\r
741 //uint8_t inverse = PackBits(si, 1, DemodBuffer); si += 1;\r
742 si += 1+1+2+1;\r
743 uint8_t modread = PackBits(si, 3, DemodBuffer); si += 3;\r
744 uint8_t maxBlk = PackBits(si, 3, DemodBuffer); si += 3;\r
745 //uint8_t ST = PackBits(si, 1, DemodBuffer); si += 1;\r
746 if (maxBlk == 0) continue;\r
747 //test modulation\r
748 if (!testQ5Modulation(mode, modread)) continue;\r
749 if (bitRate != clk) continue;\r
750 *fndBitRate = convertQ5bitRate(bitRate);\r
751 if (*fndBitRate < 0) continue;\r
752 *offset = idx;\r
753\r
754 return true;\r
755 }\r
756 return false;\r
757}\r
758\r
759bool testBitRate(uint8_t readRate, uint8_t clk){\r
760 uint8_t expected[] = {8, 16, 32, 40, 50, 64, 100, 128};\r
761 if (expected[readRate] == clk)\r
762 return true;\r
763\r
764 return false;\r
765}\r
766\r
767bool test(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk, bool *Q5){\r
768\r
769 if ( DemodBufferLen < 64 ) return false;\r
770 uint8_t si = 0;\r
771 for (uint8_t idx = 28; idx < 64; idx++){\r
772 si = idx;\r
773 if ( PackBits(si, 28, DemodBuffer) == 0x00 ) continue;\r
774\r
775 uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; //master key\r
776 uint8_t resv = PackBits(si, 4, DemodBuffer); si += 4; //was 7 & +=7+3 //should be only 4 bits if extended mode\r
777 // 2nibble must be zeroed.\r
778 // moved test to here, since this gets most faults first.\r
779 if ( resv > 0x00) continue;\r
780\r
781 uint8_t xtRate = PackBits(si, 3, DemodBuffer); si += 3; //extended mode part of rate\r
782 int bitRate = PackBits(si, 3, DemodBuffer); si += 3; //bit rate\r
783 if (bitRate > 7) continue;\r
784 uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1; //bit 15 extended mode\r
785 uint8_t modread = PackBits(si, 5, DemodBuffer); si += 5+2+1; \r
786 //uint8_t pskcr = PackBits(si, 2, DemodBuffer); si += 2+1; //could check psk cr\r
787 //uint8_t nml01 = PackBits(si, 1, DemodBuffer); si += 1+5; //bit 24, 30, 31 could be tested for 0 if not extended mode\r
788 //uint8_t nml02 = PackBits(si, 2, DemodBuffer); si += 2;\r
789 \r
790 //if extended mode\r
791 bool extMode =( (safer == 0x6 || safer == 0x9) && extend) ? true : false;\r
792\r
793 if (!extMode){\r
794 if (xtRate) continue; //nml01 || nml02 || caused issues on noralys tags\r
795 }\r
796 //test modulation\r
797 if (!testModulation(mode, modread)) continue;\r
798 if (!testBitRate(bitRate, clk)) continue;\r
799 *fndBitRate = bitRate;\r
800 *offset = idx;\r
801 *Q5 = false;\r
802 return true;\r
803 }\r
804 if (testQ5(mode, offset, fndBitRate, clk)) {\r
805 *Q5 = true;\r
806 return true;\r
807 }\r
808 return false;\r
809}\r
810\r
811void printT55xxBlock(const char *blockNum){\r
812 \r
813 uint8_t i = config.offset;\r
814 uint8_t endpos = 32 + i;\r
815 uint32_t blockData = 0;\r
816 uint8_t bits[64] = {0x00};\r
817\r
818 if ( !DemodBufferLen) return;\r
819\r
820 if ( endpos > DemodBufferLen){\r
821 PrintAndLog("The configured offset %d is too big. Possible offset: %d)", i, DemodBufferLen-32);\r
822 return;\r
823 }\r
824\r
825 for (; i < endpos; ++i)\r
826 bits[i - config.offset]=DemodBuffer[i];\r
827\r
828 blockData = PackBits(0, 32, bits);\r
829\r
830 PrintAndLog(" %s | %08X | %s", blockNum, blockData, sprint_bin(bits,32));\r
831}\r
832\r
833int special(const char *Cmd) {\r
834 uint32_t blockData = 0;\r
835 uint8_t bits[32] = {0x00};\r
836\r
837 PrintAndLog("OFFSET | DATA | BINARY");\r
838 PrintAndLog("----------------------------------------------------");\r
839 int i,j = 0;\r
840 for (; j < 64; ++j){\r
841 \r
842 for (i = 0; i < 32; ++i)\r
843 bits[i]=DemodBuffer[j+i];\r
844 \r
845 blockData = PackBits(0, 32, bits);\r
846 \r
847 PrintAndLog(" %02d | 0x%08X | %s",j , blockData, sprint_bin(bits,32)); \r
848 }\r
849 return 0;\r
850}\r
851\r
852int printConfiguration( t55xx_conf_block_t b){\r
853 PrintAndLog("Chip Type : %s", (b.Q5) ? "T5555(Q5)" : "T55x7");\r
854 PrintAndLog("Modulation : %s", GetSelectedModulationStr(b.modulation) );\r
855 PrintAndLog("Bit Rate : %s", GetBitRateStr(b.bitrate) );\r
856 PrintAndLog("Inverted : %s", (b.inverted) ? "Yes" : "No" );\r
857 PrintAndLog("Offset : %d", b.offset);\r
858 PrintAndLog("Seq. Term. : %s", (b.ST) ? "Yes" : "No" );\r
859 PrintAndLog("Block0 : 0x%08X", b.block0);\r
860 PrintAndLog("");\r
861 return 0;\r
862}\r
863\r
864int CmdT55xxWakeUp(const char *Cmd) {\r
865 uint32_t password = 0;\r
866 uint8_t cmdp = 0;\r
867 bool errors = true;\r
868 while(param_getchar(Cmd, cmdp) != 0x00) {\r
869 switch(param_getchar(Cmd, cmdp)) {\r
870 case 'h':\r
871 case 'H':\r
872 return usage_t55xx_wakup();\r
873 case 'p':\r
874 case 'P':\r
875 password = param_get32ex(Cmd, cmdp+1, 0xFFFFFFFF, 16);\r
876 cmdp += 2;\r
877 errors = false;\r
878 break;\r
879 default:\r
880 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
881 errors = true;\r
882 break;\r
883 }\r
884 }\r
885 if (errors) return usage_t55xx_wakup();\r
886\r
887 UsbCommand c = {CMD_T55XX_WAKEUP, {password, 0, 0}};\r
888 clearCommandBuffer();\r
889 SendCommand(&c);\r
890 PrintAndLog("Wake up command sent. Try read now");\r
891 return 0;\r
892}\r
893\r
894int CmdT55xxWriteBlock(const char *Cmd) {\r
895 uint8_t block = 0xFF; //default to invalid block\r
896 uint32_t data = 0; //default to blank Block \r
897 uint32_t password = 0; //default to blank Block 7\r
898 bool usepwd = false;\r
899 bool page1 = false; \r
900 bool gotdata = false;\r
901 bool errors = false;\r
902 uint8_t cmdp = 0;\r
903 while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {\r
904 switch(param_getchar(Cmd, cmdp)) {\r
905 case 'h':\r
906 case 'H':\r
907 return usage_t55xx_write();\r
908 case 'b':\r
909 case 'B':\r
910 errors |= param_getdec(Cmd, cmdp+1, &block);\r
911 cmdp += 2;\r
912 break;\r
913 case 'd':\r
914 case 'D':\r
915 data = param_get32ex(Cmd, cmdp+1, 0, 16);\r
916 gotdata = true;\r
917 cmdp += 2;\r
918 break;\r
919 case 'p':\r
920 case 'P':\r
921 password = param_get32ex(Cmd, cmdp+1, 0, 16);\r
922 usepwd = true;\r
923 cmdp += 2;\r
924 break;\r
925 case '1':\r
926 page1 = true;\r
927 cmdp++;\r
928 break;\r
929 default:\r
930 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
931 errors = true;\r
932 break;\r
933 }\r
934 }\r
935 if (errors || !gotdata) return usage_t55xx_write();\r
936\r
937 if (block > 7) {\r
938 PrintAndLog("Block number must be between 0 and 7");\r
939 return 0;\r
940 }\r
941 \r
942 UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r
943 UsbCommand resp;\r
944 c.d.asBytes[0] = (page1) ? 0x2 : 0; \r
945\r
946 char pwdStr[16] = {0};\r
947 snprintf(pwdStr, sizeof(pwdStr), "pwd: 0x%08X", password);\r
948\r
949 PrintAndLog("Writing page %d block: %02d data: 0x%08X %s", page1, block, data, (usepwd) ? pwdStr : "" );\r
950\r
951 //Password mode\r
952 if (usepwd) {\r
953 c.arg[2] = password;\r
954 c.d.asBytes[0] |= 0x1; \r
955 }\r
956 clearCommandBuffer();\r
957 SendCommand(&c);\r
958 if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)){\r
959 PrintAndLog("Error occurred, device did not ACK write operation. (May be due to old firmware)");\r
960 return 0;\r
961 }\r
962 return 1;\r
963}\r
964\r
965int CmdT55xxReadTrace(const char *Cmd) {\r
966 char cmdp = param_getchar(Cmd, 0);\r
967 bool pwdmode = false;\r
968 uint32_t password = 0;\r
969 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') \r
970 return usage_t55xx_trace();\r
971\r
972 if (strlen(Cmd)==0)\r
973 if ( !AquireData( T55x7_PAGE1, REGULAR_READ_MODE_BLOCK, pwdmode, password ) )\r
974 return 0;\r
975\r
976 if ( config.Q5 ) {\r
977 if (!DecodeT5555TraceBlock()) return 0;\r
978 } else {\r
979 if (!DecodeT55xxBlock()) return 0;\r
980 }\r
981\r
982 if ( !DemodBufferLen ) return 0;\r
983\r
984 RepaintGraphWindow();\r
985 uint8_t repeat = (config.offset > 5) ? 32 : 0;\r
986\r
987 uint8_t si = config.offset+repeat;\r
988 uint32_t bl1 = PackBits(si, 32, DemodBuffer);\r
989 uint32_t bl2 = PackBits(si+32, 32, DemodBuffer);\r
990\r
991 if (config.Q5) {\r
992 uint32_t hdr = PackBits(si, 9, DemodBuffer); si += 9;\r
993\r
994 if (hdr != 0x1FF) {\r
995 PrintAndLog("Invalid Q5 Trace data header (expected 0x1FF, found %X)", hdr);\r
996 return 0;\r
997 }\r
998\r
999 t5555_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .icr = 0, .lotidc = '?', .lotid = 0, .wafer = 0, .dw =0};\r
1000\r
1001 data.icr = PackBits(si, 2, DemodBuffer); si += 2;\r
1002 data.lotidc = 'Z' - PackBits(si, 2, DemodBuffer); si += 3;\r
1003\r
1004 data.lotid = PackBits(si, 4, DemodBuffer); si += 5;\r
1005 data.lotid <<= 4;\r
1006 data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
1007 data.lotid <<= 4;\r
1008 data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
1009 data.lotid <<= 4;\r
1010 data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
1011 data.lotid <<= 1;\r
1012 data.lotid |= PackBits(si, 1, DemodBuffer); si += 1;\r
1013\r
1014 data.wafer = PackBits(si, 3, DemodBuffer); si += 4;\r
1015 data.wafer <<= 2;\r
1016 data.wafer |= PackBits(si, 2, DemodBuffer); si += 2;\r
1017\r
1018 data.dw = PackBits(si, 2, DemodBuffer); si += 3;\r
1019 data.dw <<= 4;\r
1020 data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
1021 data.dw <<= 4;\r
1022 data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
1023 data.dw <<= 4;\r
1024 data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
1025\r
1026 printT5555Trace(data, repeat);\r
1027\r
1028 } else {\r
1029\r
1030 t55x7_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .acl = 0, .mfc = 0, .cid = 0, .year = 0, .quarter = 0, .icr = 0, .lotid = 0, .wafer = 0, .dw = 0};\r
1031 \r
1032 data.acl = PackBits(si, 8, DemodBuffer); si += 8;\r
1033 if ( data.acl != 0xE0 ) {\r
1034 PrintAndLog("The modulation is most likely wrong since the ACL is not 0xE0. ");\r
1035 return 0;\r
1036 }\r
1037\r
1038 data.mfc = PackBits(si, 8, DemodBuffer); si += 8;\r
1039 data.cid = PackBits(si, 5, DemodBuffer); si += 5;\r
1040 data.icr = PackBits(si, 3, DemodBuffer); si += 3;\r
1041 data.year = PackBits(si, 4, DemodBuffer); si += 4;\r
1042 data.quarter = PackBits(si, 2, DemodBuffer); si += 2;\r
1043 data.lotid = PackBits(si, 14, DemodBuffer); si += 14;\r
1044 data.wafer = PackBits(si, 5, DemodBuffer); si += 5;\r
1045 data.dw = PackBits(si, 15, DemodBuffer); \r
1046\r
1047 time_t t = time(NULL);\r
1048 struct tm tm = *localtime(&t);\r
1049 if ( data.year > tm.tm_year-110)\r
1050 data.year += 2000;\r
1051 else\r
1052 data.year += 2010;\r
1053\r
1054 printT55x7Trace(data, repeat);\r
1055 }\r
1056 return 0;\r
1057}\r
1058\r
1059void printT55x7Trace( t55x7_tracedata_t data, uint8_t repeat ){\r
1060 PrintAndLog("-- T55x7 Trace Information ----------------------------------");\r
1061 PrintAndLog("-------------------------------------------------------------");\r
1062 PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", data.acl, data.acl);\r
1063 PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d) - %s", data.mfc, data.mfc, getTagInfo(data.mfc));\r
1064 PrintAndLog(" CID : 0x%02X (%d) - %s", data.cid, data.cid, GetModelStrFromCID(data.cid));\r
1065 PrintAndLog(" ICR IC Revision : %d", data.icr );\r
1066 PrintAndLog(" Manufactured");\r
1067 PrintAndLog(" Year/Quarter : %d/%d", data.year, data.quarter);\r
1068 PrintAndLog(" Lot ID : %d", data.lotid );\r
1069 PrintAndLog(" Wafer number : %d", data.wafer);\r
1070 PrintAndLog(" Die Number : %d", data.dw);\r
1071 PrintAndLog("-------------------------------------------------------------");\r
1072 PrintAndLog(" Raw Data - Page 1");\r
1073 PrintAndLog(" Block 1 : 0x%08X %s", data.bl1, sprint_bin(DemodBuffer+config.offset+repeat,32) );\r
1074 PrintAndLog(" Block 2 : 0x%08X %s", data.bl2, sprint_bin(DemodBuffer+config.offset+repeat+32,32) );\r
1075 PrintAndLog("-------------------------------------------------------------"); \r
1076\r
1077 /*\r
1078 TRACE - BLOCK O\r
1079 Bits Definition HEX\r
1080 1-8 ACL Allocation class (ISO/IEC 15963-1) 0xE0 \r
1081 9-16 MFC Manufacturer ID (ISO/IEC 7816-6) 0x15 Atmel Corporation\r
1082 17-21 CID 0x1 = Atmel ATA5577M1 0x2 = Atmel ATA5577M2 \r
1083 22-24 ICR IC revision\r
1084 25-28 YEAR (BCD encoded) 9 (= 2009)\r
1085 29-30 QUARTER 1,2,3,4 \r
1086 31-32 LOT ID\r
1087 \r
1088 TRACE - BLOCK 1\r
1089 1-12 LOT ID \r
1090 13-17 Wafer number\r
1091 18-32 DW, die number sequential\r
1092 */\r
1093}\r
1094\r
1095void printT5555Trace( t5555_tracedata_t data, uint8_t repeat ){\r
1096 PrintAndLog("-- T5555 (Q5) Trace Information -----------------------------");\r
1097 PrintAndLog("-------------------------------------------------------------");\r
1098 PrintAndLog(" ICR IC Revision : %d", data.icr ); \r
1099 PrintAndLog(" Lot : %c%d", data.lotidc, data.lotid);\r
1100 PrintAndLog(" Wafer number : %d", data.wafer);\r
1101 PrintAndLog(" Die Number : %d", data.dw);\r
1102 PrintAndLog("-------------------------------------------------------------");\r
1103 PrintAndLog(" Raw Data - Page 1");\r
1104 PrintAndLog(" Block 1 : 0x%08X %s", data.bl1, sprint_bin(DemodBuffer+config.offset+repeat,32) );\r
1105 PrintAndLog(" Block 2 : 0x%08X %s", data.bl2, sprint_bin(DemodBuffer+config.offset+repeat+32,32) );\r
1106 \r
1107 /*\r
1108 ** Q5 **\r
1109 TRACE - BLOCK O and BLOCK1\r
1110 Bits Definition HEX\r
1111 1-9 Header 0x1FF\r
1112 10-11 IC Revision\r
1113 12-13 Lot ID char\r
1114 15-35 Lot ID (NB parity)\r
1115 36-41 Wafer number (NB parity)\r
1116 42-58 DW, die number sequential (NB parity)\r
1117 60-63 Parity bits\r
1118 64 Always zero\r
1119 */\r
1120}\r
1121\r
1122//need to add Q5 info...\r
1123int CmdT55xxInfo(const char *Cmd){\r
1124 /*\r
1125 Page 0 Block 0 Configuration data.\r
1126 Normal mode\r
1127 Extended mode\r
1128 */\r
1129 bool pwdmode = false;\r
1130 uint32_t password = 0;\r
1131 char cmdp = param_getchar(Cmd, 0);\r
1132\r
1133 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H')\r
1134 return usage_t55xx_info();\r
1135 \r
1136 if (strlen(Cmd)==0)\r
1137 if ( !AquireData( T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, pwdmode, password ) )\r
1138 return 1;\r
1139\r
1140 if (!DecodeT55xxBlock()) return 1;\r
1141\r
1142 // too little space to start with\r
1143 if ( DemodBufferLen < 32) return 1;\r
1144\r
1145 uint8_t si = config.offset;\r
1146 uint32_t bl0 = PackBits(si, 32, DemodBuffer);\r
1147 \r
1148 uint32_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r
1149 uint32_t resv = PackBits(si, 7, DemodBuffer); si += 7;\r
1150 uint32_t dbr = PackBits(si, 3, DemodBuffer); si += 3;\r
1151 uint32_t extend = PackBits(si, 1, DemodBuffer); si += 1;\r
1152 uint32_t datamod = PackBits(si, 5, DemodBuffer); si += 5;\r
1153 uint32_t pskcf = PackBits(si, 2, DemodBuffer); si += 2;\r
1154 uint32_t aor = PackBits(si, 1, DemodBuffer); si += 1; \r
1155 uint32_t otp = PackBits(si, 1, DemodBuffer); si += 1; \r
1156 uint32_t maxblk = PackBits(si, 3, DemodBuffer); si += 3;\r
1157 uint32_t pwd = PackBits(si, 1, DemodBuffer); si += 1; \r
1158 uint32_t sst = PackBits(si, 1, DemodBuffer); si += 1; \r
1159 uint32_t fw = PackBits(si, 1, DemodBuffer); si += 1;\r
1160 uint32_t inv = PackBits(si, 1, DemodBuffer); si += 1; \r
1161 uint32_t por = PackBits(si, 1, DemodBuffer); si += 1;\r
1162 \r
1163 if (config.Q5) PrintAndLog("*** Warning *** Config Info read off a Q5 will not display as expected");\r
1164 PrintAndLog("");\r
1165 PrintAndLog("-- T55x7 Configuration & Tag Information --------------------");\r
1166 PrintAndLog("-------------------------------------------------------------");\r
1167 PrintAndLog(" Safer key : %s", GetSaferStr(safer));\r
1168 PrintAndLog(" reserved : %d", resv);\r
1169 PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));\r
1170 PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");\r
1171 PrintAndLog(" Modulation : %s", GetModulationStr(datamod));\r
1172 PrintAndLog(" PSK clock frequency : %d", pskcf);\r
1173 PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");\r
1174 PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );\r
1175 PrintAndLog(" Max block : %d", maxblk);\r
1176 PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");\r
1177 PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");\r
1178 PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");\r
1179 PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");\r
1180 PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");\r
1181 PrintAndLog("-------------------------------------------------------------");\r
1182 PrintAndLog(" Raw Data - Page 0");\r
1183 PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(DemodBuffer+config.offset,32) );\r
1184 PrintAndLog("-------------------------------------------------------------");\r
1185 \r
1186 return 0;\r
1187}\r
1188\r
1189int CmdT55xxDump(const char *Cmd){\r
1190\r
1191 uint32_t password = 0;\r
1192 char cmdp = param_getchar(Cmd, 0);\r
1193 bool override = false;\r
1194 if ( cmdp == 'h' || cmdp == 'H') return usage_t55xx_dump();\r
1195\r
1196 bool usepwd = ( strlen(Cmd) > 0); \r
1197 if ( usepwd ){\r
1198 password = param_get32ex(Cmd, 0, 0, 16);\r
1199 if (param_getchar(Cmd, 1) =='o' )\r
1200 override = true;\r
1201 }\r
1202 \r
1203 printT5xxHeader(0);\r
1204 for ( uint8_t i = 0; i <8; ++i)\r
1205 T55xxReadBlock(i, 0, usepwd, override, password);\r
1206\r
1207 printT5xxHeader(1);\r
1208 for ( uint8_t i = 0; i<4; i++)\r
1209 T55xxReadBlock(i, 1, usepwd, override, password); \r
1210\r
1211 return 1;\r
1212}\r
1213\r
1214int AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password ){\r
1215 // arg0 bitmodes:\r
1216 // bit0 = pwdmode\r
1217 // bit1 = page to read from\r
1218 uint8_t arg0 = (page<<1) | pwdmode;\r
1219 UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}};\r
1220\r
1221 clearCommandBuffer();\r
1222 SendCommand(&c);\r
1223 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {\r
1224 PrintAndLog("command execution time out");\r
1225 return 0;\r
1226 }\r
1227\r
1228 uint8_t got[12000];\r
1229 GetFromBigBuf(got,sizeof(got),0);\r
1230 WaitForResponse(CMD_ACK,NULL);\r
1231 setGraphBuf(got, sizeof(got));\r
1232 return 1;\r
1233}\r
1234\r
1235char * GetBitRateStr(uint32_t id) {\r
1236 static char buf[25];\r
1237\r
1238 char *retStr = buf;\r
1239 switch (id) {\r
1240 case 0: snprintf(retStr,sizeof(buf),"%d - RF/8",id); break;\r
1241 case 1: snprintf(retStr,sizeof(buf),"%d - RF/16",id); break;\r
1242 case 2: snprintf(retStr,sizeof(buf),"%d - RF/32",id); break;\r
1243 case 3: snprintf(retStr,sizeof(buf),"%d - RF/40",id); break;\r
1244 case 4: snprintf(retStr,sizeof(buf),"%d - RF/50",id); break;\r
1245 case 5: snprintf(retStr,sizeof(buf),"%d - RF/64",id); break;\r
1246 case 6: snprintf(retStr,sizeof(buf),"%d - RF/100",id); break;\r
1247 case 7: snprintf(retStr,sizeof(buf),"%d - RF/128",id); break;\r
1248 default: snprintf(retStr,sizeof(buf),"%d - (Unknown)",id); break;\r
1249 }\r
1250 return buf;\r
1251}\r
1252\r
1253char * GetSaferStr(uint32_t id) {\r
1254 static char buf[40];\r
1255 char *retStr = buf;\r
1256 \r
1257 snprintf(retStr,sizeof(buf),"%d",id);\r
1258 if (id == 6) {\r
1259 snprintf(retStr,sizeof(buf),"%d - passwd",id);\r
1260 }\r
1261 if (id == 9 ){\r
1262 snprintf(retStr,sizeof(buf),"%d - testmode",id);\r
1263 }\r
1264 \r
1265 return buf;\r
1266}\r
1267\r
1268char * GetModulationStr( uint32_t id){\r
1269 static char buf[60];\r
1270 char *retStr = buf;\r
1271 \r
1272 switch (id){\r
1273 case 0: snprintf(retStr,sizeof(buf),"%d - DIRECT (ASK/NRZ)",id); break;\r
1274 case 1: snprintf(retStr,sizeof(buf),"%d - PSK 1 phase change when input changes",id); break;\r
1275 case 2: snprintf(retStr,sizeof(buf),"%d - PSK 2 phase change on bitclk if input high",id); break;\r
1276 case 3: snprintf(retStr,sizeof(buf),"%d - PSK 3 phase change on rising edge of input",id); break;\r
1277 case 4: snprintf(retStr,sizeof(buf),"%d - FSK 1 RF/8 RF/5",id); break;\r
1278 case 5: snprintf(retStr,sizeof(buf),"%d - FSK 2 RF/8 RF/10",id); break;\r
1279 case 6: snprintf(retStr,sizeof(buf),"%d - FSK 1a RF/5 RF/8",id); break;\r
1280 case 7: snprintf(retStr,sizeof(buf),"%d - FSK 2a RF/10 RF/8",id); break;\r
1281 case 8: snprintf(retStr,sizeof(buf),"%d - Manchester",id); break;\r
1282 case 16: snprintf(retStr,sizeof(buf),"%d - Biphase",id); break;\r
1283 case 0x18: snprintf(retStr,sizeof(buf),"%d - Biphase a - AKA Conditional Dephase Encoding(CDP)",id); break;\r
1284 case 17: snprintf(retStr,sizeof(buf),"%d - Reserved",id); break;\r
1285 default: snprintf(retStr,sizeof(buf),"0x%02X (Unknown)",id); break;\r
1286 }\r
1287 return buf;\r
1288}\r
1289\r
1290char * GetModelStrFromCID(uint32_t cid){\r
1291 \r
1292 static char buf[10];\r
1293 char *retStr = buf;\r
1294 \r
1295 if (cid == 1) snprintf(retStr, sizeof(buf),"ATA5577M1");\r
1296 if (cid == 2) snprintf(retStr, sizeof(buf),"ATA5577M2"); \r
1297 return buf;\r
1298}\r
1299\r
1300char * GetSelectedModulationStr( uint8_t id){\r
1301\r
1302 static char buf[20];\r
1303 char *retStr = buf;\r
1304\r
1305 switch (id) {\r
1306 case DEMOD_FSK: snprintf(retStr,sizeof(buf),"FSK"); break;\r
1307 case DEMOD_FSK1: snprintf(retStr,sizeof(buf),"FSK1"); break;\r
1308 case DEMOD_FSK1a: snprintf(retStr,sizeof(buf),"FSK1a"); break;\r
1309 case DEMOD_FSK2: snprintf(retStr,sizeof(buf),"FSK2"); break;\r
1310 case DEMOD_FSK2a: snprintf(retStr,sizeof(buf),"FSK2a"); break;\r
1311 case DEMOD_ASK: snprintf(retStr,sizeof(buf),"ASK"); break;\r
1312 case DEMOD_NRZ: snprintf(retStr,sizeof(buf),"DIRECT/NRZ"); break;\r
1313 case DEMOD_PSK1: snprintf(retStr,sizeof(buf),"PSK1"); break;\r
1314 case DEMOD_PSK2: snprintf(retStr,sizeof(buf),"PSK2"); break;\r
1315 case DEMOD_PSK3: snprintf(retStr,sizeof(buf),"PSK3"); break;\r
1316 case DEMOD_BI: snprintf(retStr,sizeof(buf),"BIPHASE"); break;\r
1317 case DEMOD_BIa: snprintf(retStr,sizeof(buf),"BIPHASEa - (CDP)"); break;\r
1318 default: snprintf(retStr,sizeof(buf),"(Unknown)"); break;\r
1319 }\r
1320 return buf;\r
1321}\r
1322\r
1323uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){\r
1324 \r
1325 int i = start;\r
1326 int j = len-1;\r
1327\r
1328 if (len > 32) return 0;\r
1329\r
1330 uint32_t tmp = 0;\r
1331 for (; j >= 0; --j, ++i)\r
1332 tmp |= bits[i] << j;\r
1333\r
1334 return tmp;\r
1335}\r
1336\r
1337int CmdResetRead(const char *Cmd) {\r
1338 UsbCommand c = {CMD_T55XX_RESET_READ, {0,0,0}};\r
1339\r
1340 clearCommandBuffer();\r
1341 SendCommand(&c);\r
1342 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {\r
1343 PrintAndLog("command execution time out");\r
1344 return 0;\r
1345 }\r
1346\r
1347 uint8_t got[BIGBUF_SIZE-1];\r
1348 GetFromBigBuf(got,sizeof(got),0);\r
1349 WaitForResponse(CMD_ACK,NULL);\r
1350 setGraphBuf(got, sizeof(got));\r
1351 return 1;\r
1352}\r
1353\r
1354int CmdT55xxWipe(const char *Cmd) {\r
1355 char writeData[20] = {0};\r
1356 char *ptrData = writeData;\r
1357\r
1358 char cmdp = param_getchar(Cmd, 0); \r
1359 if ( cmdp == 'h' || cmdp == 'H') return usage_t55xx_wipe();\r
1360\r
1361 bool Q5 = (cmdp == 'q' || cmdp == 'Q');\r
1362\r
1363 // Try with the default password to reset block 0\r
1364 // With a pwd should work even if pwd bit not set\r
1365 PrintAndLog("\nBeginning Wipe of a T55xx tag (assuming the tag is not password protected)\n");\r
1366\r
1367 if ( Q5 ){\r
1368 snprintf(ptrData,sizeof(writeData),"b 0 d 6001F004 p 0");\r
1369 } else {\r
1370 snprintf(ptrData,sizeof(writeData),"b 0 d 00088040 p 0");\r
1371 }\r
1372\r
1373 if (!CmdT55xxWriteBlock(ptrData)) PrintAndLog("Error writing blk 0");\r
1374\r
1375 for (uint8_t blk = 1; blk<8; blk++) {\r
1376 snprintf(ptrData,sizeof(writeData),"b %d d 0", blk);\r
1377 if (!CmdT55xxWriteBlock(ptrData))\r
1378 PrintAndLog("Error writing blk %d", blk);\r
1379\r
1380 memset(writeData, 0x00, sizeof(writeData));\r
1381 }\r
1382 return 0;\r
1383}\r
1384\r
1385int CmdT55xxBruteForce(const char *Cmd) {\r
1386\r
1387 // load a default pwd file.\r
1388 char buf[9];\r
1389 char filename[FILE_PATH_SIZE]={0};\r
1390 int keycnt = 0;\r
1391 int ch;\r
1392 uint8_t stKeyBlock = 20;\r
1393 uint8_t *keyBlock = NULL, *p = NULL;\r
1394 uint32_t start_password = 0x00000000; //start password\r
1395 uint32_t end_password = 0xFFFFFFFF; //end password\r
1396 bool found = false;\r
1397\r
1398 char cmdp = param_getchar(Cmd, 0);\r
1399 if (cmdp == 'h' || cmdp == 'H') return usage_t55xx_bruteforce();\r
1400\r
1401 keyBlock = calloc(stKeyBlock, 6);\r
1402 if (keyBlock == NULL) return 1;\r
1403\r
1404 if (cmdp == 'i' || cmdp == 'I') {\r
1405\r
1406 int len = strlen(Cmd+2);\r
1407 if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
1408 memcpy(filename, Cmd+2, len);\r
1409\r
1410 FILE * f = fopen( filename , "r");\r
1411\r
1412 if ( !f ) {\r
1413 PrintAndLog("File: %s: not found or locked.", filename);\r
1414 free(keyBlock);\r
1415 return 1;\r
1416 }\r
1417\r
1418 while( fgets(buf, sizeof(buf), f) ) {\r
1419 if (strlen(buf) < 8 || buf[7] == '\n') continue;\r
1420\r
1421 while (fgetc(f) != '\n' && !feof(f)) ; //goto next line\r
1422\r
1423 //The line start with # is comment, skip\r
1424 if( buf[0]=='#' ) continue;\r
1425\r
1426 if (!isxdigit(buf[0])) {\r
1427 PrintAndLog("File content error. '%s' must include 8 HEX symbols", buf);\r
1428 continue;\r
1429 }\r
1430 \r
1431 buf[8] = 0;\r
1432\r
1433 if ( stKeyBlock - keycnt < 2) {\r
1434 p = realloc(keyBlock, 6*(stKeyBlock+=10));\r
1435 if (!p) {\r
1436 PrintAndLog("Cannot allocate memory for defaultKeys");\r
1437 free(keyBlock);\r
1438 fclose(f);\r
1439 return 2;\r
1440 }\r
1441 keyBlock = p;\r
1442 }\r
1443 memset(keyBlock + 4 * keycnt, 0, 4);\r
1444 num_to_bytes(strtoll(buf, NULL, 16), 4, keyBlock + 4*keycnt);\r
1445 PrintAndLog("chk custom pwd[%2d] %08X", keycnt, bytes_to_num(keyBlock + 4*keycnt, 4));\r
1446 keycnt++;\r
1447 memset(buf, 0, sizeof(buf));\r
1448 }\r
1449 fclose(f);\r
1450 \r
1451 if (keycnt == 0) {\r
1452 PrintAndLog("No keys found in file");\r
1453 free(keyBlock);\r
1454 return 1;\r
1455 }\r
1456 PrintAndLog("Loaded %d keys", keycnt);\r
1457 \r
1458 // loop\r
1459 uint64_t testpwd = 0x00;\r
1460 for (uint16_t c = 0; c < keycnt; ++c ) {\r
1461\r
1462 if (ukbhit()) {\r
1463 ch = getchar();\r
1464 (void)ch;\r
1465 printf("\naborted via keyboard!\n");\r
1466 free(keyBlock);\r
1467 return 0;\r
1468 }\r
1469\r
1470 testpwd = bytes_to_num(keyBlock + 4*c, 4);\r
1471\r
1472 PrintAndLog("Testing %08X", testpwd);\r
1473\r
1474 if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, testpwd)) {\r
1475 PrintAndLog("Aquireing data from device failed. Quitting");\r
1476 free(keyBlock);\r
1477 return 0;\r
1478 }\r
1479\r
1480 found = tryDetectModulation();\r
1481\r
1482 if ( found ) {\r
1483 PrintAndLog("Found valid password: [%08X]", testpwd);\r
1484 free(keyBlock);\r
1485 return 0;\r
1486 }\r
1487 }\r
1488 PrintAndLog("Password NOT found.");\r
1489 free(keyBlock);\r
1490 return 0;\r
1491 }\r
1492\r
1493 // Try to read Block 7, first :)\r
1494\r
1495 // incremental pwd range search\r
1496 start_password = param_get32ex(Cmd, 0, 0, 16);\r
1497 end_password = param_get32ex(Cmd, 1, 0, 16);\r
1498\r
1499 if ( start_password >= end_password ) {\r
1500 free(keyBlock);\r
1501 return usage_t55xx_bruteforce();\r
1502 }\r
1503 PrintAndLog("Search password range [%08X -> %08X]", start_password, end_password);\r
1504\r
1505 uint32_t i = start_password;\r
1506\r
1507 while ((!found) && (i <= end_password)) {\r
1508\r
1509 printf(".");\r
1510 fflush(stdout);\r
1511 if (ukbhit()) {\r
1512 ch = getchar();\r
1513 (void)ch;\r
1514 printf("\naborted via keyboard!\n");\r
1515 free(keyBlock);\r
1516 return 0;\r
1517 }\r
1518\r
1519 if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, i)) {\r
1520 PrintAndLog("Aquireing data from device failed. Quitting");\r
1521 free(keyBlock);\r
1522 return 0;\r
1523 }\r
1524 found = tryDetectModulation();\r
1525\r
1526 if (found) break;\r
1527 i++;\r
1528 }\r
1529\r
1530 PrintAndLog("");\r
1531\r
1532 if (found)\r
1533 PrintAndLog("Found valid password: [%08x]", i);\r
1534 else\r
1535 PrintAndLog("Password NOT found. Last tried: [%08x]", --i);\r
1536\r
1537 free(keyBlock);\r
1538 return 0;\r
1539}\r
1540\r
1541static command_t CommandTable[] = {\r
1542 {"help", CmdHelp, 1, "This help"},\r
1543 {"bruteforce",CmdT55xxBruteForce,0, "<start password> <end password> [i <*.dic>] Simple bruteforce attack to find password"},\r
1544 {"config", CmdT55xxSetConfig, 1, "Set/Get T55XX configuration (modulation, inverted, offset, rate)"},\r
1545 {"detect", CmdT55xxDetect, 1, "[1] Try detecting the tag modulation from reading the configuration block."},\r
1546 {"read", CmdT55xxReadBlock, 0, "b <block> p [password] [o] [1] -- Read T55xx block data. Optional [p password], [override], [page1]"},\r
1547 {"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)"},\r
1548 {"write", CmdT55xxWriteBlock,0, "b <block> d <data> p [password] [1] -- Write T55xx block data. Optional [p password], [page1]"},\r
1549 {"trace", CmdT55xxReadTrace, 1, "[1] Show T55x7 traceability data (page 1/ blk 0-1)"},\r
1550 {"info", CmdT55xxInfo, 1, "[1] Show T55x7 configuration data (page 0/ blk 0)"},\r
1551 {"dump", CmdT55xxDump, 0, "[password] [o] Dump T55xx card block 0-7. Optional [password], [override]"},\r
1552 {"special", special, 0, "Show block changes with 64 different offsets"},\r
1553 {"wakeup", CmdT55xxWakeUp, 0, "Send AOR wakeup command"},\r
1554 {"wipe", CmdT55xxWipe, 0, "[q] Wipe a T55xx tag and set defaults (will destroy any data on tag)"},\r
1555 {NULL, NULL, 0, NULL}\r
1556};\r
1557\r
1558int CmdLFT55XX(const char *Cmd) {\r
1559 CmdsParse(CommandTable, Cmd);\r
1560 return 0;\r
1561}\r
1562\r
1563int CmdHelp(const char *Cmd) {\r
1564 CmdsHelp(CommandTable);\r
1565 return 0;\r
1566}\r
Impressum, Datenschutz