mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
add create file to channel tables, remove debug
This commit is contained in:
parent
64b3dcc2e2
commit
997234e18d
3 changed files with 59 additions and 169 deletions
|
@ -6421,127 +6421,6 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) {
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* CLIParserContext *ctx;
|
|
||||||
CLIParserInit(&ctx, "hf mfdes createvaluefile",
|
|
||||||
"Create Value File\n"
|
|
||||||
"Make sure to select aid or authenticate aid before running this command.",
|
|
||||||
"hf mfdes createvaluefile -n 03 -c 0 -r EEEE -l 00000000 -u 00002000 --val 00000001 -m 02 -a 123456\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
void *argtable[] = {
|
|
||||||
arg_param_begin,
|
|
||||||
arg_int0("n", "fileno", "<dec>", "File Number (0 - 31)"),
|
|
||||||
arg_int0("c", "com", "<dec>", "Communication setting (0 = Plain, 1 = Plain + MAC, 3 = Enciphered)"),
|
|
||||||
arg_strx0("r", "rights", "<hex>", "Access rights (2 hex bytes -> RW/Chg/R/W, 0x0 - 0xD Key, 0xE Free, 0xF Denied)"),
|
|
||||||
arg_strx0("l", "lower", "<hex>", "Lower limit (4 hex bytes, big endian)"),
|
|
||||||
arg_strx0("u", "upper", "<hex>", "Upper limit (4 hex bytes, big endian)"),
|
|
||||||
arg_strx0(NULL, "val", "<hex>", "Value (4 hex bytes, big endian)"),
|
|
||||||
arg_int0("m", NULL, "<dec>", "Limited Credit enabled (Bit 0 = Limited Credit, 1 = FreeValue)"),
|
|
||||||
arg_strx0("a", "aid", "<hex>", "App ID to select as hex bytes (3 bytes,big endian,optional)"),
|
|
||||||
arg_param_end
|
|
||||||
};
|
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
|
||||||
int fno = arg_get_int_def(ctx, 1, 0);
|
|
||||||
uint8_t comset = arg_get_int(ctx, 2);
|
|
||||||
|
|
||||||
int arlength = 0;
|
|
||||||
uint8_t ar[2] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 3, ar, &arlength);
|
|
||||||
|
|
||||||
int lllen = 0;
|
|
||||||
uint8_t lowerlimit[4] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 4, lowerlimit, &lllen);
|
|
||||||
|
|
||||||
int ullen = 0;
|
|
||||||
uint8_t upperlimit[4] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 5, upperlimit, &ullen);
|
|
||||||
|
|
||||||
int vllen = 0;
|
|
||||||
uint8_t value[4] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 6, value, &vllen);
|
|
||||||
|
|
||||||
uint8_t limited = arg_get_int_def(ctx, 7, 0);
|
|
||||||
|
|
||||||
int aidlength = 3;
|
|
||||||
uint8_t aid[3] = {0};
|
|
||||||
CLIGetHexWithReturn(ctx, 8, aid, &aidlength);
|
|
||||||
swap24(aid);
|
|
||||||
CLIParserFree(ctx);
|
|
||||||
|
|
||||||
swap32(lowerlimit);
|
|
||||||
swap32(upperlimit);
|
|
||||||
swap32(value);
|
|
||||||
|
|
||||||
if (fno > 0x1F) {
|
|
||||||
PrintAndLogEx(ERR, "File number range is invalid (exp 0 - 31), got %d", fno);
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comset != 0 && comset != 1 && comset != 3) {
|
|
||||||
PrintAndLogEx(ERR, "Communication setting must be either 0=Plain, 1=Plain+MAC or 3=Encrypt");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arlength != 2) {
|
|
||||||
PrintAndLogEx(ERR, "Access rights must have 2 hex bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lllen != 4) {
|
|
||||||
PrintAndLogEx(ERR, "Lower limit must have 4 hex bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ullen != 4) {
|
|
||||||
PrintAndLogEx(ERR, "Upper limit must have 4 hex bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vllen != 4) {
|
|
||||||
PrintAndLogEx(ERR, "Value must have 4 hex bytes length");
|
|
||||||
return PM3_EINVARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
mfdes_value_file_t ft = {
|
|
||||||
.fileno = fno,
|
|
||||||
.comset = comset,
|
|
||||||
.limitedcreditenabled = limited,
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(ft.access_rights, ar, 2);
|
|
||||||
memcpy(ft.lowerlimit, lowerlimit, 4);
|
|
||||||
memcpy(ft.upperlimit, upperlimit, 4);
|
|
||||||
memcpy(ft.value, value, 4);
|
|
||||||
|
|
||||||
if (aidlength != 3 && aidlength != 0) {
|
|
||||||
PrintAndLogEx(ERR, _RED_(" The given aid must have 3 bytes (big endian)."));
|
|
||||||
return PM3_ESOFT;
|
|
||||||
} else if (aidlength == 0) {
|
|
||||||
if (memcmp(&tag->selected_application, aid, 3) == 0) {
|
|
||||||
PrintAndLogEx(ERR, _RED_(" You need to select an aid first."));
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
memcpy(aid, (uint8_t *)&tag->selected_application, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handler_desfire_select_application(aid) != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(ERR, _RED_(" Error on selecting aid."));
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
|
|
||||||
int res = handler_desfire_create_value_file(&ft);
|
|
||||||
if (res == PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(SUCCESS, "Successfully created value file.");
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(ERR, "Couldn't create value file. Error %d", res);
|
|
||||||
}
|
|
||||||
DropFieldDesfire();
|
|
||||||
return res;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdHF14ADesDeleteFile(const char *Cmd) {
|
static int CmdHF14ADesDeleteFile(const char *Cmd) {
|
||||||
|
|
|
@ -1392,7 +1392,6 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len)
|
||||||
|
|
||||||
bool isoidpresent = ftyperec->mayHaveISOfid && (len == ftyperec->createlen + 2 + 1);
|
bool isoidpresent = ftyperec->mayHaveISOfid && (len == ftyperec->createlen + 2 + 1);
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "---: %d", ftyperec->createlen);
|
|
||||||
PrintAndLogEx(INFO, "---- " _CYAN_("Create file settings") " ----");
|
PrintAndLogEx(INFO, "---- " _CYAN_("Create file settings") " ----");
|
||||||
PrintAndLogEx(SUCCESS, "File type : %s", ftyperec->text);
|
PrintAndLogEx(SUCCESS, "File type : %s", ftyperec->text);
|
||||||
PrintAndLogEx(SUCCESS, "File number : 0x%02x (%d)", data[0], data[0]);
|
PrintAndLogEx(SUCCESS, "File number : 0x%02x (%d)", data[0], data[0]);
|
||||||
|
|
|
@ -31,6 +31,12 @@ AllowedChannelModesS AllowedChannelModes[] = {
|
||||||
{MFDES_GET_KEY_SETTINGS, DACd40, DCCNative, DCMPlain},
|
{MFDES_GET_KEY_SETTINGS, DACd40, DCCNative, DCMPlain},
|
||||||
{MFDES_GET_KEY_VERSION, DACd40, DCCNative, DCMPlain},
|
{MFDES_GET_KEY_VERSION, DACd40, DCCNative, DCMPlain},
|
||||||
{MFDES_GET_FREE_MEMORY, DACd40, DCCNative, DCMPlain},
|
{MFDES_GET_FREE_MEMORY, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_STD_DATA_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_BACKUP_DATA_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_VALUE_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_LINEAR_RECORD_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_CYCLIC_RECORD_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
{MFDES_CREATE_TRANS_MAC_FILE, DACd40, DCCNative, DCMPlain},
|
||||||
|
|
||||||
{MFDES_READ_DATA, DACd40, DCCNative, DCMMACed},
|
{MFDES_READ_DATA, DACd40, DCCNative, DCMMACed},
|
||||||
{MFDES_WRITE_DATA, DACd40, DCCNative, DCMMACed},
|
{MFDES_WRITE_DATA, DACd40, DCCNative, DCMMACed},
|
||||||
|
@ -71,6 +77,12 @@ AllowedChannelModesS AllowedChannelModes[] = {
|
||||||
{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_FILE_SETTINGS, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_STD_DATA_FILE, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_BACKUP_DATA_FILE, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_VALUE_FILE, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_LINEAR_RECORD_FILE, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_CYCLIC_RECORD_FILE, DACEV1, DCCNative, DCMMACed},
|
||||||
|
{MFDES_CREATE_TRANS_MAC_FILE, 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