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