added no-auth

This commit is contained in:
merlokk 2021-07-21 21:53:21 +03:00
commit 07d753dfea

View file

@ -6225,12 +6225,14 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
arg_str0(NULL, "wrights", "<key0/../key13/free/deny>", "Write file access mode: the specified key, free, deny"), arg_str0(NULL, "wrights", "<key0/../key13/free/deny>", "Write file access mode: the specified key, free, deny"),
arg_str0(NULL, "rwrights","<key0/../key13/free/deny>", "Read/Write file access mode: the specified key, free, deny"), arg_str0(NULL, "rwrights","<key0/../key13/free/deny>", "Read/Write file access mode: the specified key, free, deny"),
arg_str0(NULL, "chrights","<key0/../key13/free/deny>", "Change file settings access mode: the specified key, free, deny"), arg_str0(NULL, "chrights","<key0/../key13/free/deny>", "Change file settings access mode: the specified key, free, deny"),
arg_lit0(NULL, "no-auth", "execute without authentication"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
bool APDULogging = arg_get_lit(ctx, 1); bool APDULogging = arg_get_lit(ctx, 1);
bool verbose = arg_get_lit(ctx, 2); bool verbose = arg_get_lit(ctx, 2);
bool noauth = arg_get_lit(ctx, 19);
DesfireContext dctx; DesfireContext dctx;
int securechann = defaultSecureChannel; int securechann = defaultSecureChannel;
@ -6296,10 +6298,19 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
SetAPDULogging(APDULogging); SetAPDULogging(APDULogging);
CLIParserFree(ctx); CLIParserFree(ctx);
res = DesfireSelectAndAuthenticate(&dctx, securechann, appid, verbose); if (noauth) {
if (res != PM3_SUCCESS) { res = DesfireSelectAIDHex(&dctx, appid, false, 0);
DropField(); if (res != PM3_SUCCESS) {
return res; PrintAndLogEx(ERR, "Desfire select " _RED_("error") ".");
DropField();
return res;
}
} else {
res = DesfireSelectAndAuthenticate(&dctx, securechann, appid, verbose);
if (res != PM3_SUCCESS) {
DropField();
return res;
}
} }
if (verbose) if (verbose)
@ -6307,6 +6318,16 @@ static int CmdHF14ADesChFileSettings(const char *Cmd) {
DesfirePrintSetFileSettings(settings, settingslen); DesfirePrintSetFileSettings(settings, settingslen);
/* uint8_t buf[APDU_RES_LEN] = {0};
size_t buflen = 0;
res = DesfireGetFileSettings(&dctx, fileid, buf, &buflen);
if (res == PM3_SUCCESS && buflen > 5) {
uint8_t chright = buf[2] & 0x0f;
}*/
data[0] = fileid; data[0] = fileid;
res = DesfireChangeFileSettings(&dctx, data, settingslen + 1); res = DesfireChangeFileSettings(&dctx, data, settingslen + 1);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {