]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlft55xx.c
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 "proxmark3.h"
17 #include "cmdparser.h"
20 #include "cmdlft55xx.h"
24 #define LF_TRACE_BUFF_SIZE 16000
25 static int CmdHelp(const char *Cmd
);
28 int CmdReadBlk(const char *Cmd
)
30 //default to invalid block
34 sscanf(Cmd
, "%d", &Block
);
36 if ((Block
> 7) | (Block
< 0)) {
37 PrintAndLog("Block must be between 0 and 7");
41 PrintAndLog(" Reading page 0 block : %d", Block
);
43 // this command fills up BigBuff
45 c
.cmd
= CMD_T55XX_READ_BLOCK
;
46 c
.d
.asBytes
[0] = 0x00;
51 WaitForResponse(CMD_ACK
, NULL
);
53 uint8_t data
[LF_TRACE_BUFF_SIZE
];
54 memset(data
, 0x00, LF_TRACE_BUFF_SIZE
);
56 GetFromBigBuf(data
,LF_TRACE_BUFF_SIZE
,3560); //3560 -- should be offset..
57 WaitForResponseTimeout(CMD_ACK
,NULL
, 1500);
59 for (int j
= 0; j
< LF_TRACE_BUFF_SIZE
; j
++) {
60 GraphBuffer
[j
] = ((int)data
[j
]) - 128;
62 GraphTraceLen
= LF_TRACE_BUFF_SIZE
;
65 //CmdDirectionalThreshold("70 60");
71 uint8_t * bitstream
= bits
;
72 memset(bitstream
, 0x00, sizeof(bits
));
74 manchester_decode(GraphBuffer
, LF_TRACE_BUFF_SIZE
, bitstream
);
80 int CmdReadBlkPWD(const char *Cmd
)
82 int Block
= -1; //default to invalid block
83 int Password
= 0xFFFFFFFF; //default to blank Block 7
86 sscanf(Cmd
, "%d %x", &Block
, &Password
);
88 if ((Block
> 7) | (Block
< 0)) {
89 PrintAndLog("Block must be between 0 and 7");
93 PrintAndLog("Reading page 0 block %d pwd %08X", Block
, Password
);
95 c
.cmd
= CMD_T55XX_READ_BLOCK
;
96 c
.d
.asBytes
[0] = 0x1; //Password mode
101 WaitForResponse(CMD_ACK
, NULL
);
103 uint8_t data
[LF_TRACE_BUFF_SIZE
];
104 memset(data
, 0x00, LF_TRACE_BUFF_SIZE
);
106 GetFromBigBuf(data
,LF_TRACE_BUFF_SIZE
,3560); //3560 -- should be offset..
107 WaitForResponseTimeout(CMD_ACK
,NULL
, 1500);
109 for (int j
= 0; j
< LF_TRACE_BUFF_SIZE
; j
++) {
110 GraphBuffer
[j
] = ((int)data
[j
]) - 128;
112 GraphTraceLen
= LF_TRACE_BUFF_SIZE
;
115 //CmdDirectionalThreshold("70 -60");
121 uint8_t * bitstream
= bits
;
122 memset(bitstream
, 0x00, sizeof(bits
));
124 manchester_decode(GraphBuffer
, LF_TRACE_BUFF_SIZE
, bitstream
);
129 int CmdWriteBlk(const char *Cmd
)
131 int Block
= 8; //default to invalid block
132 int Data
= 0xFFFFFFFF; //default to blank Block
135 sscanf(Cmd
, "%x %d", &Data
, &Block
);
138 PrintAndLog("Block must be between 0 and 7");
142 PrintAndLog("Writting block %d with data %08X", Block
, Data
);
144 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
145 c
.d
.asBytes
[0] = 0x0; //Normal mode
153 int CmdWriteBlkPWD(const char *Cmd
)
155 int Block
= 8; //default to invalid block
156 int Data
= 0xFFFFFFFF; //default to blank Block
157 int Password
= 0xFFFFFFFF; //default to blank Block 7
160 sscanf(Cmd
, "%x %d %x", &Data
, &Block
, &Password
);
163 PrintAndLog("Block must be between 0 and 7");
167 PrintAndLog("Writting block %d with data %08X and password %08X", Block
, Data
, Password
);
169 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
170 c
.d
.asBytes
[0] = 0x1; //Password mode
178 int CmdReadTrace(const char *Cmd
)
180 PrintAndLog(" Reading page 1 - tracedata");
182 UsbCommand c
= {CMD_T55XX_READ_TRACE
, {0, 0, 0}};
184 WaitForResponse(CMD_ACK
, NULL
);
186 uint8_t data
[LF_TRACE_BUFF_SIZE
];
187 memset(data
, 0x00, LF_TRACE_BUFF_SIZE
);
189 GetFromBigBuf(data
,LF_TRACE_BUFF_SIZE
,3560); //3560 -- should be offset..
190 WaitForResponseTimeout(CMD_ACK
,NULL
, 1500);
192 for (int j
= 0; j
< LF_TRACE_BUFF_SIZE
; j
++) {
193 GraphBuffer
[j
] = ((int)data
[j
]) - 128;
195 GraphTraceLen
= LF_TRACE_BUFF_SIZE
;
198 //CmdDirectionalThreshold("70 -60");
205 uint8_t * bitstream
= bits
;
206 memset(bitstream
, 0x00, sizeof(bits
));
208 manchester_decode(GraphBuffer
, LF_TRACE_BUFF_SIZE
, bitstream
);
213 static command_t CommandTable
[] =
215 {"help", CmdHelp
, 1, "This help"},
216 {"rd", CmdReadBlk
, 0, "<Block> -- Read T55xx block data (page 0)"},
217 {"rdPWD", CmdReadBlkPWD
, 0, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},
218 {"wr", CmdWriteBlk
, 0, "<Data> <Block> -- Write T55xx block data (page 0)"},
219 {"wrPWD", CmdWriteBlkPWD
, 0, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},
220 {"trace", CmdReadTrace
, 0, "Read T55xx traceability data (page 1)"},
221 {NULL
, NULL
, 0, NULL
}
224 int CmdLFT55XX(const char *Cmd
)
226 CmdsParse(CommandTable
, Cmd
);
230 int CmdHelp(const char *Cmd
)
232 CmdsHelp(CommandTable
);