]> cvs.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/cmdlfhid.c
compiling on windows again
[proxmark3-svn] / client / cmdlfhid.c
... / ...
CommitLineData
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 HID commands
9//-----------------------------------------------------------------------------
10
11#include <stdio.h>
12#include <string.h>
13//#include "proxusb.h"
14#include "proxmark3.h"
15#include "ui.h"
16#include "graph.h"
17#include "cmdparser.h"
18#include "cmdlfhid.h"
19
20static int CmdHelp(const char *Cmd);
21
22int CmdHIDDemod(const char *Cmd)
23{
24 if (GraphTraceLen < 4800) {
25 PrintAndLog("too short; need at least 4800 samples");
26 return 0;
27 }
28
29 GraphTraceLen = 4800;
30 for (int i = 0; i < GraphTraceLen; ++i) {
31 if (GraphBuffer[i] < 0) {
32 GraphBuffer[i] = 0;
33 } else {
34 GraphBuffer[i] = 1;
35 }
36 }
37 RepaintGraphWindow();
38 return 0;
39}
40
41int CmdHIDDemodFSK(const char *Cmd)
42{
43 UsbCommand c={CMD_HID_DEMOD_FSK};
44 SendCommand(&c);
45 return 0;
46}
47
48int CmdHIDSim(const char *Cmd)
49{
50 unsigned int hi2 = 0, hi = 0, lo = 0;
51 int n = 0, i = 0;
52 UsbCommand c;
53
54 if (strchr(Cmd,'l') != 0) {
55 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
56 hi2 = (hi2 << 4) | (hi >> 28);
57 hi = (hi << 4) | (lo >> 28);
58 lo = (lo << 4) | (n & 0xf);
59 }
60
61 PrintAndLog("Cloning tag with long ID %x%08x%08x", hi2, hi, lo);
62
63 c.d.asBytes[0] = 1;
64 }
65 else {
66 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
67 hi = (hi << 4) | (lo >> 28);
68 lo = (lo << 4) | (n & 0xf);
69 }
70
71 PrintAndLog("Cloning tag with ID %x%08x", hi, lo);
72
73 hi2 = 0;
74 c.d.asBytes[0] = 0;
75 }
76
77 c.cmd = CMD_HID_CLONE_TAG;
78 c.arg[0] = hi2;
79 c.arg[1] = hi;
80 c.arg[2] = lo;
81
82// UsbCommand c = {CMD_HID_SIM_TAG, {hi, lo, 0}};
83 SendCommand(&c);
84 return 0;
85}
86
87int CmdHIDClone(const char *Cmd)
88{
89 unsigned int hi = 0, lo = 0;
90 int n = 0, i = 0;
91
92 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
93 hi = (hi << 4) | (lo >> 28);
94 lo = (lo << 4) | (n & 0xf);
95 }
96
97 PrintAndLog("Cloning tag with ID %x%08x", hi, lo);
98
99 UsbCommand c = {CMD_HID_CLONE_TAG, {hi, lo}};
100 SendCommand(&c);
101 return 0;
102}
103
104static command_t CommandTable[] =
105{
106 {"help", CmdHelp, 1, "This help"},
107 {"demod", CmdHIDDemod, 1, "Demodulate HID Prox Card II (not optimal)"},
108 {"fskdemod", CmdHIDDemodFSK, 1, "Realtime HID FSK demodulator"},
109 {"sim", CmdHIDSim, 1, "<ID> -- HID tag simulator"},
110 {"clone", CmdHIDClone, 1, "<ID> ['l'] -- Clone HID to T55x7 (tag must be in antenna)(option 'l' for 84bit ID)"},
111 {NULL, NULL, 0, NULL}
112};
113
114int CmdLFHID(const char *Cmd)
115{
116 CmdsParse(CommandTable, Cmd);
117 return 0;
118}
119
120int CmdHelp(const char *Cmd)
121{
122 CmdsHelp(CommandTable);
123 return 0;
124}
Impressum, Datenschutz