From fddf7cf6b8a0b5e4d78a2a903f1d3bfe62cd833f Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 24 Aug 2021 13:11:52 +0300 Subject: [PATCH] desfire info updates --- client/src/cmdhfmfdes.c | 18 +++++++++++++++++- client/src/mifare/desfirecore.c | 2 +- client/src/mifare/desfirecore.h | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 5868e1b56..e2b5d2dff 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -683,8 +683,24 @@ static int CmdHF14ADesInfo(const char *Cmd) { PrintAndLogEx(SUCCESS, " Card doesn't support 'free mem' cmd"); } } - PrintAndLogEx(NORMAL, ""); + + if (cardtype == DESFIRE_LIGHT) { + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(INFO, "--- " _CYAN_("Desfire Light info")); + 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"); + } + } + + PrintAndLogEx(NORMAL, ""); iso14a_card_select_t card; res = SelectCard14443A_4(true, false, &card); diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index f61254143..cf6973e86 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -1571,7 +1571,7 @@ int DesfireAuthenticate(DesfireContext_t *dctx, DesfireSecureChannel secureChann return 100; } -static bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum, uint8_t authcmd, bool checklrp) { +bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum, uint8_t authcmd, bool checklrp) { size_t recv_len = 0; uint8_t respcode = 0; uint8_t recv_data[256] = {0}; diff --git a/client/src/mifare/desfirecore.h b/client/src/mifare/desfirecore.h index 8c834137c..5cdcb3c26 100644 --- a/client/src/mifare/desfirecore.h +++ b/client/src/mifare/desfirecore.h @@ -184,6 +184,8 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s int DesfireSelectAndAuthenticateAppW(DesfireContext_t *dctx, DesfireSecureChannel secureChannel, DesfireISOSelectWay way, uint32_t id, bool noauth, bool verbose); int DesfireSelectAndAuthenticateISO(DesfireContext_t *dctx, DesfireSecureChannel secureChannel, bool useaid, uint32_t aid, uint16_t isoappid, bool selectfile, uint16_t isofileid, bool noauth, bool verbose); int DesfireAuthenticate(DesfireContext_t *dctx, DesfireSecureChannel secureChannel, bool verbose); + +bool DesfireCheckAuthCmd(DesfireISOSelectWay way, uint32_t appID, uint8_t keyNum, uint8_t authcmd, bool checklrp); void DesfireCheckAuthCommands(DesfireISOSelectWay way, uint32_t appID, char *dfname, uint8_t keyNum, AuthCommandsChk_t *authCmdCheck); void DesfireCheckAuthCommandsPrint(AuthCommandsChk_t *authCmdCheck);