1 //-----------------------------------------------------------------------------
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
6 //-----------------------------------------------------------------------------
7 // Low frequency T55xx commands
8 //-----------------------------------------------------------------------------
13 //#include "proxusb.h"
14 #include "proxmark3.h"
17 #include "cmdparser.h"
20 #include "cmdlft55xx.h"
22 static int CmdHelp(const char *Cmd
);
25 int CmdReadBlk(const char *Cmd
)
27 int Block
= 8; //default to invalid block
30 sscanf(Cmd
, "%d", &Block
);
33 PrintAndLog("Block must be between 0 and 7");
37 PrintAndLog("Reading block %d", Block
);
39 c
.cmd
= CMD_T55XX_READ_BLOCK
;
40 c
.d
.asBytes
[0] = 0x0; //Normal mode
48 int CmdReadBlkPWD(const char *Cmd
)
50 int Block
= 8; //default to invalid block
51 int Password
= 0xFFFFFFFF; //default to blank Block 7
54 sscanf(Cmd
, "%d %x", &Block
, &Password
);
57 PrintAndLog("Block must be between 0 and 7");
61 PrintAndLog("Reading block %d with password %08X", Block
, Password
);
63 c
.cmd
= CMD_T55XX_READ_BLOCK
;
64 c
.d
.asBytes
[0] = 0x1; //Password mode
72 int CmdWriteBlk(const char *Cmd
)
74 int Block
= 8; //default to invalid block
75 int Data
= 0xFFFFFFFF; //default to blank Block
78 sscanf(Cmd
, "%x %d", &Data
, &Block
);
81 PrintAndLog("Block must be between 0 and 7");
85 PrintAndLog("Writting block %d with data %08X", Block
, Data
);
87 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
88 c
.d
.asBytes
[0] = 0x0; //Normal mode
96 int CmdWriteBlkPWD(const char *Cmd
)
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
103 sscanf(Cmd
, "%x %d %x", &Data
, &Block
, &Password
);
106 PrintAndLog("Block must be between 0 and 7");
110 PrintAndLog("Writting block %d with data %08X and password %08X", Block
, Data
, Password
);
112 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
113 c
.d
.asBytes
[0] = 0x1; //Password mode
121 int CmdReadTrace(const char *Cmd
)
124 PrintAndLog("Reading traceability data");
126 UsbCommand c
= {CMD_T55XX_READ_TRACE
, {0, 0, 0}};
131 static command_t CommandTable
[] =
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
}
142 int CmdLFT55XX(const char *Cmd
)
144 CmdsParse(CommandTable
, Cmd
);
148 int CmdHelp(const char *Cmd
)
150 CmdsHelp(CommandTable
);