#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;
}
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;
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.