]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfhid.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
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
7 //-----------------------------------------------------------------------------
8 // Low frequency HID commands
9 //-----------------------------------------------------------------------------
13 //#include "proxusb.h"
14 #include "proxmark3.h"
17 #include "cmdparser.h"
20 static int CmdHelp(const char *Cmd
);
22 int CmdHIDDemod(const char *Cmd
)
24 if (GraphTraceLen
< 4800) {
25 PrintAndLog("too short; need at least 4800 samples");
30 for (int i
= 0; i
< GraphTraceLen
; ++i
) {
31 if (GraphBuffer
[i
] < 0) {
41 int CmdHIDDemodFSK(const char *Cmd
)
43 UsbCommand c
={CMD_HID_DEMOD_FSK
};
48 int CmdHIDSim(const char *Cmd
)
50 unsigned int hi
= 0, lo
= 0;
53 while (sscanf(&Cmd
[i
++], "%1x", &n
) == 1) {
54 hi
= (hi
<< 4) | (lo
>> 28);
55 lo
= (lo
<< 4) | (n
& 0xf);
58 PrintAndLog("Emulating tag with ID %x%16x", hi
, lo
);
60 UsbCommand c
= {CMD_HID_SIM_TAG
, {hi
, lo
, 0}};
65 int CmdHIDClone(const char *Cmd
)
67 unsigned int hi2
= 0, hi
= 0, lo
= 0;
71 if (strchr(Cmd
,'l') != 0) {
72 while (sscanf(&Cmd
[i
++], "%1x", &n
) == 1) {
73 hi2
= (hi2
<< 4) | (hi
>> 28);
74 hi
= (hi
<< 4) | (lo
>> 28);
75 lo
= (lo
<< 4) | (n
& 0xf);
78 PrintAndLog("Cloning tag with long ID %x%08x%08x", hi2
, hi
, lo
);
83 while (sscanf(&Cmd
[i
++], "%1x", &n
) == 1) {
84 hi
= (hi
<< 4) | (lo
>> 28);
85 lo
= (lo
<< 4) | (n
& 0xf);
88 PrintAndLog("Cloning tag with ID %x%08x", hi
, lo
);
94 c
.cmd
= CMD_HID_CLONE_TAG
;
103 static command_t CommandTable
[] =
105 {"help", CmdHelp
, 1, "This help"},
106 {"demod", CmdHIDDemod
, 1, "Demodulate HID Prox Card II (not optimal)"},
107 {"fskdemod", CmdHIDDemodFSK
, 1, "Realtime HID FSK demodulator"},
108 {"sim", CmdHIDSim
, 1, "<ID> -- HID tag simulator"},
109 {"clone", CmdHIDClone
, 1, "<ID> ['l'] -- Clone HID to T55x7 (tag must be in antenna)(option 'l' for 84bit ID)"},
110 {NULL
, NULL
, 0, NULL
}
113 int CmdLFHID(const char *Cmd
)
115 CmdsParse(CommandTable
, Cmd
);
119 int CmdHelp(const char *Cmd
)
121 CmdsHelp(CommandTable
);