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