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