]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdhfmfu.c
1 //-----------------------------------------------------------------------------
2 // Ultralight Code (c) 2013,2014 Midnitesnake & Andy Davies of Pentura
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
7 //-----------------------------------------------------------------------------
8 // High frequency MIFARE ULTRALIGHT (C) commands
9 //-----------------------------------------------------------------------------
10 #include "loclass/des.h"
16 #define MAX_ULTRA_BLOCKS 0x0f
17 #define MAX_ULTRAC_BLOCKS 0x2f
18 //#define MAX_ULTRAC_BLOCKS 0x2c
21 static int CmdHelp(const char *Cmd
);
23 int CmdHF14AMfUInfo(const char *Cmd
){
25 uint8_t datatemp
[7] = {0x00};
29 UsbCommand c
= {CMD_MIFAREU_READCARD
, {0, 4}};
33 if (WaitForResponseTimeout(CMD_ACK
, &resp
, 1500)) {
34 isOK
= resp
.arg
[0] & 0xff;
35 data
= resp
.d
.asBytes
;
38 PrintAndLog("Error reading from tag");
42 PrintAndLog("Command execute timed out");
47 PrintAndLog("-- Mifare Ultralight / Ultralight-C Tag Information ---------");
48 PrintAndLog("-------------------------------------------------------------");
51 memcpy( datatemp
, data
, 3);
52 memcpy( datatemp
+3, data
+4, 4);
54 PrintAndLog("MANUFACTURER : %s", getTagInfo(datatemp
[0]));
55 PrintAndLog(" UID : %s ", sprint_hex(datatemp
, 7));
57 // CT (cascade tag byte) 0x88 xor SN0 xor SN1 xor SN2
58 int crc0
= 0x88 ^ data
[0] ^ data
[1] ^data
[2];
59 if ( data
[3] == crc0
)
60 PrintAndLog(" BCC0 : %02x - Ok", data
[3]);
62 PrintAndLog(" BCC0 : %02x - crc should be %02x", data
[3], crc0
);
64 int crc1
= data
[4] ^ data
[5] ^ data
[6] ^data
[7];
65 if ( data
[8] == crc1
)
66 PrintAndLog(" BCC1 : %02x - Ok", data
[8]);
68 PrintAndLog(" BCC1 : %02x - crc should be %02x", data
[8], crc1
);
70 PrintAndLog(" Internal : %s ", sprint_hex(data
+ 9, 1));
72 memcpy(datatemp
, data
+10, 2);
73 PrintAndLog(" Lock : %s - %s", sprint_hex(datatemp
, 2),printBits( 2, &datatemp
) );
74 PrintAndLog(" OneTimePad : %s ", sprint_hex(data
+ 3*4, 4));
77 int len
= CmdHF14AMfucAuth("K 0");
78 // PrintAndLog("CODE: %d",len);
80 PrintAndLog("Seems to be a Ultralight %s", (len
==0) ? "-C" :"");
85 // Mifare Ultralight Write Single Block
87 int CmdHF14AMfUWrBl(const char *Cmd
){
89 bool chinese_card
= FALSE
;
90 uint8_t bldata
[16] = {0x00};
93 char cmdp
= param_getchar(Cmd
, 0);
94 if (strlen(Cmd
) < 3 || cmdp
== 'h' || cmdp
== 'H') {
95 PrintAndLog("Usage: hf mfu wrbl <block number> <block data (8 hex symbols)> [w]");
96 PrintAndLog(" [block number]");
97 PrintAndLog(" [block data] - (8 hex symbols)");
98 PrintAndLog(" [w] - Chinese magic ultralight tag");
100 PrintAndLog(" sample: hf mfu wrbl 0 01020304");
105 blockNo
= param_get8(Cmd
, 0);
107 if (blockNo
> MAX_ULTRA_BLOCKS
){
108 PrintAndLog("Error: Maximum number of blocks is 15 for Ultralight Cards!");
112 if (param_gethex(Cmd
, 1, bldata
, 8)) {
113 PrintAndLog("Block data must include 8 HEX symbols");
117 if (strchr(Cmd
,'w') != 0 || strchr(Cmd
,'W') != 0 ) {
123 PrintAndLog("Access Denied");
125 PrintAndLog("--specialblock no:%02x", blockNo
);
126 PrintAndLog("--data: %s", sprint_hex(bldata
, 4));
127 UsbCommand d
= {CMD_MIFAREU_WRITEBL
, {blockNo
}};
128 memcpy(d
.d
.asBytes
,bldata
, 4);
130 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
131 uint8_t isOK
= resp
.arg
[0] & 0xff;
132 PrintAndLog("isOk:%02x", isOK
);
134 PrintAndLog("Command execute timeout");
138 PrintAndLog("--block no:%02x", blockNo
);
139 PrintAndLog("--data: %s", sprint_hex(bldata
, 4));
140 UsbCommand e
= {CMD_MIFAREU_WRITEBL
, {blockNo
}};
141 memcpy(e
.d
.asBytes
,bldata
, 4);
143 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
144 uint8_t isOK
= resp
.arg
[0] & 0xff;
145 PrintAndLog("isOk:%02x", isOK
);
147 PrintAndLog("Command execute timeout");
154 // Mifare Ultralight Read Single Block
156 int CmdHF14AMfURdBl(const char *Cmd
){
158 uint8_t blockNo
= -1;
160 char cmdp
= param_getchar(Cmd
, 0);
162 if (strlen(Cmd
) < 1 || cmdp
== 'h' || cmdp
== 'H') {
163 PrintAndLog("Usage: hf mfu rdbl <block number>");
164 PrintAndLog(" sample: hfu mfu rdbl 0");
168 blockNo
= param_get8(Cmd
, 0);
170 if (blockNo
> MAX_ULTRA_BLOCKS
){
171 PrintAndLog("Error: Maximum number of blocks is 15 for Ultralight Cards!");
175 PrintAndLog("--block no:0x%02X (%d)", (int)blockNo
, blockNo
);
176 UsbCommand c
= {CMD_MIFAREU_READBL
, {blockNo
}};
180 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
181 uint8_t isOK
= resp
.arg
[0] & 0xff;
182 uint8_t * data
= resp
.d
.asBytes
;
184 PrintAndLog("isOk: %02x", isOK
);
187 PrintAndLog("Data: %s", sprint_hex(data
, 4));
189 PrintAndLog("Command execute timeout");
195 // Mifare Ultralight / Ultralight-C; Read and Dump Card Contents
197 int CmdHF14AMfUDump(const char *Cmd
){
200 char filename
[FILE_PATH_SIZE
] = {0x00};
201 char * fnameptr
= filename
;
203 uint8_t *lockbytes_t
= NULL
;
204 uint8_t lockbytes
[2] = {0x00};
206 uint8_t *lockbytes_t2
= NULL
;
207 uint8_t lockbytes2
[2] = {0x00};
209 bool bit
[16] = {0x00};
210 bool bit2
[16] = {0x00};
216 bool tmplockbit
= false;
218 uint8_t *data
= NULL
;
220 char cmdp
= param_getchar(Cmd
, 0);
222 if (cmdp
== 'h' || cmdp
== 'H') {
223 PrintAndLog("Reads all pages from Mifare Ultralight or Ultralight-C tag.");
224 PrintAndLog("It saves binary dump into the file `filename.bin` or `cardUID.bin`");
225 PrintAndLog("Usage: hf mfu dump <c> <filename w/o .bin>");
226 PrintAndLog(" <c> optional cardtype c == Ultralight-C, if not defaults to Ultralight");
227 PrintAndLog(" sample: hf mfu dump");
228 PrintAndLog(" : hf mfu dump myfile");
229 PrintAndLog(" : hf mfu dump c myfile");
234 Pages
= (cmdp
== 'c' || cmdp
== 'C') ? 44 : 16;
236 PrintAndLog("Dumping Ultralight%s Card Data...", (Pages
==16)?"":"-C");
238 UsbCommand c
= {CMD_MIFAREU_READCARD
, {BlockNo
,Pages
}};
242 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
243 isOK
= resp
.arg
[0] & 0xff;
245 PrintAndLog("Command error");
248 data
= resp
.d
.asBytes
;
250 PrintAndLog("Command execute timeout");
257 lockbytes_t
= data
+ 8;
258 lockbytes
[0] = lockbytes_t
[2];
259 lockbytes
[1] = lockbytes_t
[3];
260 for(j
= 0; j
< 16; j
++){
261 bit
[j
] = lockbytes
[j
/8] & ( 1 <<(7-j
%8));
264 // Load bottom lockbytes if available
267 lockbytes_t2
= data
+ (40*4);
268 lockbytes2
[0] = lockbytes_t2
[2];
269 lockbytes2
[1] = lockbytes_t2
[3];
270 for (j
= 0; j
< 16; j
++) {
271 bit2
[j
] = lockbytes2
[j
/8] & ( 1 <<(7-j
%8));
275 for (i
= 0; i
< Pages
; ++i
) {
278 PrintAndLog("Block %02x:%s ", i
,sprint_hex(data
+ i
* 4, 4));
283 case 3: tmplockbit
= bit
[4]; break;
284 case 4: tmplockbit
= bit
[3]; break;
285 case 5: tmplockbit
= bit
[2]; break;
286 case 6: tmplockbit
= bit
[1]; break;
287 case 7: tmplockbit
= bit
[0]; break;
288 case 8: tmplockbit
= bit
[15]; break;
289 case 9: tmplockbit
= bit
[14]; break;
290 case 10: tmplockbit
= bit
[13]; break;
291 case 11: tmplockbit
= bit
[12]; break;
292 case 12: tmplockbit
= bit
[11]; break;
293 case 13: tmplockbit
= bit
[10]; break;
294 case 14: tmplockbit
= bit
[9]; break;
295 case 15: tmplockbit
= bit
[8]; break;
299 case 19: tmplockbit
= bit2
[6]; break;
303 case 23: tmplockbit
= bit2
[5]; break;
307 case 27: tmplockbit
= bit2
[4]; break;
311 case 31: tmplockbit
= bit2
[2]; break;
315 case 35: tmplockbit
= bit2
[1]; break;
319 case 39: tmplockbit
= bit2
[0]; break;
320 case 40: tmplockbit
= bit2
[12]; break;
321 case 41: tmplockbit
= bit2
[11]; break;
322 case 42: tmplockbit
= bit2
[10]; break; //auth0
323 case 43: tmplockbit
= bit2
[9]; break; //auth1
326 PrintAndLog("Block %02x:%s [%d]", i
,sprint_hex(data
+ i
* 4, 4),tmplockbit
);
331 len
= param_getstr(Cmd
,0,filename
);
333 len
= param_getstr(Cmd
,1,filename
);
335 if (len
> FILE_PATH_SIZE
-5) len
= FILE_PATH_SIZE
-5;
337 // user supplied filename?
340 // UID = data 0-1-2 4-5-6-7 (skips a beat)
341 sprintf(fnameptr
,"%02X%02X%02X%02X%02X%02X%02X.bin",
342 data
[0],data
[1], data
[2], data
[4],data
[5],data
[6], data
[7]);
345 sprintf(fnameptr
+ len
," .bin");
349 if ((fout
= fopen(filename
,"wb")) == NULL
) {
350 PrintAndLog("Could not create file name %s", filename
);
353 fwrite( data
, 1, Pages
*4, fout
);
356 PrintAndLog("Dumped %d pages, wrote %d bytes to %s", Pages
, Pages
*4, filename
);
360 // Needed to Authenticate to Ultralight C tags
361 void rol (uint8_t *data
, const size_t len
){
362 uint8_t first
= data
[0];
363 for (size_t i
= 0; i
< len
-1; i
++) {
369 //-------------------------------------------------------------------------------
370 // Ultralight C Methods
371 //-------------------------------------------------------------------------------
374 // Ultralight C Authentication Demo {currently uses hard-coded key}
376 int CmdHF14AMfucAuth(const char *Cmd
){
378 uint8_t default_keys
[5][16] = {
379 { 0x42,0x52,0x45,0x41,0x4b,0x4d,0x45,0x49,0x46,0x59,0x4f,0x55,0x43,0x41,0x4e,0x21 },// 3des std key
380 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },// all zeroes
381 { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f },// 0x00-0x0F
382 { 0x49,0x45,0x4D,0x4B,0x41,0x45,0x52,0x42,0x21,0x4E,0x41,0x43,0x55,0x4F,0x59,0x46 },// NFC-key
383 { 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01 } // all ones
386 char cmdp
= param_getchar(Cmd
, 0);
390 //Change key to user defined one
391 if (cmdp
== 'k' || cmdp
== 'K'){
392 keyNo
= param_get8(Cmd
, 1);
393 if(keyNo
> 4) errors
= true;
396 if (cmdp
== 'h' || cmdp
== 'H') {
401 PrintAndLog("Usage: hf mfu cauth k <key number>");
402 PrintAndLog(" 0 (default): 3DES standard key");
403 PrintAndLog(" 1 : all zeros key");
404 PrintAndLog(" 2 : 0x00-0x0F key");
405 PrintAndLog(" 3 : nfc key");
406 PrintAndLog(" 4 : all ones key");
407 PrintAndLog(" sample : hf mfu cauth k");
408 PrintAndLog(" : hf mfu cauth k 3");
412 uint8_t random_a
[8] = { 1,1,1,1,1,1,1,1 };
413 //uint8_t enc_random_a[8] = { 0 };
414 uint8_t random_b
[8] = { 0 };
415 uint8_t enc_random_b
[8] = { 0 };
416 uint8_t random_a_and_b
[16] = { 0 };
417 des3_context ctx
= { 0 };
418 uint8_t *key
= default_keys
[keyNo
];
423 UsbCommand c
= {CMD_MIFAREUC_AUTH1
, {blockNo
}};
426 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
427 uint8_t isOK
= resp
.arg
[0] & 0xff;
429 uint8_t * data
= resp
.d
.asBytes
;
432 memcpy(enc_random_b
,data
+1,8);
434 PrintAndLog("Auth failed");
435 return 2; // auth failed.
438 PrintAndLog("Command execute timeout");
441 uint8_t iv
[8] = { 0 };
443 PrintAndLog(" RndA :%s",sprint_hex(random_a
, 8));
444 PrintAndLog(" e_RndB:%s",sprint_hex(enc_random_b
, 8));
446 des3_set2key_dec(&ctx
, key
);
448 des3_crypt_cbc(&ctx
// des3_context *ctx
449 , DES_DECRYPT
// int mode
450 , sizeof(random_b
) // size_t length
451 , iv
// unsigned char iv[8]
452 , enc_random_b
// const unsigned char *input
453 , random_b
// unsigned char *output
456 PrintAndLog(" RndB:%s",sprint_hex(random_b
, 8));
459 memcpy(random_a_and_b
,random_a
,8);
460 memcpy(random_a_and_b
+8,random_b
,8);
462 PrintAndLog(" RA+B:%s",sprint_hex(random_a_and_b
, 16));
464 des3_set2key_enc(&ctx
, key
);
466 des3_crypt_cbc(&ctx
// des3_context *ctx
467 , DES_ENCRYPT
// int mode
468 , sizeof(random_a_and_b
) // size_t length
469 , enc_random_b
// unsigned char iv[8]
470 , random_a_and_b
// const unsigned char *input
471 , random_a_and_b
// unsigned char *output
474 PrintAndLog("enc(RA+B):%s",sprint_hex(random_a_and_b
, 16));
477 UsbCommand d
= {CMD_MIFAREUC_AUTH2
, {cuid
}};
478 memcpy(d
.d
.asBytes
,random_a_and_b
, 16);
482 if (WaitForResponseTimeout(CMD_ACK
,&respb
,1500)) {
483 uint8_t isOK
= respb
.arg
[0] & 0xff;
484 uint8_t * data2
= respb
.d
.asBytes
;
487 PrintAndLog("enc(RndA'):%s", sprint_hex(data2
+1, 8));
489 uint8_t foo
[8] = { 0 };
490 uint8_t bar
[8] = { 0 };
491 memcpy(foo
, data2
+1, 8);
492 des3_set2key_enc(&ctx
, key
);
494 des3_crypt_cbc(&ctx
// des3_context *ctx
495 , DES_DECRYPT
// int mode
497 , enc_random_b
// unsigned char iv[8]
498 , foo
// const unsigned char *input
499 , bar
// unsigned char *output
502 PrintAndLog("BAR:%s",sprint_hex(bar
, 8));
510 PrintAndLog("Command execute timeout");
516 A test function to validate that the polarssl-function works the same
517 was as the openssl-implementation.
518 Commented out, since it requires openssl
520 int CmdTestDES(const char * cmd)
522 uint8_t key[16] = {0x00};
524 memcpy(key,key3_3des_data,16);
525 DES_cblock RndA, RndB;
527 PrintAndLog("----------OpenSSL DES implementation----------");
529 uint8_t e_RndB[8] = {0x00};
530 unsigned char RndARndB[16] = {0x00};
532 DES_cblock iv = { 0 };
533 DES_key_schedule ks1,ks2;
534 DES_cblock key1,key2;
536 memcpy(key,key3_3des_data,16);
538 memcpy(key2,key+8,8);
541 DES_set_key((DES_cblock *)key1,&ks1);
542 DES_set_key((DES_cblock *)key2,&ks2);
544 DES_random_key(&RndA);
545 PrintAndLog(" RndA:%s",sprint_hex(RndA, 8));
546 PrintAndLog(" e_RndB:%s",sprint_hex(e_RndB, 8));
547 //void DES_ede2_cbc_encrypt(const unsigned char *input,
548 // unsigned char *output, long length, DES_key_schedule *ks1,
549 // DES_key_schedule *ks2, DES_cblock *ivec, int enc);
550 DES_ede2_cbc_encrypt(e_RndB,RndB,sizeof(e_RndB),&ks1,&ks2,&iv,0);
552 PrintAndLog(" RndB:%s",sprint_hex(RndB, 8));
554 memcpy(RndARndB,RndA,8);
555 memcpy(RndARndB+8,RndB,8);
556 PrintAndLog(" RA+B:%s",sprint_hex(RndARndB, 16));
557 DES_ede2_cbc_encrypt(RndARndB,RndARndB,sizeof(RndARndB),&ks1,&ks2,&e_RndB,1);
558 PrintAndLog("enc(RA+B):%s",sprint_hex(RndARndB, 16));
561 PrintAndLog("----------PolarSSL implementation----------");
563 uint8_t random_a[8] = { 0 };
564 uint8_t enc_random_a[8] = { 0 };
565 uint8_t random_b[8] = { 0 };
566 uint8_t enc_random_b[8] = { 0 };
567 uint8_t random_a_and_b[16] = { 0 };
568 des3_context ctx = { 0 };
570 memcpy(random_a, RndA,8);
572 uint8_t output[8] = { 0 };
573 uint8_t iv[8] = { 0 };
575 PrintAndLog(" RndA :%s",sprint_hex(random_a, 8));
576 PrintAndLog(" e_RndB:%s",sprint_hex(enc_random_b, 8));
578 des3_set2key_dec(&ctx, key);
580 des3_crypt_cbc(&ctx // des3_context *ctx
581 , DES_DECRYPT // int mode
582 , sizeof(random_b) // size_t length
583 , iv // unsigned char iv[8]
584 , enc_random_b // const unsigned char *input
585 , random_b // unsigned char *output
588 PrintAndLog(" RndB:%s",sprint_hex(random_b, 8));
591 memcpy(random_a_and_b ,random_a,8);
592 memcpy(random_a_and_b+8,random_b,8);
594 PrintAndLog(" RA+B:%s",sprint_hex(random_a_and_b, 16));
596 des3_set2key_enc(&ctx, key);
598 des3_crypt_cbc(&ctx // des3_context *ctx
599 , DES_ENCRYPT // int mode
600 , sizeof(random_a_and_b) // size_t length
601 , enc_random_b // unsigned char iv[8]
602 , random_a_and_b // const unsigned char *input
603 , random_a_and_b // unsigned char *output
606 PrintAndLog("enc(RA+B):%s",sprint_hex(random_a_and_b, 16));
612 // Ultralight C Read Single Block
614 int CmdHF14AMfUCRdBl(const char *Cmd
)
617 uint8_t blockNo
= -1;
618 unsigned char key
[16];
619 char cmdp
= param_getchar(Cmd
, 0);
621 if (strlen(Cmd
) < 1 || cmdp
== 'h' || cmdp
== 'H') {
622 PrintAndLog("Usage: hf mfu crdbl <block number> <password>");
624 PrintAndLog("sample: hf mfu crdbl 0");
625 PrintAndLog(" hf mfu crdbl 0 1122334455667788");
629 blockNo
= param_get8(Cmd
, 0);
631 PrintAndLog("Wrong block number");
635 if (blockNo
> MAX_ULTRAC_BLOCKS
){
636 PrintAndLog("Error: Maximum number of readable blocks is 47 for Ultralight-C Cards!");
641 if ( strlen(Cmd
) > 3){
642 if (param_gethex(Cmd
, 1, key
, 16)) {
643 PrintAndLog("Key must include %d HEX symbols", 16);
651 PrintAndLog("--block no: 0x%02X (%d) PWD: %s", (int)blockNo
, blockNo
, key
);
653 PrintAndLog("--block no: 0x%02X (%d)", (int)blockNo
, blockNo
);
656 UsbCommand c
= {CMD_MIFAREU_READBL
, {blockNo
}};
659 memcpy(c
.d
.asBytes
,key
,16);
663 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
664 uint8_t isOK
= resp
.arg
[0] & 0xff;
665 uint8_t *data
= resp
.d
.asBytes
;
667 PrintAndLog("isOk: %02x", isOK
);
669 PrintAndLog("Data: %s", sprint_hex(data
, 4));
672 PrintAndLog("Command execute timeout");
678 // Mifare Ultralight C Write Single Block
680 int CmdHF14AMfUCWrBl(const char *Cmd
){
682 uint8_t blockNo
= -1;
683 bool chinese_card
= FALSE
;
684 uint8_t bldata
[16] = {0x00};
687 char cmdp
= param_getchar(Cmd
, 0);
689 if (strlen(Cmd
) < 3 || cmdp
== 'h' || cmdp
== 'H') {
690 PrintAndLog("Usage: hf mfu cwrbl <block number> <block data (8 hex symbols)> [w]");
691 PrintAndLog(" [block number]");
692 PrintAndLog(" [block data] - (8 hex symbols)");
693 PrintAndLog(" [w] - Chinese magic ultralight tag");
695 PrintAndLog(" sample: hf mfu cwrbl 0 01020304");
700 blockNo
= param_get8(Cmd
, 0);
701 if (blockNo
> MAX_ULTRAC_BLOCKS
){
702 PrintAndLog("Error: Maximum number of blocks is 47 for Ultralight-C Cards!");
706 if (param_gethex(Cmd
, 1, bldata
, 8)) {
707 PrintAndLog("Block data must include 8 HEX symbols");
711 if (strchr(Cmd
,'w') != 0 || strchr(Cmd
,'W') != 0 ) {
715 if ( blockNo
<= 3 ) {
717 PrintAndLog("Access Denied");
719 PrintAndLog("--Special block no: 0x%02x", blockNo
);
720 PrintAndLog("--Data: %s", sprint_hex(bldata
, 4));
721 UsbCommand d
= {CMD_MIFAREU_WRITEBL
, {blockNo
}};
722 memcpy(d
.d
.asBytes
,bldata
, 4);
724 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
725 uint8_t isOK
= resp
.arg
[0] & 0xff;
726 PrintAndLog("isOk:%02x", isOK
);
728 PrintAndLog("Command execute timeout");
732 PrintAndLog("--Block no : 0x%02x", blockNo
);
733 PrintAndLog("--Data: %s", sprint_hex(bldata
, 4));
734 UsbCommand e
= {CMD_MIFAREU_WRITEBL
, {blockNo
}};
735 memcpy(e
.d
.asBytes
,bldata
, 4);
737 if (WaitForResponseTimeout(CMD_ACK
,&resp
,1500)) {
738 uint8_t isOK
= resp
.arg
[0] & 0xff;
739 PrintAndLog("isOk : %02x", isOK
);
741 PrintAndLog("Command execute timeout");
747 //------------------------------------
749 //------------------------------------
750 static command_t CommandTable
[] =
752 {"help", CmdHelp
, 1,"This help"},
753 {"dbg", CmdHF14AMfDbg
, 0,"Set default debug mode"},
754 {"info", CmdHF14AMfUInfo
, 0,"Taginfo"},
755 {"dump", CmdHF14AMfUDump
, 0,"Dump MIFARE Ultralight / Ultralight-C tag to binary file"},
756 {"rdbl", CmdHF14AMfURdBl
, 0,"Read block - MIFARE Ultralight"},
757 {"wrbl", CmdHF14AMfUWrBl
, 0,"Write block - MIFARE Ultralight"},
758 {"crdbl", CmdHF14AMfUCRdBl
, 0,"Read block - MIFARE Ultralight C"},
759 {"cwrbl", CmdHF14AMfUCWrBl
, 0,"Write MIFARE Ultralight C block"},
760 {"cauth", CmdHF14AMfucAuth
, 0,"try a Ultralight C Authentication"},
761 //{"testdes", CmdTestDES , 1, "Test DES"},
762 {NULL
, NULL
, 0, NULL
}
765 int CmdHFMFUltra(const char *Cmd
){
766 WaitForResponseTimeout(CMD_ACK
,NULL
,100);
767 CmdsParse(CommandTable
, Cmd
);
771 int CmdHelp(const char *Cmd
){
772 CmdsHelp(CommandTable
);