mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 22:33:48 -07:00
get file settings command
This commit is contained in:
parent
d4a086739b
commit
408fc64e55
4 changed files with 97 additions and 0 deletions
|
@ -6114,6 +6114,96 @@ static int CmdHF14ADesGetFileISOIDs(const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {"getfilesettings", CmdHF14ADesGetFileSettings, IfPm3Iso14443a, "[new]Get file settings"},
|
||||||
|
static int CmdHF14ADesGetFileSettings(const char *Cmd) {
|
||||||
|
CLIParserContext *ctx;
|
||||||
|
CLIParserInit(&ctx, "hf mfdes getfilesettings",
|
||||||
|
"Get File Settings from file from application. Master key needs to be provided or flag --no-auth set (depend on cards settings).",
|
||||||
|
"hf mfdes getfilesettings --aid 123456 --fid 01 -> execute with defaults from `default` command\n"
|
||||||
|
"hf mfdes getfilesettings -n 0 -t des -k 0000000000000000 -f none --aid 123456 --fid 01 -> execute with default factory setup");
|
||||||
|
|
||||||
|
void *argtable[] = {
|
||||||
|
arg_param_begin,
|
||||||
|
arg_lit0("a", "apdu", "show APDU requests and responses"),
|
||||||
|
arg_lit0("v", "verbose", "show technical data"),
|
||||||
|
arg_int0("n", "keyno", "<keyno>", "Key number"),
|
||||||
|
arg_str0("t", "algo", "<DES/2TDEA/3TDEA/AES>", "Crypt algo: DES, 2TDEA, 3TDEA, AES"),
|
||||||
|
arg_str0("k", "key", "<Key>", "Key for authenticate (HEX 8(DES), 16(2TDEA or AES) or 24(3TDEA) bytes)"),
|
||||||
|
arg_str0("f", "kdf", "<none/AN10922/gallagher>", "Key Derivation Function (KDF): None, AN10922, Gallagher"),
|
||||||
|
arg_str0("i", "kdfi", "<kdfi>", "KDF input (HEX 1-31 bytes)"),
|
||||||
|
arg_str0("m", "cmode", "<plain/mac/encrypt>", "Communicaton mode: plain/mac/encrypt"),
|
||||||
|
arg_str0("c", "ccset", "<native/niso/iso>", "Communicaton command set: native/niso/iso"),
|
||||||
|
arg_str0("s", "schann", "<d40/ev1/ev2>", "Secure channel: d40/ev1/ev2"),
|
||||||
|
arg_str0(NULL, "aid", "<app id hex>", "Application ID (3 hex bytes, big endian)"),
|
||||||
|
arg_str0(NULL, "fid", "<file id hex>", "File ID (1 hex byte)"),
|
||||||
|
arg_lit0(NULL, "no-auth", "execute without authentication"),
|
||||||
|
arg_param_end
|
||||||
|
};
|
||||||
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
|
bool APDULogging = arg_get_lit(ctx, 1);
|
||||||
|
bool verbose = arg_get_lit(ctx, 2);
|
||||||
|
bool noauth = arg_get_lit(ctx, 13);
|
||||||
|
|
||||||
|
DesfireContext dctx;
|
||||||
|
int securechann = defaultSecureChannel;
|
||||||
|
uint32_t appid = 0x000000;
|
||||||
|
int res = CmdDesGetSessionParameters(ctx, &dctx, 3, 4, 5, 6, 7, 8, 9, 10, 11, &securechann, DCMPlain, &appid);
|
||||||
|
if (res) {
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t fileid = 1;
|
||||||
|
|
||||||
|
SetAPDULogging(APDULogging);
|
||||||
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
if (noauth) {
|
||||||
|
res = DesfireSelectAIDHex(&dctx, appid, false, 0);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(ERR, "Desfire select " _RED_("error") ".");
|
||||||
|
DropField();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = DesfireSelectAndAuthenticate(&dctx, securechann, appid, verbose);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
DropField();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t buf[APDU_RES_LEN] = {0};
|
||||||
|
size_t buflen = 0;
|
||||||
|
|
||||||
|
res = DesfireGetFileSettings(&dctx, fileid, buf, &buflen);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
PrintAndLogEx(ERR, "Desfire GetFileSettings command " _RED_("error") ". Result: %d", res);
|
||||||
|
DropField();
|
||||||
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
PrintAndLogEx(INFO, "app %06x file %02x settings[%d]: %s", appid, fileid, buflen, sprint_hex(buf, buflen));
|
||||||
|
/*if (buflen >= 3) {
|
||||||
|
PrintAndLogEx(INFO, "---- " _CYAN_("File ISO ID list") " ----");
|
||||||
|
for (int i = 0; i < buflen; i += 2)
|
||||||
|
PrintAndLogEx(INFO, "File ID: %02x%02x", buf[i], buf[i + 1]);
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(INFO, "There is no files in the application %06x", appid);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
DropField();
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// {"chfilesettings", CmdHF14ADesChFileSettings, IfPm3Iso14443a, "[new]Change file settings"},
|
||||||
|
static int CmdHF14ADesChFileSettings(const char *Cmd) {
|
||||||
|
DropField();
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int CmdHF14ADesTest(const char *Cmd) {
|
static int CmdHF14ADesTest(const char *Cmd) {
|
||||||
DesfireTest(true);
|
DesfireTest(true);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -6149,6 +6239,8 @@ static command_t CommandTable[] = {
|
||||||
{"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("Files") " -----------------------"},
|
{"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("Files") " -----------------------"},
|
||||||
{"getfileids", CmdHF14ADesGetFileIDs, IfPm3Iso14443a, "[new]Get File IDs list"},
|
{"getfileids", CmdHF14ADesGetFileIDs, IfPm3Iso14443a, "[new]Get File IDs list"},
|
||||||
{"getfileisoids", CmdHF14ADesGetFileISOIDs, IfPm3Iso14443a, "[new]Get File ISO IDs list"},
|
{"getfileisoids", CmdHF14ADesGetFileISOIDs, IfPm3Iso14443a, "[new]Get File ISO IDs list"},
|
||||||
|
{"getfilesettings", CmdHF14ADesGetFileSettings, IfPm3Iso14443a, "[new]Get file settings"},
|
||||||
|
{"chfilesettings", CmdHF14ADesChFileSettings, IfPm3Iso14443a, "[new]Change file settings"},
|
||||||
{"changevalue", CmdHF14ADesChangeValue, IfPm3Iso14443a, "Write value of a value file (credit/debit/clear)"},
|
{"changevalue", CmdHF14ADesChangeValue, IfPm3Iso14443a, "Write value of a value file (credit/debit/clear)"},
|
||||||
{"clearfile", CmdHF14ADesClearRecordFile, IfPm3Iso14443a, "Clear record File"},
|
{"clearfile", CmdHF14ADesClearRecordFile, IfPm3Iso14443a, "Clear record File"},
|
||||||
{"createfile", CmdHF14ADesCreateFile, IfPm3Iso14443a, "Create Standard/Backup File"},
|
{"createfile", CmdHF14ADesCreateFile, IfPm3Iso14443a, "Create Standard/Backup File"},
|
||||||
|
|
|
@ -1021,6 +1021,9 @@ int DesfireGetFileISOIDList(DesfireContext *dctx, uint8_t *resp, size_t *resplen
|
||||||
return DesfireCommandRxData(dctx, MFDES_GET_ISOFILE_IDS, resp, resplen, -1);
|
return DesfireCommandRxData(dctx, MFDES_GET_ISOFILE_IDS, resp, resplen, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DesfireGetFileSettings(DesfireContext *dctx, uint8_t fileid, uint8_t *resp, size_t *resplen) {
|
||||||
|
return DesfireCommand(dctx, MFDES_GET_FILE_SETTINGS, &fileid, 1, resp, resplen, -1);
|
||||||
|
}
|
||||||
int DesfireCreateFile(DesfireContext *dctx, uint8_t *fdata, size_t fdatalen) {
|
int DesfireCreateFile(DesfireContext *dctx, uint8_t *fdata, size_t fdatalen) {
|
||||||
return DesfireCommandTxData(dctx, MFDES_CREATE_STD_DATA_FILE, fdata, fdatalen);
|
return DesfireCommandTxData(dctx, MFDES_CREATE_STD_DATA_FILE, fdata, fdatalen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *para
|
||||||
|
|
||||||
int DesfireGetFileIDList(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
int DesfireGetFileIDList(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireGetFileISOIDList(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
int DesfireGetFileISOIDList(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
||||||
|
int DesfireGetFileSettings(DesfireContext *dctx, uint8_t fileid, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireCreateFile(DesfireContext *dctx, uint8_t *fdata, size_t fdatalen);
|
int DesfireCreateFile(DesfireContext *dctx, uint8_t *fdata, size_t fdatalen);
|
||||||
int DesfireDeleteFile(DesfireContext *dctx, uint8_t fid);
|
int DesfireDeleteFile(DesfireContext *dctx, uint8_t fid);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ AllowedChannelModesS AllowedChannelModes[] = {
|
||||||
{MFDES_FORMAT_PICC, DACEV1, DCCNative, DCMMACed},
|
{MFDES_FORMAT_PICC, DACEV1, DCCNative, DCMMACed},
|
||||||
{MFDES_GET_FILE_IDS, DACEV1, DCCNative, DCMMACed},
|
{MFDES_GET_FILE_IDS, DACEV1, DCCNative, DCMMACed},
|
||||||
{MFDES_GET_ISOFILE_IDS, DACEV1, DCCNative, DCMMACed},
|
{MFDES_GET_ISOFILE_IDS, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_GET_FILE_SETTINGS, DACEV1, DCCNative, DCMMACed},
|
||||||
|
|
||||||
{MFDES_GET_UID, DACEV1, DCCNative, DCMEncrypted},
|
{MFDES_GET_UID, DACEV1, DCCNative, DCMEncrypted},
|
||||||
{MFDES_CHANGE_KEY_SETTINGS, DACEV1, DCCNative, DCMEncrypted},
|
{MFDES_CHANGE_KEY_SETTINGS, DACEV1, DCCNative, DCMEncrypted},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue