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