diff --git a/CHANGELOG.md b/CHANGELOG.md index b35b1be0c..4eb13dad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ 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 mfdes dump` - the ISO file id probe ends the PICC session on applications without ISO file ids (@iceman1001) +- Changed `hf mfdes lsfiles` / `hf mfdes dump` - no longer warn about a missing ISO file id list (@iceman1001) - Fixed `hf mfdes read` / `hf mfdes write` - a file whose access right is free (0x0E) is served in plain by the PICC (@iceman1001) - Fixed `hf mfdes value` - credit/debit/limitedcredit used a fixed comm mode, now look on card (@iceman1001) - Fixed `hf mfdes value -o get` / `hf mfdes dump` - a value file read in the wrong comm mode printed a silently wrong value instead of failing (@iceman1001) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 2e1ee30a7..97df7ea5e 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -8322,6 +8322,18 @@ static int CmdHF14ADesDump(const char *Cmd) { return res; } + // the ISO file id probe in DesfireFillFileList makes the PICC end the session on + // applications without ISO file ids, so get it back before reading the files + if (noauth == false && DesfireIsAuthenticated(&dctx) == false) { + DesfireSetCommMode(&dctx, DCMPlain); + res = DesfireSelectAndAuthenticateAppW(&dctx, securechann, selectway, id, noauth, verbose); + if (res != PM3_SUCCESS) { + DropField(); + PrintAndLogEx(FAILED, "Select or authentication %s " _RED_("failed") ". Result [%d] %s", DesfireWayIDStr(selectway, id), res, DesfireAuthErrorToStr(res)); + return res; + } + } + PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, "Application " _CYAN_("%s") " have " _GREEN_("%zu") " files", DesfireWayIDStr(selectway, id), filescount); diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 73315925c..14ec978a4 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -2358,7 +2358,12 @@ int DesfireFillFileList(DesfireContext_t *dctx, FileList_t FileList, size_t *fil buflen = 0; res = DesfireGetFileISOIDList(dctx, buf, &buflen); if (res != PM3_SUCCESS) { - PrintAndLogEx(WARNING, "Desfire GetFileISOIDList command, res " _RED_("%d"), res); + // An application created without ISO file IDs answers 0x91F0 here, and the PICC + // ends the authentication on a command error. Drop our side of the session too, + // otherwise the next command is still framed as MACed and the plain response to + // it gets parsed as a CMAC. Callers that keep using the card re-authenticate. + dctx->secureChannel = DACNone; + PrintAndLogEx(DEBUG, "Desfire GetFileISOIDList command, res " _RED_("%d") ". Session dropped by the PICC", res); } size_t isoindx = 0; @@ -2373,7 +2378,7 @@ int DesfireFillFileList(DesfireContext_t *dctx, FileList_t FileList, size_t *fil if (isoindx * 2 != buflen) PrintAndLogEx(WARNING, "Wrong ISO ID list length. must be %zu but %zu", buflen, isoindx * 2); } else { - PrintAndLogEx(WARNING, "ISO ID list returned no data"); + PrintAndLogEx(DEBUG, "ISO ID list returned no data"); } *isopresent = (isoindx > 0);