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