]> git.zerfleddert.de Git - proxmark3-svn/blame - client/cmdhf14b.c
add -s to hf 14b raw to select a std 14b tag first
[proxmark3-svn] / client / cmdhf14b.c
CommitLineData
a553f267 1//-----------------------------------------------------------------------------
2// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
3//
4// This code is licensed to you under the terms of the GNU GPL, version 2 or,
5// at your option, any later version. See the LICENSE.txt file for the text of
6// the license.
7//-----------------------------------------------------------------------------
8// High frequency ISO14443B commands
9//-----------------------------------------------------------------------------
10
7fe9b0b7 11#include <stdio.h>
12#include <stdlib.h>
13#include <stdbool.h>
14#include <string.h>
15#include <stdint.h>
16#include "iso14443crc.h"
902cb3c0 17#include "proxmark3.h"
7fe9b0b7 18#include "data.h"
19#include "graph.h"
3fe4ff4f 20#include "util.h"
7fe9b0b7 21#include "ui.h"
22#include "cmdparser.h"
23#include "cmdhf14b.h"
7cf3ef20 24#include "cmdmain.h"
ff4fdb32 25#include "cmdhf14a.h"
7fe9b0b7 26
27static int CmdHelp(const char *Cmd);
28
7fe9b0b7 29int CmdHF14BList(const char *Cmd)
30{
388c92bd 31 PrintAndLog("Deprecated command, use 'hf list 14b' instead");
7fe9b0b7 32
388c92bd 33 return 0;
7fe9b0b7 34}
7fe9b0b7 35
132a0217 36int CmdHF14BSim(const char *Cmd)
7fe9b0b7 37{
132a0217 38 UsbCommand c={CMD_SIMULATE_TAG_ISO_14443B};
ff4fdb32 39 clearCommandBuffer();
7fe9b0b7 40 SendCommand(&c);
41 return 0;
42}
43
44int CmdHF14BSnoop(const char *Cmd)
45{
132a0217 46 UsbCommand c = {CMD_SNOOP_ISO_14443B};
ff4fdb32 47 clearCommandBuffer();
7fe9b0b7 48 SendCommand(&c);
49 return 0;
50}
51
52/* New command to read the contents of a SRI512 tag
53 * SRI512 tags are ISO14443-B modulated memory tags,
54 * this command just dumps the contents of the memory
55 */
56int CmdSri512Read(const char *Cmd)
57{
58 UsbCommand c = {CMD_READ_SRI512_TAG, {strtol(Cmd, NULL, 0), 0, 0}};
ff4fdb32 59 clearCommandBuffer();
7fe9b0b7 60 SendCommand(&c);
61 return 0;
62}
63
64/* New command to read the contents of a SRIX4K tag
65 * SRIX4K tags are ISO14443-B modulated memory tags,
66 * this command just dumps the contents of the memory/
67 */
68int CmdSrix4kRead(const char *Cmd)
69{
70 UsbCommand c = {CMD_READ_SRIX4K_TAG, {strtol(Cmd, NULL, 0), 0, 0}};
ff4fdb32 71 clearCommandBuffer();
7fe9b0b7 72 SendCommand(&c);
73 return 0;
74}
75
ff4fdb32 76int rawClose(void){
77 UsbCommand resp;
78 UsbCommand c = {CMD_ISO_14443B_COMMAND, {0, 0, 0}};
79 clearCommandBuffer();
80 SendCommand(&c);
81 if (!WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
82 return 0;
83 }
84 return 0;
85}
86
87int HF14BCmdRaw(bool reply, bool *crc, bool power, uint8_t *data, uint8_t *datalen, bool verbose){
88 UsbCommand resp;
89 UsbCommand c = {CMD_ISO_14443B_COMMAND, {0, 0, 0}}; // len,recv,power
90 if(*crc)
91 {
92 uint8_t first, second;
93 ComputeCrc14443(CRC_14443_B, data, *datalen, &first, &second);
94 data[*datalen] = first;
95 data[*datalen + 1] = second;
96 *datalen += 2;
97 }
98
99 c.arg[0] = *datalen;
100 c.arg[1] = reply;
101 c.arg[2] = power;
102 memcpy(c.d.asBytes,data,*datalen);
103 clearCommandBuffer();
104 SendCommand(&c);
105
106 if (!reply) return 1;
107
108 if (!WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
109 if (verbose) PrintAndLog("timeout while waiting for reply.");
110 return 0;
111 }
112 *datalen = resp.arg[0];
113 if (verbose) PrintAndLog("received %u octets", *datalen);
114 if(*datalen<2) return 0;
115
116 memcpy(data, resp.d.asBytes, *datalen);
117 if (verbose) PrintAndLog("%s", sprint_hex(data, *datalen));
118
119 uint8_t first, second;
120 ComputeCrc14443(CRC_14443_B, data, *datalen-2, &first, &second);
121 if(data[*datalen-2] == first && data[*datalen-1] == second) {
122 if (verbose) PrintAndLog("CRC OK");
123 *crc = true;
124 } else {
125 if (verbose) PrintAndLog("CRC failed");
126 *crc = false;
127 }
128 return 1;
129}
130
131int CmdHF14BCmdRaw (const char *Cmd) {
132 bool reply = true;
133 bool crc = false;
134 bool power = false;
b8edab0f 135 bool select = false;
ff4fdb32 136 char buf[5] = "";
137 uint8_t data[100] = {0x00};
138 uint8_t datalen = 0;
139 unsigned int temp;
140 int i = 0;
141 if (strlen(Cmd)<3) {
142 PrintAndLog("Usage: hf 14b raw [-r] [-c] [-p] <0A 0B 0C ... hex>");
143 PrintAndLog(" -r do not read response");
144 PrintAndLog(" -c calculate and append CRC");
145 PrintAndLog(" -p leave the field on after receive");
b8edab0f 146 PrintAndLog(" -s active signal field ON with select");
147 return 0;
ff4fdb32 148 }
149
150 // strip
151 while (*Cmd==' ' || *Cmd=='\t') Cmd++;
152
153 while (Cmd[i]!='\0') {
154 if (Cmd[i]==' ' || Cmd[i]=='\t') { i++; continue; }
155 if (Cmd[i]=='-') {
156 switch (Cmd[i+1]) {
157 case 'r':
158 case 'R':
159 reply = false;
160 break;
161 case 'c':
162 case 'C':
163 crc = true;
164 break;
165 case 'p':
166 case 'P':
167 power = true;
168 break;
b8edab0f 169 case 's':
170 case 'S':
171 select = true;
172 break;
ff4fdb32 173 default:
174 PrintAndLog("Invalid option");
175 return 0;
176 }
177 i+=2;
178 continue;
179 }
180 if ((Cmd[i]>='0' && Cmd[i]<='9') ||
181 (Cmd[i]>='a' && Cmd[i]<='f') ||
182 (Cmd[i]>='A' && Cmd[i]<='F') ) {
183 buf[strlen(buf)+1]=0;
184 buf[strlen(buf)]=Cmd[i];
185 i++;
186
187 if (strlen(buf)>=2) {
188 sscanf(buf,"%x",&temp);
189 data[datalen++]=(uint8_t)(temp & 0xff);
190 *buf=0;
191 }
192 continue;
193 }
194 PrintAndLog("Invalid char on input");
195 return 1;
196 }
197 if (datalen == 0)
198 {
199 PrintAndLog("Missing data input");
200 return 0;
201 }
202
b8edab0f 203 if (select){
204 uint8_t cmd2[16];
205 uint8_t cmdLen = 3;
206 bool crc2 = true;
207 cmd2[0] = 0x05;
208 cmd2[1] = 0x00;
209 cmd2[2] = 0x08;
210
211 if (HF14BCmdRaw(true, &crc2, true, cmd2, &cmdLen, false)==0) return rawClose();
212
213 if (cmd2[0] != 0x50 || cmdLen != 14 || !crc2) return rawClose();
214
215 data[0] = 0x1D;
216 data[5] = 0x00;
217 data[6] = 0x08;
218 data[7] = 0x01;
219 data[8] = 0x00;
220
221 cmdLen = 9;
222 if (HF14BCmdRaw(true, &crc2, true, cmd2, &cmdLen, false)==0) return rawClose();
223
224 if (cmd2[0] != 0x10 || cmdLen != 3 || !crc2) return rawClose();
225 }
226
ff4fdb32 227 return HF14BCmdRaw(reply, &crc, power, data, &datalen, true);
7cf3ef20 228}
229
b29d55f2 230// print full atqb info
ff4fdb32 231static void print_atqb_resp(uint8_t *data){
232 PrintAndLog (" UID: %s", sprint_hex(data+1,4));
233 PrintAndLog (" App Data: %s", sprint_hex(data+5,4));
234 PrintAndLog (" Protocol: %s", sprint_hex(data+9,3));
235 uint8_t BitRate = data[9];
236 if (!BitRate)
237 PrintAndLog (" Bit Rate: 106 kbit/s only PICC <-> PCD");
238 if (BitRate & 0x10)
239 PrintAndLog (" Bit Rate: 212 kbit/s PICC -> PCD supported");
240 if (BitRate & 0x20)
241 PrintAndLog (" Bit Rate: 424 kbit/s PICC -> PCD supported");
242 if (BitRate & 0x40)
243 PrintAndLog (" Bit Rate: 847 kbit/s PICC -> PCD supported");
244 if (BitRate & 0x01)
245 PrintAndLog (" Bit Rate: 212 kbit/s PICC <- PCD supported");
246 if (BitRate & 0x02)
247 PrintAndLog (" Bit Rate: 424 kbit/s PICC <- PCD supported");
248 if (BitRate & 0x04)
249 PrintAndLog (" Bit Rate: 847 kbit/s PICC <- PCD supported");
250 if (BitRate & 0x80)
251 PrintAndLog (" Same bit rate <-> required");
252
253 uint16_t maxFrame = data[10]>>4;
254 if (maxFrame < 5)
255 maxFrame = 8*maxFrame + 16;
256 else if (maxFrame == 5)
257 maxFrame = 64;
258 else if (maxFrame == 6)
259 maxFrame = 96;
260 else if (maxFrame == 7)
261 maxFrame = 128;
262 else if (maxFrame == 8)
263 maxFrame = 256;
264 else
265 maxFrame = 257;
266
267 PrintAndLog ("Max Frame Size: %d%s",maxFrame, (maxFrame == 257) ? "+ RFU" : "");
268
269 uint8_t protocolT = data[10] & 0xF;
270 PrintAndLog (" Protocol Type: Protocol is %scompliant with ISO/IEC 14443-4",(protocolT) ? "" : "not " );
271 PrintAndLog ("Frame Wait Int: %d", data[11]>>4);
272 PrintAndLog (" App Data Code: Application is %s",(data[11]&4) ? "Standard" : "Proprietary");
273 PrintAndLog (" Frame Options: NAD is %ssupported",(data[11]&2) ? "" : "not ");
274 PrintAndLog (" Frame Options: CID is %ssupported",(data[11]&1) ? "" : "not ");
275
276 return;
277}
278
b29d55f2 279// get SRx chip model (from UID) // from ST Microelectronics
ff4fdb32 280char *get_ST_Chip_Model(uint8_t data){
281 static char model[20];
282 char *retStr = model;
283 memset(model,0, sizeof(model));
284
285 switch (data) {
286 case 0x0: sprintf(retStr, "SRIX4K (Special)"); break;
287 case 0x2: sprintf(retStr, "SR176"); break;
288 case 0x3: sprintf(retStr, "SRIX4K"); break;
289 case 0x4: sprintf(retStr, "SRIX512"); break;
290 case 0x6: sprintf(retStr, "SRI512"); break;
291 case 0x7: sprintf(retStr, "SRI4K"); break;
292 case 0xC: sprintf(retStr, "SRT512"); break;
293 default : sprintf(retStr, "Unknown"); break;
294 }
295 return retStr;
296}
297
cc34cc7b 298int print_ST_Lock_info(uint8_t model){
299 //assume connection open and tag selected...
c3ebcce4 300 uint8_t data[16] = {0x00};
cc34cc7b 301 uint8_t datalen = 2;
302 bool crc = true;
303 uint8_t resplen;
304 uint8_t blk1;
305 data[0] = 0x08;
306
307 if (model == 0x2) { //SR176 has special command:
308 data[1] = 0xf;
309 resplen = 4;
310 } else {
311 data[1] = 0xff;
312 resplen = 6;
313 }
314
315 //std read cmd
316 if (HF14BCmdRaw(true, &crc, true, data, &datalen, false)==0) return rawClose();
317
318 if (datalen != resplen || !crc) return rawClose();
319
320 PrintAndLog("Chip Write Protection Bits:");
321 // now interpret the data
322 switch (model){
323 case 0x0: //fall through (SRIX4K special)
324 case 0x3: //fall through (SRIx4K)
325 case 0x7: // (SRI4K)
326 //only need data[3]
327 blk1 = 9;
8e00825a 328 PrintAndLog(" raw: %s",printBits(1,data+3));
c3ebcce4 329 PrintAndLog(" 07/08:%slocked", (data[3] & 1) ? " not " : " " );
cc34cc7b 330 for (uint8_t i = 1; i<8; i++){
c3ebcce4 331 PrintAndLog(" %02u:%slocked", blk1, (data[3] & (1 << i)) ? " not " : " " );
cc34cc7b 332 blk1++;
333 }
334 break;
335 case 0x4: //fall through (SRIX512)
336 case 0x6: //fall through (SRI512)
337 case 0xC: // (SRT512)
338 //need data[2] and data[3]
339 blk1 = 0;
8e00825a 340 PrintAndLog(" raw: %s",printBits(2,data+2));
cc34cc7b 341 for (uint8_t b=2; b<4; b++){
342 for (uint8_t i=0; i<8; i++){
c3ebcce4 343 PrintAndLog(" %02u:%slocked", blk1, (data[b] & (1 << i)) ? " not " : " " );
cc34cc7b 344 blk1++;
345 }
346 }
347 break;
348 case 0x2: // (SR176)
349 //need data[2]
350 blk1 = 0;
8e00825a 351 PrintAndLog(" raw: %s",printBits(1,data+2));
cc34cc7b 352 for (uint8_t i = 0; i<8; i++){
c3ebcce4 353 PrintAndLog(" %02u/%02u:%slocked", blk1, blk1+1, (data[2] & (1 << i)) ? " " : " not " );
cc34cc7b 354 blk1+=2;
355 }
356 break;
357 default:
358 return rawClose();
359 }
360 return 1;
361}
362
b29d55f2 363// print UID info from SRx chips (ST Microelectronics)
364static void print_st_general_info(uint8_t *data){
ff4fdb32 365 //uid = first 8 bytes in data
cc34cc7b 366 PrintAndLog(" UID: %s", sprint_hex(SwapEndian64(data,8,8),8));
367 PrintAndLog(" MFG: %02X, %s", data[6], getTagInfo(data[6]));
368 PrintAndLog(" Chip: %02X, %s", data[5]>>2, get_ST_Chip_Model(data[5]>>2));
ff4fdb32 369 return;
370}
371
b29d55f2 372// 14b get and print UID only (general info)
373int HF14BStdReader(uint8_t *data, uint8_t *datalen){
ff4fdb32 374 //05 00 00 = find one tag in field
b8edab0f 375 //1d xx xx xx xx 00 08 01 00 = attrib xx=UID (resp 10 [f9 e0])
376 //a3 = ? (resp 03 [e2 c2])
377 //02 = ? (resp 02 [6a d3])
ff4fdb32 378 // 022b (resp 02 67 00 [29 5b])
379 // 0200a40400 (resp 02 67 00 [29 5b])
380 // 0200a4040c07a0000002480300 (resp 02 67 00 [29 5b])
381 // 0200a4040c07a0000002480200 (resp 02 67 00 [29 5b])
382 // 0200a4040006a0000000010100 (resp 02 6a 82 [4b 4c])
383 // 0200a4040c09d27600002545500200 (resp 02 67 00 [29 5b])
384 // 0200a404000cd2760001354b414e4d30310000 (resp 02 6a 82 [4b 4c])
385 // 0200a404000ca000000063504b43532d313500 (resp 02 6a 82 [4b 4c])
386 // 0200a4040010a000000018300301000000000000000000 (resp 02 6a 82 [4b 4c])
387 //03 = ? (resp 03 [e3 c2])
388 //c2 = ? (resp c2 [66 15])
389 //b2 = ? (resp a3 [e9 67])
390 bool crc = true;
391 *datalen = 3;
392 //std read cmd
393 data[0] = 0x05;
394 data[1] = 0x00;
b29d55f2 395 data[2] = 0x08;
ff4fdb32 396
397 if (HF14BCmdRaw(true, &crc, false, data, datalen, false)==0) return 0;
398
b8edab0f 399 if (data[0] != 0x50 || *datalen != 14 || !crc) return 0;
ff4fdb32 400
401 PrintAndLog ("\n14443-3b tag found:");
b29d55f2 402 PrintAndLog (" UID: %s", sprint_hex(data+1,4));
ff4fdb32 403
404 return 1;
405}
406
8a258b58 407// 14b get and print Full Info (as much as we know)
408int HF14BStdInfo(uint8_t *data, uint8_t *datalen){
409 if (!HF14BStdReader(data,datalen)) return 0;
b29d55f2 410
8a258b58 411 //add more info here
412 print_atqb_resp(data);
b29d55f2 413
414 return 1;
415}
416
417// SRx get and print general info about SRx chip from UID
cc34cc7b 418int HF14B_ST_Reader(uint8_t *data, uint8_t *datalen, bool closeCon){
ff4fdb32 419 bool crc = true;
420 *datalen = 2;
421 //wake cmd
422 data[0] = 0x06;
423 data[1] = 0x00;
424
425 //leave power on
426 // verbose on for now for testing - turn off when functional
427 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)==0) return rawClose();
428
429 if (*datalen != 3 || !crc) return rawClose();
430
431 uint8_t chipID = data[0];
432 // select
433 data[0] = 0x0E;
434 data[1] = chipID;
435 *datalen = 2;
436
437 //leave power on
ff4fdb32 438 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)==0) return rawClose();
439
440 if (*datalen != 3 || !crc || data[0] != chipID) return rawClose();
441
442 // get uid
443 data[0] = 0x0B;
444 *datalen = 1;
445
cc34cc7b 446 //leave power on
447 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)==0) return rawClose();
c3ebcce4 448
449 if (*datalen != 10 || !crc) return rawClose();
450
cc34cc7b 451 //power off ?
452 if (closeCon) rawClose();
453
ff4fdb32 454 PrintAndLog("\n14443-3b ST tag found:");
b29d55f2 455 print_st_general_info(data);
ff4fdb32 456 return 1;
457}
458
8a258b58 459// SRx get and print full info (needs more info...)
460int HF14B_ST_Info(uint8_t *data, uint8_t *datalen){
cc34cc7b 461 if (!HF14B_ST_Reader(data, datalen, false)) return 0;
8a258b58 462
463 //add locking bit information here.
cc34cc7b 464 if (print_ST_Lock_info(data[5]>>2))
465 rawClose();
8a258b58 466
467 return 1;
468}
469
ff4fdb32 470// test for other 14b type tags (mimic another reader - don't have tags to identify)
b29d55f2 471int HF14B_Other_Reader(uint8_t *data, uint8_t *datalen){
ff4fdb32 472 bool crc = true;
473 *datalen = 4;
474 //std read cmd
475 data[0] = 0x00;
476 data[1] = 0x0b;
477 data[2] = 0x3f;
478 data[3] = 0x80;
479
b29d55f2 480 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)!=0) {
ff4fdb32 481 if (*datalen > 2 || !crc) {
482 PrintAndLog ("\n14443-3b tag found:");
483 PrintAndLog ("Unknown tag type answered to a 0x000b3f80 command ans:");
484 PrintAndLog ("%s",sprint_hex(data,*datalen));
cc34cc7b 485 rawClose();
ff4fdb32 486 return 1;
487 }
488 }
489
490 crc = false;
491 *datalen = 1;
492 data[0] = 0x0a;
493
b29d55f2 494 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)!=0) {
ff4fdb32 495 if (*datalen > 0) {
496 PrintAndLog ("\n14443-3b tag found:");
497 PrintAndLog ("Unknown tag type answered to a 0x0A command ans:");
498 PrintAndLog ("%s",sprint_hex(data,*datalen));
cc34cc7b 499 rawClose();
ff4fdb32 500 return 1;
501 }
502 }
503
504 crc = false;
505 *datalen = 1;
506 data[0] = 0x0c;
507
b29d55f2 508 if (HF14BCmdRaw(true, &crc, true, data, datalen, false)!=0) {
ff4fdb32 509 if (*datalen > 0) {
510 PrintAndLog ("\n14443-3b tag found:");
511 PrintAndLog ("Unknown tag type answered to a 0x0C command ans:");
512 PrintAndLog ("%s",sprint_hex(data,*datalen));
cc34cc7b 513 rawClose();
ff4fdb32 514 return 1;
515 }
516 }
b29d55f2 517 rawClose();
ff4fdb32 518 return 0;
ff4fdb32 519}
520
b29d55f2 521// get and print all info known about any known 14b tag
ff4fdb32 522int HF14BInfo(bool verbose){
523 uint8_t data[100];
524 uint8_t datalen = 5;
525
526 // try std 14b (atqb)
527 if (HF14BStdInfo(data, &datalen)) return 1;
528
529 // try st 14b
530 if (HF14B_ST_Info(data, &datalen)) return 1;
531
532 // try unknown 14b read commands (to be identified later)
533 // could be read of calypso, CEPAS, moneo, or pico pass.
b29d55f2 534 if (HF14B_Other_Reader(data, &datalen)) return 1;
ff4fdb32 535
536 if (verbose) PrintAndLog("no 14443B tag found");
537 return 0;
538}
539
b29d55f2 540// menu command to get and print all info known about any known 14b tag
ff4fdb32 541int CmdHF14Binfo(const char *Cmd){
542 return HF14BInfo(true);
543}
3fe4ff4f 544
b29d55f2 545// get and print general info about all known 14b chips
546int HF14BReader(bool verbose){
547 uint8_t data[100];
548 uint8_t datalen = 5;
549
550 // try std 14b (atqb)
551 if (HF14BStdReader(data, &datalen)) return 1;
552
553 // try st 14b
cc34cc7b 554 if (HF14B_ST_Reader(data, &datalen, true)) return 1;
b29d55f2 555
556 // try unknown 14b read commands (to be identified later)
557 // could be read of calypso, CEPAS, moneo, or pico pass.
558 if (HF14B_Other_Reader(data, &datalen)) return 1;
559
560 if (verbose) PrintAndLog("no 14443B tag found");
561 return 0;
562}
563
564// menu command to get and print general info about all known 14b chips
565int CmdHF14BReader(const char *Cmd){
566 return HF14BReader(true);
567}
568
ff4fdb32 569int CmdSriWrite( const char *Cmd){
3fe4ff4f 570/*
571 * For SRIX4K blocks 00 - 7F
572 * hf 14b raw -c -p 09 $srix4kwblock $srix4kwdata
573 *
574 * For SR512 blocks 00 - 0F
575 * hf 14b raw -c -p 09 $sr512wblock $sr512wdata
576 *
577 * Special block FF = otp_lock_reg block.
578 * Data len 4 bytes-
579 */
580 char cmdp = param_getchar(Cmd, 0);
581 uint8_t blockno = -1;
582 uint8_t data[4] = {0x00};
583 bool isSrix4k = true;
584 char str[20];
585
b5be31f9 586 if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') {
3fe4ff4f 587 PrintAndLog("Usage: hf 14b write <1|2> <BLOCK> <DATA>");
b5be31f9 588 PrintAndLog(" [1 = SRIX4K]");
589 PrintAndLog(" [2 = SRI512]");
590 PrintAndLog(" [BLOCK number depends on tag, special block == FF]");
591 PrintAndLog(" sample: hf 14b write 1 7F 11223344");
592 PrintAndLog(" : hf 14b write 1 FF 11223344");
593 PrintAndLog(" : hf 14b write 2 15 11223344");
594 PrintAndLog(" : hf 14b write 2 FF 11223344");
3fe4ff4f 595 return 0;
596 }
597
b5be31f9 598 if ( cmdp == '2' )
3fe4ff4f 599 isSrix4k = false;
600
b5be31f9 601 //blockno = param_get8(Cmd, 1);
602
603 if ( param_gethex(Cmd,1, &blockno, 2) ) {
604 PrintAndLog("Block number must include 2 HEX symbols");
605 return 0;
606 }
3fe4ff4f 607
608 if ( isSrix4k ){
609 if ( blockno > 0x7f && blockno != 0xff ){
610 PrintAndLog("Block number out of range");
611 return 0;
612 }
613 } else {
614 if ( blockno > 0x0f && blockno != 0xff ){
615 PrintAndLog("Block number out of range");
616 return 0;
617 }
618 }
619
620 if (param_gethex(Cmd, 2, data, 8)) {
621 PrintAndLog("Data must include 8 HEX symbols");
622 return 0;
623 }
624
625 if ( blockno == 0xff)
b5be31f9 626 PrintAndLog("[%s] Write special block %02X [ %s ]", (isSrix4k)?"SRIX4K":"SRI512" , blockno, sprint_hex(data,4) );
3fe4ff4f 627 else
b5be31f9 628 PrintAndLog("[%s] Write block %02X [ %s ]", (isSrix4k)?"SRIX4K":"SRI512", blockno, sprint_hex(data,4) );
3fe4ff4f 629
fe5b3a44 630 sprintf(str, "-c 09 %02x %02x%02x%02x%02x", blockno, data[0], data[1], data[2], data[3]);
b5be31f9 631
3fe4ff4f 632 CmdHF14BCmdRaw(str);
633 return 0;
634}
635
7fe9b0b7 636static command_t CommandTable[] =
637{
638 {"help", CmdHelp, 1, "This help"},
b29d55f2 639 {"info", CmdHF14Binfo, 0, "Find and print details about a 14443B tag"},
640 {"list", CmdHF14BList, 0, "[Deprecated] List ISO 14443B history"},
641 {"reader", CmdHF14BReader, 0, "Act as a 14443B reader to identify a tag"},
132a0217 642 {"sim", CmdHF14BSim, 0, "Fake ISO 14443B tag"},
643 {"snoop", CmdHF14BSnoop, 0, "Eavesdrop ISO 14443B"},
7cf3ef20 644 {"sri512read", CmdSri512Read, 0, "Read contents of a SRI512 tag"},
645 {"srix4kread", CmdSrix4kRead, 0, "Read contents of a SRIX4K tag"},
ff4fdb32 646 {"sriwrite", CmdSriWrite, 0, "Write data to a SRI512 | SRIX4K tag"},
7cf3ef20 647 {"raw", CmdHF14BCmdRaw, 0, "Send raw hex data to tag"},
7fe9b0b7 648 {NULL, NULL, 0, NULL}
649};
650
651int CmdHF14B(const char *Cmd)
652{
653 CmdsParse(CommandTable, Cmd);
654 return 0;
655}
656
657int CmdHelp(const char *Cmd)
658{
659 CmdsHelp(CommandTable);
660 return 0;
661}
Impressum, Datenschutz