]> git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfio.c
First check in.
[proxmark3-svn] / client / cmdlfio.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <limits.h>
6 #include "proxmark3.h"
7 #include "data.h"
8 #include "graph.h"
9 #include "ui.h"
10 #include "cmdparser.h"
11 #include "cmdmain.h"
12 #include "cmddata.h"
13 #include "cmdlf.h"
14
15 static int CmdHelp(const char *Cmd);
16
17 int CmdIODemodFSK(const char *Cmd)
18 {
19 UsbCommand c={CMD_IO_DEMOD_FSK};
20 SendCommand(&c);
21 return 0;
22 }
23
24
25 int CmdIOProxDemod(const char *Cmd){
26 if (GraphTraceLen < 4800) {
27 PrintAndLog("too short; need at least 4800 samples");
28 return 0;
29 }
30
31 GraphTraceLen = 4800;
32 for (int i = 0; i < GraphTraceLen; ++i) {
33 if (GraphBuffer[i] < 0) {
34 GraphBuffer[i] = 0;
35 } else {
36 GraphBuffer[i] = 1;
37 }
38 }
39 RepaintGraphWindow();
40 return 0;
41 }
42
43 int CmdIOClone(const char *Cmd)
44 {
45 unsigned int hi = 0, lo = 0;
46 int n = 0, i = 0;
47 UsbCommand c;
48
49
50 //if (1 == sscanf(str, "0x%"SCNx32, &hi)) {
51 // value now contains the value in the string--decimal 255, in this case.
52 //}
53
54 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
55 hi = (hi << 4) | (lo >> 28);
56 lo = (lo << 4) | (n & 0xf);
57 }
58
59 PrintAndLog("Cloning tag with ID %08x %08x", hi, lo);
60
61 c.cmd = CMD_IO_CLONE_TAG;
62 c.arg[0] = hi;
63 c.arg[1] = lo;
64
65 SendCommand(&c);
66 return 0;
67 }
68
69 static command_t CommandTable[] =
70 {
71 {"help", CmdHelp, 1, "This help"},
72 {"demod", CmdIOProxDemod, 1, "Demodulate Stream"},
73 {"fskdemod", CmdIODemodFSK, 1, "Demodulate ioProx Tag"},
74 {"clone", CmdIOClone, 1, "Clone ioProx Tag"},
75 {NULL, NULL, 0, NULL}
76 };
77
78 int CmdLFIO(const char *Cmd)
79 {
80 CmdsParse(CommandTable, Cmd);
81 return 0;
82 }
83
84 int CmdHelp(const char *Cmd)
85 {
86 CmdsHelp(CommandTable);
87 return 0;
88 }
Impressum, Datenschutz