From 857d67d7332a698b8c2cb4537143e8084a2a80f5 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 3 Aug 2021 00:19:11 +0300 Subject: [PATCH] some fixes in info command --- client/src/cmdhfmfdes.c | 21 ++++++++++++++------- client/src/mifare/desfirecore.c | 4 +++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 3f0bcbeeb..1b3d42862 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -1255,7 +1255,7 @@ static int CmdHF14ADesInfo(const char *Cmd) { CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - DropFieldDesfire(); + DropField(); mfdes_info_res_t info; int res = mfdes_get_info(&info); @@ -1270,8 +1270,7 @@ static int CmdHF14ADesInfo(const char *Cmd) { } PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ---------------------------"); - PrintAndLogEx(INFO, "-------------------------------------------------------------"); + PrintAndLogEx(INFO, "---------------------------------- " _CYAN_("Tag Information") " ----------------------------------"); PrintAndLogEx(SUCCESS, " UID: " _GREEN_("%s"), sprint_hex(info.uid, info.uidlen)); PrintAndLogEx(SUCCESS, " Batch number: " _GREEN_("%s"), sprint_hex(info.details + 7, 5)); PrintAndLogEx(SUCCESS, " Production date: week " _GREEN_("%02x") " / " _GREEN_("20%02x"), info.details[12], info.details[13]); @@ -1296,7 +1295,7 @@ static int CmdHF14ADesInfo(const char *Cmd) { PrintAndLogEx(INFO, " Protocol: %s", getProtocolStr(info.versionSW[6], false)); PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(INFO, "--- " _CYAN_("Card capabilities")); + PrintAndLogEx(INFO, "--------------------------------- " _CYAN_("Card capabilities") " ---------------------------------"); uint8_t major = info.versionSW[3]; uint8_t minor = info.versionSW[4]; if (major == 0 && minor == 4) @@ -1324,6 +1323,15 @@ static int CmdHF14ADesInfo(const char *Cmd) { if (res != PM3_SUCCESS) return res; + PICCInfoS PICCInfo = {0}; + + uint8_t buf[250] = {0}; + size_t buflen = 0; + res = DesfireGetAIDList(&dctx, buf, &buflen); + if (res == PM3_SUCCESS) { + PICCInfo.appCount = buflen / 3; + } + if (cardtype == DESFIRE_EV2 || cardtype == DESFIRE_LIGHT || cardtype == DESFIRE_EV3 || @@ -1345,7 +1353,6 @@ static int CmdHF14ADesInfo(const char *Cmd) { } } - PICCInfoS PICCInfo = {0}; DesfireFillPICCInfo(&dctx, &PICCInfo, true); DesfirePrintPICCInfo(&dctx, &PICCInfo); @@ -1358,8 +1365,8 @@ static int CmdHF14ADesInfo(const char *Cmd) { } else { PrintAndLogEx(SUCCESS, " Card doesn't support 'free mem' cmd"); } - PrintAndLogEx(INFO, "-------------------------------------------------------------"); } + PrintAndLogEx(NORMAL, ""); iso14a_card_select_t card; @@ -1402,7 +1409,7 @@ static int CmdHF14ADesInfo(const char *Cmd) { */ - DropFieldDesfire(); + DropField(); return PM3_SUCCESS; } diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 438125051..01f4b2b2b 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -1934,8 +1934,10 @@ static void PrintKeySettingsPICC(uint8_t keysettings, uint8_t numkeys, bool prin PrintAndLogEx(SUCCESS, "[...%c] CMK is changeable : %s", (keysettings & (1 << 0)) ? '1' : '0', (keysettings & (1 << 0)) ? _GREEN_("YES") : _RED_("NO (frozen)")); PrintAndLogEx(SUCCESS, ""); - if (print2ndbyte) + if (print2ndbyte) { + DesfirePrintCardKeyType(numkeys >> 6); PrintAndLogEx(SUCCESS, "key count: %d", numkeys & 0x0f); + } } static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print2ndbyte) {