#define MAX_UL_BLOCKS 0x0f
#define MAX_ULC_BLOCKS 0x2f
-#define MAX_ULEV1a_BLOCKS 0x0b
+#define MAX_ULEV1a_BLOCKS 0x12
#define MAX_ULEV1b_BLOCKS 0x20
#define MAX_NTAG_213 0x2c
#define MAX_NTAG_215 0x86
{0x32,0x0C,0x16,0x17}, // PACK 0x80,0x80 -- AMiiboo (sniffed)
};
+#define MAX_UL_TYPES 13
+uint16_t UL_TYPES_ARRAY[MAX_UL_TYPES] = {UNKNOWN, UL, UL_C, UL_EV1_48, UL_EV1_128,
+ NTAG, NTAG_213, NTAG_215, NTAG_216, MY_D, MY_D_NFC, MY_D_MOVE, MY_D_MOVE_NFC};
+uint8_t UL_MEMORY_ARRAY[MAX_UL_TYPES] = {MAX_UL_BLOCKS, MAX_UL_BLOCKS, MAX_ULC_BLOCKS,
+ MAX_ULEV1a_BLOCKS, MAX_ULEV1b_BLOCKS, MAX_NTAG_213, MAX_NTAG_213, MAX_NTAG_215,
+ MAX_NTAG_216, MAX_UL_BLOCKS, MAX_UL_BLOCKS, MAX_UL_BLOCKS, MAX_UL_BLOCKS};
+
+
static int CmdHelp(const char *Cmd);
char* getProductTypeStr( uint8_t id){
PrintAndLog(" BCC1 : %02X - crc should be %02X", data[8], crc1 );
PrintAndLog(" Internal : %02X - %s default", data[9], (data[9]==0x48)?"":"not" );
- PrintAndLog(" Lock : %s - %s", sprint_hex(data+10, 2),printBits( 2, data+10) );
- PrintAndLog("OneTimePad : %s ", sprint_hex(data + 12, 4));
- PrintAndLog("");
+ PrintAndLog(" Lock : %s - %s",
+ sprint_hex(data+10, 2),
+ printBits(2, data+10)
+ );
+ PrintAndLog("OneTimePad : %s - %s\n",
+ sprint_hex(data + 12, 4),
+ printBits(4, data+12)
+ );
return 0;
}
PrintAndLog(" deskey1 [45/0x2D]: %s [%.4s]", sprint_hex(data+4 ,4),data+4);
PrintAndLog(" deskey2 [46/0x2E]: %s [%.4s]", sprint_hex(data+8 ,4),data+8);
PrintAndLog(" deskey2 [47/0x2F]: %s [%.4s]", sprint_hex(data+12,4),data+12);
- PrintAndLog("\n 3des key : %s", sprint_hex(SwapEndian64(data, 16), 16));
+ PrintAndLog("\n 3des key : %s", sprint_hex(SwapEndian64(data, 16, 8), 16));
return 0;
}
key = default_3des_keys[i];
if (try3DesAuthentication(key) == 1){
PrintAndLog("Found default 3des key: "); //%s", sprint_hex(key,16));
- ulc_print_3deskey(SwapEndian64(key,16));
+ uint8_t keySwap[16];
+ memcpy(keySwap, SwapEndian64(key,16,8), 16);
+ ulc_print_3deskey(keySwap);
return 1;
}
}
FILE *fout;
char filename[FILE_PATH_SIZE] = {0x00};
char *fnameptr = filename;
- char *str = "Dumping Ultralight%s%s Card Data...";
+ //char *str = "Dumping Ultralight%s%s Card Data...";
uint8_t *lockbytes_t = NULL;
uint8_t lockbytes[2] = {0x00};
uint8_t *lockbytes_t2 = NULL;
size_t fileNlen = 0;
bool errors = false;
bool swapEndian = false;
-
+ bool manualPages = false;
+ uint8_t startPage = 0;
while(param_getchar(Cmd, cmdp) != 0x00)
{
switch(param_getchar(Cmd, cmdp))
if (fileNlen > FILE_PATH_SIZE-5) fileNlen = FILE_PATH_SIZE-5;
cmdp += 2;
break;
+ case 'p':
+ case 'P':
+ startPage = param_get8(Cmd, cmdp+1);
+ manualPages = true;
+ cmdp += 2;
+ break;
+ case 'q':
+ case 'Q':
+ Pages = param_get8(Cmd, cmdp+1);
+ cmdp += 2;
+ manualPages = true;
+ break;
case 's':
+ case 'S':
swapEndian = true;
cmdp++;
break;
+ case 't':
+ case 'T':
+ //key type - ul-c or ev1/ntag
+ //TODO
+ cmdp += 2;
+ break;
default:
PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
errors = true;
if(errors) return usage_hf_mfu_dump();
if (swapEndian)
- keyPtr = SwapEndian64(data, 16);
+ keyPtr = SwapEndian64(data, 16, 8);
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
+ if (!manualPages)
+ for (uint8_t idx = 0; idx < MAX_UL_TYPES; idx++)
+ if (tagtype & UL_TYPES_ARRAY[idx])
+ Pages = UL_MEMORY_ARRAY[idx]+1;
+
+ ul_print_type(tagtype, 0);
+ PrintAndLog("Reading tag memory...");
+ /*
if ( tagtype & UL ) {
Pages = 16;
PrintAndLog(str,"", (tagtype & MAGIC)?" (magic)":"" );
Pages = 16;
PrintAndLog("Dumping unknown Ultralight, using default values.");
}
-
- UsbCommand c = {CMD_MIFAREUC_READCARD, {0,Pages}};
- if ( hasPwd ) {
- c.arg[2] = 1;
- memcpy(c.d.asBytes, key, 16);
- }
- SendCommand(&c);
- UsbCommand resp;
- if (!WaitForResponseTimeout(CMD_ACK, &resp,1500)) {
- PrintAndLog("Command execute time-out");
- return 1;
- }
- PrintAndLog ("%u,%u",resp.arg[0],resp.arg[1]);
- uint8_t isOK = resp.arg[0] & 0xff;
- if (isOK) {
- memcpy(data, resp.d.asBytes, resp.arg[1]);
+ */
+ if (!hasPwd || (tagtype & UL_C)){
+ UsbCommand c = {CMD_MIFAREUC_READCARD, {startPage,Pages}};
+ if ( hasPwd ) {
+ c.arg[2] = 1;
+ memcpy(c.d.asBytes, key, 16);
+ }
+ SendCommand(&c);
+ UsbCommand resp;
+ if (!WaitForResponseTimeout(CMD_ACK, &resp,1500)) {
+ PrintAndLog("Command execute time-out");
+ return 1;
+ }
+ PrintAndLog ("%u,%u",resp.arg[0],resp.arg[1]);
+ uint8_t isOK = resp.arg[0] & 0xff;
+ if (isOK) {
+ memcpy(data, resp.d.asBytes, resp.arg[1]);
+ } else {
+ PrintAndLog("Failed reading block: (%02x)", i);
+ return 1;
+ }
} else {
- PrintAndLog("Failed reading block: (%02x)", i);
- return 1;
+ PrintAndLog("EV1 and NTAG pwd mode not ready yet");
+ return 0;
}
// Load lock bytes.
sprintf(fnameptr,"%02X%02X%02X%02X%02X%02X%02X.bin",
data[0],data[1], data[2], data[4],data[5],data[6], data[7]);
} else {
- sprintf(fnameptr + fileNlen," .bin");
+ sprintf(fnameptr + fileNlen,".bin");
}
if ((fout = fopen(filename,"wb")) == NULL) {
hasPwd = TRUE;
}
}
- //uint8_t *key2 = SwapEndian64(key, 16);
+ //uint8_t *key2 = SwapEndian64(key, 16, 8);
//Read Block
UsbCommand c = {CMD_MIFAREU_READBL, {blockNo}};