mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
Add Mifare Desfire GetDFNames and improve HF MFDES Enum output
This commit is contained in:
parent
82fad10e16
commit
3833b8ee3b
5 changed files with 61 additions and 9 deletions
|
@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Add Mifare Desfire GetDFNames and improve HF MFDES Enum output (@bkerler)
|
||||||
|
- Fix Mifare Desfire select appid handling (@bkerler)
|
||||||
- Improved `hf 14a info` - card detection handling (@bkerler)
|
- Improved `hf 14a info` - card detection handling (@bkerler)
|
||||||
- Updated helptext layout in all luascripts (@iceman1001)
|
- Updated helptext layout in all luascripts (@iceman1001)
|
||||||
- Change `hf mfdes info` - output and logging (@bkerler)
|
- Change `hf mfdes info` - output and logging (@bkerler)
|
||||||
|
|
|
@ -150,6 +150,7 @@ enum DESFIRE_CMD {
|
||||||
GET_FREE_MEMORY = 0x6e,
|
GET_FREE_MEMORY = 0x6e,
|
||||||
GET_FILE_IDS = 0x6f,
|
GET_FILE_IDS = 0x6f,
|
||||||
GET_FILE_SETTINGS = 0xf5,
|
GET_FILE_SETTINGS = 0xf5,
|
||||||
|
GET_DF_NAMES = 0x6d,
|
||||||
CHANGE_FILE_SETTINGS = 0x5f,
|
CHANGE_FILE_SETTINGS = 0x5f,
|
||||||
CREATE_STD_DATA_FILE = 0xcd,
|
CREATE_STD_DATA_FILE = 0xcd,
|
||||||
CREATE_BACKUP_DATA_FILE = 0xcb,
|
CREATE_BACKUP_DATA_FILE = 0xcb,
|
||||||
|
|
|
@ -768,6 +768,9 @@ void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||||
case MFDES_GET_FILE_IDS:
|
case MFDES_GET_FILE_IDS:
|
||||||
snprintf(exp, size, "GET FILE IDS");
|
snprintf(exp, size, "GET FILE IDS");
|
||||||
break;
|
break;
|
||||||
|
case MFDES_GET_DF_NAMES:
|
||||||
|
snprintf(exp, size, "GET DF NAMES");
|
||||||
|
break;
|
||||||
case MFDES_GET_ISOFILE_IDS:
|
case MFDES_GET_ISOFILE_IDS:
|
||||||
snprintf(exp, size, "GET ISOFILE IDS");
|
snprintf(exp, size, "GET ISOFILE IDS");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -345,6 +345,32 @@ static int get_desfire_appids(uint8_t *dest, uint8_t *app_ids_len) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t aid[3];
|
||||||
|
uint8_t fid[2];
|
||||||
|
uint8_t name[16];
|
||||||
|
} dfname_t;
|
||||||
|
|
||||||
|
static int get_desfire_dfnames(dfname_t *dest, uint8_t* dfname_count) {
|
||||||
|
if (dest == NULL) return PM3_ESOFT;
|
||||||
|
uint8_t c[] = {MFDES_GET_DF_NAMES, 0x00, 0x00, 0x00}; //0x6d
|
||||||
|
PacketResponseNG resp;
|
||||||
|
int ret = SendDesfireCmd(c, sizeof(c), INIT, sizeof(c), 0, &resp, 3000);
|
||||||
|
if (ret != PM3_SUCCESS) return ret;
|
||||||
|
|
||||||
|
uint8_t count=0;
|
||||||
|
memcpy(&dest[count], resp.data.asBytes+1, resp.length - 5);
|
||||||
|
if (resp.data.asBytes[resp.length - 3] == MFDES_ADDITIONAL_FRAME) {
|
||||||
|
c[0] = MFDES_ADDITIONAL_FRAME; //0xAF
|
||||||
|
ret = SendDesfireCmd(c, sizeof(c), NONE, sizeof(c), 0, &resp, 3000);
|
||||||
|
if (ret != PM3_SUCCESS) return ret;
|
||||||
|
count++;
|
||||||
|
memcpy(&dest[count], resp.data.asBytes+1, resp.length - 5);
|
||||||
|
}
|
||||||
|
*dfname_count=count-1;
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// none
|
// none
|
||||||
static int get_desfire_fileids(uint8_t *dest, uint8_t *file_ids_len) {
|
static int get_desfire_fileids(uint8_t *dest, uint8_t *file_ids_len) {
|
||||||
|
@ -562,9 +588,7 @@ void getKeySettings(uint8_t *aid) {
|
||||||
if (memcmp(aid, "\x00\x00\x00", 3) == 0) {
|
if (memcmp(aid, "\x00\x00\x00", 3) == 0) {
|
||||||
|
|
||||||
// CARD MASTER KEY
|
// CARD MASTER KEY
|
||||||
PrintAndLogEx(NORMAL, "");
|
//PrintAndLogEx(INFO, "--- " _CYAN_("CMK - PICC, Card Master Key settings"));
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("CMK - PICC, Card Master Key settings"));
|
|
||||||
|
|
||||||
if (get_desfire_select_application(aid) != PM3_SUCCESS) {
|
if (get_desfire_select_application(aid) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, _RED_(" Can't select AID"));
|
PrintAndLogEx(WARNING, _RED_(" Can't select AID"));
|
||||||
DropField();
|
DropField();
|
||||||
|
@ -627,9 +651,7 @@ void getKeySettings(uint8_t *aid) {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// AID - APPLICATION MASTER KEYS
|
// AID - APPLICATION MASTER KEYS
|
||||||
PrintAndLogEx(NORMAL, "");
|
//PrintAndLogEx(SUCCESS, "--- " _CYAN_("AMK - Application Master Key settings"));
|
||||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("AMK - Application Master Key settings"));
|
|
||||||
|
|
||||||
if (get_desfire_select_application(aid) != PM3_SUCCESS) {
|
if (get_desfire_select_application(aid) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, _RED_(" Can't select AID"));
|
PrintAndLogEx(WARNING, _RED_(" Can't select AID"));
|
||||||
DropField();
|
DropField();
|
||||||
|
@ -682,11 +704,21 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
|
||||||
uint8_t file_ids[33] = {0};
|
uint8_t file_ids[33] = {0};
|
||||||
uint8_t file_ids_len = 0;
|
uint8_t file_ids_len = 0;
|
||||||
|
|
||||||
|
dfname_t dfnames[255] = {0};
|
||||||
|
uint8_t dfname_count=0;
|
||||||
|
|
||||||
if (get_desfire_appids(app_ids, &app_ids_len) != PM3_SUCCESS) {
|
if (get_desfire_appids(app_ids, &app_ids_len) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Can't get list of applications on tag");
|
PrintAndLogEx(ERR, "Can't get list of applications on tag");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_desfire_dfnames(dfnames,&dfname_count)!=PM3_SUCCESS)
|
||||||
|
{
|
||||||
|
PrintAndLogEx(WARNING, _RED_("Can't get DF Names"));
|
||||||
|
DropField();
|
||||||
|
return PM3_ESOFT;
|
||||||
|
}
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "-- Mifare DESFire Enumerate applications --------------------");
|
PrintAndLogEx(INFO, "-- Mifare DESFire Enumerate applications --------------------");
|
||||||
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
PrintAndLogEx(INFO, "-------------------------------------------------------------");
|
||||||
|
@ -698,7 +730,21 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
|
||||||
aid[1] = app_ids[i + 1];
|
aid[1] = app_ids[i + 1];
|
||||||
aid[2] = app_ids[i + 2];
|
aid[2] = app_ids[i + 2];
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, " AID %d : " _GREEN_("%02X %02X %02X"), i, app_ids[i], app_ids[i + 1], app_ids[i + 2]);
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
|
if (memcmp(aid, "\x00\x00\x00", 3) == 0) {
|
||||||
|
// CARD MASTER KEY
|
||||||
|
PrintAndLogEx(INFO, "--- " _CYAN_("CMK - PICC, Card Master Key settings"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PrintAndLogEx(SUCCESS, "--- " _CYAN_("AMK - Application Master Key settings"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i<dfname_count) {
|
||||||
|
PrintAndLogEx(SUCCESS, " AID : " _GREEN_("%02X %02X %02X"), aid[0], aid[1], aid[2]);
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(SUCCESS, " AID : " _GREEN_("%02X %02X %02X") " - Name : " _YELLOW_("%s"), aid[0], aid[1], aid[2], dfnames[i/3].name);
|
||||||
|
}
|
||||||
|
|
||||||
getKeySettings(aid);
|
getKeySettings(aid);
|
||||||
|
|
||||||
|
@ -709,7 +755,6 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get File IDs
|
// Get File IDs
|
||||||
if (get_desfire_fileids(file_ids, &file_ids_len) == PM3_SUCCESS) {
|
if (get_desfire_fileids(file_ids, &file_ids_len) == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(SUCCESS, " Tag report " _GREEN_("%d") "file%c", file_ids_len, (file_ids_len == 1) ? ' ' : 's');
|
PrintAndLogEx(SUCCESS, " Tag report " _GREEN_("%d") "file%c", file_ids_len, (file_ids_len == 1) ? ' ' : 's');
|
||||||
|
|
|
@ -387,6 +387,7 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
||||||
#define MFDES_AUTHENTICATION_FRAME 0xAF
|
#define MFDES_AUTHENTICATION_FRAME 0xAF
|
||||||
#define MFDES_ADDITIONAL_FRAME 0xAF
|
#define MFDES_ADDITIONAL_FRAME 0xAF
|
||||||
#define MFDES_READSIG 0x3C
|
#define MFDES_READSIG 0x3C
|
||||||
|
#define MFDES_GET_DF_NAMES 0x6D
|
||||||
|
|
||||||
// LEGIC Commands
|
// LEGIC Commands
|
||||||
#define LEGIC_MIM_22 0x0D
|
#define LEGIC_MIM_22 0x0D
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue