]>
Commit | Line | Data |
---|---|---|
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 | |
f38a1528 | 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 | |
f38a1528 | 21 | #include "util.h"\r |
22 | #include "data.h"\r | |
54a942b0 | 23 | \r |
f6c18637 | 24 | \r |
25 | #define LF_TRACE_BUFF_SIZE 12000 // 32 x 32 x 10 (32 bit times numofblock (7), times clock skip..)\r | |
54a942b0 | 26 | static int CmdHelp(const char *Cmd);\r |
27 | \r | |
28 | \r | |
29 | int CmdReadBlk(const char *Cmd)\r | |
30 | {\r | |
f38a1528 | 31 | int Block = -1;\r |
b44e5233 | 32 | sscanf(Cmd, "%d", &Block);\r |
54a942b0 | 33 | \r |
f38a1528 | 34 | if ((Block > 7) | (Block < 0)) {\r |
b44e5233 | 35 | PrintAndLog("Block must be between 0 and 7");\r |
36 | return 1;\r | |
37 | } \r | |
54a942b0 | 38 | \r |
72e930ef | 39 | UsbCommand c;\r |
b44e5233 | 40 | c.cmd = CMD_T55XX_READ_BLOCK;\r |
f38a1528 | 41 | c.d.asBytes[0] = 0x00;\r |
b44e5233 | 42 | c.arg[0] = 0;\r |
43 | c.arg[1] = Block;\r | |
44 | c.arg[2] = 0;\r | |
45 | SendCommand(&c);\r | |
f38a1528 | 46 | WaitForResponse(CMD_ACK, NULL);\r |
47 | \r | |
081151ea | 48 | // uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r |
f38a1528 | 49 | \r |
081151ea | 50 | // GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,3560); //3560 -- should be offset..\r |
51 | // WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r | |
52 | \r | |
53 | // for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r | |
54 | // GraphBuffer[j] = (int)data[j];\r | |
55 | // }\r | |
56 | // GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
57 | CmdSamples("12000");\r | |
c2d25819 | 58 | ManchesterDemod(Block);\r |
081151ea | 59 | // RepaintGraphWindow();\r |
54a942b0 | 60 | return 0;\r |
61 | }\r | |
62 | \r | |
63 | int CmdReadBlkPWD(const char *Cmd)\r | |
64 | {\r | |
f38a1528 | 65 | int Block = -1; //default to invalid block\r |
b44e5233 | 66 | int Password = 0xFFFFFFFF; //default to blank Block 7\r |
67 | UsbCommand c;\r | |
54a942b0 | 68 | \r |
b44e5233 | 69 | sscanf(Cmd, "%d %x", &Block, &Password);\r |
54a942b0 | 70 | \r |
f38a1528 | 71 | if ((Block > 7) | (Block < 0)) {\r |
b44e5233 | 72 | PrintAndLog("Block must be between 0 and 7");\r |
73 | return 1;\r | |
74 | } \r | |
54a942b0 | 75 | \r |
f38a1528 | 76 | PrintAndLog("Reading page 0 block %d pwd %08X", Block, Password);\r |
54a942b0 | 77 | \r |
b44e5233 | 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 | |
f38a1528 | 84 | WaitForResponse(CMD_ACK, NULL);\r |
85 | \r | |
f6c18637 | 86 | uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r |
f38a1528 | 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 | |
081151ea | 92 | GraphBuffer[j] = ((int)data[j]);\r |
f38a1528 | 93 | }\r |
94 | GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
c2d25819 | 95 | ManchesterDemod(Block); \r |
f6c18637 | 96 | RepaintGraphWindow();\r |
54a942b0 | 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 | |
fbceacc5 | 151 | char cmdp = param_getchar(Cmd, 0);\r |
f38a1528 | 152 | \r |
fbceacc5 | 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 | |
081151ea | 157 | PrintAndLog(" sample: lf t55xx trace");\r |
158 | PrintAndLog(" sample: lf t55xx trace 1");\r | |
fbceacc5 | 159 | return 0;\r |
160 | }\r | |
f38a1528 | 161 | \r |
fbceacc5 | 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 | |
f38a1528 | 166 | \r |
fbceacc5 | 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 | |
f38a1528 | 176 | }\r |
f38a1528 | 177 | \r |
f6c18637 | 178 | uint8_t bits[1000] = {0x00};\r |
179 | uint8_t * bitstream = bits;\r | |
f38a1528 | 180 | \r |
f6c18637 | 181 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);\r |
182 | RepaintGraphWindow();\r | |
b44e5233 | 183 | \r |
f6c18637 | 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 | |
77376577 | 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 | |
f6c18637 | 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 | |
77376577 | 207 | PrintAndLog(" Lot ID : %d", lotid );\r |
f6c18637 | 208 | PrintAndLog(" Wafer number : %d", wafer);\r |
209 | PrintAndLog(" Die Number : %d", dw);\r | |
210 | PrintAndLog("-------------------------------------------------------------");\r | |
77376577 | 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 | |
f6c18637 | 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 | |
77376577 | 224 | 31-32 LOT ID\r |
f6c18637 | 225 | \r |
226 | TRACE - BLOCK 1\r | |
77376577 | 227 | 1-12 LOT ID \r |
f6c18637 | 228 | 13-17 Wafer number\r |
229 | 18-32 DW, die number sequential\r | |
230 | */\r | |
231 | \r | |
232 | return 0;\r | |
233 | }\r | |
f38a1528 | 234 | \r |
f6c18637 | 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 | |
fbceacc5 | 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 | |
081151ea | 247 | PrintAndLog(" sample: lf t55xx info");\r |
248 | PrintAndLog(" sample: lf t55xx info 1");\r | |
fbceacc5 | 249 | return 0;\r |
250 | }\r | |
251 | \r | |
252 | if ( strlen(Cmd)==0){\r | |
253 | CmdReadBlk("0");\r | |
081151ea | 254 | } \r |
fbceacc5 | 255 | \r |
f6c18637 | 256 | uint8_t bits[1000] = {0x00};\r |
b44e5233 | 257 | uint8_t * bitstream = bits;\r |
f38a1528 | 258 | \r |
b44e5233 | 259 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream);\r |
f6c18637 | 260 | \r |
261 | uint8_t si = 5;\r | |
77376577 | 262 | uint32_t bl0 = PackBits(si, 32, bitstream);\r |
f6c18637 | 263 | \r |
77376577 | 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 | |
f6c18637 | 267 | uint32_t extend = PackBits(si, 1, bitstream); si += 1;\r |
268 | uint32_t datamodulation = PackBits(si, 5, bitstream); si += 5;\r | |
77376577 | 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 | |
f6c18637 | 272 | uint32_t maxblk = PackBits(si, 3, bitstream); si += 3;\r |
77376577 | 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 | |
b44e5233 | 278 | \r |
f6c18637 | 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 | |
77376577 | 297 | PrintAndLog(" Raw Data - Page 0");\r |
298 | PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bitstream+5,32) );\r | |
f6c18637 | 299 | PrintAndLog("-------------------------------------------------------------");\r |
300 | \r | |
301 | return 0;\r | |
302 | }\r | |
303 | \r | |
77376577 | 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 | |
149aeada | 309 | bool hasPwd = ( strlen(Cmd) > 0);\r |
310 | \r | |
311 | if ( cmdp == 'h' || cmdp == 'H') {\r | |
77376577 | 312 | PrintAndLog("Usage: lf t55xx dump <password>");\r |
313 | PrintAndLog(" sample: lf t55xx dump FFFFFFFF");\r | |
314 | return 0;\r | |
315 | }\r | |
77376577 | 316 | \r |
317 | if ( hasPwd ){\r | |
318 | if (param_gethex(Cmd, 0, pwd, 4)) {\r | |
319 | PrintAndLog("password must include 4 HEX symbols");\r | |
320 | return 0;\r | |
321 | }\r | |
322 | }\r | |
323 | \r | |
77376577 | 324 | for ( int i = 0; i <8; ++i){\r |
149aeada | 325 | memset(s,0,sizeof(s));\r |
77376577 | 326 | if ( hasPwd ) {\r |
149aeada | 327 | sprintf(s,"%d %s", i, sprint_hex(pwd,4));\r |
77376577 | 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 | |
7bd30f12 | 337 | int CmdIceFsk(const char *Cmd){\r |
7bd30f12 | 338 | iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);\r |
7bd30f12 | 339 | RepaintGraphWindow();\r |
340 | return 0;\r | |
341 | }\r | |
fbceacc5 | 342 | int CmdIceManchester(const char *Cmd){\r |
72e930ef | 343 | ManchesterDemod( -1);\r |
344 | return 0;\r | |
345 | }\r | |
346 | int ManchesterDemod(int block){\r | |
fbceacc5 | 347 | \r |
348 | int blockNum = -1;\r | |
081151ea | 349 | uint8_t sizebyte = 32;\r |
350 | uint8_t offset = 5;\r | |
fbceacc5 | 351 | uint32_t blockData;\r |
352 | uint8_t bits[1000] = {0x00};\r | |
353 | uint8_t * bitstream = bits;\r | |
354 | \r | |
355 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream); \r | |
081151ea | 356 | blockData = PackBits(offset, sizebyte, bitstream);\r |
72e930ef | 357 | \r |
081151ea | 358 | if ( blockNum < 0)\r |
359 | PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
360 | else\r | |
361 | PrintAndLog(" Block %d : 0x%08X %s", blockNum, blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
362 | \r | |
fbceacc5 | 363 | return 0;\r |
364 | } \r | |
7bd30f12 | 365 | \r |
f6c18637 | 366 | char * GetBitRateStr(uint32_t id){\r |
367 | static char buf[40];\r | |
368 | char *retStr = buf;\r | |
369 | switch (id){\r | |
370 | case 0: \r | |
371 | sprintf(retStr,"%d - RF/8",id);\r | |
372 | break;\r | |
373 | case 1:\r | |
374 | sprintf(retStr,"%d - RF/16",id);\r | |
375 | break;\r | |
376 | case 2: \r | |
377 | sprintf(retStr,"%d - RF/32",id);\r | |
378 | break;\r | |
379 | case 3:\r | |
380 | sprintf(retStr,"%d - RF/40",id);\r | |
381 | break;\r | |
382 | case 4:\r | |
383 | sprintf(retStr,"%d - RF/50",id);\r | |
384 | break;\r | |
385 | case 5:\r | |
386 | sprintf(retStr,"%d - RF/64",id);\r | |
387 | break;\r | |
388 | case 6:\r | |
389 | sprintf(retStr,"%d - RF/100",id);\r | |
390 | break;\r | |
391 | case 7:\r | |
392 | sprintf(retStr,"%d - RF/128",id);\r | |
393 | break;\r | |
394 | default:\r | |
395 | sprintf(retStr,"%d - (Unknown)",id);\r | |
396 | break;\r | |
397 | }\r | |
398 | \r | |
399 | return buf;\r | |
400 | }\r | |
401 | \r | |
f6c18637 | 402 | char * GetSaferStr(uint32_t id){\r |
403 | static char buf[40];\r | |
404 | char *retStr = buf;\r | |
405 | \r | |
406 | sprintf(retStr,"%d",id);\r | |
407 | if (id == 6) {\r | |
408 | sprintf(retStr,"%d - pasdwd",id);\r | |
409 | }\r | |
410 | if (id == 9 ){\r | |
411 | sprintf(retStr,"%d - testmode ",id);\r | |
412 | }\r | |
413 | \r | |
414 | return buf;\r | |
415 | }\r | |
416 | char * GetModulationStr( uint32_t id){\r | |
417 | static char buf[40];\r | |
418 | char *retStr = buf;\r | |
419 | \r | |
420 | switch (id){\r | |
421 | case 0: \r | |
7bd30f12 | 422 | sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);\r |
f6c18637 | 423 | break;\r |
424 | case 1:\r | |
425 | sprintf(retStr,"%d - PSK 1 phase change when input changes",id);\r | |
426 | break;\r | |
427 | case 2: \r | |
428 | sprintf(retStr,"%d - PSK 2 phase change on bitclk if input high",id);\r | |
429 | break;\r | |
430 | case 3:\r | |
431 | sprintf(retStr,"%d - PSK 3 phase change on rising edge of input",id);\r | |
432 | break;\r | |
433 | case 4:\r | |
434 | sprintf(retStr,"%d - FSK 1 RF/8 RF/5",id);\r | |
435 | break;\r | |
436 | case 5:\r | |
437 | sprintf(retStr,"%d - FSK 2 RF/8 RF/10",id);\r | |
438 | break;\r | |
439 | case 6:\r | |
440 | sprintf(retStr,"%d - FSK 1a RF/5 RF/8",id);\r | |
441 | break;\r | |
442 | case 7:\r | |
443 | sprintf(retStr,"%d - FSK 2a RF/10 RF/8",id);\r | |
444 | break;\r | |
445 | case 8:\r | |
446 | sprintf(retStr,"%d - Manschester",id);\r | |
447 | break;\r | |
448 | case 16:\r | |
449 | sprintf(retStr,"%d - Biphase",id);\r | |
450 | break;\r | |
451 | case 17:\r | |
452 | sprintf(retStr,"%d - Reserved",id);\r | |
453 | break;\r | |
454 | default:\r | |
455 | sprintf(retStr,"0x%02X (Unknown)",id);\r | |
456 | break;\r | |
457 | }\r | |
458 | return buf;\r | |
459 | }\r | |
460 | \r | |
461 | \r | |
462 | uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){\r | |
463 | \r | |
464 | int i = start;\r | |
465 | int j = len-1;\r | |
466 | uint32_t tmp = 0;\r | |
467 | for (; j >= 0; --j, ++i){\r | |
468 | tmp |= bits[i] << j;\r | |
469 | }\r | |
470 | return tmp;\r | |
54a942b0 | 471 | }\r |
472 | \r | |
473 | static command_t CommandTable[] =\r | |
474 | {\r | |
b44e5233 | 475 | {"help", CmdHelp, 1, "This help"},\r |
7bd30f12 | 476 | {"rd", CmdReadBlk, 0, "<block> -- Read T55xx block data (page 0)"},\r |
c2d25819 | 477 | {"rdpwd", CmdReadBlkPWD, 0, "<block> <password> -- Read T55xx block data with password mode"},\r |
7bd30f12 | 478 | {"wr", CmdWriteBlk, 0, "<data> <block> -- Write T55xx block data (page 0)"},\r |
c2d25819 | 479 | {"wrpwd", CmdWriteBlkPWD, 0, "<data> <block> <password> -- Write T55xx block data with password"},\r |
fbceacc5 | 480 | {"trace", CmdReadTrace, 0, "[1] Read T55xx traceability data (page 1 / blk 0-1) "},\r |
481 | {"info", CmdInfo, 0, "[1] Read T55xx configuration data (page0 /blk 0)"},\r | |
7bd30f12 | 482 | {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. optional with password"},\r |
483 | {"fsk", CmdIceFsk, 0, "FSK demod"},\r | |
72e930ef | 484 | {"man", CmdIceManchester, 0, "Manchester demod (with SST)"},\r |
54a942b0 | 485 | {NULL, NULL, 0, NULL}\r |
486 | };\r | |
487 | \r | |
488 | int CmdLFT55XX(const char *Cmd)\r | |
489 | {\r | |
490 | CmdsParse(CommandTable, Cmd);\r | |
491 | return 0;\r | |
492 | }\r | |
493 | \r | |
494 | int CmdHelp(const char *Cmd)\r | |
495 | {\r | |
496 | CmdsHelp(CommandTable);\r | |
497 | return 0;\r | |
498 | }\r |