mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
lsapp: get key settins for all app
This commit is contained in:
parent
784ebe2e3d
commit
a2eca79ed9
5 changed files with 89 additions and 47 deletions
|
@ -6266,6 +6266,20 @@ static int CmdHF14ADesLsApp(const char *Cmd) {
|
||||||
numkeys0 = buf[1];
|
numkeys0 = buf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (appcount > 0) {
|
||||||
|
for (int i = 0; i < appcount; i++) {
|
||||||
|
DesfireGetKeySettings(&dctx, buf, &buflen);
|
||||||
|
if (res == PM3_SUCCESS && buflen >= 2) {
|
||||||
|
AppList[i].keySettings = buf[0];
|
||||||
|
AppList[i].numKeysRaw = buf[1];
|
||||||
|
AppList[i].numberOfKeys = AppList[i].numKeysRaw & 0x1f;
|
||||||
|
AppList[i].isoFileIDEnabled = ((AppList[i].numKeysRaw & 0x20) != 0);
|
||||||
|
AppList[i].keyType = DesfireKeyTypeToAlgo(AppList[i].numKeysRaw >> 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// field on-off zone
|
||||||
AuthCommandsChk authCmdCheck0 = {0};
|
AuthCommandsChk authCmdCheck0 = {0};
|
||||||
DesfireCheckAuthCommands(0x000000, NULL, 0, &authCmdCheck0);
|
DesfireCheckAuthCommands(0x000000, NULL, 0, &authCmdCheck0);
|
||||||
|
|
||||||
|
@ -6275,21 +6289,26 @@ static int CmdHF14ADesLsApp(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "------------------- " _CYAN_("PICC level") " ------------------");
|
// print zone
|
||||||
PrintAndLogEx(INFO, "Applications count: " _GREEN_("%zu") " free memory " _GREEN_("%d"), appcount, freemem);
|
PrintAndLogEx(SUCCESS, "------------------- " _CYAN_("PICC level") " ------------------");
|
||||||
PrintAndLogEx(INFO, "PICC level auth commands: " NOLF);
|
PrintAndLogEx(SUCCESS, "Applications count: " _GREEN_("%zu") " free memory " _GREEN_("%d"), appcount, freemem);
|
||||||
|
PrintAndLogEx(SUCCESS, "PICC level auth commands: " NOLF);
|
||||||
DesfireCheckAuthCommandsPrint(&authCmdCheck0);
|
DesfireCheckAuthCommandsPrint(&authCmdCheck0);
|
||||||
if (numkeys0 > 0)
|
if (numkeys0 > 0)
|
||||||
PrintKeySettings(keysettings0, numkeys0, false, true);
|
PrintKeySettings(keysettings0, numkeys0, false, true);
|
||||||
|
|
||||||
if (appcount > 0) {
|
if (appcount > 0) {
|
||||||
PrintAndLogEx(INFO, "-------------- " _CYAN_("Alications list") " --------------");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
|
PrintAndLogEx(SUCCESS, "-------------- " _CYAN_("Alications list") " --------------");
|
||||||
|
|
||||||
for (int i = 0; i < appcount; i++) {
|
for (int i = 0; i < appcount; i++) {
|
||||||
PrintAndLogEx(INFO, "App num: 0x%02x iso id: 0x%04x name: %s", AppList[i].appNum, AppList[i].appISONum, AppList[i].appDFName);
|
PrintAndLogEx(SUCCESS, _CYAN_("Application number: 0x%02x") " iso id: " _GREEN_("0x%04x") " name: " _GREEN_("%s"), AppList[i].appNum, AppList[i].appISONum, AppList[i].appDFName);
|
||||||
PrintAndLogEx(INFO, "Auth commands: " NOLF);
|
PrintAndLogEx(SUCCESS, "Auth commands: " NOLF);
|
||||||
DesfireCheckAuthCommandsPrint(&AppList[i].authCmdCheck);
|
DesfireCheckAuthCommandsPrint(&AppList[i].authCmdCheck);
|
||||||
PrintAndLogEx(INFO, "");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
|
if (AppList[i].numberOfKeys > 0) {
|
||||||
|
PrintKeySettings(AppList[i].keySettings, AppList[i].numKeysRaw, true, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1702,42 +1702,12 @@ int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uin
|
||||||
return DesfireCommandTxData(dctx, MFDES_UPDATE_RECORD, xdata, 10 + len);
|
return DesfireCommandTxData(dctx, MFDES_UPDATE_RECORD, xdata, 10 + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
|
||||||
switch (keyType) {
|
|
||||||
case T_DES:
|
|
||||||
return 0x00;
|
|
||||||
case T_3DES:
|
|
||||||
return 0x00;
|
|
||||||
case T_3K3DES:
|
|
||||||
return 0x01;
|
|
||||||
case T_AES:
|
|
||||||
return 0x02;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static void PrintKeyType(uint8_t keytype) {
|
|
||||||
switch (keytype) {
|
|
||||||
case 00:
|
|
||||||
PrintAndLogEx(SUCCESS, "Key: 2TDEA");
|
|
||||||
break;
|
|
||||||
case 01:
|
|
||||||
PrintAndLogEx(SUCCESS, "Key: 3TDEA");
|
|
||||||
break;
|
|
||||||
case 02:
|
|
||||||
PrintAndLogEx(SUCCESS, "Key: AES");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
PrintAndLogEx(SUCCESS, "Key: unknown: 0x%02x", keytype);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrintKeySettingsPICC(uint8_t keysettings, uint8_t numkeys, bool print2ndbyte) {
|
static void PrintKeySettingsPICC(uint8_t keysettings, uint8_t numkeys, bool print2ndbyte) {
|
||||||
PrintAndLogEx(SUCCESS, "PICC level rights:");
|
PrintAndLogEx(SUCCESS, "PICC level rights:");
|
||||||
PrintAndLogEx(SUCCESS, "[%c...] CMK Configuration changeable : %s", (keysettings & (1 << 3)) ? '1' : '0', (keysettings & (1 << 3)) ? _GREEN_("YES") : "NO (frozen)");
|
PrintAndLogEx(SUCCESS, "[%c...] CMK Configuration changeable : %s", (keysettings & (1 << 3)) ? '1' : '0', (keysettings & (1 << 3)) ? _GREEN_("YES") : _RED_("NO (frozen)"));
|
||||||
PrintAndLogEx(SUCCESS, "[.%c..] CMK required for create/delete : %s", (keysettings & (1 << 2)) ? '1' : '0', (keysettings & (1 << 2)) ? _GREEN_("NO") : "YES");
|
PrintAndLogEx(SUCCESS, "[.%c..] CMK required for create/delete : %s", (keysettings & (1 << 2)) ? '1' : '0', (keysettings & (1 << 2)) ? _GREEN_("NO") : "YES");
|
||||||
PrintAndLogEx(SUCCESS, "[..%c.] Directory list access with CMK : %s", (keysettings & (1 << 1)) ? '1' : '0', (keysettings & (1 << 1)) ? _GREEN_("NO") : "YES");
|
PrintAndLogEx(SUCCESS, "[..%c.] Directory list access with CMK : %s", (keysettings & (1 << 1)) ? '1' : '0', (keysettings & (1 << 1)) ? _GREEN_("NO") : "YES");
|
||||||
PrintAndLogEx(SUCCESS, "[...%c] CMK is changeable : %s", (keysettings & (1 << 0)) ? '1' : '0', (keysettings & (1 << 0)) ? _GREEN_("YES") : "NO (frozen)");
|
PrintAndLogEx(SUCCESS, "[...%c] CMK is changeable : %s", (keysettings & (1 << 0)) ? '1' : '0', (keysettings & (1 << 0)) ? _GREEN_("YES") : _RED_("NO (frozen)"));
|
||||||
PrintAndLogEx(SUCCESS, "");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
|
|
||||||
if (print2ndbyte)
|
if (print2ndbyte)
|
||||||
|
@ -1768,14 +1738,14 @@ static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "[%c...] AMK Configuration changeable : %s", (keysettings & (1 << 3)) ? '1' : '0', (keysettings & (1 << 3)) ? _GREEN_("YES") : "NO (frozen)");
|
PrintAndLogEx(SUCCESS, "[%c...] AMK Configuration changeable : %s", (keysettings & (1 << 3)) ? '1' : '0', (keysettings & (1 << 3)) ? _GREEN_("YES") : _RED_("NO (frozen)"));
|
||||||
PrintAndLogEx(SUCCESS, "[.%c..] AMK required for create/delete : %s", (keysettings & (1 << 2)) ? '1' : '0', (keysettings & (1 << 2)) ? "NO" : "YES");
|
PrintAndLogEx(SUCCESS, "[.%c..] AMK required for create/delete : %s", (keysettings & (1 << 2)) ? '1' : '0', (keysettings & (1 << 2)) ? _GREEN_("NO") : "YES");
|
||||||
PrintAndLogEx(SUCCESS, "[..%c.] Directory list access with AMK : %s", (keysettings & (1 << 1)) ? '1' : '0', (keysettings & (1 << 1)) ? "NO" : "YES");
|
PrintAndLogEx(SUCCESS, "[..%c.] Directory list access with AMK : %s", (keysettings & (1 << 1)) ? '1' : '0', (keysettings & (1 << 1)) ? _GREEN_("NO") : "YES");
|
||||||
PrintAndLogEx(SUCCESS, "[...%c] AMK is changeable : %s", (keysettings & (1 << 0)) ? '1' : '0', (keysettings & (1 << 0)) ? _GREEN_("YES") : "NO (frozen)");
|
PrintAndLogEx(SUCCESS, "[...%c] AMK is changeable : %s", (keysettings & (1 << 0)) ? '1' : '0', (keysettings & (1 << 0)) ? _GREEN_("YES") : _RED_("NO (frozen)"));
|
||||||
PrintAndLogEx(SUCCESS, "");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
|
|
||||||
if (print2ndbyte) {
|
if (print2ndbyte) {
|
||||||
PrintKeyType(numkeys >> 6);
|
DesfirePrintCardKeyType(numkeys >> 6);
|
||||||
PrintAndLogEx(SUCCESS, "key count: %d", numkeys & 0x0f);
|
PrintAndLogEx(SUCCESS, "key count: %d", numkeys & 0x0f);
|
||||||
if (numkeys & 0x20)
|
if (numkeys & 0x20)
|
||||||
PrintAndLogEx(SUCCESS, "iso file id: enabled");
|
PrintAndLogEx(SUCCESS, "iso file id: enabled");
|
||||||
|
|
|
@ -98,6 +98,12 @@ typedef struct {
|
||||||
uint16_t appISONum;
|
uint16_t appISONum;
|
||||||
char appDFName[16];
|
char appDFName[16];
|
||||||
AuthCommandsChk authCmdCheck;
|
AuthCommandsChk authCmdCheck;
|
||||||
|
|
||||||
|
uint8_t keySettings;
|
||||||
|
uint8_t numKeysRaw;
|
||||||
|
bool isoFileIDEnabled; // from numKeysRaw
|
||||||
|
uint8_t numberOfKeys; // from numKeysRaw
|
||||||
|
DesfireCryptoAlgorythm keyType; // from numKeysRaw
|
||||||
} AppListElmS;
|
} AppListElmS;
|
||||||
typedef AppListElmS AppListS[64];
|
typedef AppListElmS AppListS[64];
|
||||||
|
|
||||||
|
@ -151,7 +157,6 @@ int DesfireGetKeyVersion(DesfireContext *dctx, uint8_t *data, size_t len, uint8_
|
||||||
int DesfireGetKeySettings(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
int DesfireGetKeySettings(DesfireContext *dctx, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len);
|
int DesfireChangeKeySettings(DesfireContext *dctx, uint8_t *data, size_t len);
|
||||||
void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool print2ndbyte);
|
void PrintKeySettings(uint8_t keysettings, uint8_t numkeys, bool applevel, bool print2ndbyte);
|
||||||
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType);
|
|
||||||
|
|
||||||
int DesfireChangeKeyCmd(DesfireContext *dctx, uint8_t *data, size_t datalen, uint8_t *resp, size_t *resplen);
|
int DesfireChangeKeyCmd(DesfireContext *dctx, uint8_t *data, size_t datalen, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose);
|
int DesfireChangeKey(DesfireContext *dctx, bool change_master_key, uint8_t newkeynum, DesfireCryptoAlgorythm newkeytype, uint32_t newkeyver, uint8_t *newkey, DesfireCryptoAlgorythm oldkeytype, uint8_t *oldkey, bool verbose);
|
||||||
|
|
|
@ -353,6 +353,50 @@ uint8_t DesfireDESKeyGetVersion(uint8_t *key) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesfireCryptoAlgorythm DesfireKeyTypeToAlgo(uint8_t keyType) {
|
||||||
|
switch (keyType) {
|
||||||
|
case 00:
|
||||||
|
return T_3DES;
|
||||||
|
case 01:
|
||||||
|
return T_3K3DES;
|
||||||
|
case 02:
|
||||||
|
return T_AES;
|
||||||
|
default:
|
||||||
|
return T_3DES; // unknown....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
||||||
|
switch (keyType) {
|
||||||
|
case T_DES:
|
||||||
|
return 0x00;
|
||||||
|
case T_3DES:
|
||||||
|
return 0x00;
|
||||||
|
case T_3K3DES:
|
||||||
|
return 0x01;
|
||||||
|
case T_AES:
|
||||||
|
return 0x02;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesfirePrintCardKeyType(uint8_t keyType) {
|
||||||
|
switch (keyType) {
|
||||||
|
case 00:
|
||||||
|
PrintAndLogEx(SUCCESS, "Key: 2TDEA");
|
||||||
|
break;
|
||||||
|
case 01:
|
||||||
|
PrintAndLogEx(SUCCESS, "Key: 3TDEA");
|
||||||
|
break;
|
||||||
|
case 02:
|
||||||
|
PrintAndLogEx(SUCCESS, "Key: AES");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PrintAndLogEx(SUCCESS, "Key: unknown: 0x%02x", keyType);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode) {
|
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode) {
|
||||||
DesfireCommunicationMode mode = DCMNone;
|
DesfireCommunicationMode mode = DCMNone;
|
||||||
switch (file_comm_mode & 0x03) {
|
switch (file_comm_mode & 0x03) {
|
||||||
|
|
|
@ -107,6 +107,10 @@ void DesfireCryptoCMAC(DesfireContext *ctx, uint8_t *srcdata, size_t srcdatalen,
|
||||||
void DesfireDESKeySetVersion(uint8_t *key, DesfireCryptoAlgorythm keytype, uint8_t version);
|
void DesfireDESKeySetVersion(uint8_t *key, DesfireCryptoAlgorythm keytype, uint8_t version);
|
||||||
uint8_t DesfireDESKeyGetVersion(uint8_t *key);
|
uint8_t DesfireDESKeyGetVersion(uint8_t *key);
|
||||||
|
|
||||||
|
DesfireCryptoAlgorythm DesfireKeyTypeToAlgo(uint8_t keyType);
|
||||||
|
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType);
|
||||||
|
void DesfirePrintCardKeyType(uint8_t keyType);
|
||||||
|
|
||||||
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode);
|
DesfireCommunicationMode DesfireFileCommModeToCommMode(uint8_t file_comm_mode);
|
||||||
uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode);
|
uint8_t DesfireCommModeToFileCommMode(DesfireCommunicationMode comm_mode);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue