From 81343f0ec174d6ba44710865754ca8856e301810 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 25 Aug 2021 13:57:35 +0300 Subject: [PATCH] fix info, add there desfire light tests --- client/src/cmdhfmfdes.c | 19 ++++++++++++------- client/src/mifare/desfirecore.c | 6 ++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index e2b5d2dff..52d1afad4 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -688,15 +688,20 @@ static int CmdHF14ADesInfo(const char *Cmd) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("Desfire Light info")); - if (DesfireSelect(&dctx, ISWIsoID, 0xdf01, NULL) == PM3_SUCCESS) + if (DesfireSelect(&dctx, ISWIsoID, 0xdf01, NULL) == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, " Card have " _GREEN_("default (0xdf01)") " iso id for application"); - else - PrintAndLogEx(SUCCESS, " Card have " _RED_("not a default") " iso id for application"); - if (DesfireCheckAuthCmd(ISWIsoID, 0x3f00, 1, MFDES_AUTHENTICATE_EV2F, false)) { - PrintAndLogEx(SUCCESS, " Card in the " _GREEN_("AES") " mode"); - } else if (DesfireCheckAuthCmd(ISWIsoID, 0x3f00, 1, MFDES_AUTHENTICATE_EV2F, true)) { - PrintAndLogEx(SUCCESS, " Card in the " _GREEN_("LRP") " mode"); + if (DesfireCheckAuthCmd(ISWIsoID, 0xdf01, 0, MFDES_AUTHENTICATE_EV2F, false)) { + PrintAndLogEx(SUCCESS, " Card in the " _GREEN_("AES") " mode"); + } else if (DesfireCheckAuthCmd(ISWIsoID, 0xdf01, 0, MFDES_AUTHENTICATE_EV2F, true)) { + PrintAndLogEx(SUCCESS, " Card in the " _GREEN_("LRP") " mode"); + } + } else { + PrintAndLogEx(SUCCESS, " Card have " _RED_("not a default") " iso id for application"); + } + + if (DesfireCheckAuthCmd(ISWIsoID, 0x3f00, 1, MFDES_AUTHENTICATE_EV2F, true)) { + PrintAndLogEx(SUCCESS, " Card have " _GREEN_("LRP") " key in the MF/key1"); } } diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 28e81b161..e15f73437 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -1579,7 +1579,7 @@ bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum DesfireContext_t dctx = {0}; dctx.keyNum = keyNum; dctx.commMode = DCMPlain; - dctx.cmdSet = (checklrp) ? DCCNativeISO : DCCNative; + dctx.cmdSet = (checklrp || way != ISW6bAID) ? DCCNativeISO : DCCNative; // if cant select - return false int res = DesfireSelect(&dctx, way, appID, NULL); @@ -1587,9 +1587,7 @@ bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum return false; uint8_t data[] = {keyNum, 0x01, (checklrp) ? 0x02 : 0x00}; - uint8_t datalen = (authcmd == MFDES_AUTHENTICATE_EV2F) ? 2 : 1; - if (checklrp) - datalen = 3; + uint8_t datalen = (authcmd == MFDES_AUTHENTICATE_EV2F) ? 3 : 1; res = DesfireExchangeEx(false, &dctx, authcmd, data, datalen, &respcode, recv_data, &recv_len, false, 0); DropField();