]>
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
;
73 len
= manchester_decode(data
, LF_TRACE_BUFF_SIZE
, bitstream
);
75 PrintPaddedManchester(bitstream
, len
, 32);
81 int CmdReadBlkPWD(const char *Cmd
)
83 int Block
= -1; //default to invalid block
84 int Password
= 0xFFFFFFFF; //default to blank Block 7
87 sscanf(Cmd
, "%d %x", &Block
, &Password
);
89 if ((Block
> 7) | (Block
< 0)) {
90 PrintAndLog("Block must be between 0 and 7");
94 PrintAndLog("Reading page 0 block %d pwd %08X", Block
, Password
);
96 c
.cmd
= CMD_T55XX_READ_BLOCK
;
97 c
.d
.asBytes
[0] = 0x1; //Password mode
102 WaitForResponse(CMD_ACK
, NULL
);
104 uint8_t data
[LF_TRACE_BUFF_SIZE
];
105 memset(data
, 0x00, LF_TRACE_BUFF_SIZE
);
107 GetFromBigBuf(data
,LF_TRACE_BUFF_SIZE
,3560); //3560 -- should be offset..
108 WaitForResponseTimeout(CMD_ACK
,NULL
, 1500);
110 for (int j
= 0; j
< LF_TRACE_BUFF_SIZE
; j
++) {
111 GraphBuffer
[j
] = ((int)data
[j
]) - 128;
113 GraphTraceLen
= LF_TRACE_BUFF_SIZE
;
116 CmdDirectionalThreshold("70 -60");
123 len
= manchester_decode(data
, LF_TRACE_BUFF_SIZE
, bits
);
125 PrintPaddedManchester(bits
, len
, 32);
131 int CmdWriteBlk(const char *Cmd
)
133 int Block
= 8; //default to invalid block
134 int Data
= 0xFFFFFFFF; //default to blank Block
137 sscanf(Cmd
, "%x %d", &Data
, &Block
);
140 PrintAndLog("Block must be between 0 and 7");
144 PrintAndLog("Writting block %d with data %08X", Block
, Data
);
146 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
147 c
.d
.asBytes
[0] = 0x0; //Normal mode
155 int CmdWriteBlkPWD(const char *Cmd
)
157 int Block
= 8; //default to invalid block
158 int Data
= 0xFFFFFFFF; //default to blank Block
159 int Password
= 0xFFFFFFFF; //default to blank Block 7
162 sscanf(Cmd
, "%x %d %x", &Data
, &Block
, &Password
);
165 PrintAndLog("Block must be between 0 and 7");
169 PrintAndLog("Writting block %d with data %08X and password %08X", Block
, Data
, Password
);
171 c
.cmd
= CMD_T55XX_WRITE_BLOCK
;
172 c
.d
.asBytes
[0] = 0x1; //Password mode
180 int CmdReadTrace(const char *Cmd
)
182 PrintAndLog(" Reading page 1 - tracedata");
184 UsbCommand c
= {CMD_T55XX_READ_TRACE
, {0, 0, 0}};
186 WaitForResponse(CMD_ACK
, NULL
);
188 uint8_t data
[LF_TRACE_BUFF_SIZE
];
189 memset(data
, 0x00, LF_TRACE_BUFF_SIZE
);
191 GetFromBigBuf(data
,LF_TRACE_BUFF_SIZE
,3560); //3560 -- should be offset..
192 WaitForResponseTimeout(CMD_ACK
,NULL
, 1500);
194 for (int j
= 0; j
< LF_TRACE_BUFF_SIZE
; j
++) {
195 GraphBuffer
[j
] = ((int)data
[j
]) - 128;
197 GraphTraceLen
= LF_TRACE_BUFF_SIZE
;
200 CmdDirectionalThreshold("70 -60");
207 len
= manchester_decode(data
,LF_TRACE_BUFF_SIZE
,bits
);
209 PrintPaddedManchester(bits
, len
, 64);
214 static command_t CommandTable
[] =
216 {"help", CmdHelp
, 1, "This help"},
217 {"readblock", CmdReadBlk
, 1, "<Block> -- Read T55xx block data (page 0)"},
218 {"readblockPWD", CmdReadBlkPWD
, 1, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},
219 {"writeblock", CmdWriteBlk
, 1, "<Data> <Block> -- Write T55xx block data (page 0)"},
220 {"writeblockPWD", CmdWriteBlkPWD
, 1, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},
221 {"readtrace", CmdReadTrace
, 1, "Read T55xx traceability data (page 1)"},
222 {NULL
, NULL
, 0, NULL
}
225 int CmdLFT55XX(const char *Cmd
)
227 CmdsParse(CommandTable
, Cmd
);
231 int CmdHelp(const char *Cmd
)
233 CmdsHelp(CommandTable
);