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