diff --git a/CHANGELOG.md b/CHANGELOG.md index d2f28c41e..4f50b6cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fixed `hf mf dump` replacing readable sector trailer Key B values with values from the key file (@oSPANNERo) - Added `hf felica seacauth1` command - Added `lf trovan` commands to support Trovan Animal ID (@iceman1001) - Added `hf mf gdmgetblk/gdmgethidblk/gdmsethidblk/gdmsetuid/gdmwipe/gdmsetsig` (@0x6r1an0y) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 6707ad17d..2ebc9a608 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -1085,9 +1085,12 @@ static int mfc_read_tag(iso14a_card_select_t *card, uint8_t *carddata, uint8_t n uint8_t *data = resp.data.asBytes; if (mfIsSectorTrailerBasedOnBlocks(sectorNo, blockNo)) { - // sector trailer. Fill in the keys. + // sector trailer. Key A is never readable; preserve Key B when ACL allows it. memcpy(data, keyA + (sectorNo * MIFARE_KEY_SIZE), MIFARE_KEY_SIZE); - memcpy(data + 10, keyB + (sectorNo * MIFARE_KEY_SIZE), MIFARE_KEY_SIZE); + uint8_t trailer_acl = mf_get_accesscondition(3, &data[6]); + if (trailer_acl != 0 && trailer_acl != 1 && trailer_acl != 2) { + memcpy(data + 10, keyB + (sectorNo * MIFARE_KEY_SIZE), MIFARE_KEY_SIZE); + } } memcpy(carddata + (MFBLOCK_SIZE * (mfFirstBlockOfSector(sectorNo) + blockNo)), data, MFBLOCK_SIZE);