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