Generic tracing; removed iso14a_XX-functions, removed traceLen as global varible
[legacy-proxmark3.git] / client / cmdlft55xx.c
bloba719c7ad7a56e4a6216e910aa4d28cad3069007d
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 //-----------------------------------------------------------------------------
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"
21 static int CmdHelp(const char *Cmd);
24 int CmdReadBlk(const char *Cmd)
26 int Block = 8; //default to invalid block
27 UsbCommand c;
29 sscanf(Cmd, "%d", &Block);
31 if (Block > 7) {
32 PrintAndLog("Block must be between 0 and 7");
33 return 1;
36 PrintAndLog("Reading block %d", Block);
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;
47 int CmdReadBlkPWD(const char *Cmd)
49 int Block = 8; //default to invalid block
50 int Password = 0xFFFFFFFF; //default to blank Block 7
51 UsbCommand c;
53 sscanf(Cmd, "%d %x", &Block, &Password);
55 if (Block > 7) {
56 PrintAndLog("Block must be between 0 and 7");
57 return 1;
60 PrintAndLog("Reading block %d with password %08X", Block, Password);
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;
71 int CmdWriteBlk(const char *Cmd)
73 int Block = 8; //default to invalid block
74 int Data = 0xFFFFFFFF; //default to blank Block
75 UsbCommand c;
77 sscanf(Cmd, "%x %d", &Data, &Block);
79 if (Block > 7) {
80 PrintAndLog("Block must be between 0 and 7");
81 return 1;
84 PrintAndLog("Writting block %d with data %08X", Block, Data);
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;
95 int CmdWriteBlkPWD(const char *Cmd)
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;
102 sscanf(Cmd, "%x %d %x", &Data, &Block, &Password);
104 if (Block > 7) {
105 PrintAndLog("Block must be between 0 and 7");
106 return 1;
109 PrintAndLog("Writting block %d with data %08X and password %08X", Block, Data, Password);
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;
120 int CmdReadTrace(const char *Cmd)
123 PrintAndLog("Reading traceability data");
125 UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};
126 SendCommand(&c);
127 return 0;
130 static command_t CommandTable[] =
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}
141 int CmdLFT55XX(const char *Cmd)
143 CmdsParse(CommandTable, Cmd);
144 return 0;
147 int CmdHelp(const char *Cmd)
149 CmdsHelp(CommandTable);
150 return 0;