Fixed: "hf mfdes info"
This commit is contained in:
@@ -134,17 +134,18 @@ int CmdHF14ADesRb(const char *Cmd)
|
||||
|
||||
int CmdHF14ADesInfo(const char *Cmd){
|
||||
|
||||
UsbCommand c = {CMD_MIFARE_DESFIRE_INFO, { 0x00 }};
|
||||
|
||||
UsbCommand c = {CMD_MIFARE_DESFIRE_INFO};
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
PrintAndLog("isOk:%02x", isOK);
|
||||
} else {
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500) ) {
|
||||
PrintAndLog("Command execute timeout");
|
||||
return 0;
|
||||
}
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
if ( !isOK ){
|
||||
PrintAndLog("Command unsuccessfull");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("---Desfire Information---------------------------------------");
|
||||
@@ -170,34 +171,59 @@ int CmdHF14ADesInfo(const char *Cmd){
|
||||
PrintAndLog(" Protocol : %s", GetProtocolStr(resp.d.asBytes[20]));
|
||||
PrintAndLog("-------------------------------------------------------------");
|
||||
|
||||
|
||||
UsbCommand c1 = {CMD_MIFARE_DESFIRE, { 0x01, 0x01 }};
|
||||
c1.d.asBytes[0] = GET_KEY_SETTINGS;
|
||||
SendCommand(&c1);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog(" Master Key settings");
|
||||
if ( resp.d.asBytes[35] & (1 << 3 ) )
|
||||
if ( resp.d.asBytes[3] & (1 << 3 ) )
|
||||
PrintAndLog(" 0x08 Configuration changeable;");
|
||||
else
|
||||
PrintAndLog(" 0x08 Configuration NOT changeable;");
|
||||
|
||||
if ( resp.d.asBytes[35] & (1 << 2 ) )
|
||||
if ( resp.d.asBytes[3] & (1 << 2 ) )
|
||||
PrintAndLog(" 0x04 PICC Master Key not required for create / delete;");
|
||||
else
|
||||
PrintAndLog(" 0x04 PICC Master Key required for create / delete;");
|
||||
|
||||
if ( resp.d.asBytes[35] & (1 << 1 ) )
|
||||
if ( resp.d.asBytes[3] & (1 << 1 ) )
|
||||
PrintAndLog(" 0x02 Free directory list access without PICC Master Key;");
|
||||
else
|
||||
PrintAndLog(" 0x02 Directory list access with PICC Master Key;");
|
||||
|
||||
if ( resp.d.asBytes[35] & (1 << 0 ) )
|
||||
if ( resp.d.asBytes[3] & (1 << 0 ) )
|
||||
PrintAndLog(" 0x01 Allow changing the Master Key;");
|
||||
else
|
||||
PrintAndLog(" 0x01 Master Key is not changeable anymore;");
|
||||
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" Max number of keys : %d", resp.d.asBytes[36]);
|
||||
PrintAndLog(" Master key Version : %d (0x%02x)", resp.d.asBytes[37], resp.d.asBytes[37]);
|
||||
// init len
|
||||
UsbCommand c2 = {CMD_MIFARE_DESFIRE, { 0x01, 0x02 }};
|
||||
c2.d.asBytes[0] = GET_KEY_VERSION;
|
||||
c2.d.asBytes[1] = 0x00;
|
||||
SendCommand(&c2);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("");
|
||||
PrintAndLog(" Max number of keys : %d", resp.d.asBytes[2]);
|
||||
PrintAndLog(" Master key Version : %d (0x%02x)", resp.d.asBytes[3], resp.d.asBytes[3]);
|
||||
PrintAndLog("-------------------------------------------------------------");
|
||||
|
||||
|
||||
UsbCommand c3 = {CMD_MIFARE_DESFIRE, { 0x01, 0x01 }};
|
||||
c3.d.asBytes[0] = GET_FREE_MEMORY;
|
||||
SendCommand(&c3);
|
||||
if ( !WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t tmp[3];
|
||||
memcpy(tmp, resp.d.asBytes+38,3);
|
||||
memcpy(tmp, resp.d.asBytes+3,3);
|
||||
|
||||
PrintAndLog(" Free memory on card : %d bytes", le24toh( tmp ));
|
||||
PrintAndLog("-------------------------------------------------------------");
|
||||
@@ -226,7 +252,6 @@ int CmdHF14ADesInfo(const char *Cmd){
|
||||
AES 16 : RndA(byte0-byte3) + RndB(byte0-byte3) + RndA(byte12-byte15) + RndB(byte12-byte15)
|
||||
*/
|
||||
|
||||
PrintAndLog(" RX :%s",sprint_hex(resp.d.asBytes, 40));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -434,3 +459,5 @@ int CmdHelp(const char *Cmd)
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,3 +18,41 @@ int CmdHF14ADesNonces(const char *Cmd);
|
||||
char * GetCardSizeStr( uint8_t fsize );
|
||||
char * GetVendorStr( uint8_t id);
|
||||
char * GetProtocolStr(uint8_t id);
|
||||
|
||||
|
||||
|
||||
#define CREATE_APPLICATION 0xca
|
||||
#define DELETE_APPLICATION 0xda
|
||||
#define GET_APPLICATION_IDS 0x6a
|
||||
#define SELECT_APPLICATION 0x5a
|
||||
#define FORMAT_PICC 0xfc
|
||||
#define GET_VERSION 0x60
|
||||
#define READ_DATA 0xbd
|
||||
#define WRITE_DATA 0x3d
|
||||
#define GET_VALUE 0x6c
|
||||
#define CREDIT 0x0c
|
||||
#define DEBIT 0xdc
|
||||
#define LIMITED_CREDIT 0x1c
|
||||
#define WRITE_RECORD 0x3b
|
||||
#define READ_RECORDS 0xbb
|
||||
#define CLEAR_RECORD_FILE 0xeb
|
||||
#define COMMIT_TRANSACTION 0xc7
|
||||
#define ABORT_TRANSACTION 0xa7
|
||||
#define GET_FREE_MEMORY 0x6e
|
||||
#define GET_FILE_IDS 0x6f
|
||||
#define GET_FILE_SETTINGS 0xf5
|
||||
#define CHANGE_FILE_SETTINGS 0x5f
|
||||
#define CREATE_STD_DATA_FILE 0xcd
|
||||
#define CREATE_BACKUP_DATA_FILE 0xcb
|
||||
#define CREATE_VALUE_FILE 0xcc
|
||||
#define CREATE_LINEAR_RECORD_FILE 0xc1
|
||||
#define CREATE_CYCLIC_RECORD_FILE 0xc0
|
||||
#define DELETE_FILE 0xdf
|
||||
#define AUTHENTICATE 0x0a // AUTHENTICATE_NATIVE
|
||||
#define AUTHENTICATE_ISO 0x1a // AUTHENTICATE_STANDARD
|
||||
#define AUTHENTICATE_AES 0xaa
|
||||
#define CHANGE_KEY_SETTINGS 0x54
|
||||
#define GET_KEY_SETTINGS 0x45
|
||||
#define CHANGE_KEY 0xc4
|
||||
#define GET_KEY_VERSION 0x64
|
||||
#define AUTHENTICATION_FRAME 0xAF
|
||||
@@ -11,8 +11,8 @@
|
||||
* @return
|
||||
*/
|
||||
int fileExists(const char *filename) {
|
||||
struct _stat st;
|
||||
int result = stat(filename, &st);
|
||||
struct _stat fileStat;
|
||||
int result = _stat(filename, &fileStat);
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user