Skip to content

Commit

Permalink
vary expected dump size based on tag type
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Laurie committed Mar 23, 2017
1 parent c04dd91 commit 963eb07
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions utils/nfc-mfultralight.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ int
main(int argc, const char *argv[])
{
int iAction = 0;
uint8_t iDumpSize= sizeof(mifareul_tag);
uint8_t iUID[MAX_UID_LEN] = { 0x0 };
size_t szUID = 0;
bool bOTP = false;
Expand Down Expand Up @@ -521,30 +522,6 @@ main(int argc, const char *argv[])
}
}

if (iAction == 1) {
memset(&mtDump, 0x00, sizeof(mtDump));
} else if (iAction == 2) {
pfDump = fopen(argv[2], "rb");

if (pfDump == NULL) {
ERR("Could not open dump file: %s\n", argv[2]);
exit(EXIT_FAILURE);
}

if (fread(&mtDump, 1, sizeof(mtDump), pfDump) != sizeof(mtDump)) {
ERR("Could not read from dump file: %s\n", argv[2]);
fclose(pfDump);
exit(EXIT_FAILURE);
}
fclose(pfDump);
DBG("Successfully opened the dump file\n");
} else if (iAction == 3) {
DBG("Switching to Check Magic Mode\n");
} else {
ERR("Unable to determine operating mode");
exit(EXIT_FAILURE);
}

nfc_context *context;
nfc_init(&context);
if (context == NULL) {
Expand Down Expand Up @@ -615,11 +592,13 @@ main(int argc, const char *argv[])
printf("48 bytes\n");
uiBlocks= 0x13;
iEV1Type= EV1_UL11;
iDumpSize= sizeof(mifareul_ev1_mf0ul11_tag);
}
else if(abtRx[6] == 0x0e) {
printf("128 bytes\n");
uiBlocks= 0x28;
iEV1Type= EV1_UL21;
iDumpSize= sizeof(mifareul_ev1_mf0ul21_tag);
}
else
printf("unknown!\n");
Expand Down Expand Up @@ -648,6 +627,30 @@ main(int argc, const char *argv[])
}
}

if (iAction == 1) {
memset(&mtDump, 0x00, sizeof(mtDump));
} else if (iAction == 2) {
pfDump = fopen(argv[2], "rb");

if (pfDump == NULL) {
ERR("Could not open dump file: %s\n", argv[2]);
exit(EXIT_FAILURE);
}

if (fread(&mtDump, 1, sizeof(mtDump), pfDump) != iDumpSize) {
ERR("Could not read from dump file or size mismatch: %s\n", argv[2]);
fclose(pfDump);
exit(EXIT_FAILURE);
}
fclose(pfDump);
DBG("Successfully opened the dump file\n");
} else if (iAction == 3) {
DBG("Switching to Check Magic Mode\n");
} else {
ERR("Unable to determine operating mode");
exit(EXIT_FAILURE);
}

if (iAction == 1) {
bool bRF= read_card();
printf("Writing data to file: %s ... ", argv[2]);
Expand Down

0 comments on commit 963eb07

Please sign in to comment.