]> git.zerfleddert.de Git - proxmark3-svn/blame - client/cmdhf.c
hf search - prelim - re-use hf mfu GetTagType...
[proxmark3-svn] / client / cmdhf.c
CommitLineData
a553f267 1//-----------------------------------------------------------------------------
2// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
3//
4// This code is licensed to you under the terms of the GNU GPL, version 2 or,
5// at your option, any later version. See the LICENSE.txt file for the text of
6// the license.
7//-----------------------------------------------------------------------------
8// High frequency commands
9//-----------------------------------------------------------------------------
10
7fe9b0b7 11#include <stdio.h>
4c3de57a 12#include <string.h>
902cb3c0 13#include "proxmark3.h"
7fe9b0b7 14#include "graph.h"
15#include "ui.h"
16#include "cmdparser.h"
17#include "cmdhf.h"
18#include "cmdhf14a.h"
19#include "cmdhf14b.h"
20#include "cmdhf15.h"
5acd09bd 21#include "cmdhfepa.h"
7fe9b0b7 22#include "cmdhflegic.h"
cee5a30d 23#include "cmdhficlass.h"
9ca155ba 24#include "cmdhfmf.h"
5ee70129 25#include "cmdhfmfu.h"
b67f7ec3 26#include "protocols.h"
7fe9b0b7 27
28static int CmdHelp(const char *Cmd);
29
30int CmdHFTune(const char *Cmd)
31{
32 UsbCommand c={CMD_MEASURE_ANTENNA_TUNING_HF};
33 SendCommand(&c);
34 return 0;
35}
4c3de57a 36
4c3de57a
MHS
37
38void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
39{
40 switch(cmd[0])
41 {
41fdd0f0
MHS
42 case ISO14443A_CMD_WUPA: snprintf(exp,size,"WUPA"); break;
43 case ISO14443A_CMD_ANTICOLL_OR_SELECT:{
4df54240
MHS
44 // 93 20 = Anticollision (usage: 9320 - answer: 4bytes UID+1byte UID-bytes-xor)
45 // 93 70 = Select (usage: 9370+5bytes 9320 answer - answer: 1byte SAK)
383608a6 46 if(cmd[1] == 0x70)
4c3de57a
MHS
47 {
48 snprintf(exp,size,"SELECT_UID"); break;
49 }else
50 {
4df54240
MHS
51 snprintf(exp,size,"ANTICOLL"); break;
52 }
53 }
41fdd0f0 54 case ISO14443A_CMD_ANTICOLL_OR_SELECT_2:{
4df54240
MHS
55 //95 20 = Anticollision of cascade level2
56 //95 70 = Select of cascade level2
57 if(cmd[2] == 0x70)
58 {
59 snprintf(exp,size,"SELECT_UID-2"); break;
60 }else
61 {
62 snprintf(exp,size,"ANTICOLL-2"); break;
4c3de57a
MHS
63 }
64 }
16a95d76 65 case ISO14443A_CMD_REQA: snprintf(exp,size,"REQA"); break;
66 case ISO14443A_CMD_READBLOCK: snprintf(exp,size,"READBLOCK(%d)",cmd[1]); break;
67 case ISO14443A_CMD_WRITEBLOCK: snprintf(exp,size,"WRITEBLOCK(%d)",cmd[1]); break;
68 case ISO14443A_CMD_HALT: snprintf(exp,size,"HALT"); break;
69 case ISO14443A_CMD_RATS: snprintf(exp,size,"RATS"); break;
70 case MIFARE_CMD_INC: snprintf(exp,size,"INC(%d)",cmd[1]); break;
71 case MIFARE_CMD_DEC: snprintf(exp,size,"DEC(%d)",cmd[1]); break;
72 case MIFARE_CMD_RESTORE: snprintf(exp,size,"RESTORE(%d)",cmd[1]); break;
73 case MIFARE_CMD_TRANSFER: snprintf(exp,size,"TRANSFER(%d)",cmd[1]); break;
75377d29 74 case MIFARE_AUTH_KEYA:{
75 if ( cmdsize > 3)
76 snprintf(exp,size,"AUTH-A(%d)",cmd[1]);
77 else
78 // case MIFARE_ULEV1_VERSION : both 0x60.
79 snprintf(exp,size,"EV1 VERSION");
80 break;
81 }
16a95d76 82 case MIFARE_AUTH_KEYB: snprintf(exp,size,"AUTH-B(%d)",cmd[1]); break;
83 case MIFARE_MAGICWUPC1: snprintf(exp,size,"MAGIC WUPC1"); break;
84 case MIFARE_MAGICWUPC2: snprintf(exp,size,"MAGIC WUPC2"); break;
85 case MIFARE_MAGICWIPEC: snprintf(exp,size,"MAGIC WIPEC"); break;
75377d29 86 case MIFARE_ULC_AUTH_1: snprintf(exp,size,"AUTH "); break;
87 case MIFARE_ULC_AUTH_2: snprintf(exp,size,"AUTH_ANSW"); break;
88 case MIFARE_ULEV1_AUTH: snprintf(exp,size,"PWD-AUTH"); break;
89 case MIFARE_ULEV1_FASTREAD:{
90 if ( cmdsize >=3 && cmd[2] < 0x21)
91 snprintf(exp,size,"READ RANGE (%d-%d)",cmd[1],cmd[2]);
92 else
93 snprintf(exp,size,"?");
94 break;
95 }
c585a5cf 96 case MIFARE_ULC_WRITE:{
75377d29 97 if ( cmd[1] < 0x21 )
98 snprintf(exp,size,"WRITEBLOCK(%d)",cmd[1]);
99 else
100 snprintf(exp,size,"?");
101 break;
102 }
103 case MIFARE_ULEV1_READ_CNT:{
104 if ( cmd[1] < 5 )
105 snprintf(exp,size,"READ CNT(%d)",cmd[1]);
106 else
107 snprintf(exp,size,"?");
108 break;
109 }
110 case MIFARE_ULEV1_INCR_CNT:{
111 if ( cmd[1] < 5 )
112 snprintf(exp,size,"INCR(%d)",cmd[1]);
113 else
114 snprintf(exp,size,"?");
115 break;
116 }
117 case MIFARE_ULEV1_READSIG: snprintf(exp,size,"READ_SIG"); break;
118 case MIFARE_ULEV1_CHECKTEAR: snprintf(exp,size,"CHK_TEARING(%d)",cmd[1]); break;
119 case MIFARE_ULEV1_VCSL: snprintf(exp,size,"VCSL"); break;
16a95d76 120 default: snprintf(exp,size,"?"); break;
4c3de57a
MHS
121 }
122 return;
123}
124
125void annotateIclass(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
126{
4c3de57a
MHS
127 switch(cmd[0])
128 {
337818f7 129 case ICLASS_CMD_ACTALL: snprintf(exp,size,"ACTALL"); break;
4df54240
MHS
130 case ICLASS_CMD_READ_OR_IDENTIFY:{
131 if(cmdsize > 1){
132 snprintf(exp,size,"READ(%d)",cmd[1]);
133 }else{
134 snprintf(exp,size,"IDENTIFY");
135 }
136 break;
137 }
337818f7 138 case ICLASS_CMD_SELECT: snprintf(exp,size,"SELECT"); break;
49726b40
MHS
139 case ICLASS_CMD_PAGESEL: snprintf(exp,size,"PAGESEL(%d)", cmd[1]); break;
140 case ICLASS_CMD_READCHECK_KC:snprintf(exp,size,"READCHECK[Kc](%d)", cmd[1]); break;
141 case ICLASS_CMD_READCHECK_KD:snprintf(exp,size,"READCHECK[Kd](%d)", cmd[1]); break;
337818f7 142 case ICLASS_CMD_CHECK: snprintf(exp,size,"CHECK"); break;
49726b40 143 case ICLASS_CMD_DETECT: snprintf(exp,size,"DETECT"); break;
337818f7 144 case ICLASS_CMD_HALT: snprintf(exp,size,"HALT"); break;
49726b40
MHS
145 case ICLASS_CMD_UPDATE: snprintf(exp,size,"UPDATE(%d)",cmd[1]); break;
146 case ICLASS_CMD_ACT: snprintf(exp,size,"ACT"); break;
147 case ICLASS_CMD_READ4: snprintf(exp,size,"READ4(%d)",cmd[1]); break;
337818f7 148 default: snprintf(exp,size,"?"); break;
4c3de57a
MHS
149 }
150 return;
151}
152
4df54240
MHS
153void annotateIso15693(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
154{
155
156 if(cmd[0] == 0x26)
157 {
158 switch(cmd[1]){
159 case ISO15693_INVENTORY :snprintf(exp, size, "INVENTORY");break;
160 case ISO15693_STAYQUIET :snprintf(exp, size, "STAY_QUIET");break;
161 default: snprintf(exp,size,"?"); break;
4c3de57a 162
4df54240
MHS
163 }
164 }else if(cmd[0] == 0x02)
165 {
166 switch(cmd[1])
167 {
168 case ISO15693_READBLOCK :snprintf(exp, size, "READBLOCK");break;
169 case ISO15693_WRITEBLOCK :snprintf(exp, size, "WRITEBLOCK");break;
170 case ISO15693_LOCKBLOCK :snprintf(exp, size, "LOCKBLOCK");break;
171 case ISO15693_READ_MULTI_BLOCK :snprintf(exp, size, "READ_MULTI_BLOCK");break;
172 case ISO15693_SELECT :snprintf(exp, size, "SELECT");break;
173 case ISO15693_RESET_TO_READY :snprintf(exp, size, "RESET_TO_READY");break;
174 case ISO15693_WRITE_AFI :snprintf(exp, size, "WRITE_AFI");break;
175 case ISO15693_LOCK_AFI :snprintf(exp, size, "LOCK_AFI");break;
176 case ISO15693_WRITE_DSFID :snprintf(exp, size, "WRITE_DSFID");break;
177 case ISO15693_LOCK_DSFID :snprintf(exp, size, "LOCK_DSFID");break;
178 case ISO15693_GET_SYSTEM_INFO :snprintf(exp, size, "GET_SYSTEM_INFO");break;
179 case ISO15693_READ_MULTI_SECSTATUS :snprintf(exp, size, "READ_MULTI_SECSTATUS");break;
41fdd0f0 180 default: snprintf(exp,size,"?"); break;
4df54240
MHS
181 }
182 }
183}
08e8317c
MHS
184
185/**
18606 00 = INITIATE
1870E xx = SELECT ID (xx = Chip-ID)
1880B = Get UID
18908 yy = Read Block (yy = block number)
19009 yy dd dd dd dd = Write Block (yy = block number; dd dd dd dd = data to be written)
1910C = Reset to Inventory
1920F = Completion
1930A 11 22 33 44 55 66 = Authenticate (11 22 33 44 55 66 = data to authenticate)
194**/
195
41fdd0f0
MHS
196void annotateIso14443b(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
197{
198 switch(cmd[0]){
199 case ISO14443B_REQB : snprintf(exp,size,"REQB");break;
200 case ISO14443B_ATTRIB : snprintf(exp,size,"ATTRIB");break;
201 case ISO14443B_HALT : snprintf(exp,size,"HALT");break;
08e8317c
MHS
202 case ISO14443B_INITIATE : snprintf(exp,size,"INITIATE");break;
203 case ISO14443B_SELECT : snprintf(exp,size,"SELECT(%d)",cmd[1]);break;
204 case ISO14443B_GET_UID : snprintf(exp,size,"GET UID");break;
205 case ISO14443B_READ_BLK : snprintf(exp,size,"READ_BLK(%d)", cmd[1]);break;
206 case ISO14443B_WRITE_BLK : snprintf(exp,size,"WRITE_BLK(%d)",cmd[1]);break;
207 case ISO14443B_RESET : snprintf(exp,size,"RESET");break;
208 case ISO14443B_COMPLETION : snprintf(exp,size,"COMPLETION");break;
209 case ISO14443B_AUTHENTICATE : snprintf(exp,size,"AUTHENTICATE");break;
210 default : snprintf(exp,size ,"?");break;
41fdd0f0
MHS
211 }
212
213}
214
215/**
216 * @brief iso14443B_CRC_Ok Checks CRC in command or response
217 * @param isResponse
218 * @param data
219 * @param len
220 * @return 0 : CRC-command, CRC not ok
221 * 1 : CRC-command, CRC ok
222 * 2 : Not crc-command
223 */
224
225uint8_t iso14443B_CRC_check(bool isResponse, uint8_t* data, uint8_t len)
226{
227 uint8_t b1,b2;
228
229 if(len <= 2) return 2;
230
231 ComputeCrc14443(CRC_14443_B, data, len-2, &b1, &b2);
232 if(b1 != data[len-2] || b2 != data[len-1]) {
233 return 0;
234 }
235 return 1;
236}
237
49726b40
MHS
238/**
239 * @brief iclass_CRC_Ok Checks CRC in command or response
240 * @param isResponse
241 * @param data
242 * @param len
243 * @return 0 : CRC-command, CRC not ok
244 * 1 : CRC-command, CRC ok
245 * 2 : Not crc-command
246 */
41fdd0f0 247uint8_t iclass_CRC_check(bool isResponse, uint8_t* data, uint8_t len)
49726b40
MHS
248{
249 if(len < 4) return 2;//CRC commands (and responses) are all at least 4 bytes
250
251 uint8_t b1, b2;
252
253 if(!isResponse)//Commands to tag
254 {
255 /**
256 These commands should have CRC. Total length leftmost
257 4 READ
258 4 READ4
259 12 UPDATE - unsecured, ends with CRC16
260 14 UPDATE - secured, ends with signature instead
261 4 PAGESEL
262 **/
263 if(len == 4 || len == 12)//Covers three of them
264 {
265 //Don't include the command byte
266 ComputeCrc14443(CRC_ICLASS, (data+1), len-3, &b1, &b2);
267 return b1 == data[len -2] && b2 == data[len-1];
268 }
269 return 2;
270 }else{
271 /**
272 These tag responses should have CRC. Total length leftmost
273
274 10 READ data[8] crc[2]
275 34 READ4 data[32]crc[2]
276 10 UPDATE data[8] crc[2]
277 10 SELECT csn[8] crc[2]
278 10 IDENTIFY asnb[8] crc[2]
279 10 PAGESEL block1[8] crc[2]
280 10 DETECT csn[8] crc[2]
281
282 These should not
283
284 4 CHECK chip_response[4]
285 8 READCHECK data[8]
286 1 ACTALL sof[1]
287 1 ACT sof[1]
288
289 In conclusion, without looking at the command; any response
290 of length 10 or 34 should have CRC
291 **/
292 if(len != 10 && len != 34) return true;
293
294 ComputeCrc14443(CRC_ICLASS, data, len-2, &b1, &b2);
295 return b1 == data[len -2] && b2 == data[len-1];
296 }
297}
4c3de57a 298
f71f4deb 299uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol, bool showWaitCycles)
4c3de57a
MHS
300{
301 bool isResponse;
f71f4deb 302 uint16_t duration, data_len, parity_len;
4c3de57a
MHS
303
304 uint32_t timestamp, first_timestamp, EndOfTransmissionTimestamp;
305 char explanation[30] = {0};
306
f71f4deb 307 if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
308
4c3de57a
MHS
309 first_timestamp = *((uint32_t *)(trace));
310 timestamp = *((uint32_t *)(trace + tracepos));
4c3de57a
MHS
311
312 tracepos += 4;
313 duration = *((uint16_t *)(trace + tracepos));
314 tracepos += 2;
315 data_len = *((uint16_t *)(trace + tracepos));
316 tracepos += 2;
317
318 if (data_len & 0x8000) {
319 data_len &= 0x7fff;
320 isResponse = true;
321 } else {
322 isResponse = false;
323 }
324 parity_len = (data_len-1)/8 + 1;
325
f71f4deb 326 if (tracepos + data_len + parity_len > traceLen) {
327 return traceLen;
4c3de57a 328 }
4c3de57a
MHS
329 uint8_t *frame = trace + tracepos;
330 tracepos += data_len;
331 uint8_t *parityBytes = trace + tracepos;
332 tracepos += parity_len;
333
27eabcdc
MHS
334 //Check the CRC status
335 uint8_t crcStatus = 2;
336
337 if (data_len > 2) {
338 uint8_t b1, b2;
339 if(protocol == ICLASS)
340 {
341 crcStatus = iclass_CRC_check(isResponse, frame, data_len);
342
343 }else if (protocol == ISO_14443B)
344 {
345 crcStatus = iso14443B_CRC_check(isResponse, frame, data_len);
346 }
347 else if (protocol == ISO_14443A){//Iso 14443a
348
349 ComputeCrc14443(CRC_14443_A, frame, data_len-2, &b1, &b2);
350
351 if (b1 != frame[data_len-2] || b2 != frame[data_len-1]) {
352 if(!(isResponse & (data_len < 6)))
353 {
354 crcStatus = 0;
355 }
356 }
357 }
358 }
359 //0 CRC-command, CRC not ok
360 //1 CRC-command, CRC ok
361 //2 Not crc-command
9e8255d4 362
4c3de57a 363 //--- Draw the data column
9e8255d4 364 //char line[16][110];
4c3de57a 365 char line[16][110];
9e8255d4
MHS
366
367 for (int j = 0; j < data_len && j/16 < 16; j++) {
368
4c3de57a
MHS
369 int oddparity = 0x01;
370 int k;
371
372 for (k=0 ; k<8 ; k++) {
373 oddparity ^= (((frame[j] & 0xFF) >> k) & 0x01);
374 }
4c3de57a 375 uint8_t parityBits = parityBytes[j>>3];
4c3de57a 376 if (isResponse && (oddparity != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
9e8255d4
MHS
377 snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
378
4c3de57a 379 } else {
8b9393d3 380 snprintf(line[j/16]+(( j % 16) * 4),110, "%02x ", frame[j]);
9e8255d4 381 }
27eabcdc
MHS
382
383 }
384 if(crcStatus == 1)
385 {//CRC-command
386 char *pos1 = line[(data_len-2)/16]+(((data_len-2) % 16) * 4)-1;
387 (*pos1) = '[';
388 char *pos2 = line[(data_len)/16]+(((data_len) % 16) * 4)-2;
389 (*pos2) = ']';
9e8255d4
MHS
390 }
391 if(data_len == 0)
392 {
393 if(data_len == 0){
394 sprintf(line[0],"<empty trace - possible error>");
4c3de57a
MHS
395 }
396 }
397 //--- Draw the CRC column
4c3de57a 398
49726b40 399 char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
4c3de57a
MHS
400
401 EndOfTransmissionTimestamp = timestamp + duration;
402
403 if(!isResponse)
404 {
41fdd0f0 405 if(protocol == ICLASS)
79bf1ad2 406 annotateIclass(explanation,sizeof(explanation),frame,data_len);
41fdd0f0 407 else if (protocol == ISO_14443A)
79bf1ad2 408 annotateIso14443a(explanation,sizeof(explanation),frame,data_len);
41fdd0f0
MHS
409 else if(protocol == ISO_14443B)
410 annotateIso14443b(explanation,sizeof(explanation),frame,data_len);
4c3de57a
MHS
411 }
412
9e8255d4
MHS
413 int num_lines = MIN((data_len - 1)/16 + 1, 16);
414 for (int j = 0; j < num_lines ; j++) {
4c3de57a
MHS
415 if (j == 0) {
416 PrintAndLog(" %9d | %9d | %s | %-64s| %s| %s",
417 (timestamp - first_timestamp),
418 (EndOfTransmissionTimestamp - first_timestamp),
419 (isResponse ? "Tag" : "Rdr"),
420 line[j],
421 (j == num_lines-1) ? crc : " ",
422 (j == num_lines-1) ? explanation : "");
423 } else {
424 PrintAndLog(" | | | %-64s| %s| %s",
425 line[j],
426 (j == num_lines-1)?crc:" ",
427 (j == num_lines-1) ? explanation : "");
428 }
429 }
430
f71f4deb 431 if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
432
4c3de57a
MHS
433 bool next_isResponse = *((uint16_t *)(trace + tracepos + 6)) & 0x8000;
434
435 if (showWaitCycles && !isResponse && next_isResponse) {
436 uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
437 if (next_timestamp != 0x44444444) {
438 PrintAndLog(" %9d | %9d | %s | fdt (Frame Delay Time): %d",
439 (EndOfTransmissionTimestamp - first_timestamp),
440 (next_timestamp - first_timestamp),
441 " ",
442 (next_timestamp - EndOfTransmissionTimestamp));
443 }
444 }
f71f4deb 445
4c3de57a
MHS
446 return tracepos;
447}
448
f71f4deb 449
4c3de57a
MHS
450int CmdHFList(const char *Cmd)
451{
452 bool showWaitCycles = false;
453 char type[40] = {0};
454 int tlen = param_getstr(Cmd,0,type);
455 char param = param_getchar(Cmd, 1);
456 bool errors = false;
b689b842 457 uint8_t protocol = 0;
4c3de57a 458 //Validate params
b689b842 459 if(tlen == 0)
4c3de57a
MHS
460 {
461 errors = true;
462 }
463 if(param == 'h' || (param !=0 && param != 'f'))
464 {
465 errors = true;
466 }
b689b842
MHS
467 if(!errors)
468 {
469 if(strcmp(type, "iclass") == 0)
470 {
471 protocol = ICLASS;
472 }else if(strcmp(type, "14a") == 0)
473 {
474 protocol = ISO_14443A;
475 }
476 else if(strcmp(type, "14b") == 0)
477 {
478 protocol = ISO_14443B;
479 }else if(strcmp(type,"raw")== 0)
480 {
481 protocol = -1;//No crc, no annotations
482 }else{
483 errors = true;
484 }
485 }
4c3de57a
MHS
486
487 if (errors) {
488 PrintAndLog("List protocol data in trace buffer.");
92623113
MHS
489 PrintAndLog("Usage: hf list <protocol> [f]");
490 PrintAndLog(" f - show frame delay times as well");
491 PrintAndLog("Supported <protocol> values:");
492 PrintAndLog(" raw - just show raw data without annotations");
337818f7 493 PrintAndLog(" 14a - interpret data as iso14443a communications");
41fdd0f0 494 PrintAndLog(" 14b - interpret data as iso14443b communications");
4c3de57a 495 PrintAndLog(" iclass - interpret data as iclass communications");
4c3de57a
MHS
496 PrintAndLog("");
497 PrintAndLog("example: hf list 14a f");
498 PrintAndLog("example: hf list iclass");
499 return 0;
500 }
b689b842 501
4c3de57a
MHS
502
503 if (param == 'f') {
504 showWaitCycles = true;
505 }
506
507
f71f4deb 508 uint8_t *trace;
4c3de57a 509 uint16_t tracepos = 0;
f71f4deb 510 trace = malloc(USB_CMD_DATA_SIZE);
511
512 // Query for the size of the trace
513 UsbCommand response;
514 GetFromBigBuf(trace, USB_CMD_DATA_SIZE, 0);
515 WaitForResponse(CMD_ACK, &response);
516 uint16_t traceLen = response.arg[2];
517 if (traceLen > USB_CMD_DATA_SIZE) {
518 uint8_t *p = realloc(trace, traceLen);
519 if (p == NULL) {
520 PrintAndLog("Cannot allocate memory for trace");
521 free(trace);
522 return 2;
523 }
524 trace = p;
525 GetFromBigBuf(trace, traceLen, 0);
526 WaitForResponse(CMD_ACK, NULL);
527 }
528
529 PrintAndLog("Recorded Activity (TraceLen = %d bytes)", traceLen);
4c3de57a
MHS
530 PrintAndLog("");
531 PrintAndLog("Start = Start of Start Bit, End = End of last modulation. Src = Source of Transfer");
532 PrintAndLog("iso14443a - All times are in carrier periods (1/13.56Mhz)");
533 PrintAndLog("iClass - Timings are not as accurate");
534 PrintAndLog("");
535 PrintAndLog(" Start | End | Src | Data (! denotes parity error) | CRC | Annotation |");
536 PrintAndLog("-----------|-----------|-----|-----------------------------------------------------------------|-----|--------------------|");
537
f71f4deb 538 while(tracepos < traceLen)
4c3de57a 539 {
f71f4deb 540 tracepos = printTraceLine(tracepos, traceLen, trace, protocol, showWaitCycles);
4c3de57a 541 }
f71f4deb 542
543 free(trace);
4c3de57a
MHS
544 return 0;
545}
546
8ceb6b03 547int CmdHFSearch(const char *Cmd){
548 int ans = 0;
549 ans = CmdHF14AReader(Cmd);
550 if (ans > 0) return ans;
551
552 ans = CmdHF15Reader(Cmd);
553 //if (ans > 0) return ans;
554
555 ans = CmdHF14BRead(Cmd);
556 //if (ans > 0) return ans;
557
558 ans = CmdHFiClassReader(Cmd);
559 //if (ans > 0) return ans;
560 return 0;
561}
7fe9b0b7 562
563static command_t CommandTable[] =
564{
565 {"help", CmdHelp, 1, "This help"},
37239a7c 566 {"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"},
567 {"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"},
568 {"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"},
5acd09bd 569 {"epa", CmdHFEPA, 1, "{ German Identification Card... }"},
8e220a91 570 {"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"},
cee5a30d 571 {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
8ceb6b03 572 {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
573 {"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
c59c3405 574 {"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
8ceb6b03 575 {"list", CmdHFList, 1, "List protocol data in trace buffer"},
576 {"search", CmdHFSearch, 1, "Search for known HF tags"},
4c3de57a 577 {NULL, NULL, 0, NULL}
7fe9b0b7 578};
579
580int CmdHF(const char *Cmd)
581{
582 CmdsParse(CommandTable, Cmd);
583 return 0;
584}
585
586int CmdHelp(const char *Cmd)
587{
588 CmdsHelp(CommandTable);
589 return 0;
590}
Impressum, Datenschutz