added no-authenticate option to read file

This commit is contained in:
merlokk 2021-06-03 14:53:51 +03:00
commit e5fe614a4f

View file

@ -184,6 +184,7 @@ static int CmdHFCipurseReadFile(const char *Cmd) {
arg_str0("k", "key", "<hex>", "key for authenticate"),
arg_str0("f", "file", "<hex>", "file ID"),
arg_int0("o", "offset", "<dec>", "offset for reading data from file"),
arg_lit0(NULL, "noauth", "read file without authentication"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -217,6 +218,13 @@ static int CmdHFCipurseReadFile(const char *Cmd) {
size_t offset = arg_get_int_def(ctx, 6, 0);
bool noAuth = arg_get_lit(ctx, 7);
//CipurseCChannelSetSecurityLevels(&cpc, CPSEncrypted, CPSEncrypted);
//CipurseCChannelSetSecurityLevels(&cpc, CPSMACed, CPSMACed);
//CipurseCChannelSetSecurityLevels(&cpc, CPSPlain, CPSPlain);
SetAPDULogging(APDULogging);
CLIParserFree(ctx);
@ -231,6 +239,7 @@ static int CmdHFCipurseReadFile(const char *Cmd) {
if (verbose)
PrintAndLogEx(INFO, "File id: %x offset %d key id: %d key: %s", fileId, offset, keyId, sprint_hex(key, CIPURSE_AES_KEY_LENGTH));
if (noAuth == false) {
bool bres = CIPURSEChannelAuthenticate(keyId, key, verbose);
if (bres == false) {
if (verbose == false)
@ -238,6 +247,7 @@ static int CmdHFCipurseReadFile(const char *Cmd) {
DropField();
return PM3_ESOFT;
}
}
res = CIPURSESelectFile(fileId, buf, sizeof(buf), &len, &sw);
if (res != 0 || sw != 0x9000) {