Add OTP/Capability Bytes handling to NTAG

This commit is contained in:
Adam Laurie 2018-09-18 11:14:08 +01:00
parent 3ba065f00b
commit 25ee3a2f76
2 changed files with 11 additions and 13 deletions

View file

@ -247,7 +247,7 @@ typedef struct {
mifareul_block amb[11]; mifareul_block amb[11];
} mifareul_ev1_mf0ul21_tag; } mifareul_ev1_mf0ul21_tag;
// NOT really UL but so similar we can re-use this code // NTAG is a range of NXP tags some of which are essentially Ultralights so we can support them here
// if Edwin van Andel doesn't distract us... // if Edwin van Andel doesn't distract us...
// https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf // https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf

View file

@ -349,9 +349,8 @@ write_card(bool write_otp, bool write_lock, bool write_dyn_lock, bool write_uid)
char buffer[BUFSIZ]; char buffer[BUFSIZ];
// NTAG does not have explicit OTP bytes if (!write_otp) {
if (!write_otp && iNTAGType == NTAG_NONE) { printf("Write OTP/Capability Bytes ? [yN] ");
printf("Write OTP Bytes ? [yN] ");
if (!fgets(buffer, BUFSIZ, stdin)) { if (!fgets(buffer, BUFSIZ, stdin)) {
ERR("Unable to read standard input."); ERR("Unable to read standard input.");
} }
@ -402,8 +401,8 @@ write_card(bool write_otp, bool write_lock, bool write_dyn_lock, bool write_uid)
uiSkippedPages++; uiSkippedPages++;
continue; continue;
} }
// NTAG doesn't have OTP blocks // OTP/Capability blocks
if ((iNTAGType == NTAG_NONE && page == 0x3) && (!write_otp)) { if ((page == 0x3) && (!write_otp)) {
printf("s"); printf("s");
uiSkippedPages++; uiSkippedPages++;
continue; continue;
@ -650,30 +649,29 @@ main(int argc, const char *argv[])
// test if tag is EV1 or NTAG // test if tag is EV1 or NTAG
if (get_ev1_version()) { if (get_ev1_version()) {
if (!bPWD) if (!bPWD)
printf("Tag is EV1 - PASSWORD may be required\n"); printf("WARNING: Tag is EV1 or NTAG - PASSWORD may be required\n");
printf("EV1 type: ");
if (abtRx[6] == 0x0b) { if (abtRx[6] == 0x0b) {
printf("MF0UL11 (48 bytes)\n"); printf("EV1 type: MF0UL11 (48 bytes)\n");
uiBlocks = 20; // total number of 4 byte 'pages' uiBlocks = 20; // total number of 4 byte 'pages'
iDumpSize = uiBlocks * 4; iDumpSize = uiBlocks * 4;
iEV1Type = EV1_UL11; iEV1Type = EV1_UL11;
} else if (abtRx[6] == 0x0e) { } else if (abtRx[6] == 0x0e) {
printf("MF0UL21 (128 user bytes)\n"); printf("EV1 type: MF0UL21 (128 user bytes)\n");
uiBlocks = 41; uiBlocks = 41;
iDumpSize = uiBlocks * 4; iDumpSize = uiBlocks * 4;
iEV1Type = EV1_UL21; iEV1Type = EV1_UL21;
} else if (abtRx[6] == 0x0f) { } else if (abtRx[6] == 0x0f) {
printf("NTAG213 (144 user bytes)\n"); printf("NTAG Type: NTAG213 (144 user bytes)\n");
uiBlocks = 45; uiBlocks = 45;
iDumpSize = uiBlocks * 4; iDumpSize = uiBlocks * 4;
iNTAGType = NTAG_213; iNTAGType = NTAG_213;
} else if (abtRx[6] == 0x11) { } else if (abtRx[6] == 0x11) {
printf("NTAG215 (504 user bytes)\n"); printf("NTAG Type: NTAG215 (504 user bytes)\n");
uiBlocks = 135; uiBlocks = 135;
iDumpSize = uiBlocks * 4; iDumpSize = uiBlocks * 4;
iNTAGType = NTAG_215; iNTAGType = NTAG_215;
} else if (abtRx[6] == 0x13) { } else if (abtRx[6] == 0x13) {
printf("NTAG216 (888 user bytes)\n"); printf("NTAG Type: NTAG216 (888 user bytes)\n");
uiBlocks = 231; uiBlocks = 231;
iDumpSize = uiBlocks * 4; iDumpSize = uiBlocks * 4;
iNTAGType = NTAG_216; iNTAGType = NTAG_216;