]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/cmdlf.c
add: added @AdamLaurie 's iclass raw keys changes
[proxmark3-svn] / client / cmdlf.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// Low frequency commands
9//-----------------------------------------------------------------------------
10
7fe9b0b7 11#include <stdio.h>
590f8ff9 12#include <stdlib.h>
7fe9b0b7 13#include <string.h>
393c3ef9 14#include <limits.h>
902cb3c0 15#include "proxmark3.h"
7fe9b0b7 16#include "data.h"
17#include "graph.h"
18#include "ui.h"
19#include "cmdparser.h"
040a7baa 20#include "cmdmain.h"
7fe9b0b7 21#include "cmddata.h"
31d1caa5 22#include "util.h"
7fe9b0b7 23#include "cmdlf.h"
24#include "cmdlfhid.h"
db25599d 25#include "cmdlfawid.h"
7fe9b0b7 26#include "cmdlfti.h"
27#include "cmdlfem4x.h"
db09cb3a 28#include "cmdlfhitag.h"
54a942b0 29#include "cmdlft55xx.h"
30#include "cmdlfpcf7931.h"
a1f3bb12 31#include "cmdlfio.h"
3bc66a96 32#include "lfdemod.h"
0de8e387 33#include "cmdlfviking.h"
7fe9b0b7 34static int CmdHelp(const char *Cmd);
35
f82894ba 36int usage_lf_cmdread(void) {
9276e859 37 PrintAndLog("Usage: lf cmdread d <delay period> z <zero period> o <one period> c <cmdbytes> [H]");
0de8e387 38 PrintAndLog("Options: ");
39 PrintAndLog(" h This help");
9276e859 40 PrintAndLog(" H Freqency High (134 KHz), default is 'Low (125KHz)'");
41 PrintAndLog(" d <delay> delay OFF period, (dec)");
42 PrintAndLog(" z <zero> time period ZERO, (dec)");
43 PrintAndLog(" o <one> time period ONE, (dec)");
44 PrintAndLog(" c <cmd> Command bytes");
45 PrintAndLog(" ************* All periods in microseconds (ms)");
0de8e387 46 PrintAndLog("Examples:");
9276e859 47 PrintAndLog(" lf cmdread d 80 z 100 o 200 c 11000");
48 PrintAndLog(" lf cmdread d 80 z 100 o 100 c 11000 H");
0de8e387 49 return 0;
50}
f82894ba 51int usage_lf_read(void){
52 PrintAndLog("Usage: lf read [h] [s]");
53 PrintAndLog("Options: ");
54 PrintAndLog(" h This help");
55 PrintAndLog(" s silent run no printout");
56 PrintAndLog("This function takes no arguments. ");
57 PrintAndLog("Use 'lf config' to set parameters.");
58 return 0;
59}
60int usage_lf_snoop(void) {
61 PrintAndLog("Usage: lf snoop");
62 PrintAndLog("Options: ");
63 PrintAndLog(" h This help");
64 PrintAndLog("This function takes no arguments. ");
65 PrintAndLog("Use 'lf config' to set parameters.");
66 return 0;
67}
68int usage_lf_config(void) {
69 PrintAndLog("Usage: lf config [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]");
70 PrintAndLog("Options: ");
71 PrintAndLog(" h This help");
72 PrintAndLog(" L Low frequency (125 KHz)");
73 PrintAndLog(" H High frequency (134 KHz)");
74 PrintAndLog(" q <divisor> Manually set divisor. 88-> 134KHz, 95-> 125 Hz");
75 PrintAndLog(" b <bps> Sets resolution of bits per sample. Default (max): 8");
76 PrintAndLog(" d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
77 PrintAndLog(" a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
78 PrintAndLog(" t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)");
79 PrintAndLog("Examples:");
80 PrintAndLog(" lf config b 8 L");
81 PrintAndLog(" Samples at 125KHz, 8bps.");
82 PrintAndLog(" lf config H b 4 d 3");
83 PrintAndLog(" Samples at 134KHz, averages three samples into one, stored with ");
84 PrintAndLog(" a resolution of 4 bits per sample.");
85 PrintAndLog(" lf read");
86 PrintAndLog(" Performs a read (active field)");
87 PrintAndLog(" lf snoop");
88 PrintAndLog(" Performs a snoop (no active field)");
89 return 0;
90}
91int usage_lf_simfsk(void) {
92 PrintAndLog("Usage: lf simfsk [c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>]");
93 PrintAndLog("Options: ");
94 PrintAndLog(" h This help");
95 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
96 PrintAndLog(" i invert data");
97 PrintAndLog(" H <fcHigh> Manually set the larger Field Clock");
98 PrintAndLog(" L <fcLow> Manually set the smaller Field Clock");
99 //PrintAndLog(" s TBD- -to enable a gap between playback repetitions - default: no gap");
100 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
101 PrintAndLog("\n NOTE: if you set one clock manually set them all manually");
102 return 0;
103}
104int usage_lf_simask(void) {
105 PrintAndLog("Usage: lf simask [c <clock>] [i] [b|m|r] [s] [d <raw hex to sim>]");
106 PrintAndLog("Options: ");
107 PrintAndLog(" h This help");
108 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
109 PrintAndLog(" i invert data");
110 PrintAndLog(" b sim ask/biphase");
111 PrintAndLog(" m sim ask/manchester - Default");
112 PrintAndLog(" r sim ask/raw");
113 PrintAndLog(" s TBD- -to enable a gap between playback repetitions - default: no gap");
114 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
115 return 0;
116}
117int usage_lf_simpsk(void) {
118 PrintAndLog("Usage: lf simpsk [1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>]");
119 PrintAndLog("Options: ");
120 PrintAndLog(" h This help");
121 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
122 PrintAndLog(" i invert data");
123 PrintAndLog(" 1 set PSK1 (default)");
124 PrintAndLog(" 2 set PSK2");
125 PrintAndLog(" 3 set PSK3");
126 PrintAndLog(" r <carrier> 2|4|8 are valid carriers: default = 2");
127 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
128 return 0;
129}
70459879 130int usage_lf_find(void){
131 PrintAndLog("Usage: lf search <0|1> [u]");
132 PrintAndLog(" <use data from Graphbuffer> , if not set, try reading data from tag.");
133 PrintAndLog(" [Search for Unknown tags] , if not set, reads only known tags.");
134 PrintAndLog("");
135 PrintAndLog(" sample: lf search = try reading data from tag & search for known tags");
136 PrintAndLog(" : lf search 1 = use data from GraphBuffer & search for known tags");
137 PrintAndLog(" : lf search u = try reading data from tag & search for known and unknown tags");
138 PrintAndLog(" : lf search 1 u = use data from GraphBuffer & search for known and unknown tags");
139 return 0;
140}
141
0de8e387 142
a739812e 143/* send a LF command before reading */
7fe9b0b7 144int CmdLFCommandRead(const char *Cmd)
145{
0de8e387 146 static char dummy[3] = {0x20,0x00,0x00};
9276e859 147 UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K};
0de8e387 148 bool errors = FALSE;
9276e859 149
150 uint8_t cmdp = 0;
151 int strLength = 0;
152
153 while(param_getchar(Cmd, cmdp) != 0x00) {
0de8e387 154 switch(param_getchar(Cmd, cmdp))
155 {
156 case 'h':
157 return usage_lf_cmdread();
158 case 'H':
9276e859 159 dummy[1]='h';
0de8e387 160 cmdp++;
161 break;
9276e859 162 case 'L':
163 cmdp++;
164 break;
165 case 'c':
166 strLength = param_getstr(Cmd, cmdp+1, (char *)&c.d.asBytes);
167 cmdp+=2;
168 break;
169 case 'd':
170 c.arg[0] = param_get32ex(Cmd, cmdp+1, 0, 10);
171 cmdp+=2;
172 break;
173 case 'z':
174 c.arg[1] = param_get32ex(Cmd, cmdp+1, 0, 10);
175 cmdp+=2;
176 break;
177 case 'o':
178 c.arg[2] = param_get32ex(Cmd, cmdp+1, 0, 10);
0de8e387 179 cmdp+=2;
180 break;
181 default:
182 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
183 errors = 1;
184 break;
185 }
186 if(errors) break;
187 }
188 // No args
9276e859 189 if (cmdp == 0) errors = 1;
7fe9b0b7 190
0de8e387 191 //Validations
9276e859 192 if (errors) return usage_lf_cmdread();
e98572a1 193
9276e859 194 // in case they specified 'H'
9276e859 195 strcpy((char *)&c.d.asBytes + strLength, dummy);
7fe9b0b7 196
0de8e387 197 clearCommandBuffer();
198 SendCommand(&c);
199 return 0;
7fe9b0b7 200}
201
202int CmdFlexdemod(const char *Cmd)
203{
204 int i;
205 for (i = 0; i < GraphTraceLen; ++i) {
206 if (GraphBuffer[i] < 0) {
207 GraphBuffer[i] = -1;
208 } else {
209 GraphBuffer[i] = 1;
210 }
211 }
212
213#define LONG_WAIT 100
214 int start;
215 for (start = 0; start < GraphTraceLen - LONG_WAIT; start++) {
216 int first = GraphBuffer[start];
217 for (i = start; i < start + LONG_WAIT; i++) {
218 if (GraphBuffer[i] != first) {
219 break;
220 }
221 }
222 if (i == (start + LONG_WAIT)) {
223 break;
224 }
225 }
226 if (start == GraphTraceLen - LONG_WAIT) {
227 PrintAndLog("nothing to wait for");
228 return 0;
229 }
230
231 GraphBuffer[start] = 2;
232 GraphBuffer[start+1] = -2;
3fe4ff4f 233 uint8_t bits[64] = {0x00};
7fe9b0b7 234
3fe4ff4f 235 int bit, sum;
7fe9b0b7 236 i = start;
237 for (bit = 0; bit < 64; bit++) {
3fe4ff4f 238 sum = 0;
239 for (int j = 0; j < 16; j++) {
7fe9b0b7 240 sum += GraphBuffer[i++];
241 }
3fe4ff4f 242
243 bits[bit] = (sum > 0) ? 1 : 0;
244
7fe9b0b7 245 PrintAndLog("bit %d sum %d", bit, sum);
246 }
247
248 for (bit = 0; bit < 64; bit++) {
249 int j;
250 int sum = 0;
251 for (j = 0; j < 16; j++) {
252 sum += GraphBuffer[i++];
253 }
254 if (sum > 0 && bits[bit] != 1) {
255 PrintAndLog("oops1 at %d", bit);
256 }
257 if (sum < 0 && bits[bit] != 0) {
258 PrintAndLog("oops2 at %d", bit);
259 }
260 }
261
3fe4ff4f 262 // HACK writing back to graphbuffer.
7fe9b0b7 263 GraphTraceLen = 32*64;
264 i = 0;
265 int phase = 0;
266 for (bit = 0; bit < 64; bit++) {
3fe4ff4f 267
268 phase = (bits[bit] == 0) ? 0 : 1;
269
7fe9b0b7 270 int j;
271 for (j = 0; j < 32; j++) {
272 GraphBuffer[i++] = phase;
273 phase = !phase;
274 }
275 }
276
277 RepaintGraphWindow();
278 return 0;
279}
a1f3bb12 280
7fe9b0b7 281int CmdIndalaDemod(const char *Cmd)
282{
70459879 283 // Usage: recover 64bit UID by default, specify "224" as arg to recover a 224bit UID
284
285 int state = -1;
286 int count = 0;
287 int i, j;
288
289 // worst case with GraphTraceLen=64000 is < 4096
290 // under normal conditions it's < 2048
291
292 uint8_t rawbits[4096];
293 int rawbit = 0;
294 int worst = 0, worstPos = 0;
295 // PrintAndLog("Expecting a bit less than %d raw bits", GraphTraceLen / 32);
6426f6ba 296
297 // loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
70459879 298 for (i = 0; i < GraphTraceLen-1; i += 2) {
299 count += 1;
300 if ((GraphBuffer[i] > GraphBuffer[i + 1]) && (state != 1)) {
6426f6ba 301 // appears redundant - marshmellow
70459879 302 if (state == 0) {
303 for (j = 0; j < count - 8; j += 16) {
304 rawbits[rawbit++] = 0;
305 }
306 if ((abs(count - j)) > worst) {
307 worst = abs(count - j);
308 worstPos = i;
309 }
310 }
311 state = 1;
312 count = 0;
313 } else if ((GraphBuffer[i] < GraphBuffer[i + 1]) && (state != 0)) {
6426f6ba 314 //appears redundant
70459879 315 if (state == 1) {
316 for (j = 0; j < count - 8; j += 16) {
317 rawbits[rawbit++] = 1;
318 }
319 if ((abs(count - j)) > worst) {
320 worst = abs(count - j);
321 worstPos = i;
322 }
323 }
324 state = 0;
325 count = 0;
326 }
327 }
328
329 if ( rawbit>0 ){
330 PrintAndLog("Recovered %d raw bits, expected: %d", rawbit, GraphTraceLen/32);
331 PrintAndLog("worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
3fe4ff4f 332 } else {
333 return 0;
334 }
335
70459879 336 // Finding the start of a UID
337 int uidlen, long_wait;
338 if (strcmp(Cmd, "224") == 0) {
339 uidlen = 224;
340 long_wait = 30;
341 } else {
342 uidlen = 64;
343 long_wait = 29;
344 }
3fe4ff4f 345
70459879 346 int start;
347 int first = 0;
348 for (start = 0; start <= rawbit - uidlen; start++) {
349 first = rawbits[start];
350 for (i = start; i < start + long_wait; i++) {
351 if (rawbits[i] != first) {
352 break;
353 }
354 }
355 if (i == (start + long_wait)) {
356 break;
357 }
358 }
3fe4ff4f 359
70459879 360 if (start == rawbit - uidlen + 1) {
361 PrintAndLog("nothing to wait for");
362 return 0;
363 }
7fe9b0b7 364
70459879 365 // Inverting signal if needed
366 if (first == 1) {
367 for (i = start; i < rawbit; i++) {
368 rawbits[i] = !rawbits[i];
369 }
370 }
7fe9b0b7 371
70459879 372 // Dumping UID
3fe4ff4f 373 uint8_t bits[224] = {0x00};
374 char showbits[225] = {0x00};
70459879 375 int bit;
376 i = start;
377 int times = 0;
3fe4ff4f 378
70459879 379 if (uidlen > rawbit) {
380 PrintAndLog("Warning: not enough raw bits to get a full UID");
381 for (bit = 0; bit < rawbit; bit++) {
382 bits[bit] = rawbits[i++];
383 // As we cannot know the parity, let's use "." and "/"
384 showbits[bit] = '.' + bits[bit];
385 }
386 showbits[bit+1]='\0';
387 PrintAndLog("Partial UID=%s", showbits);
388 return 0;
389 } else {
390 for (bit = 0; bit < uidlen; bit++) {
391 bits[bit] = rawbits[i++];
392 showbits[bit] = '0' + bits[bit];
393 }
394 times = 1;
395 }
2414f978 396
70459879 397 //convert UID to HEX
398 uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7;
399 int idx;
3fe4ff4f 400 uid1 = uid2 = 0;
401
70459879 402 if (uidlen==64){
403 for( idx=0; idx<64; idx++) {
404 if (showbits[idx] == '0') {
405 uid1 = (uid1<<1) | (uid2>>31);
406 uid2 = (uid2<<1) | 0;
407 } else {
408 uid1 = (uid1<<1) | (uid2>>31);
409 uid2 = (uid2<<1) | 1;
410 }
411 }
412 PrintAndLog("UID=%s (%x%08x)", showbits, uid1, uid2);
413 } else {
3fe4ff4f 414 uid3 = uid4 = uid5 = uid6 = uid7 = 0;
415
70459879 416 for( idx=0; idx<224; idx++) {
417 uid1 = (uid1<<1) | (uid2>>31);
418 uid2 = (uid2<<1) | (uid3>>31);
419 uid3 = (uid3<<1) | (uid4>>31);
420 uid4 = (uid4<<1) | (uid5>>31);
421 uid5 = (uid5<<1) | (uid6>>31);
422 uid6 = (uid6<<1) | (uid7>>31);
423
3fe4ff4f 424 if (showbits[idx] == '0')
425 uid7 = (uid7<<1) | 0;
426 else
427 uid7 = (uid7<<1) | 1;
70459879 428 }
429 PrintAndLog("UID=%s (%x%08x%08x%08x%08x%08x%08x)", showbits, uid1, uid2, uid3, uid4, uid5, uid6, uid7);
430 }
7fe9b0b7 431
70459879 432 // Checking UID against next occurrences
433 int failed = 0;
3fe4ff4f 434 for (; i + uidlen <= rawbit;) {
435 failed = 0;
70459879 436 for (bit = 0; bit < uidlen; bit++) {
437 if (bits[bit] != rawbits[i++]) {
438 failed = 1;
439 break;
440 }
441 }
442 if (failed == 1) {
443 break;
444 }
445 times += 1;
446 }
3fe4ff4f 447
70459879 448 PrintAndLog("Occurrences: %d (expected %d)", times, (rawbit - start) / uidlen);
7fe9b0b7 449
70459879 450 // Remodulating for tag cloning
3fe4ff4f 451 // HACK: 2015-01-04 this will have an impact on our new way of seening lf commands (demod)
452 // since this changes graphbuffer data.
70459879 453 GraphTraceLen = 32 * uidlen;
454 i = 0;
455 int phase = 0;
456 for (bit = 0; bit < uidlen; bit++) {
457 phase = (bits[bit] == 0) ? 0 : 1;
458 int j;
459 for (j = 0; j < 32; j++) {
460 GraphBuffer[i++] = phase;
461 phase = !phase;
462 }
463 }
7fe9b0b7 464
70459879 465 RepaintGraphWindow();
466 return 1;
7fe9b0b7 467}
468
2414f978 469int CmdIndalaClone(const char *Cmd)
470{
2414f978 471 UsbCommand c;
3fe4ff4f 472 unsigned int uid1, uid2, uid3, uid4, uid5, uid6, uid7;
473
474 uid1 = uid2 = uid3 = uid4 = uid5 = uid6 = uid7 = 0;
2414f978 475 int n = 0, i = 0;
476
477 if (strchr(Cmd,'l') != 0) {
478 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
479 uid1 = (uid1 << 4) | (uid2 >> 28);
480 uid2 = (uid2 << 4) | (uid3 >> 28);
481 uid3 = (uid3 << 4) | (uid4 >> 28);
482 uid4 = (uid4 << 4) | (uid5 >> 28);
483 uid5 = (uid5 << 4) | (uid6 >> 28);
484 uid6 = (uid6 << 4) | (uid7 >> 28);
485 uid7 = (uid7 << 4) | (n & 0xf);
486 }
487 PrintAndLog("Cloning 224bit tag with UID %x%08x%08x%08x%08x%08x%08x", uid1, uid2, uid3, uid4, uid5, uid6, uid7);
488 c.cmd = CMD_INDALA_CLONE_TAG_L;
489 c.d.asDwords[0] = uid1;
490 c.d.asDwords[1] = uid2;
491 c.d.asDwords[2] = uid3;
492 c.d.asDwords[3] = uid4;
493 c.d.asDwords[4] = uid5;
494 c.d.asDwords[5] = uid6;
495 c.d.asDwords[6] = uid7;
3fe4ff4f 496 } else {
2414f978 497 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
498 uid1 = (uid1 << 4) | (uid2 >> 28);
499 uid2 = (uid2 << 4) | (n & 0xf);
500 }
501 PrintAndLog("Cloning 64bit tag with UID %x%08x", uid1, uid2);
502 c.cmd = CMD_INDALA_CLONE_TAG;
503 c.arg[0] = uid1;
504 c.arg[1] = uid2;
505 }
506
a126332a 507 clearCommandBuffer();
2414f978 508 SendCommand(&c);
509 return 0;
510}
511
31abe49f 512int CmdLFSetConfig(const char *Cmd)
7fe9b0b7 513{
31abe49f
MHS
514
515 uint8_t divisor = 0;//Frequency divisor
516 uint8_t bps = 0; // Bits per sample
517 uint8_t decimation = 0; //How many to keep
518 bool averaging = 1; // Defaults to true
f6d9fb17 519 bool errors = FALSE;
31abe49f
MHS
520 int trigger_threshold =-1;//Means no change
521 uint8_t unsigned_trigg = 0;
f6d9fb17
MHS
522
523 uint8_t cmdp =0;
31abe49f 524 while(param_getchar(Cmd, cmdp) != 0x00)
f6d9fb17 525 {
31abe49f
MHS
526 switch(param_getchar(Cmd, cmdp))
527 {
528 case 'h':
529 return usage_lf_config();
530 case 'H':
531 divisor = 88;
532 cmdp++;
533 break;
534 case 'L':
535 divisor = 95;
536 cmdp++;
537 break;
538 case 'q':
539 errors |= param_getdec(Cmd,cmdp+1,&divisor);
540 cmdp+=2;
541 break;
542 case 't':
543 errors |= param_getdec(Cmd,cmdp+1,&unsigned_trigg);
544 cmdp+=2;
545 if(!errors) trigger_threshold = unsigned_trigg;
546 break;
547 case 'b':
548 errors |= param_getdec(Cmd,cmdp+1,&bps);
549 cmdp+=2;
550 break;
551 case 'd':
552 errors |= param_getdec(Cmd,cmdp+1,&decimation);
553 cmdp+=2;
554 break;
555 case 'a':
556 averaging = param_getchar(Cmd,cmdp+1) == '1';
557 cmdp+=2;
558 break;
559 default:
560 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
561 errors = 1;
562 break;
563 }
564 if(errors) break;
f6d9fb17 565 }
31abe49f 566 if(cmdp == 0)
f6d9fb17 567 {
31abe49f 568 errors = 1;// No args
f6d9fb17 569 }
31abe49f 570
f6d9fb17
MHS
571 //Validations
572 if(errors)
573 {
31abe49f 574 return usage_lf_config();
f6d9fb17 575 }
f6d9fb17 576 //Bps is limited to 8, so fits in lower half of arg1
31abe49f 577 if(bps >> 8) bps = 8;
f6d9fb17 578
31abe49f
MHS
579 sample_config config = {
580 decimation,bps,averaging,divisor,trigger_threshold
581 };
582 //Averaging is a flag on high-bit of arg[1]
583 UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG};
584 memcpy(c.d.asBytes,&config,sizeof(sample_config));
a126332a 585 clearCommandBuffer();
31abe49f
MHS
586 SendCommand(&c);
587 return 0;
588}
f6d9fb17 589
7fe9b0b7 590int CmdLFRead(const char *Cmd)
591{
1fbf8956 592 bool arg1 = false;
f82894ba 593 uint8_t cmdp = param_getchar(Cmd, 0);
594
595 if ( cmdp == 'h' || cmdp == 'H') return usage_lf_read();
596
597 //suppress print
598 if ( cmdp == 's' || cmdp == 'S') arg1 = true;
599
1fbf8956 600 UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {arg1,0,0}};
f82894ba 601 clearCommandBuffer();
31abe49f 602 SendCommand(&c);
68008fb5 603 if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {
604 PrintAndLog("command execution time out");
605 return 1;
606 }
31abe49f
MHS
607 return 0;
608}
f6d9fb17 609
31abe49f
MHS
610int CmdLFSnoop(const char *Cmd)
611{
f82894ba 612 uint8_t cmdp = param_getchar(Cmd, 0);
613 if(cmdp == 'h' || cmdp == 'H') return usage_lf_snoop();
614
31abe49f 615 UsbCommand c = {CMD_LF_SNOOP_RAW_ADC_SAMPLES};
f82894ba 616 clearCommandBuffer();
f6d9fb17
MHS
617 SendCommand(&c);
618 WaitForResponse(CMD_ACK,NULL);
619 return 0;
7fe9b0b7 620}
621
622static void ChkBitstream(const char *str)
623{
624 int i;
78f5b1a7 625
7fe9b0b7 626 /* convert to bitstream if necessary */
b915fda3 627 for (i = 0; i < (int)(GraphTraceLen / 2); i++){
628 if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
78f5b1a7 629 CmdGetBitStream("");
7fe9b0b7 630 break;
631 }
632 }
633}
2767fc02 634//Attempt to simulate any wave in buffer (one bit per output sample)
635// converts GraphBuffer to bitstream (based on zero crossings) if needed.
7fe9b0b7 636int CmdLFSim(const char *Cmd)
637{
f82894ba 638 int i,j;
639 static int gap;
7fe9b0b7 640
f82894ba 641 sscanf(Cmd, "%i", &gap);
7fe9b0b7 642
2767fc02 643 // convert to bitstream if necessary
f82894ba 644 ChkBitstream(Cmd);
7fe9b0b7 645
2767fc02 646 //can send only 512 bits at a time (1 byte sent per bit...)
f82894ba 647 printf("Sending [%d bytes]", GraphTraceLen);
648 for (i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
649 UsbCommand c = {CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}};
7fe9b0b7 650
f82894ba 651 for (j = 0; j < USB_CMD_DATA_SIZE; j++) {
652 c.d.asBytes[j] = GraphBuffer[i+j];
653 }
654 clearCommandBuffer();
655 SendCommand(&c);
656 WaitForResponse(CMD_ACK,NULL);
657 printf(".");
658 }
abd6112f 659
f82894ba 660 PrintAndLog("\nStarting to simulate");
661 UsbCommand c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}};
662 clearCommandBuffer();
663 SendCommand(&c);
664 return 0;
872e3d4d 665}
712ebfa6 666
abd6112f 667// by marshmellow - sim ask data given clock, fcHigh, fcLow, invert
668// - allow pull data from DemodBuffer
669int CmdLFfskSim(const char *Cmd)
670{
2767fc02 671 //might be able to autodetect FCs and clock from Graphbuffer if using demod buffer
672 // otherwise will need FChigh, FClow, Clock, and bitstream
abd6112f 673 uint8_t fcHigh=0, fcLow=0, clk=0;
674 uint8_t invert=0;
675 bool errors = FALSE;
676 char hexData[32] = {0x00}; // store entered hex data
677 uint8_t data[255] = {0x00};
678 int dataLen = 0;
679 uint8_t cmdp = 0;
680 while(param_getchar(Cmd, cmdp) != 0x00)
681 {
682 switch(param_getchar(Cmd, cmdp))
683 {
684 case 'h':
685 return usage_lf_simfsk();
686 case 'i':
687 invert = 1;
688 cmdp++;
689 break;
690 case 'c':
691 errors |= param_getdec(Cmd,cmdp+1,&clk);
692 cmdp+=2;
693 break;
694 case 'H':
695 errors |= param_getdec(Cmd,cmdp+1,&fcHigh);
696 cmdp+=2;
697 break;
698 case 'L':
699 errors |= param_getdec(Cmd,cmdp+1,&fcLow);
700 cmdp+=2;
701 break;
702 //case 's':
703 // separator=1;
704 // cmdp++;
705 // break;
706 case 'd':
707 dataLen = param_getstr(Cmd, cmdp+1, hexData);
708 if (dataLen==0) {
709 errors=TRUE;
710 } else {
711 dataLen = hextobinarray((char *)data, hexData);
872e3d4d 712 }
713 if (dataLen==0) errors=TRUE;
abd6112f 714 if (errors) PrintAndLog ("Error getting hex data");
715 cmdp+=2;
716 break;
717 default:
718 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
719 errors = TRUE;
720 break;
721 }
722 if(errors) break;
723 }
724 if(cmdp == 0 && DemodBufferLen == 0)
725 {
726 errors = TRUE;// No args
727 }
728
729 //Validations
730 if(errors)
731 {
732 return usage_lf_simfsk();
733 }
872e3d4d 734
735 if (dataLen == 0){ //using DemodBuffer
736 if (clk==0 || fcHigh==0 || fcLow==0){ //manual settings must set them all
abd6112f 737 uint8_t ans = fskClocks(&fcHigh, &fcLow, &clk, 0);
738 if (ans==0){
872e3d4d 739 if (!fcHigh) fcHigh=10;
740 if (!fcLow) fcLow=8;
741 if (!clk) clk=50;
abd6112f 742 }
743 }
744 } else {
745 setDemodBuf(data, dataLen, 0);
746 }
2767fc02 747
748 //default if not found
abd6112f 749 if (clk == 0) clk = 50;
750 if (fcHigh == 0) fcHigh = 10;
751 if (fcLow == 0) fcLow = 8;
752
753 uint16_t arg1, arg2;
754 arg1 = fcHigh << 8 | fcLow;
755 arg2 = invert << 8 | clk;
5658e82e 756 size_t size = DemodBufferLen;
757 if (size > USB_CMD_DATA_SIZE) {
758 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
759 size = USB_CMD_DATA_SIZE;
760 }
761 UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}};
762
763 memcpy(c.d.asBytes, DemodBuffer, size);
a126332a 764 clearCommandBuffer();
abd6112f 765 SendCommand(&c);
766 return 0;
767}
768
769// by marshmellow - sim ask data given clock, invert, manchester or raw, separator
770// - allow pull data from DemodBuffer
771int CmdLFaskSim(const char *Cmd)
772{
abd6112f 773 //autodetect clock from Graphbuffer if using demod buffer
2767fc02 774 // needs clock, invert, manchester/raw as m or r, separator as s, and bitstream
b41534d1 775 uint8_t encoding = 1, separator = 0;
abd6112f 776 uint8_t clk=0, invert=0;
777 bool errors = FALSE;
778 char hexData[32] = {0x00};
779 uint8_t data[255]= {0x00}; // store entered hex data
780 int dataLen = 0;
781 uint8_t cmdp = 0;
782 while(param_getchar(Cmd, cmdp) != 0x00)
783 {
784 switch(param_getchar(Cmd, cmdp))
785 {
786 case 'h':
787 return usage_lf_simask();
788 case 'i':
789 invert = 1;
790 cmdp++;
791 break;
792 case 'c':
793 errors |= param_getdec(Cmd,cmdp+1,&clk);
794 cmdp+=2;
795 break;
b41534d1 796 case 'b':
797 encoding=2; //biphase
798 cmdp++;
799 break;
abd6112f 800 case 'm':
b41534d1 801 encoding=1;
abd6112f 802 cmdp++;
803 break;
804 case 'r':
b41534d1 805 encoding=0;
abd6112f 806 cmdp++;
807 break;
808 case 's':
809 separator=1;
810 cmdp++;
811 break;
812 case 'd':
813 dataLen = param_getstr(Cmd, cmdp+1, hexData);
814 if (dataLen==0) {
815 errors=TRUE;
816 } else {
817 dataLen = hextobinarray((char *)data, hexData);
818 }
819 if (dataLen==0) errors=TRUE;
820 if (errors) PrintAndLog ("Error getting hex data, datalen: %d",dataLen);
821 cmdp+=2;
822 break;
823 default:
824 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
825 errors = TRUE;
826 break;
827 }
828 if(errors) break;
829 }
830 if(cmdp == 0 && DemodBufferLen == 0)
831 {
832 errors = TRUE;// No args
833 }
834
835 //Validations
836 if(errors)
837 {
838 return usage_lf_simask();
839 }
840 if (dataLen == 0){ //using DemodBuffer
841 if (clk == 0) clk = GetAskClock("0", false, false);
842 } else {
843 setDemodBuf(data, dataLen, 0);
844 }
845 if (clk == 0) clk = 64;
b41534d1 846 if (encoding == 0) clk = clk/2; //askraw needs to double the clock speed
abd6112f 847 uint16_t arg1, arg2;
8d960002 848 size_t size=DemodBufferLen;
b41534d1 849 arg1 = clk << 8 | encoding;
abd6112f 850 arg2 = invert << 8 | separator;
8d960002 851 if (size > USB_CMD_DATA_SIZE) {
852 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
853 size = USB_CMD_DATA_SIZE;
abd6112f 854 }
8d960002 855 UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}};
8d960002 856 PrintAndLog("preparing to sim ask data: %d bits", size);
857 memcpy(c.d.asBytes, DemodBuffer, size);
a126332a 858 clearCommandBuffer();
abd6112f 859 SendCommand(&c);
860 return 0;
861}
862
872e3d4d 863// by marshmellow - sim psk data given carrier, clock, invert
864// - allow pull data from DemodBuffer or parameters
865int CmdLFpskSim(const char *Cmd)
866{
867 //might be able to autodetect FC and clock from Graphbuffer if using demod buffer
868 //will need carrier, Clock, and bitstream
869 uint8_t carrier=0, clk=0;
870 uint8_t invert=0;
871 bool errors = FALSE;
872 char hexData[32] = {0x00}; // store entered hex data
873 uint8_t data[255] = {0x00};
874 int dataLen = 0;
875 uint8_t cmdp = 0;
876 uint8_t pskType = 1;
877 while(param_getchar(Cmd, cmdp) != 0x00)
878 {
879 switch(param_getchar(Cmd, cmdp))
880 {
881 case 'h':
882 return usage_lf_simpsk();
883 case 'i':
884 invert = 1;
885 cmdp++;
886 break;
887 case 'c':
888 errors |= param_getdec(Cmd,cmdp+1,&clk);
889 cmdp+=2;
890 break;
891 case 'r':
892 errors |= param_getdec(Cmd,cmdp+1,&carrier);
893 cmdp+=2;
894 break;
895 case '1':
896 pskType=1;
897 cmdp++;
898 break;
899 case '2':
900 pskType=2;
901 cmdp++;
902 break;
903 case '3':
904 pskType=3;
905 cmdp++;
906 break;
907 case 'd':
908 dataLen = param_getstr(Cmd, cmdp+1, hexData);
909 if (dataLen==0) {
910 errors=TRUE;
911 } else {
912 dataLen = hextobinarray((char *)data, hexData);
913 }
914 if (dataLen==0) errors=TRUE;
915 if (errors) PrintAndLog ("Error getting hex data");
916 cmdp+=2;
917 break;
918 default:
919 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
920 errors = TRUE;
921 break;
922 }
923 if (errors) break;
924 }
925 if (cmdp == 0 && DemodBufferLen == 0)
926 {
927 errors = TRUE;// No args
928 }
929
930 //Validations
931 if (errors)
932 {
933 return usage_lf_simpsk();
934 }
935 if (dataLen == 0){ //using DemodBuffer
8d960002 936 PrintAndLog("Getting Clocks");
937 if (clk==0) clk = GetPskClock("", FALSE, FALSE);
938 PrintAndLog("clk: %d",clk);
939 if (!carrier) carrier = GetPskCarrier("", FALSE, FALSE);
940 PrintAndLog("carrier: %d", carrier);
872e3d4d 941 } else {
942 setDemodBuf(data, dataLen, 0);
943 }
8d960002 944
872e3d4d 945 if (clk <= 0) clk = 32;
946 if (carrier == 0) carrier = 2;
3bc66a96 947 if (pskType != 1){
948 if (pskType == 2){
949 //need to convert psk2 to psk1 data before sim
950 psk2TOpsk1(DemodBuffer, DemodBufferLen);
951 } else {
952 PrintAndLog("Sorry, PSK3 not yet available");
953 }
954 }
872e3d4d 955 uint16_t arg1, arg2;
956 arg1 = clk << 8 | carrier;
957 arg2 = invert;
5658e82e 958 size_t size=DemodBufferLen;
959 if (size > USB_CMD_DATA_SIZE) {
960 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
961 size=USB_CMD_DATA_SIZE;
872e3d4d 962 }
5658e82e 963 UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}};
964 PrintAndLog("DEBUG: Sending DemodBuffer Length: %d", size);
965 memcpy(c.d.asBytes, DemodBuffer, size);
a126332a 966 clearCommandBuffer();
872e3d4d 967 SendCommand(&c);
78f5b1a7 968
872e3d4d 969 return 0;
970}
abd6112f 971
7fe9b0b7 972int CmdLFSimBidir(const char *Cmd)
973{
3fe4ff4f 974 // Set ADC to twice the carrier for a slight supersampling
975 // HACK: not implemented in ARMSRC.
976 PrintAndLog("Not implemented yet.");
7fe9b0b7 977 UsbCommand c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}};
978 SendCommand(&c);
979 return 0;
980}
981
7fe9b0b7 982int CmdVchDemod(const char *Cmd)
983{
984 // Is this the entire sync pattern, or does this also include some
985 // data bits that happen to be the same everywhere? That would be
986 // lovely to know.
987 static const int SyncPattern[] = {
988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
989 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
991 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
992 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
993 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
994 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
995 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
996 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
997 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
998 };
999
1000 // So first, we correlate for the sync pattern, and mark that.
1001 int bestCorrel = 0, bestPos = 0;
1002 int i;
1003 // It does us no good to find the sync pattern, with fewer than
1004 // 2048 samples after it...
1005 for (i = 0; i < (GraphTraceLen-2048); i++) {
1006 int sum = 0;
1007 int j;
1008 for (j = 0; j < arraylen(SyncPattern); j++) {
1009 sum += GraphBuffer[i+j]*SyncPattern[j];
1010 }
1011 if (sum > bestCorrel) {
1012 bestCorrel = sum;
1013 bestPos = i;
1014 }
1015 }
1016 PrintAndLog("best sync at %d [metric %d]", bestPos, bestCorrel);
1017
1018 char bits[257];
1019 bits[256] = '\0';
1020
1021 int worst = INT_MAX;
fddf220a 1022 int worstPos = 0;
7fe9b0b7 1023
1024 for (i = 0; i < 2048; i += 8) {
1025 int sum = 0;
1026 int j;
1027 for (j = 0; j < 8; j++) {
1028 sum += GraphBuffer[bestPos+i+j];
1029 }
1030 if (sum < 0) {
1031 bits[i/8] = '.';
1032 } else {
1033 bits[i/8] = '1';
1034 }
1035 if(abs(sum) < worst) {
1036 worst = abs(sum);
1037 worstPos = i;
1038 }
1039 }
1040 PrintAndLog("bits:");
1041 PrintAndLog("%s", bits);
1042 PrintAndLog("worst metric: %d at pos %d", worst, worstPos);
1043
1044 if (strcmp(Cmd, "clone")==0) {
1045 GraphTraceLen = 0;
1046 char *s;
1047 for(s = bits; *s; s++) {
1048 int j;
1049 for(j = 0; j < 16; j++) {
1050 GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0;
1051 }
1052 }
1053 RepaintGraphWindow();
1054 }
1055 return 0;
1056}
1057
d5a72d2f 1058//by marshmellow
e9a92fe2 1059int CmdLFfind(const char *Cmd) {
1060 int ans = 0;
1061 char cmdp = param_getchar(Cmd, 0);
1062 char testRaw = param_getchar(Cmd, 1);
1063 if (strlen(Cmd) > 3 || cmdp == 'h' || cmdp == 'H') return usage_lf_find();
1064
1065 if (!offline && (cmdp != '1')){
1066 CmdLFRead("s");
1067 getSamples("30000",false);
1068 } else if (GraphTraceLen < 1000) {
1069 PrintAndLog("Data in Graphbuffer was too small.");
1070 return 0;
1071 }
1072 if (cmdp == 'u' || cmdp == 'U') testRaw = 'u';
13d77ef9 1073
e9a92fe2 1074 PrintAndLog("NOTE: some demods output possible binary\n if it finds something that looks like a tag");
1075 PrintAndLog("False Positives ARE possible\n");
1076 PrintAndLog("\nChecking for known tags:\n");
13d77ef9 1077
e9a92fe2 1078 ans=CmdFSKdemodIO("");
1079 if (ans>0) {
1080 PrintAndLog("\nValid IO Prox ID Found!");
1081 return 1;
1082 }
13d77ef9 1083
e9a92fe2 1084 ans=CmdFSKdemodPyramid("");
1085 if (ans>0) {
1086 PrintAndLog("\nValid Pyramid ID Found!");
1087 return 1;
1088 }
13d77ef9 1089
e9a92fe2 1090 ans=CmdFSKdemodParadox("");
1091 if (ans>0) {
1092 PrintAndLog("\nValid Paradox ID Found!");
1093 return 1;
1094 }
13d77ef9 1095
e9a92fe2 1096 ans=CmdFSKdemodAWID("");
1097 if (ans>0) {
1098 PrintAndLog("\nValid AWID ID Found!");
1099 return 1;
1100 }
13d77ef9 1101
e9a92fe2 1102 ans=CmdFSKdemodHID("");
1103 if (ans>0) {
1104 PrintAndLog("\nValid HID Prox ID Found!");
1105 return 1;
1106 }
13d77ef9 1107
e9a92fe2 1108 ans=CmdAskEM410xDemod("");
1109 if (ans>0) {
1110 PrintAndLog("\nValid EM410x ID Found!");
1111 return 1;
1112 }
13d77ef9 1113
e9a92fe2 1114 ans=CmdG_Prox_II_Demod("");
1115 if (ans>0) {
1116 PrintAndLog("\nValid Guardall G-Prox II ID Found!");
1117 return 1;
1118 }
13d77ef9 1119
ad6219fc 1120 ans=CmdFDXBdemodBI("");
1121 if (ans>0) {
1122 PrintAndLog("\nValid FDX-B ID Found!");
1123 return 1;
1124 }
1125
23f0a7d8 1126 ans=EM4x50Read("", false);
1127 if (ans>0) {
1128 PrintAndLog("\nValid EM4x50 ID Found!");
1129 return 1;
1130 }
411105e0 1131
70459879 1132 ans=CmdVikingDemod("");
1133 if (ans>0) {
1134 PrintAndLog("\nValid Viking ID Found!");
1135 return 1;
1136 }
1137
6426f6ba 1138 ans=CmdIndalaDecode("");
1139 if (ans>0) {
1140 PrintAndLog("\nValid Indala ID Found!");
1141 return 1;
1142 }
1143
411105e0 1144 ans=CmdPSKNexWatch("");
1145 if (ans>0) {
1146 PrintAndLog("\nValid NexWatch ID Found!");
1147 return 1;
1148 }
e9a92fe2 1149 // TIdemod?
1150
411105e0 1151
e9a92fe2 1152 PrintAndLog("\nNo Known Tags Found!\n");
1153 if (testRaw=='u' || testRaw=='U'){
1154 //test unknown tag formats (raw mode)
1155 PrintAndLog("\nChecking for Unknown tags:\n");
1156 ans=AutoCorrelate(4000, FALSE, FALSE);
251d07db 1157
e9a92fe2 1158 if (ans > 0) {
251d07db 1159
e9a92fe2 1160 PrintAndLog("Possible Auto Correlation of %d repeating samples",ans);
251d07db 1161
e9a92fe2 1162 if ( ans % 8 == 0) {
1163 int bytes = (ans / 8);
1164 PrintAndLog("Possible %d bytes", bytes);
1165 int blocks = 0;
1166 if ( bytes % 2 == 0) {
1167 blocks = (bytes / 2);
1168 PrintAndLog("Possible 2 blocks, width %d", blocks);
1169 }
1170 if ( bytes % 4 == 0) {
1171 blocks = (bytes / 4);
1172 PrintAndLog("Possible 4 blocks, width %d", blocks);
1173 }
1174 if ( bytes % 8 == 0) {
1175 blocks = (bytes / 8);
1176 PrintAndLog("Possible 8 blocks, width %d", blocks);
1177 }
1178 if ( bytes % 16 == 0) {
1179 blocks = (bytes / 16);
1180 PrintAndLog("Possible 16 blocks, width %d", blocks);
1181 }
251d07db 1182 }
e9a92fe2 1183 }
1184
1185 ans=GetFskClock("",FALSE,FALSE);
1186 if (ans != 0){ //fsk
1187 ans=FSKrawDemod("",TRUE);
1188 if (ans>0) {
1189 PrintAndLog("\nUnknown FSK Modulated Tag Found!");
1190 return 1;
251d07db 1191 }
1192 }
e9a92fe2 1193
1194 ans=ASKDemod("0 0 0",TRUE,FALSE,1);
70459879 1195 if (ans>0) {
e9a92fe2 1196 PrintAndLog("\nUnknown ASK Modulated and Manchester encoded Tag Found!");
1197 PrintAndLog("\nif it does not look right it could instead be ASK/Biphase - try 'data rawdemod ab'");
1198 return 1;
1199 }
1200
1201 ans=CmdPSK1rawDemod("");
1202 if (ans>0) {
1203 PrintAndLog("Possible unknown PSK1 Modulated Tag Found above!\n\nCould also be PSK2 - try 'data rawdemod p2'");
1204 PrintAndLog("\nCould also be PSK3 - [currently not supported]");
1205 PrintAndLog("\nCould also be NRZ - try 'data nrzrawdemod");
70459879 1206 return 1;
1207 }
e9a92fe2 1208 PrintAndLog("\nNo Data Found!\n");
1209 }
1210 return 0;
d5a72d2f 1211}
1212
7fe9b0b7 1213static command_t CommandTable[] =
1214{
c2731f37 1215 {"help", CmdHelp, 1, "This help"},
9276e859 1216 {"awid", CmdLFAWID, 1, "{ AWID RFIDs... }"},
c2731f37 1217 {"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"},
1218 {"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
1219 {"hitag", CmdLFHitag, 1, "{ HITAG RFIDs... }"},
1220 {"io", CmdLFIO, 1, "{ IOPROX RFIDs... }"},
1221 {"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 RFIDs... }"},
1222 {"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
1223 {"t55xx", CmdLFT55XX, 1, "{ T55X7 RFIDs... }"},
1224 {"viking", CmdLFViking, 1, "{ Viking RFIDs... }"},
1225 {"config", CmdLFSetConfig, 0, "Set config for LF sampling, bit/sample, decimation, frequency"},
1226
1227 {"cmdread", CmdLFCommandRead, 0, "<off period> <'0' period> <'1' period> <command> ['h' 134] \n\t\t-- Modulate LF reader field to send command before read (all periods in microseconds)"},
1228 {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},
1229 {"indalademod", CmdIndalaDemod, 1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
1230 {"indalaclone", CmdIndalaClone, 0, "<UID> ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"},
1231 {"read", CmdLFRead, 0, "['s' silent] Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"},
1232 {"search", CmdLFfind, 1, "[offline] ['u'] Read and Search for valid known tag (in offline mode it you can load first then search) \n\t\t-- 'u' to search for unknown tags"},
1233 {"sim", CmdLFSim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
1234 {"simask", CmdLFaskSim, 0, "[clock] [invert <1|0>] [biphase/manchester/raw <'b'|'m'|'r'>] [msg separator 's'] [d <hexdata>] \n\t\t-- Simulate LF ASK tag from demodbuffer or input"},
1235 {"simfsk", CmdLFfskSim, 0, "[c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>] \n\t\t-- Simulate LF FSK tag from demodbuffer or input"},
1236 {"simpsk", CmdLFpskSim, 0, "[1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>] \n\t\t-- Simulate LF PSK tag from demodbuffer or input"},
1237 {"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
1238 {"snoop", CmdLFSnoop, 0, "Snoop LF"},
1239 {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
1240 {NULL, NULL, 0, NULL}
7fe9b0b7 1241};
1242
1243int CmdLF(const char *Cmd)
1244{
1245 CmdsParse(CommandTable, Cmd);
1246 return 0;
1247}
1248
1249int CmdHelp(const char *Cmd)
1250{
1251 CmdsHelp(CommandTable);
1252 return 0;
1253}
Impressum, Datenschutz