]>
Commit | Line | Data |
---|---|---|
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 | \r | |
24 | \r | |
25 | #define LF_TRACE_BUFF_SIZE 12000 // 32 x 32 x 10 (32 bit times numofblock (7), times clock skip..)\r | |
26 | #define LF_BITSSTREAM_LEN 1000 // more then 1000 bits shouldn't happend.. 8block * 4 bytes * 8bits = \r | |
27 | static int CmdHelp(const char *Cmd);\r | |
28 | \r | |
29 | \r | |
30 | int CmdReadBlk(const char *Cmd)\r | |
31 | {\r | |
32 | int block = -1;\r | |
33 | sscanf(Cmd, "%d", &block);\r | |
34 | \r | |
35 | if ((block > 7) | (block < 0)) {\r | |
36 | PrintAndLog("Block must be between 0 and 7");\r | |
37 | return 1;\r | |
38 | } \r | |
39 | \r | |
40 | UsbCommand c;\r | |
41 | c.cmd = CMD_T55XX_READ_BLOCK;\r | |
42 | c.d.asBytes[0] = 0x00;\r | |
43 | c.arg[0] = 0;\r | |
44 | c.arg[1] = block;\r | |
45 | c.arg[2] = 0;\r | |
46 | SendCommand(&c);\r | |
47 | WaitForResponse(CMD_ACK, NULL);\r | |
48 | \r | |
49 | uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r | |
50 | \r | |
51 | GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset..\r | |
52 | WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r | |
53 | \r | |
54 | for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r | |
55 | GraphBuffer[j] = (int)data[j];\r | |
56 | }\r | |
57 | GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
58 | ManchesterDemod(block);\r | |
59 | RepaintGraphWindow();\r | |
60 | return 0;\r | |
61 | }\r | |
62 | \r | |
63 | int CmdReadBlkPWD(const char *Cmd)\r | |
64 | {\r | |
65 | int Block = -1; //default to invalid block\r | |
66 | int Password = 0xFFFFFFFF; //default to blank Block 7\r | |
67 | UsbCommand c;\r | |
68 | \r | |
69 | sscanf(Cmd, "%d %x", &Block, &Password);\r | |
70 | \r | |
71 | if ((Block > 7) | (Block < 0)) {\r | |
72 | PrintAndLog("Block must be between 0 and 7");\r | |
73 | return 1;\r | |
74 | } \r | |
75 | \r | |
76 | PrintAndLog("Reading page 0 block %d pwd %08X", Block, Password);\r | |
77 | \r | |
78 | c.cmd = CMD_T55XX_READ_BLOCK;\r | |
79 | c.d.asBytes[0] = 0x1; //Password mode\r | |
80 | c.arg[0] = 0;\r | |
81 | c.arg[1] = Block;\r | |
82 | c.arg[2] = Password;\r | |
83 | SendCommand(&c);\r | |
84 | WaitForResponse(CMD_ACK, NULL);\r | |
85 | \r | |
86 | uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r | |
87 | \r | |
88 | GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset..\r | |
89 | WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r | |
90 | \r | |
91 | for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r | |
92 | GraphBuffer[j] = ((int)data[j]);\r | |
93 | }\r | |
94 | GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
95 | ManchesterDemod(Block); \r | |
96 | RepaintGraphWindow();\r | |
97 | return 0;\r | |
98 | }\r | |
99 | \r | |
100 | int CmdWriteBlk(const char *Cmd)\r | |
101 | {\r | |
102 | int Block = 8; //default to invalid block\r | |
103 | int Data = 0xFFFFFFFF; //default to blank Block \r | |
104 | UsbCommand c;\r | |
105 | \r | |
106 | sscanf(Cmd, "%x %d", &Data, &Block);\r | |
107 | \r | |
108 | if (Block > 7) {\r | |
109 | PrintAndLog("Block must be between 0 and 7");\r | |
110 | return 1;\r | |
111 | } \r | |
112 | \r | |
113 | PrintAndLog("Writting block %d with data %08X", Block, Data);\r | |
114 | \r | |
115 | c.cmd = CMD_T55XX_WRITE_BLOCK;\r | |
116 | c.d.asBytes[0] = 0x0; //Normal mode\r | |
117 | c.arg[0] = Data;\r | |
118 | c.arg[1] = Block;\r | |
119 | c.arg[2] = 0;\r | |
120 | SendCommand(&c);\r | |
121 | return 0;\r | |
122 | }\r | |
123 | \r | |
124 | int CmdWriteBlkPWD(const char *Cmd)\r | |
125 | {\r | |
126 | int Block = 8; //default to invalid block\r | |
127 | int Data = 0xFFFFFFFF; //default to blank Block \r | |
128 | int Password = 0xFFFFFFFF; //default to blank Block 7\r | |
129 | UsbCommand c;\r | |
130 | \r | |
131 | sscanf(Cmd, "%x %d %x", &Data, &Block, &Password);\r | |
132 | \r | |
133 | if (Block > 7) {\r | |
134 | PrintAndLog("Block must be between 0 and 7");\r | |
135 | return 1;\r | |
136 | } \r | |
137 | \r | |
138 | PrintAndLog("Writting block %d with data %08X and password %08X", Block, Data, Password);\r | |
139 | \r | |
140 | c.cmd = CMD_T55XX_WRITE_BLOCK;\r | |
141 | c.d.asBytes[0] = 0x1; //Password mode\r | |
142 | c.arg[0] = Data;\r | |
143 | c.arg[1] = Block;\r | |
144 | c.arg[2] = Password;\r | |
145 | SendCommand(&c);\r | |
146 | return 0;\r | |
147 | }\r | |
148 | \r | |
149 | int CmdReadTrace(const char *Cmd)\r | |
150 | {\r | |
151 | char cmdp = param_getchar(Cmd, 0);\r | |
152 | \r | |
153 | if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r | |
154 | PrintAndLog("Usage: lf t55xx trace [use data from Graphbuffer]");\r | |
155 | PrintAndLog(" [use data from Graphbuffer], if not set, try reading data from tag.");\r | |
156 | PrintAndLog("");\r | |
157 | PrintAndLog(" sample: lf t55xx trace");\r | |
158 | PrintAndLog(" sample: lf t55xx trace 1");\r | |
159 | return 0;\r | |
160 | }\r | |
161 | \r | |
162 | if ( strlen(Cmd)==0){\r | |
163 | UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};\r | |
164 | SendCommand(&c);\r | |
165 | WaitForResponse(CMD_ACK, NULL);\r | |
166 | \r | |
167 | uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r | |
168 | \r | |
169 | GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset..\r | |
170 | WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r | |
171 | \r | |
172 | for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r | |
173 | GraphBuffer[j] = ((int)data[j]);\r | |
174 | }\r | |
175 | GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
176 | }\r | |
177 | \r | |
178 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
179 | uint8_t * bitstream = bits;\r | |
180 | \r | |
181 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);\r | |
182 | RepaintGraphWindow();\r | |
183 | \r | |
184 | uint8_t si = 5;\r | |
185 | uint32_t bl0 = PackBits(si, 32, bitstream);\r | |
186 | uint32_t bl1 = PackBits(si+32, 32, bitstream);\r | |
187 | \r | |
188 | uint32_t acl = PackBits(si, 8, bitstream); si += 8;\r | |
189 | uint32_t mfc = PackBits(si, 8, bitstream); si += 8;\r | |
190 | uint32_t cid = PackBits(si, 5, bitstream); si += 5;\r | |
191 | uint32_t icr = PackBits(si, 3, bitstream); si += 3;\r | |
192 | uint32_t year = PackBits(si, 4, bitstream); si += 4;\r | |
193 | uint32_t quarter = PackBits(si, 2, bitstream); si += 2;\r | |
194 | uint32_t lotid = PackBits(si, 12, bitstream); si += 12;\r | |
195 | uint32_t wafer = PackBits(si, 5, bitstream); si += 5;\r | |
196 | uint32_t dw = PackBits(si, 15, bitstream); \r | |
197 | \r | |
198 | PrintAndLog("");\r | |
199 | PrintAndLog("-- T55xx Trace Information ----------------------------------");\r | |
200 | PrintAndLog("-------------------------------------------------------------");\r | |
201 | PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", acl, acl);\r | |
202 | PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d)", mfc, mfc);\r | |
203 | PrintAndLog(" CID : 0x%02X (%d)", cid, cid);\r | |
204 | PrintAndLog(" ICR IC Revision : %d",icr );\r | |
205 | PrintAndLog(" Manufactured");\r | |
206 | PrintAndLog(" Year/Quarter : %d/%d",2000+year, quarter );\r | |
207 | PrintAndLog(" Lot ID : %d", lotid );\r | |
208 | PrintAndLog(" Wafer number : %d", wafer);\r | |
209 | PrintAndLog(" Die Number : %d", dw);\r | |
210 | PrintAndLog("-------------------------------------------------------------");\r | |
211 | PrintAndLog(" Raw Data - Page 1");\r | |
212 | PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bitstream+5,32) );\r | |
213 | PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(bitstream+37,32) );\r | |
214 | PrintAndLog("-------------------------------------------------------------");\r | |
215 | /*\r | |
216 | TRACE - BLOCK O\r | |
217 | Bits Definition HEX\r | |
218 | 1-8 ACL Allocation class (ISO/IEC 15963-1) 0xE0 \r | |
219 | 9-16 MFC Manufacturer ID (ISO/IEC 7816-6) 0x15 Atmel Corporation\r | |
220 | 17-21 CID 0x1 = Atmel ATA5577M1 0x2 = Atmel ATA5577M2 \r | |
221 | 22-24 ICR IC revision\r | |
222 | 25-28 YEAR (BCD encoded) 9 (= 2009)\r | |
223 | 29-30 QUARTER 1,2,3,4 \r | |
224 | 31-32 LOT ID\r | |
225 | \r | |
226 | TRACE - BLOCK 1\r | |
227 | 1-12 LOT ID \r | |
228 | 13-17 Wafer number\r | |
229 | 18-32 DW, die number sequential\r | |
230 | */\r | |
231 | \r | |
232 | return 0;\r | |
233 | }\r | |
234 | \r | |
235 | int CmdInfo(const char *Cmd){\r | |
236 | /*\r | |
237 | Page 0 Block 0 Configuration data.\r | |
238 | Normal mode\r | |
239 | Extended mode\r | |
240 | */\r | |
241 | char cmdp = param_getchar(Cmd, 0);\r | |
242 | \r | |
243 | if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r | |
244 | PrintAndLog("Usage: lf t55xx info [use data from Graphbuffer]");\r | |
245 | PrintAndLog(" [use data from Graphbuffer], if not set, try reading data from tag.");\r | |
246 | PrintAndLog("");\r | |
247 | PrintAndLog(" sample: lf t55xx info");\r | |
248 | PrintAndLog(" sample: lf t55xx info 1");\r | |
249 | return 0;\r | |
250 | }\r | |
251 | \r | |
252 | if ( strlen(Cmd)==0){\r | |
253 | CmdReadBlk("0");\r | |
254 | } \r | |
255 | \r | |
256 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
257 | uint8_t * bitstream = bits;\r | |
258 | \r | |
259 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);\r | |
260 | \r | |
261 | uint8_t si = 5;\r | |
262 | uint32_t bl0 = PackBits(si, 32, bitstream);\r | |
263 | \r | |
264 | uint32_t safer = PackBits(si, 4, bitstream); si += 4; \r | |
265 | uint32_t resv = PackBits(si, 7, bitstream); si += 7;\r | |
266 | uint32_t dbr = PackBits(si, 3, bitstream); si += 3;\r | |
267 | uint32_t extend = PackBits(si, 1, bitstream); si += 1;\r | |
268 | uint32_t datamodulation = PackBits(si, 5, bitstream); si += 5;\r | |
269 | uint32_t pskcf = PackBits(si, 2, bitstream); si += 2;\r | |
270 | uint32_t aor = PackBits(si, 1, bitstream); si += 1; \r | |
271 | uint32_t otp = PackBits(si, 1, bitstream); si += 1; \r | |
272 | uint32_t maxblk = PackBits(si, 3, bitstream); si += 3;\r | |
273 | uint32_t pwd = PackBits(si, 1, bitstream); si += 1; \r | |
274 | uint32_t sst = PackBits(si, 1, bitstream); si += 1; \r | |
275 | uint32_t fw = PackBits(si, 1, bitstream); si += 1;\r | |
276 | uint32_t inv = PackBits(si, 1, bitstream); si += 1; \r | |
277 | uint32_t por = PackBits(si, 1, bitstream); si += 1;\r | |
278 | \r | |
279 | PrintAndLog("");\r | |
280 | PrintAndLog("-- T55xx Configuration --------------------------------------");\r | |
281 | PrintAndLog("-------------------------------------------------------------");\r | |
282 | PrintAndLog(" Safer key : %s", GetSaferStr(safer));\r | |
283 | PrintAndLog(" reserved : %d", resv);\r | |
284 | PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));\r | |
285 | PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");\r | |
286 | PrintAndLog(" Modulation : %s", GetModulationStr(datamodulation) );\r | |
287 | PrintAndLog(" PSK clock freq : %d", pskcf);\r | |
288 | PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");\r | |
289 | PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );\r | |
290 | PrintAndLog(" Max block : %d", maxblk);\r | |
291 | PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");\r | |
292 | PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");\r | |
293 | PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");\r | |
294 | PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");\r | |
295 | PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");\r | |
296 | PrintAndLog("-------------------------------------------------------------");\r | |
297 | PrintAndLog(" Raw Data - Page 0");\r | |
298 | PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bitstream+5,32) );\r | |
299 | PrintAndLog("-------------------------------------------------------------");\r | |
300 | \r | |
301 | return 0;\r | |
302 | }\r | |
303 | \r | |
304 | int CmdDump(const char *Cmd){\r | |
305 | \r | |
306 | char cmdp = param_getchar(Cmd, 0);\r | |
307 | char s[20];\r | |
308 | uint8_t pwd[4] = {0x00};\r | |
309 | bool hasPwd = ( strlen(Cmd) > 0);\r | |
310 | \r | |
311 | if ( cmdp == 'h' || cmdp == 'H') {\r | |
312 | PrintAndLog("Usage: lf t55xx dump <password>");\r | |
313 | PrintAndLog(" sample: lf t55xx dump FFFFFFFF");\r | |
314 | return 0;\r | |
315 | }\r | |
316 | \r | |
317 | if ( hasPwd ){\r | |
318 | if (param_gethex(Cmd, 0, pwd, 8)) {\r | |
319 | PrintAndLog("password must include 8 HEX symbols");\r | |
320 | return 0;\r | |
321 | }\r | |
322 | }\r | |
323 | \r | |
324 | for ( int i = 0; i <8; ++i){\r | |
325 | memset(s,0,sizeof(s));\r | |
326 | if ( hasPwd ) {\r | |
327 | sprintf(s,"%d %02x%02x%02x%02x", i, pwd[0],pwd[1],pwd[2],pwd[3]);\r | |
328 | CmdReadBlkPWD(s);\r | |
329 | } else {\r | |
330 | sprintf(s,"%d", i);\r | |
331 | CmdReadBlk(s);\r | |
332 | }\r | |
333 | }\r | |
334 | return 0;\r | |
335 | }\r | |
336 | \r | |
337 | int CmdIceFsk(const char *Cmd){\r | |
338 | \r | |
339 | if (!HasGraphData()) return 0;\r | |
340 | \r | |
341 | iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);\r | |
342 | RepaintGraphWindow();\r | |
343 | return 0;\r | |
344 | }\r | |
345 | int CmdIceManchester(const char *Cmd){\r | |
346 | ManchesterDemod( -1);\r | |
347 | return 0;\r | |
348 | }\r | |
349 | int ManchesterDemod(int blockNum){\r | |
350 | \r | |
351 | if (!HasGraphData()) return 0;\r | |
352 | \r | |
353 | uint8_t sizebyte = 32;\r | |
354 | // the value 5 was selected during empirical studies of the decoded data. Some signal noise to skip.\r | |
355 | uint8_t offset = 5;\r | |
356 | uint32_t blockData;\r | |
357 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
358 | uint8_t * bitstream = bits;\r | |
359 | \r | |
360 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN); \r | |
361 | blockData = PackBits(offset, sizebyte, bitstream);\r | |
362 | \r | |
363 | if ( blockNum < 0)\r | |
364 | PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
365 | else\r | |
366 | PrintAndLog(" Block %d : 0x%08X %s", blockNum, blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
367 | \r | |
368 | return 0;\r | |
369 | } \r | |
370 | \r | |
371 | char * GetBitRateStr(uint32_t id){\r | |
372 | static char buf[40];\r | |
373 | char *retStr = buf;\r | |
374 | switch (id){\r | |
375 | case 0: \r | |
376 | sprintf(retStr,"%d - RF/8",id);\r | |
377 | break;\r | |
378 | case 1:\r | |
379 | sprintf(retStr,"%d - RF/16",id);\r | |
380 | break;\r | |
381 | case 2: \r | |
382 | sprintf(retStr,"%d - RF/32",id);\r | |
383 | break;\r | |
384 | case 3:\r | |
385 | sprintf(retStr,"%d - RF/40",id);\r | |
386 | break;\r | |
387 | case 4:\r | |
388 | sprintf(retStr,"%d - RF/50",id);\r | |
389 | break;\r | |
390 | case 5:\r | |
391 | sprintf(retStr,"%d - RF/64",id);\r | |
392 | break;\r | |
393 | case 6:\r | |
394 | sprintf(retStr,"%d - RF/100",id);\r | |
395 | break;\r | |
396 | case 7:\r | |
397 | sprintf(retStr,"%d - RF/128",id);\r | |
398 | break;\r | |
399 | default:\r | |
400 | sprintf(retStr,"%d - (Unknown)",id);\r | |
401 | break;\r | |
402 | }\r | |
403 | \r | |
404 | return buf;\r | |
405 | }\r | |
406 | \r | |
407 | char * GetSaferStr(uint32_t id){\r | |
408 | static char buf[40];\r | |
409 | char *retStr = buf;\r | |
410 | \r | |
411 | sprintf(retStr,"%d",id);\r | |
412 | if (id == 6) {\r | |
413 | sprintf(retStr,"%d - pasdwd",id);\r | |
414 | }\r | |
415 | if (id == 9 ){\r | |
416 | sprintf(retStr,"%d - testmode ",id);\r | |
417 | }\r | |
418 | \r | |
419 | return buf;\r | |
420 | }\r | |
421 | char * GetModulationStr( uint32_t id){\r | |
422 | static char buf[40];\r | |
423 | char *retStr = buf;\r | |
424 | \r | |
425 | switch (id){\r | |
426 | case 0: \r | |
427 | sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);\r | |
428 | break;\r | |
429 | case 1:\r | |
430 | sprintf(retStr,"%d - PSK 1 phase change when input changes",id);\r | |
431 | break;\r | |
432 | case 2: \r | |
433 | sprintf(retStr,"%d - PSK 2 phase change on bitclk if input high",id);\r | |
434 | break;\r | |
435 | case 3:\r | |
436 | sprintf(retStr,"%d - PSK 3 phase change on rising edge of input",id);\r | |
437 | break;\r | |
438 | case 4:\r | |
439 | sprintf(retStr,"%d - FSK 1 RF/8 RF/5",id);\r | |
440 | break;\r | |
441 | case 5:\r | |
442 | sprintf(retStr,"%d - FSK 2 RF/8 RF/10",id);\r | |
443 | break;\r | |
444 | case 6:\r | |
445 | sprintf(retStr,"%d - FSK 1a RF/5 RF/8",id);\r | |
446 | break;\r | |
447 | case 7:\r | |
448 | sprintf(retStr,"%d - FSK 2a RF/10 RF/8",id);\r | |
449 | break;\r | |
450 | case 8:\r | |
451 | sprintf(retStr,"%d - Manschester",id);\r | |
452 | break;\r | |
453 | case 16:\r | |
454 | sprintf(retStr,"%d - Biphase",id);\r | |
455 | break;\r | |
456 | case 17:\r | |
457 | sprintf(retStr,"%d - Reserved",id);\r | |
458 | break;\r | |
459 | default:\r | |
460 | sprintf(retStr,"0x%02X (Unknown)",id);\r | |
461 | break;\r | |
462 | }\r | |
463 | return buf;\r | |
464 | }\r | |
465 | \r | |
466 | \r | |
467 | uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){\r | |
468 | \r | |
469 | int i = start;\r | |
470 | int j = len-1;\r | |
471 | if (len > 32) {\r | |
472 | return 0;\r | |
473 | }\r | |
474 | uint32_t tmp = 0;\r | |
475 | for (; j >= 0; --j, ++i){\r | |
476 | tmp |= bits[i] << j;\r | |
477 | }\r | |
478 | return tmp;\r | |
479 | }\r | |
480 | \r | |
481 | static command_t CommandTable[] =\r | |
482 | {\r | |
483 | {"help", CmdHelp, 1, "This help"},\r | |
484 | {"rd", CmdReadBlk, 0, "<block> -- Read T55xx block data (page 0)"},\r | |
485 | {"rdpwd", CmdReadBlkPWD, 0, "<block> <password> -- Read T55xx block data with password mode"},\r | |
486 | {"wr", CmdWriteBlk, 0, "<data> <block> -- Write T55xx block data (page 0)"},\r | |
487 | {"wrpwd", CmdWriteBlkPWD, 0, "<data> <block> <password> -- Write T55xx block data with password"},\r | |
488 | {"trace", CmdReadTrace, 0, "[1] Read T55xx traceability data (page 1/ blk 0-1)"},\r | |
489 | {"info", CmdInfo, 0, "[1] Read T55xx configuration data (page 0/ blk 0)"},\r | |
490 | {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. optional with password"},\r | |
491 | {"fsk", CmdIceFsk, 0, "FSK demod"},\r | |
492 | {"man", CmdIceManchester, 0, "Manchester demod (with SST)"},\r | |
493 | {NULL, NULL, 0, NULL}\r | |
494 | };\r | |
495 | \r | |
496 | int CmdLFT55XX(const char *Cmd)\r | |
497 | {\r | |
498 | CmdsParse(CommandTable, Cmd);\r | |
499 | return 0;\r | |
500 | }\r | |
501 | \r | |
502 | int CmdHelp(const char *Cmd)\r | |
503 | {\r | |
504 | CmdsHelp(CommandTable);\r | |
505 | return 0;\r | |
506 | }\r |