From 709ef8381f16588de94d08592670772364f18ffb Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 26 Jun 2020 13:34:50 +0200 Subject: [PATCH] reinit for retrieving new uid after block 0 write --- utils/nfc-mfclassic.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index f39dbe2..5278a37 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -490,7 +490,18 @@ write_card(int write_block_zero) return false; } - + if (magic2 || magic3) { + if (nfc_initiator_init(pnd) < 0) { + nfc_perror(pnd, "nfc_initiator_init"); + nfc_close(pnd); + nfc_exit(context); + exit(EXIT_FAILURE); + }; + if (nfc_initiator_select_passive_target(pnd, nmMifare, NULL, 0, &nt) <= 0) { + printf("!\nError: tag was removed\n"); + return false; + } + } // Completely write the card, but skipping block 0 for (uiBlock = 1; uiBlock <= uiBlocks; uiBlock++) { // Authenticate everytime we reach the first sector of a new block