From 4adf6633004ac6efdbd42715e1d7131605d028cc Mon Sep 17 00:00:00 2001 From: Lucifer Voeltner Date: Sun, 1 Dec 2024 16:27:35 +0700 Subject: [PATCH] Fix Gen 3 APDU block 0 SAK not being written correctly --- armsrc/mifarecmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 659c5eec00..2eed2ca5c6 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -3482,7 +3482,8 @@ void MifareGen3Blk(uint8_t block_len, uint8_t *block) { retval = PM3_ESOFT; goto OUT; } - cmd[ofs++] = card_info->sak; + cmd[ofs] = block_len < card_info->uidlen ? card_info->sak : cmd[ofs]; + ofs++; cmd[ofs++] = card_info->atqa[0]; cmd[ofs++] = card_info->atqa[1]; AddCrc14A(cmd, sizeof(block_cmd) + MIFARE_BLOCK_SIZE);