]> git.zerfleddert.de Git - proxmark3-svn/blame - client/cmdhf.c
fix warning under linux (#709)
[proxmark3-svn] / client / cmdhf.c
CommitLineData
a553f267 1//-----------------------------------------------------------------------------
2// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
4f131b53 3// Merlok - 2017
a553f267 4//
5// This code is licensed to you under the terms of the GNU GPL, version 2 or,
6// at your option, any later version. See the LICENSE.txt file for the text of
7// the license.
8//-----------------------------------------------------------------------------
9// High frequency commands
10//-----------------------------------------------------------------------------
11
ad939de5 12#include "cmdhf.h"
13
acf0582d 14#include <stdlib.h>
7fe9b0b7 15#include <stdio.h>
4c3de57a 16#include <string.h>
ad939de5 17#include "comms.h"
7cb8516c 18#include "util.h"
7fe9b0b7 19#include "ui.h"
7cb8516c 20#include "iso14443crc.h"
1f065e1d 21#include "parity.h"
7cb8516c 22#include "cmdmain.h"
7fe9b0b7 23#include "cmdparser.h"
7fe9b0b7 24#include "cmdhf14a.h"
25#include "cmdhf14b.h"
26#include "cmdhf15.h"
5acd09bd 27#include "cmdhfepa.h"
7fe9b0b7 28#include "cmdhflegic.h"
cee5a30d 29#include "cmdhficlass.h"
9ca155ba 30#include "cmdhfmf.h"
dc3e2acf 31#include "cmdhfmfp.h"
5ee70129 32#include "cmdhfmfu.h"
05ddb52c 33#include "cmdhftopaz.h"
b67f7ec3 34#include "protocols.h"
3c5fce2b 35#include "emv/cmdemv.h"
4f131b53 36#include "cmdhflist.h"
7fe9b0b7 37
38static int CmdHelp(const char *Cmd);
39
40int CmdHFTune(const char *Cmd)
41{
42 UsbCommand c={CMD_MEASURE_ANTENNA_TUNING_HF};
43 SendCommand(&c);
44 return 0;
45}
4c3de57a 46
ef00343c 47/**
48 * @brief iso14443B_CRC_check Checks CRC in command or response
41fdd0f0
MHS
49 * @param isResponse
50 * @param data
51 * @param len
52 * @return 0 : CRC-command, CRC not ok
53 * 1 : CRC-command, CRC ok
54 * 2 : Not crc-command
55 */
56
57uint8_t iso14443B_CRC_check(bool isResponse, uint8_t* data, uint8_t len)
58{
59 uint8_t b1,b2;
60
61 if(len <= 2) return 2;
62
63 ComputeCrc14443(CRC_14443_B, data, len-2, &b1, &b2);
64 if(b1 != data[len-2] || b2 != data[len-1]) {
ef00343c 65 return 0;
66 } else {
67 return 1;
41fdd0f0 68 }
41fdd0f0
MHS
69}
70
49726b40
MHS
71/**
72 * @brief iclass_CRC_Ok Checks CRC in command or response
73 * @param isResponse
74 * @param data
75 * @param len
76 * @return 0 : CRC-command, CRC not ok
77 * 1 : CRC-command, CRC ok
78 * 2 : Not crc-command
79 */
41fdd0f0 80uint8_t iclass_CRC_check(bool isResponse, uint8_t* data, uint8_t len)
49726b40
MHS
81{
82 if(len < 4) return 2;//CRC commands (and responses) are all at least 4 bytes
83
84 uint8_t b1, b2;
85
86 if(!isResponse)//Commands to tag
87 {
88 /**
89 These commands should have CRC. Total length leftmost
90 4 READ
91 4 READ4
92 12 UPDATE - unsecured, ends with CRC16
93 14 UPDATE - secured, ends with signature instead
94 4 PAGESEL
95 **/
96 if(len == 4 || len == 12)//Covers three of them
97 {
98 //Don't include the command byte
99 ComputeCrc14443(CRC_ICLASS, (data+1), len-3, &b1, &b2);
100 return b1 == data[len -2] && b2 == data[len-1];
101 }
102 return 2;
103 }else{
104 /**
105 These tag responses should have CRC. Total length leftmost
106
107 10 READ data[8] crc[2]
108 34 READ4 data[32]crc[2]
109 10 UPDATE data[8] crc[2]
110 10 SELECT csn[8] crc[2]
111 10 IDENTIFY asnb[8] crc[2]
112 10 PAGESEL block1[8] crc[2]
113 10 DETECT csn[8] crc[2]
114
115 These should not
116
117 4 CHECK chip_response[4]
118 8 READCHECK data[8]
119 1 ACTALL sof[1]
120 1 ACT sof[1]
121
122 In conclusion, without looking at the command; any response
123 of length 10 or 34 should have CRC
124 **/
125 if(len != 10 && len != 34) return true;
126
127 ComputeCrc14443(CRC_ICLASS, data, len-2, &b1, &b2);
128 return b1 == data[len -2] && b2 == data[len-1];
129 }
130}
4c3de57a 131
ee1eadee 132
a8904ebd 133bool is_last_record(uint16_t tracepos, uint8_t *trace, uint16_t traceLen)
4c3de57a 134{
a8904ebd 135 return(tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) >= traceLen);
136}
137
138
139bool next_record_is_response(uint16_t tracepos, uint8_t *trace)
140{
141 uint16_t next_records_datalen = *((uint16_t *)(trace + tracepos + sizeof(uint32_t) + sizeof(uint16_t)));
142
143 return(next_records_datalen & 0x8000);
144}
145
146
ef00343c 147bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, uint16_t *tracepos, uint16_t traceLen, uint8_t *trace, uint8_t *frame, uint8_t *topaz_reader_command, uint16_t *data_len)
a8904ebd 148{
149
48ece4a7 150#define MAX_TOPAZ_READER_CMD_LEN 16
a8904ebd 151
152 uint32_t last_timestamp = timestamp + *duration;
153
ef00343c 154 if ((*data_len != 1) || (frame[0] == TOPAZ_WUPA) || (frame[0] == TOPAZ_REQA)) return false;
4c3de57a 155
ef00343c 156 memcpy(topaz_reader_command, frame, *data_len);
a8904ebd 157
158 while (!is_last_record(*tracepos, trace, traceLen) && !next_record_is_response(*tracepos, trace)) {
159 uint32_t next_timestamp = *((uint32_t *)(trace + *tracepos));
160 *tracepos += sizeof(uint32_t);
ef00343c 161 uint16_t next_duration = *((uint16_t *)(trace + *tracepos));
a8904ebd 162 *tracepos += sizeof(uint16_t);
163 uint16_t next_data_len = *((uint16_t *)(trace + *tracepos)) & 0x7FFF;
164 *tracepos += sizeof(uint16_t);
165 uint8_t *next_frame = (trace + *tracepos);
166 *tracepos += next_data_len;
ef00343c 167 if ((next_data_len == 1) && (*data_len + next_data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
a8904ebd 168 memcpy(topaz_reader_command + *data_len, next_frame, next_data_len);
169 *data_len += next_data_len;
ef00343c 170 last_timestamp = next_timestamp + next_duration;
171 } else {
172 // rewind and exit
173 *tracepos = *tracepos - next_data_len - sizeof(uint16_t) - sizeof(uint16_t) - sizeof(uint32_t);
174 break;
175 }
a8904ebd 176 uint16_t next_parity_len = (next_data_len-1)/8 + 1;
177 *tracepos += next_parity_len;
178 }
179
180 *duration = last_timestamp - timestamp;
ef00343c 181
182 return true;
ee1eadee 183}
184
185
05ddb52c 186uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, uint8_t protocol, bool showWaitCycles, bool markCRCBytes)
4c3de57a
MHS
187{
188 bool isResponse;
a8904ebd 189 uint16_t data_len, parity_len;
190 uint32_t duration;
ee1eadee 191 uint8_t topaz_reader_command[9];
4c3de57a
MHS
192 uint32_t timestamp, first_timestamp, EndOfTransmissionTimestamp;
193 char explanation[30] = {0};
7b215d14
OM
194 uint8_t mfData[32] = {0};
195 size_t mfDataLen = 0;
4c3de57a 196
f71f4deb 197 if (tracepos + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) > traceLen) return traceLen;
198
4c3de57a
MHS
199 first_timestamp = *((uint32_t *)(trace));
200 timestamp = *((uint32_t *)(trace + tracepos));
4c3de57a
MHS
201
202 tracepos += 4;
203 duration = *((uint16_t *)(trace + tracepos));
204 tracepos += 2;
205 data_len = *((uint16_t *)(trace + tracepos));
206 tracepos += 2;
207
208 if (data_len & 0x8000) {
209 data_len &= 0x7fff;
210 isResponse = true;
211 } else {
212 isResponse = false;
213 }
214 parity_len = (data_len-1)/8 + 1;
215
f71f4deb 216 if (tracepos + data_len + parity_len > traceLen) {
217 return traceLen;
4c3de57a 218 }
4c3de57a
MHS
219 uint8_t *frame = trace + tracepos;
220 tracepos += data_len;
221 uint8_t *parityBytes = trace + tracepos;
222 tracepos += parity_len;
223
ee1eadee 224 if (protocol == TOPAZ && !isResponse) {
ef00343c 225 // topaz reader commands come in 1 or 9 separate frames with 7 or 8 Bits each.
ee1eadee 226 // merge them:
ef00343c 227 if (merge_topaz_reader_frames(timestamp, &duration, &tracepos, traceLen, trace, frame, topaz_reader_command, &data_len)) {
228 frame = topaz_reader_command;
229 }
ee1eadee 230 }
231
27eabcdc
MHS
232 //Check the CRC status
233 uint8_t crcStatus = 2;
234
235 if (data_len > 2) {
ee1eadee 236 switch (protocol) {
237 case ICLASS:
238 crcStatus = iclass_CRC_check(isResponse, frame, data_len);
239 break;
240 case ISO_14443B:
ef00343c 241 case TOPAZ:
a8904ebd 242 crcStatus = iso14443B_CRC_check(isResponse, frame, data_len);
ee1eadee 243 break;
4f131b53 244 case PROTO_MIFARE:
6612a5a2 245 crcStatus = mifare_CRC_check(isResponse, frame, data_len);
246 break;
ee1eadee 247 case ISO_14443A:
ef00343c 248 crcStatus = iso14443A_CRC_check(isResponse, frame, data_len);
ee1eadee 249 break;
250 default:
251 break;
27eabcdc
MHS
252 }
253 }
254 //0 CRC-command, CRC not ok
255 //1 CRC-command, CRC ok
256 //2 Not crc-command
9e8255d4 257
4c3de57a 258 //--- Draw the data column
9e8255d4 259 //char line[16][110];
4c3de57a 260 char line[16][110];
9e8255d4
MHS
261
262 for (int j = 0; j < data_len && j/16 < 16; j++) {
263
4c3de57a 264 uint8_t parityBits = parityBytes[j>>3];
1f065e1d 265 if (protocol != ISO_14443B && (isResponse || protocol == ISO_14443A) && (oddparity8(frame[j]) != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
9e8255d4 266 snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
4c3de57a 267 } else {
ef00343c 268 snprintf(line[j/16]+(( j % 16) * 4), 110, " %02x ", frame[j]);
9e8255d4 269 }
27eabcdc
MHS
270
271 }
05ddb52c 272
273 if (markCRCBytes) {
274 if(crcStatus == 0 || crcStatus == 1)
275 {//CRC-command
276 char *pos1 = line[(data_len-2)/16]+(((data_len-2) % 16) * 4);
277 (*pos1) = '[';
278 char *pos2 = line[(data_len)/16]+(((data_len) % 16) * 4);
279 sprintf(pos2, "%c", ']');
280 }
9e8255d4 281 }
05ddb52c 282
9e8255d4
MHS
283 if(data_len == 0)
284 {
285 if(data_len == 0){
286 sprintf(line[0],"<empty trace - possible error>");
4c3de57a
MHS
287 }
288 }
289 //--- Draw the CRC column
4c3de57a 290
49726b40 291 char *crc = (crcStatus == 0 ? "!crc" : (crcStatus == 1 ? " ok " : " "));
4c3de57a
MHS
292
293 EndOfTransmissionTimestamp = timestamp + duration;
294
6612a5a2 295 if (protocol == PROTO_MIFARE)
b957bcd3 296 annotateMifare(explanation, sizeof(explanation), frame, data_len, parityBytes, parity_len, isResponse);
6612a5a2 297
4c3de57a
MHS
298 if(!isResponse)
299 {
ee1eadee 300 switch(protocol) {
301 case ICLASS: annotateIclass(explanation,sizeof(explanation),frame,data_len); break;
302 case ISO_14443A: annotateIso14443a(explanation,sizeof(explanation),frame,data_len); break;
303 case ISO_14443B: annotateIso14443b(explanation,sizeof(explanation),frame,data_len); break;
304 case TOPAZ: annotateTopaz(explanation,sizeof(explanation),frame,data_len); break;
305 default: break;
306 }
4c3de57a
MHS
307 }
308
9e8255d4
MHS
309 int num_lines = MIN((data_len - 1)/16 + 1, 16);
310 for (int j = 0; j < num_lines ; j++) {
4c3de57a 311 if (j == 0) {
48ece4a7 312 PrintAndLog(" %10d | %10d | %s |%-64s | %s| %s",
4c3de57a
MHS
313 (timestamp - first_timestamp),
314 (EndOfTransmissionTimestamp - first_timestamp),
315 (isResponse ? "Tag" : "Rdr"),
316 line[j],
317 (j == num_lines-1) ? crc : " ",
318 (j == num_lines-1) ? explanation : "");
319 } else {
48ece4a7 320 PrintAndLog(" | | |%-64s | %s| %s",
4c3de57a 321 line[j],
ee1eadee 322 (j == num_lines-1) ? crc : " ",
4c3de57a
MHS
323 (j == num_lines-1) ? explanation : "");
324 }
325 }
b957bcd3 326
2d7bdee3 327 if (DecodeMifareData(frame, data_len, parityBytes, isResponse, mfData, &mfDataLen)) {
747885a6
OM
328 memset(explanation, 0x00, sizeof(explanation));
329 if (!isResponse) {
330 explanation[0] = '>';
331 annotateIso14443a(&explanation[1], sizeof(explanation) - 1, mfData, mfDataLen);
332 }
333 uint8_t crcc = iso14443A_CRC_check(isResponse, mfData, mfDataLen);
28ee794f 334 PrintAndLog(" | * | dec |%-64s | %-4s| %s",
7b215d14 335 sprint_hex(mfData, mfDataLen),
747885a6 336 (crcc == 0 ? "!crc" : (crcc == 1 ? " ok " : " ")),
28ee794f 337 (true) ? explanation : "");
7b215d14 338 };
4c3de57a 339
a8904ebd 340 if (is_last_record(tracepos, trace, traceLen)) return traceLen;
f71f4deb 341
a8904ebd 342 if (showWaitCycles && !isResponse && next_record_is_response(tracepos, trace)) {
4c3de57a 343 uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
275d9e61 344 PrintAndLog(" %10d | %10d | %s | fdt (Frame Delay Time): %d",
a8904ebd 345 (EndOfTransmissionTimestamp - first_timestamp),
346 (next_timestamp - first_timestamp),
347 " ",
348 (next_timestamp - EndOfTransmissionTimestamp));
4c3de57a 349 }
f71f4deb 350
4c3de57a
MHS
351 return tracepos;
352}
353
f71f4deb 354
4c3de57a
MHS
355int CmdHFList(const char *Cmd)
356{
43591e64 357 #ifdef WITH_SMARTCARD
358 PrintAndLog("TEST_WITH_SMARTCARD");
359 #endif
360 #ifdef WITH_TEST
361 PrintAndLog("TEST_WITH_TEST");
362 #endif
4c3de57a 363 bool showWaitCycles = false;
05ddb52c 364 bool markCRCBytes = false;
3bcc4d77 365 bool loadFromFile = false;
366 bool saveToFile = false;
367 char param1 = '\0';
368 char param2 = '\0';
369 char param3 = '\0';
4c3de57a 370 char type[40] = {0};
44964fd1 371 char filename[FILE_PATH_SIZE] = {0};
b689b842 372 uint8_t protocol = 0;
3bcc4d77 373
374 // parse command line
375 int tlen = param_getstr(Cmd, 0, type, sizeof(type));
376 if (param_getlength(Cmd, 1) == 1) {
377 param1 = param_getchar(Cmd, 1);
378 } else {
379 param_getstr(Cmd, 1, filename, sizeof(filename));
380 }
381 if (param_getlength(Cmd, 2) == 1) {
382 param2 = param_getchar(Cmd, 2);
383 } else if (strlen(filename) == 0) {
384 param_getstr(Cmd, 2, filename, sizeof(filename));
385 }
386 if (param_getlength(Cmd, 3) == 1) {
387 param3 = param_getchar(Cmd, 3);
388 } else if (strlen(filename) == 0) {
389 param_getstr(Cmd, 3, filename, sizeof(filename));
390 }
391
392 // Validate param1
393 bool errors = false;
05ddb52c 394
395 if(tlen == 0) {
4c3de57a
MHS
396 errors = true;
397 }
05ddb52c 398
399 if(param1 == 'h'
3bcc4d77 400 || (param1 != 0 && param1 != 'f' && param1 != 'c' && param1 != 'l')
401 || (param2 != 0 && param2 != 'f' && param2 != 'c' && param2 != 'l')
402 || (param3 != 0 && param3 != 'f' && param3 != 'c' && param3 != 'l')) {
4c3de57a
MHS
403 errors = true;
404 }
05ddb52c 405
406 if(!errors) {
ee1eadee 407 if(strcmp(type, "iclass") == 0) {
b689b842 408 protocol = ICLASS;
4f131b53 409 } else if(strcmp(type, "mf") == 0) {
410 protocol = PROTO_MIFARE;
ee1eadee 411 } else if(strcmp(type, "14a") == 0) {
b689b842 412 protocol = ISO_14443A;
ee1eadee 413 } else if(strcmp(type, "14b") == 0) {
b689b842 414 protocol = ISO_14443B;
3bcc4d77 415 } else if(strcmp(type,"topaz") == 0) {
ee1eadee 416 protocol = TOPAZ;
3bcc4d77 417 } else if(strcmp(type,"raw") == 0) {
418 protocol = -1; //No crc, no annotations
419 } else if (strcmp(type, "save") == 0) {
420 saveToFile = true;
ee1eadee 421 } else {
b689b842
MHS
422 errors = true;
423 }
424 }
3bcc4d77 425
426 if (param1 == 'f' || param2 == 'f' || param3 == 'f') {
427 showWaitCycles = true;
428 }
4c3de57a 429
3bcc4d77 430 if (param1 == 'c' || param2 == 'c' || param3 == 'c') {
431 markCRCBytes = true;
432 }
433
434 if (param1 == 'l' || param2 == 'l' || param3 == 'l') {
435 loadFromFile = true;
436 }
437
438 if ((loadFromFile || saveToFile) && strlen(filename) == 0) {
439 errors = true;
440 }
441
442 if (loadFromFile && saveToFile) {
443 errors = true;
444 }
445
4c3de57a 446 if (errors) {
3bcc4d77 447 PrintAndLog("List or save protocol data.");
448 PrintAndLog("Usage: hf list <protocol> [f] [c] [l <filename>]");
449 PrintAndLog(" hf list save <filename>");
92623113 450 PrintAndLog(" f - show frame delay times as well");
05ddb52c 451 PrintAndLog(" c - mark CRC bytes");
3bcc4d77 452 PrintAndLog(" l - load data from file instead of trace buffer");
453 PrintAndLog(" save - save data to file");
92623113
MHS
454 PrintAndLog("Supported <protocol> values:");
455 PrintAndLog(" raw - just show raw data without annotations");
337818f7 456 PrintAndLog(" 14a - interpret data as iso14443a communications");
4f131b53 457 PrintAndLog(" mf - interpret data as iso14443a communications and decrypt crypto1 stream");
41fdd0f0 458 PrintAndLog(" 14b - interpret data as iso14443b communications");
4c3de57a 459 PrintAndLog(" iclass - interpret data as iclass communications");
ee1eadee 460 PrintAndLog(" topaz - interpret data as topaz communications");
4c3de57a
MHS
461 PrintAndLog("");
462 PrintAndLog("example: hf list 14a f");
463 PrintAndLog("example: hf list iclass");
3bcc4d77 464 PrintAndLog("example: hf list save myCardTrace.trc");
465 PrintAndLog("example: hf list 14a l myCardTrace.trc");
4c3de57a
MHS
466 return 0;
467 }
b689b842 468
4c3de57a 469
f71f4deb 470 uint8_t *trace;
3bcc4d77 471 uint32_t tracepos = 0;
472 uint32_t traceLen = 0;
473
474 if (loadFromFile) {
475 #define TRACE_CHUNK_SIZE (1<<16) // 64K to start with. Will be enough for BigBuf and some room for future extensions
476 FILE *tracefile = NULL;
477 size_t bytes_read;
478 trace = malloc(TRACE_CHUNK_SIZE);
479 if (trace == NULL) {
f71f4deb 480 PrintAndLog("Cannot allocate memory for trace");
f71f4deb 481 return 2;
482 }
3bcc4d77 483 if ((tracefile = fopen(filename,"rb")) == NULL) {
484 PrintAndLog("Could not open file %s", filename);
485 free(trace);
486 return 0;
487 }
488 while (!feof(tracefile)) {
489 bytes_read = fread(trace+traceLen, 1, TRACE_CHUNK_SIZE, tracefile);
490 traceLen += bytes_read;
491 if (!feof(tracefile)) {
492 uint8_t *p = realloc(trace, traceLen + TRACE_CHUNK_SIZE);
493 if (p == NULL) {
494 PrintAndLog("Cannot allocate memory for trace");
495 free(trace);
496 fclose(tracefile);
497 return 2;
498 }
499 trace = p;
500 }
501 }
502 fclose(tracefile);
503 } else {
504 trace = malloc(USB_CMD_DATA_SIZE);
505 // Query for the size of the trace
506 UsbCommand response;
babca445 507 GetFromBigBuf(trace, USB_CMD_DATA_SIZE, 0, &response, -1, false);
3bcc4d77 508 traceLen = response.arg[2];
509 if (traceLen > USB_CMD_DATA_SIZE) {
510 uint8_t *p = realloc(trace, traceLen);
511 if (p == NULL) {
512 PrintAndLog("Cannot allocate memory for trace");
513 free(trace);
514 return 2;
515 }
516 trace = p;
babca445 517 GetFromBigBuf(trace, traceLen, 0, NULL, -1, false);
3bcc4d77 518 }
f71f4deb 519 }
4c3de57a 520
3bcc4d77 521 if (saveToFile) {
522 FILE *tracefile = NULL;
523 if ((tracefile = fopen(filename,"wb")) == NULL) {
524 PrintAndLog("Could not create file %s", filename);
525 return 1;
526 }
527 fwrite(trace, 1, traceLen, tracefile);
528 PrintAndLog("Recorded Activity (TraceLen = %d bytes) written to file %s", traceLen, filename);
529 fclose(tracefile);
530 } else {
531 PrintAndLog("Recorded Activity (TraceLen = %d bytes)", traceLen);
532 PrintAndLog("");
533 PrintAndLog("Start = Start of Start Bit, End = End of last modulation. Src = Source of Transfer");
534 PrintAndLog("iso14443a - All times are in carrier periods (1/13.56Mhz)");
535 PrintAndLog("iClass - Timings are not as accurate");
536 PrintAndLog("");
537 PrintAndLog(" Start | End | Src | Data (! denotes parity error) | CRC | Annotation |");
538 PrintAndLog("------------|------------|-----|-----------------------------------------------------------------|-----|--------------------|");
539
540 ClearAuthData();
541 while(tracepos < traceLen)
542 {
543 tracepos = printTraceLine(tracepos, traceLen, trace, protocol, showWaitCycles, markCRCBytes);
544 }
4c3de57a 545 }
f71f4deb 546
547 free(trace);
4c3de57a
MHS
548 return 0;
549}
550
8ceb6b03 551int CmdHFSearch(const char *Cmd){
552 int ans = 0;
6ce0e538 553 PrintAndLog("");
fe842bed 554 ans = CmdHF14AInfo("s");
6ce0e538 555 if (ans > 0) {
556 PrintAndLog("\nValid ISO14443A Tag Found - Quiting Search\n");
557 return ans;
ff4fdb32 558 }
aa53efc3 559 ans = HFiClassReader("", false, false);
ff4fdb32 560 if (ans) {
aa53efc3 561 PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n");
ff4fdb32 562 return ans;
563 }
979c7655 564 ans = HF15Reader("", false);
6ce0e538 565 if (ans) {
979c7655 566 PrintAndLog("\nValid ISO15693 Tag Found - Quiting Search\n");
6ce0e538 567 return ans;
568 }
979c7655 569 //14b is longest test currently (and rarest chip type) ... put last
570 ans = HF14BInfo(false);
6ce0e538 571 if (ans) {
979c7655 572 PrintAndLog("\nValid ISO14443B Tag Found - Quiting Search\n");
6ce0e538 573 return ans;
574 }
ff4fdb32 575 PrintAndLog("\nno known/supported 13.56 MHz tags found\n");
8ceb6b03 576 return 0;
577}
7fe9b0b7 578
0472d76d 579int CmdHFSnoop(const char *Cmd)
580{
581 char * pEnd;
582 UsbCommand c = {CMD_HF_SNIFFER, {strtol(Cmd, &pEnd,0),strtol(pEnd, &pEnd,0),0}};
583 SendCommand(&c);
584 return 0;
585}
586
7fe9b0b7 587static command_t CommandTable[] =
588{
05ddb52c 589 {"help", CmdHelp, 1, "This help"},
590 {"14a", CmdHF14A, 1, "{ ISO14443A RFIDs... }"},
591 {"14b", CmdHF14B, 1, "{ ISO14443B RFIDs... }"},
592 {"15", CmdHF15, 1, "{ ISO15693 RFIDs... }"},
593 {"epa", CmdHFEPA, 1, "{ German Identification Card... }"},
3c5fce2b 594 {"emv", CmdHFEMV, 1, "{ EMV cards... }"},
05ddb52c 595 {"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"},
596 {"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
597 {"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
598 {"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
dc3e2acf 599 {"mfp", CmdHFMFP, 1, "{ MIFARE Plus RFIDs... }"},
05ddb52c 600 {"topaz", CmdHFTopaz, 1, "{ TOPAZ (NFC Type 1) RFIDs... }"},
601 {"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
602 {"list", CmdHFList, 1, "List protocol data in trace buffer"},
7624e8b2 603 {"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"},
b2fe0e77 604 {"snoop", CmdHFSnoop, 0, "<samples to skip (10000)> <triggers to skip (1)> Generic HF Snoop"},
05ddb52c 605 {NULL, NULL, 0, NULL}
7fe9b0b7 606};
607
608int CmdHF(const char *Cmd)
609{
610 CmdsParse(CommandTable, Cmd);
611 return 0;
612}
613
614int CmdHelp(const char *Cmd)
615{
616 CmdsHelp(CommandTable);
617 return 0;
618}
Impressum, Datenschutz