From 741f560a8d7f15228d944580f5e35eefd123d0bd Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 13 Jul 2021 17:29:45 +0300 Subject: [PATCH] hf mfdes getaids -- no-auth --- client/src/cmdhfmfdes.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 593469590..c453393f3 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -5624,7 +5624,7 @@ static int CmdHF14ADesGetFreeMem(const char *Cmd) { static int CmdHF14ADesChKeySettings(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf mfdes chkeysetings", - "Change key settings for card level or application level. WARNING: card level changes may block card!", + "Change key settings for card level or application level. WARNING: card level changes may block the card!", "hf mfdes chkeysetings -d 0f -> set picc key settings with default key/channel setup\n"\ "hf mfdes chkeysetings --aid 123456 -d 0f -> set app 123456 key settings with default key/channel setup"); @@ -5903,12 +5903,14 @@ static int CmdHF14ADesGetAIDs(const char *Cmd) { arg_str0("m", "cmode", "", "Communicaton mode: plain/mac/encrypt"), arg_str0("c", "ccset", "", "Communicaton command set: native/niso/iso"), arg_str0("s", "schann", "", "Secure channel: d40/ev1/ev2"), + arg_lit0(NULL, "no-auth", "execute without authentication"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); bool APDULogging = arg_get_lit(ctx, 1); bool verbose = arg_get_lit(ctx, 2); + bool noauth = arg_get_lit(ctx, 11); DesfireContext dctx; int securechann = defaultSecureChannel; @@ -5921,10 +5923,19 @@ static int CmdHF14ADesGetAIDs(const char *Cmd) { SetAPDULogging(APDULogging); CLIParserFree(ctx); - res = DesfireSelectAndAuthenticate(&dctx, securechann, 0x000000, verbose); - if (res != PM3_SUCCESS) { - DropField(); - return res; + if (noauth) { + res = DesfireSelectAIDHex(&dctx, 0x000000, false, 0); + if (res != PM3_SUCCESS) { + PrintAndLogEx(ERR, "Desfire select " _RED_("error") "."); + DropField(); + return res; + } + } else { + res = DesfireSelectAndAuthenticate(&dctx, securechann, 0x000000, verbose); + if (res != PM3_SUCCESS) { + DropField(); + return res; + } } uint8_t buf[APDU_RES_LEN] = {0};