]> git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlf.c
add: timeouts for "lf read"
[proxmark3-svn] / client / cmdlf.c
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 // Low frequency commands
9 //-----------------------------------------------------------------------------
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <limits.h>
15 #include "proxmark3.h"
16 #include "data.h"
17 #include "graph.h"
18 #include "ui.h"
19 #include "cmdparser.h"
20 #include "cmdmain.h"
21 #include "cmddata.h"
22 #include "util.h"
23 #include "cmdlf.h"
24 #include "cmdlfhid.h"
25 #include "cmdlfti.h"
26 #include "cmdlfem4x.h"
27 #include "cmdlfhitag.h"
28 #include "cmdlft55xx.h"
29 #include "cmdlfpcf7931.h"
30 #include "cmdlfio.h"
31
32 static int CmdHelp(const char *Cmd);
33
34 /* send a command before reading */
35 int CmdLFCommandRead(const char *Cmd)
36 {
37 static char dummy[3];
38
39 dummy[0]= ' ';
40
41 UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K};
42 sscanf(Cmd, "%"lli" %"lli" %"lli" %s %s", &c.arg[0], &c.arg[1], &c.arg[2],(char*)(&c.d.asBytes),(char*)(&dummy+1));
43 // in case they specified 'h'
44 strcpy((char *)&c.d.asBytes + strlen((char *)c.d.asBytes), dummy);
45 SendCommand(&c);
46 return 0;
47 }
48
49 int CmdFlexdemod(const char *Cmd)
50 {
51 int i;
52 for (i = 0; i < GraphTraceLen; ++i) {
53 if (GraphBuffer[i] < 0) {
54 GraphBuffer[i] = -1;
55 } else {
56 GraphBuffer[i] = 1;
57 }
58 }
59
60 #define LONG_WAIT 100
61 int start;
62 for (start = 0; start < GraphTraceLen - LONG_WAIT; start++) {
63 int first = GraphBuffer[start];
64 for (i = start; i < start + LONG_WAIT; i++) {
65 if (GraphBuffer[i] != first) {
66 break;
67 }
68 }
69 if (i == (start + LONG_WAIT)) {
70 break;
71 }
72 }
73 if (start == GraphTraceLen - LONG_WAIT) {
74 PrintAndLog("nothing to wait for");
75 return 0;
76 }
77
78 GraphBuffer[start] = 2;
79 GraphBuffer[start+1] = -2;
80 uint8_t bits[64] = {0x00};
81
82 int bit, sum;
83 i = start;
84 for (bit = 0; bit < 64; bit++) {
85 sum = 0;
86 for (int j = 0; j < 16; j++) {
87 sum += GraphBuffer[i++];
88 }
89
90 bits[bit] = (sum > 0) ? 1 : 0;
91
92 PrintAndLog("bit %d sum %d", bit, sum);
93 }
94
95 for (bit = 0; bit < 64; bit++) {
96 int j;
97 int sum = 0;
98 for (j = 0; j < 16; j++) {
99 sum += GraphBuffer[i++];
100 }
101 if (sum > 0 && bits[bit] != 1) {
102 PrintAndLog("oops1 at %d", bit);
103 }
104 if (sum < 0 && bits[bit] != 0) {
105 PrintAndLog("oops2 at %d", bit);
106 }
107 }
108
109 // HACK writing back to graphbuffer.
110 GraphTraceLen = 32*64;
111 i = 0;
112 int phase = 0;
113 for (bit = 0; bit < 64; bit++) {
114
115 phase = (bits[bit] == 0) ? 0 : 1;
116
117 int j;
118 for (j = 0; j < 32; j++) {
119 GraphBuffer[i++] = phase;
120 phase = !phase;
121 }
122 }
123
124 RepaintGraphWindow();
125 return 0;
126 }
127
128 int CmdIndalaDemod(const char *Cmd)
129 {
130 // Usage: recover 64bit UID by default, specify "224" as arg to recover a 224bit UID
131
132 int state = -1;
133 int count = 0;
134 int i, j;
135
136 // worst case with GraphTraceLen=64000 is < 4096
137 // under normal conditions it's < 2048
138
139 uint8_t rawbits[4096];
140 int rawbit = 0;
141 int worst = 0, worstPos = 0;
142 // PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
143 for (i = 0; i < GraphTraceLen-1; i += 2) {
144 count += 1;
145 if ((GraphBuffer[i] > GraphBuffer[i + 1]) && (state != 1)) {
146 if (state == 0) {
147 for (j = 0; j < count - 8; j += 16) {
148 rawbits[rawbit++] = 0;
149 }
150 if ((abs(count - j)) > worst) {
151 worst = abs(count - j);
152 worstPos = i;
153 }
154 }
155 state = 1;
156 count = 0;
157 } else if ((GraphBuffer[i] < GraphBuffer[i + 1]) && (state != 0)) {
158 if (state == 1) {
159 for (j = 0; j < count - 8; j += 16) {
160 rawbits[rawbit++] = 1;
161 }
162 if ((abs(count - j)) > worst) {
163 worst = abs(count - j);
164 worstPos = i;
165 }
166 }
167 state = 0;
168 count = 0;
169 }
170 }
171
172 if (rawbit>0){
173 PrintAndLog("Recovered %d raw bits, expected: %d", rawbit, GraphTraceLen/32);
174 PrintAndLog("worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
175 } else {
176 return 0;
177 }
178
179 // Finding the start of a UID
180 int uidlen, long_wait;
181 if (strcmp(Cmd, "224") == 0) {
182 uidlen = 224;
183 long_wait = 30;
184 } else {
185 uidlen = 64;
186 long_wait = 29;
187 }
188
189 int start;
190 int first = 0;
191 for (start = 0; start <= rawbit - uidlen; start++) {
192 first = rawbits[start];
193 for (i = start; i < start + long_wait; i++) {
194 if (rawbits[i] != first) {
195 break;
196 }
197 }
198 if (i == (start + long_wait)) {
199 break;
200 }
201 }
202
203 if (start == rawbit - uidlen + 1) {
204 PrintAndLog("nothing to wait for");
205 return 0;
206 }
207
208 // Inverting signal if needed
209 if (first == 1) {
210 for (i = start; i < rawbit; i++) {
211 rawbits[i] = !rawbits[i];
212 }
213 }
214
215 // Dumping UID
216 uint8_t bits[224] = {0x00};
217 char showbits[225] = {0x00};
218 int bit;
219 i = start;
220 int times = 0;
221
222 if (uidlen > rawbit) {
223 PrintAndLog("Warning: not enough raw bits to get a full UID");
224 for (bit = 0; bit < rawbit; bit++) {
225 bits[bit] = rawbits[i++];
226 // As we cannot know the parity, let's use "." and "/"
227 showbits[bit] = '.' + bits[bit];
228 }
229 showbits[bit+1]='\0';
230 PrintAndLog("Partial UID=%s", showbits);
231 return 0;
232 } else {
233 for (bit = 0; bit < uidlen; bit++) {
234 bits[bit] = rawbits[i++];
235 showbits[bit] = '0' + bits[bit];
236 }
237 times = 1;
238 }
239
240 //convert UID to HEX
241 uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7;
242 int idx;
243 uid1 = uid2 = 0;
244
245 if (uidlen==64){
246 for( idx=0; idx<64; idx++) {
247 if (showbits[idx] == '0') {
248 uid1=(uid1<<1)|(uid2>>31);
249 uid2=(uid2<<1)|0;
250 } else {
251 uid1=(uid1<<1)|(uid2>>31);
252 uid2=(uid2<<1)|1;
253 }
254 }
255 PrintAndLog("UID=%s (%x%08x)", showbits, uid1, uid2);
256 }
257 else {
258 uid3 = uid4 = uid5 = uid6 = uid7 = 0;
259
260 for( idx=0; idx<224; idx++) {
261 uid1=(uid1<<1)|(uid2>>31);
262 uid2=(uid2<<1)|(uid3>>31);
263 uid3=(uid3<<1)|(uid4>>31);
264 uid4=(uid4<<1)|(uid5>>31);
265 uid5=(uid5<<1)|(uid6>>31);
266 uid6=(uid6<<1)|(uid7>>31);
267
268 if (showbits[idx] == '0')
269 uid7 = (uid7<<1) | 0;
270 else
271 uid7 = (uid7<<1) | 1;
272 }
273 PrintAndLog("UID=%s (%x%08x%08x%08x%08x%08x%08x)", showbits, uid1, uid2, uid3, uid4, uid5, uid6, uid7);
274 }
275
276 // Checking UID against next occurrences
277 int failed = 0;
278 for (; i + uidlen <= rawbit;) {
279 failed = 0;
280 for (bit = 0; bit < uidlen; bit++) {
281 if (bits[bit] != rawbits[i++]) {
282 failed = 1;
283 break;
284 }
285 }
286 if (failed == 1) {
287 break;
288 }
289 times += 1;
290 }
291
292 PrintAndLog("Occurrences: %d (expected %d)", times, (rawbit - start) / uidlen);
293
294 // Remodulating for tag cloning
295 // HACK: 2015-01-04 this will have an impact on our new way of seening lf commands (demod)
296 // since this changes graphbuffer data.
297 GraphTraceLen = 32*uidlen;
298 i = 0;
299 int phase = 0;
300 for (bit = 0; bit < uidlen; bit++) {
301 if (bits[bit] == 0) {
302 phase = 0;
303 } else {
304 phase = 1;
305 }
306 int j;
307 for (j = 0; j < 32; j++) {
308 GraphBuffer[i++] = phase;
309 phase = !phase;
310 }
311 }
312
313 RepaintGraphWindow();
314 return 1;
315 }
316
317 int CmdIndalaClone(const char *Cmd)
318 {
319 UsbCommand c;
320 unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
321
322 uid1 = uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
323 int n = 0, i = 0;
324
325 if (strchr(Cmd,'l') != 0) {
326 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
327 uid1 = (uid1 << 4) | (uid2 >> 28);
328 uid2 = (uid2 << 4) | (uid3 >> 28);
329 uid3 = (uid3 << 4) | (uid4 >> 28);
330 uid4 = (uid4 << 4) | (uid5 >> 28);
331 uid5 = (uid5 << 4) | (uid6 >> 28);
332 uid6 = (uid6 << 4) | (uid7 >> 28);
333 uid7 = (uid7 << 4) | (n & 0xf);
334 }
335 PrintAndLog("Cloning 224bit tag with UID %x%08x%08x%08x%08x%08x%08x", uid1, uid2, uid3, uid4, uid5, uid6, uid7);
336 c.cmd = CMD_INDALA_CLONE_TAG_L;
337 c.d.asDwords[0] = uid1;
338 c.d.asDwords[1] = uid2;
339 c.d.asDwords[2] = uid3;
340 c.d.asDwords[3] = uid4;
341 c.d.asDwords[4] = uid5;
342 c.d.asDwords[5] = uid6;
343 c.d.asDwords[6] = uid7;
344 } else {
345 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
346 uid1 = (uid1 << 4) | (uid2 >> 28);
347 uid2 = (uid2 << 4) | (n & 0xf);
348 }
349 PrintAndLog("Cloning 64bit tag with UID %x%08x", uid1, uid2);
350 c.cmd = CMD_INDALA_CLONE_TAG;
351 c.arg[0] = uid1;
352 c.arg[1] = uid2;
353 }
354
355 SendCommand(&c);
356 return 0;
357 }
358
359 int usage_lf_read()
360 {
361 PrintAndLog("Usage: lf read");
362 PrintAndLog("Options: ");
363 PrintAndLog(" h This help");
364 PrintAndLog("This function takes no arguments. ");
365 PrintAndLog("Use 'lf config' to set parameters.");
366 return 0;
367 }
368 int usage_lf_snoop()
369 {
370 PrintAndLog("Usage: lf snoop");
371 PrintAndLog("Options: ");
372 PrintAndLog(" h This help");
373 PrintAndLog("This function takes no arguments. ");
374 PrintAndLog("Use 'lf config' to set parameters.");
375 return 0;
376 }
377
378 int usage_lf_config()
379 {
380 PrintAndLog("Usage: lf config [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]");
381 PrintAndLog("Options: ");
382 PrintAndLog(" h This help");
383 PrintAndLog(" L Low frequency (125 KHz)");
384 PrintAndLog(" H High frequency (134 KHz)");
385 PrintAndLog(" q <divisor> Manually set divisor. 88-> 134KHz, 95-> 125 Hz");
386 PrintAndLog(" b <bps> Sets resolution of bits per sample. Default (max): 8");
387 PrintAndLog(" d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
388 PrintAndLog(" a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
389 PrintAndLog(" t <threshold> Sets trigger threshold. 0 means no threshold");
390 PrintAndLog("Examples:");
391 PrintAndLog(" lf config b 8 L");
392 PrintAndLog(" Samples at 125KHz, 8bps.");
393 PrintAndLog(" lf config H b 4 d 3");
394 PrintAndLog(" Samples at 134KHz, averages three samples into one, stored with ");
395 PrintAndLog(" a resolution of 4 bits per sample.");
396 PrintAndLog(" lf read");
397 PrintAndLog(" Performs a read (active field)");
398 PrintAndLog(" lf snoop");
399 PrintAndLog(" Performs a snoop (no active field)");
400 return 0;
401 }
402
403 int CmdLFSetConfig(const char *Cmd)
404 {
405
406 uint8_t divisor = 0;//Frequency divisor
407 uint8_t bps = 0; // Bits per sample
408 uint8_t decimation = 0; //How many to keep
409 bool averaging = 1; // Defaults to true
410 bool errors = FALSE;
411 int trigger_threshold =-1;//Means no change
412 uint8_t unsigned_trigg = 0;
413
414 uint8_t cmdp =0;
415 while(param_getchar(Cmd, cmdp) != 0x00)
416 {
417 PrintAndLog("working %c", param_getchar(Cmd, cmdp));
418 switch(param_getchar(Cmd, cmdp))
419 {
420 case 'h':
421 return usage_lf_config();
422 case 'H':
423 divisor = 88;
424 cmdp++;
425 break;
426 case 'L':
427 divisor = 95;
428 cmdp++;
429 break;
430 case 'q':
431 errors |= param_getdec(Cmd,cmdp+1,&divisor);
432 cmdp+=2;
433 break;
434 case 't':
435 errors |= param_getdec(Cmd,cmdp+1,&unsigned_trigg);
436 cmdp+=2;
437 if(!errors) trigger_threshold = unsigned_trigg;
438 break;
439 case 'b':
440 errors |= param_getdec(Cmd,cmdp+1,&bps);
441 cmdp+=2;
442 break;
443 case 'd':
444 errors |= param_getdec(Cmd,cmdp+1,&decimation);
445 cmdp+=2;
446 break;
447 case 'a':
448 averaging = param_getchar(Cmd,cmdp+1) == '1';
449 cmdp+=2;
450 break;
451 default:
452 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
453 errors = 1;
454 break;
455 }
456 if(errors) break;
457 }
458 if(cmdp == 0)
459 {
460 errors = 1;// No args
461 }
462
463 //Validations
464 if(errors)
465 {
466 return usage_lf_config();
467 }
468 //Bps is limited to 8, so fits in lower half of arg1
469 if(bps >> 8) bps = 8;
470
471 sample_config config = {
472 decimation,bps,averaging,divisor,trigger_threshold
473 };
474 //Averaging is a flag on high-bit of arg[1]
475 UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG};
476 memcpy(c.d.asBytes,&config,sizeof(sample_config));
477 SendCommand(&c);
478 return 0;
479 }
480
481 int CmdLFRead(const char *Cmd)
482 {
483
484 uint8_t cmdp =0;
485 if(param_getchar(Cmd, cmdp) == 'h')
486 {
487 return usage_lf_read();
488 }
489 //And ship it to device
490 UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K};
491 SendCommand(&c);
492 //WaitForResponse(CMD_ACK,NULL);
493 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
494 PrintAndLog("command execution time out");
495 return 1;
496 }
497
498 return 0;
499 }
500
501 int CmdLFSnoop(const char *Cmd)
502 {
503 uint8_t cmdp =0;
504 if(param_getchar(Cmd, cmdp) == 'h')
505 {
506 return usage_lf_snoop();
507 }
508
509 UsbCommand c = {CMD_LF_SNOOP_RAW_ADC_SAMPLES};
510 SendCommand(&c);
511 WaitForResponse(CMD_ACK,NULL);
512 return 0;
513 }
514
515 static void ChkBitstream(const char *str)
516 {
517 int i;
518
519 /* convert to bitstream if necessary */
520 for (i = 0; i < (int)(GraphTraceLen / 2); i++){
521 if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
522 CmdBitstream(str);
523 break;
524 }
525 }
526 }
527 //appears to attempt to simulate manchester
528 int CmdLFSim(const char *Cmd)
529 {
530 int i,j;
531 static int gap;
532
533 sscanf(Cmd, "%i", &gap);
534
535 /* convert to bitstream if necessary */
536 ChkBitstream(Cmd);
537
538 printf("Sending [%d bytes]", GraphTraceLen);
539 for (i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
540 UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}};
541
542 for (j = 0; j < USB_CMD_DATA_SIZE; j++) {
543 c.d.asBytes[j] = GraphBuffer[i+j];
544 }
545 SendCommand(&c);
546 WaitForResponse(CMD_ACK,NULL);
547 printf(".");
548 }
549
550 printf("\n");
551 PrintAndLog("Starting to simulate");
552 UsbCommand c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}};
553 SendCommand(&c);
554 return 0;
555 }
556
557 int CmdLFSimBidir(const char *Cmd)
558 {
559 // Set ADC to twice the carrier for a slight supersampling
560 // HACK: not implemented in ARMSRC.
561 PrintAndLog("Not implemented yet.");
562 UsbCommand c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}};
563 SendCommand(&c);
564 return 0;
565 }
566
567 /* simulate an LF Manchester encoded tag with specified bitstream, clock rate and inter-id gap */
568 int CmdLFSimManchester(const char *Cmd)
569 {
570 static int clock, gap;
571 static char data[1024], gapstring[8];
572
573 sscanf(Cmd, "%i %s %i", &clock, &data[0], &gap);
574
575 ClearGraph(0);
576
577 for (int i = 0; i < strlen(data) ; ++i)
578 AppendGraph(0, clock, data[i]- '0');
579
580 CmdManchesterMod("");
581
582 RepaintGraphWindow();
583
584 sprintf(&gapstring[0], "%i", gap);
585 CmdLFSim(gapstring);
586 return 0;
587 }
588
589
590 int CmdVchDemod(const char *Cmd)
591 {
592 // Is this the entire sync pattern, or does this also include some
593 // data bits that happen to be the same everywhere? That would be
594 // lovely to know.
595 static const int SyncPattern[] = {
596 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
597 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
598 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
599 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
600 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
601 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
602 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
603 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
604 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
605 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
606 };
607
608 // So first, we correlate for the sync pattern, and mark that.
609 int bestCorrel = 0, bestPos = 0;
610 int i;
611 // It does us no good to find the sync pattern, with fewer than
612 // 2048 samples after it...
613 for (i = 0; i < (GraphTraceLen-2048); i++) {
614 int sum = 0;
615 int j;
616 for (j = 0; j < arraylen(SyncPattern); j++) {
617 sum += GraphBuffer[i+j]*SyncPattern[j];
618 }
619 if (sum > bestCorrel) {
620 bestCorrel = sum;
621 bestPos = i;
622 }
623 }
624 PrintAndLog("best sync at %d [metric %d]", bestPos, bestCorrel);
625
626 char bits[257];
627 bits[256] = '\0';
628
629 int worst = INT_MAX;
630 int worstPos = 0;
631
632 for (i = 0; i < 2048; i += 8) {
633 int sum = 0;
634 int j;
635 for (j = 0; j < 8; j++) {
636 sum += GraphBuffer[bestPos+i+j];
637 }
638 if (sum < 0) {
639 bits[i/8] = '.';
640 } else {
641 bits[i/8] = '1';
642 }
643 if(abs(sum) < worst) {
644 worst = abs(sum);
645 worstPos = i;
646 }
647 }
648 PrintAndLog("bits:");
649 PrintAndLog("%s", bits);
650 PrintAndLog("worst metric: %d at pos %d", worst, worstPos);
651
652 if (strcmp(Cmd, "clone")==0) {
653 GraphTraceLen = 0;
654 char *s;
655 for(s = bits; *s; s++) {
656 int j;
657 for(j = 0; j < 16; j++) {
658 GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0;
659 }
660 }
661 RepaintGraphWindow();
662 }
663 return 0;
664 }
665
666 //by marshmellow
667 int CmdLFfind(const char *Cmd)
668 {
669 int ans=0;
670 char cmdp = param_getchar(Cmd, 0);
671 char testRaw = param_getchar(Cmd, 1);
672 if (strlen(Cmd) > 2 || cmdp == 'h' || cmdp == 'H') {
673 PrintAndLog("Usage: lf search <0|1> [u]");
674 PrintAndLog(" <use data from Graphbuffer> , if not set, try reading data from tag.");
675 PrintAndLog(" [Search for Unknown tags] , if not set, reads only known tags.");
676 PrintAndLog("");
677 PrintAndLog(" sample: lf search = try reading data from tag & search for known tags");
678 PrintAndLog(" : lf search 1 = use data from GraphBuffer & search for known tags");
679 PrintAndLog(" : lf search u = try reading data from tag & search for known and unknown tags");
680 PrintAndLog(" : lf search 1 u = use data from GraphBuffer & search for known and unknown tags");
681
682 return 0;
683 }
684
685 if (!offline && (cmdp != '1')){
686 ans=CmdLFRead("");
687 ans=CmdSamples("20000");
688 } else if (GraphTraceLen < 1000) {
689 PrintAndLog("Data in Graphbuffer was too small.");
690 return 0;
691 }
692 if (cmdp == 'u' || cmdp == 'U') testRaw = 'u';
693 PrintAndLog("NOTE: some demods output possible binary\n if it finds something that looks like a tag");
694 PrintAndLog("False Positives ARE possible\n");
695 PrintAndLog("\nChecking for known tags:\n");
696 ans=CmdFSKdemodIO("");
697 if (ans>0) {
698 PrintAndLog("\nValid IO Prox ID Found!");
699 return 1;
700 }
701 ans=CmdFSKdemodPyramid("");
702 if (ans>0) {
703 PrintAndLog("\nValid Pyramid ID Found!");
704 return 1;
705 }
706 ans=CmdFSKdemodParadox("");
707 if (ans>0) {
708 PrintAndLog("\nValid Paradox ID Found!");
709 return 1;
710 }
711 ans=CmdFSKdemodAWID("");
712 if (ans>0) {
713 PrintAndLog("\nValid AWID ID Found!");
714 return 1;
715 }
716 ans=CmdFSKdemodHID("");
717 if (ans>0) {
718 PrintAndLog("\nValid HID Prox ID Found!");
719 return 1;
720 }
721 //add psk and indala
722 ans=CmdIndalaDecode("");
723 if (ans>0) {
724 PrintAndLog("\nValid Indala ID Found!");
725 return 1;
726 }
727 ans=CmdAskEM410xDemod("");
728 if (ans>0) {
729 PrintAndLog("\nValid EM410x ID Found!");
730 return 1;
731 }
732 PrintAndLog("\nNo Known Tags Found!\n");
733 if (testRaw=='u' || testRaw=='U'){
734 //test unknown tag formats (raw mode)
735 PrintAndLog("\nChecking for Unknown tags:\n");
736 ans=CmdDetectClockRate("f");
737 if (ans != 0){ //fsk
738 ans=CmdFSKrawdemod("");
739 if (ans>0) {
740 PrintAndLog("\nUnknown FSK Modulated Tag Found!");
741 return 1;
742 }
743 }
744 ans=Cmdaskmandemod("");
745 if (ans>0) {
746 PrintAndLog("\nUnknown ASK Modulated and Manchester encoded Tag Found!");
747 return 1;
748 }
749 ans=CmdPSK1rawDemod("");
750 if (ans>0) {
751 PrintAndLog("Possible unknown PSK1 Modulated Tag Found above!\n\nCould also be PSK2 - try 'data psk2rawdemod'");
752 PrintAndLog("\nCould also be PSK3 - [currently not supported]");
753 PrintAndLog("\nCould also be NRZ - try 'data nrzrawdemod");
754 return 1;
755 }
756 PrintAndLog("\nNo Data Found!\n");
757 }
758 return 0;
759 }
760
761 static command_t CommandTable[] =
762 {
763 {"help", CmdHelp, 1, "This help"},
764 {"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"},
765 {"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
766 {"hitag", CmdLFHitag, 1, "{ HITAG RFIDs... }"},
767 {"io", CmdLFIO, 1, "{ IOPROX RFIDs... }"},
768 {"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 RFIDs... }"},
769 {"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
770 {"t55xx", CmdLFT55XX, 1, "{ T55X7 RFIDs... }"},
771
772 {"config", CmdLFSetConfig, 0, "Set config for LF sampling, bit/sample, decimation, frequency"},
773
774 {"cmdread", CmdLFCommandRead, 0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},
775 {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},
776 {"indalademod", CmdIndalaDemod, 1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
777 {"indalaclone", CmdIndalaClone, 0, "<UID> ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"},
778 {"read", CmdLFRead, 0, "Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"},
779 {"search", CmdLFfind, 1, "[offline] ['u'] Read and Search for valid known tag (in offline mode it you can load first then search) - 'u' to search for unknown tags"},
780 {"sim", CmdLFSim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
781 {"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
782 {"simman", CmdLFSimManchester, 0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},
783 {"snoop", CmdLFSnoop, 0, "['l'|'h'|<divisor>] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"},
784 {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
785 {NULL, NULL, 0, NULL}
786 };
787
788 int CmdLF(const char *Cmd)
789 {
790 CmdsParse(CommandTable, Cmd);
791 return 0;
792 }
793
794 int CmdHelp(const char *Cmd)
795 {
796 CmdsHelp(CommandTable);
797 return 0;
798 }
Impressum, Datenschutz