]> git.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlft55xx.c
implemented 'hf iclass dump xxxx',
[proxmark3-svn] / client / cmdlft55xx.c
1 //-----------------------------------------------------------------------------
2 //
3 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
4 // at your option, any later version. See the LICENSE.txt file for the text of
5 // the license.
6 //-----------------------------------------------------------------------------
7 // Low frequency T55xx commands
8 //-----------------------------------------------------------------------------
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <inttypes.h>
13 //#include "proxusb.h"
14 #include "proxmark3.h"
15 #include "ui.h"
16 #include "graph.h"
17 #include "cmdparser.h"
18 #include "cmddata.h"
19 #include "cmdlf.h"
20 #include "cmdlft55xx.h"
21
22 static int CmdHelp(const char *Cmd);
23
24
25 int CmdReadBlk(const char *Cmd)
26 {
27 int Block = 8; //default to invalid block
28 UsbCommand c;
29
30 sscanf(Cmd, "%d", &Block);
31
32 if (Block > 7) {
33 PrintAndLog("Block must be between 0 and 7");
34 return 1;
35 }
36
37 PrintAndLog("Reading block %d", Block);
38
39 c.cmd = CMD_T55XX_READ_BLOCK;
40 c.d.asBytes[0] = 0x0; //Normal mode
41 c.arg[0] = 0;
42 c.arg[1] = Block;
43 c.arg[2] = 0;
44 SendCommand(&c);
45 return 0;
46 }
47
48 int CmdReadBlkPWD(const char *Cmd)
49 {
50 int Block = 8; //default to invalid block
51 int Password = 0xFFFFFFFF; //default to blank Block 7
52 UsbCommand c;
53
54 sscanf(Cmd, "%d %x", &Block, &Password);
55
56 if (Block > 7) {
57 PrintAndLog("Block must be between 0 and 7");
58 return 1;
59 }
60
61 PrintAndLog("Reading block %d with password %08X", Block, Password);
62
63 c.cmd = CMD_T55XX_READ_BLOCK;
64 c.d.asBytes[0] = 0x1; //Password mode
65 c.arg[0] = 0;
66 c.arg[1] = Block;
67 c.arg[2] = Password;
68 SendCommand(&c);
69 return 0;
70 }
71
72 int CmdWriteBlk(const char *Cmd)
73 {
74 int Block = 8; //default to invalid block
75 int Data = 0xFFFFFFFF; //default to blank Block
76 UsbCommand c;
77
78 sscanf(Cmd, "%x %d", &Data, &Block);
79
80 if (Block > 7) {
81 PrintAndLog("Block must be between 0 and 7");
82 return 1;
83 }
84
85 PrintAndLog("Writting block %d with data %08X", Block, Data);
86
87 c.cmd = CMD_T55XX_WRITE_BLOCK;
88 c.d.asBytes[0] = 0x0; //Normal mode
89 c.arg[0] = Data;
90 c.arg[1] = Block;
91 c.arg[2] = 0;
92 SendCommand(&c);
93 return 0;
94 }
95
96 int CmdWriteBlkPWD(const char *Cmd)
97 {
98 int Block = 8; //default to invalid block
99 int Data = 0xFFFFFFFF; //default to blank Block
100 int Password = 0xFFFFFFFF; //default to blank Block 7
101 UsbCommand c;
102
103 sscanf(Cmd, "%x %d %x", &Data, &Block, &Password);
104
105 if (Block > 7) {
106 PrintAndLog("Block must be between 0 and 7");
107 return 1;
108 }
109
110 PrintAndLog("Writting block %d with data %08X and password %08X", Block, Data, Password);
111
112 c.cmd = CMD_T55XX_WRITE_BLOCK;
113 c.d.asBytes[0] = 0x1; //Password mode
114 c.arg[0] = Data;
115 c.arg[1] = Block;
116 c.arg[2] = Password;
117 SendCommand(&c);
118 return 0;
119 }
120
121 int CmdReadTrace(const char *Cmd)
122 {
123
124 PrintAndLog("Reading traceability data");
125
126 UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};
127 SendCommand(&c);
128 return 0;
129 }
130
131 static command_t CommandTable[] =
132 {
133 {"help", CmdHelp, 1, "This help"},
134 {"readblock", CmdReadBlk, 1, "<Block> -- Read T55xx block data (page 0)"},
135 {"readblockPWD", CmdReadBlkPWD, 1, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},
136 {"writeblock", CmdWriteBlk, 1, "<Data> <Block> -- Write T55xx block data (page 0)"},
137 {"writeblockPWD", CmdWriteBlkPWD, 1, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},
138 {"readtrace", CmdReadTrace, 1, "Read T55xx traceability data (page 1)"},
139 {NULL, NULL, 0, NULL}
140 };
141
142 int CmdLFT55XX(const char *Cmd)
143 {
144 CmdsParse(CommandTable, Cmd);
145 return 0;
146 }
147
148 int CmdHelp(const char *Cmd)
149 {
150 CmdsHelp(CommandTable);
151 return 0;
152 }
Impressum, Datenschutz