]>
Commit | Line | Data |
---|---|---|
7fe9b0b7 | 1 | #include <stdio.h> |
2 | #include "proxusb.h" | |
3 | #include "ui.h" | |
4 | #include "graph.h" | |
5 | #include "cmdparser.h" | |
6 | #include "cmdlfhid.h" | |
7 | ||
8 | static int CmdHelp(const char *Cmd); | |
9 | ||
10 | int CmdHIDDemod(const char *Cmd) | |
11 | { | |
12 | if (GraphTraceLen < 4800) { | |
13 | PrintAndLog("too short; need at least 4800 samples"); | |
14 | return 0; | |
15 | } | |
16 | ||
17 | GraphTraceLen = 4800; | |
18 | for (int i = 0; i < GraphTraceLen; ++i) { | |
19 | if (GraphBuffer[i] < 0) { | |
20 | GraphBuffer[i] = 0; | |
21 | } else { | |
22 | GraphBuffer[i] = 1; | |
23 | } | |
24 | } | |
25 | RepaintGraphWindow(); | |
26 | return 0; | |
27 | } | |
28 | ||
29 | int CmdHIDDemodFSK(const char *Cmd) | |
30 | { | |
31 | UsbCommand c={CMD_HID_DEMOD_FSK}; | |
32 | SendCommand(&c); | |
33 | return 0; | |
34 | } | |
35 | ||
36 | int CmdHIDSim(const char *Cmd) | |
37 | { | |
38 | unsigned int hi = 0, lo = 0; | |
39 | int n = 0, i = 0; | |
40 | ||
41 | while (sscanf(&Cmd[i++], "%1x", &n ) == 1) { | |
42 | hi = (hi << 4) | (lo >> 28); | |
43 | lo = (lo << 4) | (n & 0xf); | |
44 | } | |
45 | ||
46 | PrintAndLog("Emulating tag with ID %x%16x", hi, lo); | |
47 | ||
48 | UsbCommand c = {CMD_HID_SIM_TAG, {hi, lo, 0}}; | |
49 | SendCommand(&c); | |
50 | return 0; | |
51 | } | |
52 | ||
53 | static command_t CommandTable[] = | |
54 | { | |
55 | {"help", CmdHelp, 1, "This help"}, | |
56 | {"demod", CmdHIDDemod, 1, "Demodulate HID Prox Card II (not optimal)"}, | |
57 | {"fskdemod", CmdHIDDemodFSK, 0, "Realtime HID FSK demodulator"}, | |
58 | {"sim", CmdHIDSim, 0, "<ID> -- HID tag simulator"}, | |
59 | {NULL, NULL, 0, NULL} | |
60 | }; | |
61 | ||
62 | int CmdLFHID(const char *Cmd) | |
63 | { | |
64 | CmdsParse(CommandTable, Cmd); | |
65 | return 0; | |
66 | } | |
67 | ||
68 | int CmdHelp(const char *Cmd) | |
69 | { | |
70 | CmdsHelp(CommandTable); | |
71 | return 0; | |
72 | } |