mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
text and style
This commit is contained in:
parent
2f56bdcf10
commit
f5650a53af
7 changed files with 86 additions and 66 deletions
|
@ -1344,10 +1344,7 @@ static int CmdHFiClassEView(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
printIclassDumpContents(dump, 1, blocks, bytes, dense_output);
|
printIclassDumpContents(dump, 1, blocks, bytes, dense_output);
|
||||||
|
print_iclass_sio(dump, bytes, verbose);
|
||||||
if (verbose) {
|
|
||||||
print_iclass_sio(dump, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(dump);
|
free(dump);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -1708,11 +1705,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output);
|
printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output);
|
||||||
|
print_iclass_sio(decrypted, decryptedlen, verbose);
|
||||||
if (verbose) {
|
|
||||||
print_iclass_sio(decrypted, decryptedlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
// decode block 6
|
// decode block 6
|
||||||
|
@ -3518,10 +3511,7 @@ static int CmdHFiClassView(const char *Cmd) {
|
||||||
print_picopass_info((picopass_hdr_t *) dump);
|
print_picopass_info((picopass_hdr_t *) dump);
|
||||||
printIclassDumpContents(dump, startblock, endblock, bytes_read, dense_output);
|
printIclassDumpContents(dump, startblock, endblock, bytes_read, dense_output);
|
||||||
iclass_decode_credentials(dump);
|
iclass_decode_credentials(dump);
|
||||||
|
print_iclass_sio(dump, bytes_read, verbose);
|
||||||
if (verbose) {
|
|
||||||
print_iclass_sio(dump, bytes_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(dump);
|
free(dump);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -2122,9 +2122,9 @@ static int CmdEMVScan(const char *Cmd) {
|
||||||
|
|
||||||
uint8_t psenum = (channel == CC_CONTACT) ? 1 : 2;
|
uint8_t psenum = (channel == CC_CONTACT) ? 1 : 2;
|
||||||
|
|
||||||
char filename[FILE_PATH_SIZE] = {0};
|
uint8_t filename[FILE_PATH_SIZE] = {0};
|
||||||
int fnlen = 0;
|
int filenamelen = sizeof(filename) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 12), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);
|
CLIGetStrWithReturn(ctx, 12, filename, &filenamelen);
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
|
@ -2507,7 +2507,7 @@ static int CmdEMVRoca(const char *Cmd) {
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_lit0("t", "selftest", "Self test"),
|
arg_lit0(NULL, "test", "Perform self tests"),
|
||||||
arg_lit0("a", "apdu", "Show APDU requests and responses"),
|
arg_lit0("a", "apdu", "Show APDU requests and responses"),
|
||||||
arg_lit0("w", "wired", "Send data via contact (iso7816) interface. (def: Contactless interface)"),
|
arg_lit0("w", "wired", "Send data via contact (iso7816) interface. (def: Contactless interface)"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
|
@ -2981,7 +2981,7 @@ static command_t CommandTable[] = {
|
||||||
{"-----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("General") " -----------------------"},
|
{"-----------", CmdHelp, AlwaysAvailable, "----------------------- " _CYAN_("General") " -----------------------"},
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"list", CmdEMVList, AlwaysAvailable, "List ISO7816 history"},
|
{"list", CmdEMVList, AlwaysAvailable, "List ISO7816 history"},
|
||||||
{"test", CmdEMVTest, AlwaysAvailable, "Crypto logic selftest"},
|
{"test", CmdEMVTest, AlwaysAvailable, "Perform crypto logic self tests"},
|
||||||
{"-----------", CmdHelp, IfPm3Iso14443a, "---------------------- " _CYAN_("Operations") " ---------------------"},
|
{"-----------", CmdHelp, IfPm3Iso14443a, "---------------------- " _CYAN_("Operations") " ---------------------"},
|
||||||
{"challenge", CmdEMVGenerateChallenge, IfPm3Iso14443, "Generate challenge"},
|
{"challenge", CmdEMVGenerateChallenge, IfPm3Iso14443, "Generate challenge"},
|
||||||
{"exec", CmdEMVExec, IfPm3Iso14443, "Executes EMV contactless transaction"},
|
{"exec", CmdEMVExec, IfPm3Iso14443, "Executes EMV contactless transaction"},
|
||||||
|
|
|
@ -809,7 +809,7 @@ int saveFileJSONrootEx(const char *preferredName, const void *root, size_t flags
|
||||||
|
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Saved to json file `" _YELLOW_("%s") "`", filename);
|
PrintAndLogEx(SUCCESS, "Saved to json file " _YELLOW_("%s"), filename);
|
||||||
}
|
}
|
||||||
free(filename);
|
free(filename);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -1008,7 +1008,7 @@ void DesfirePrintAIDFunctions(uint32_t appid) {
|
||||||
if ((aid[2] >> 4) == 0xF) {
|
if ((aid[2] >> 4) == 0xF) {
|
||||||
uint16_t short_aid = ((aid[2] & 0xF) << 12) | (aid[1] << 4) | (aid[0] >> 4);
|
uint16_t short_aid = ((aid[2] & 0xF) << 12) | (aid[1] << 4) | (aid[0] >> 4);
|
||||||
PrintAndLogEx(SUCCESS, " AID mapped to MIFARE Classic AID (MAD): " _YELLOW_("%02X"), short_aid);
|
PrintAndLogEx(SUCCESS, " AID mapped to MIFARE Classic AID (MAD): " _YELLOW_("%02X"), short_aid);
|
||||||
PrintAndLogEx(SUCCESS, " MAD AID Cluster 0x%02X : " _YELLOW_("%s"), short_aid >> 8, nxp_cluster_to_text(short_aid >> 8));
|
PrintAndLogEx(SUCCESS, " MAD AID Cluster 0x%02X..... " _YELLOW_("%s"), short_aid >> 8, nxp_cluster_to_text(short_aid >> 8));
|
||||||
MADDFDecodeAndPrint(short_aid, false);
|
MADDFDecodeAndPrint(short_aid, false);
|
||||||
} else {
|
} else {
|
||||||
AIDDFDecodeAndPrint(aid);
|
AIDDFDecodeAndPrint(aid);
|
||||||
|
@ -1016,53 +1016,64 @@ void DesfirePrintAIDFunctions(uint32_t appid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DesfireSelectAndAuthenticateEx(DesfireContext_t *dctx, DesfireSecureChannel secureChannel, uint32_t aid, bool noauth, bool verbose) {
|
int DesfireSelectAndAuthenticateEx(DesfireContext_t *dctx, DesfireSecureChannel secureChannel, uint32_t aid, bool noauth, bool verbose) {
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
DesfirePrintContext(dctx);
|
DesfirePrintContext(dctx);
|
||||||
|
}
|
||||||
|
|
||||||
// needs card uid for diversification
|
// needs card uid for diversification
|
||||||
if (dctx->kdfAlgo == MFDES_KDF_ALGO_GALLAGHER)
|
if (dctx->kdfAlgo == MFDES_KDF_ALGO_GALLAGHER) {
|
||||||
DesfireGetCardUID(dctx);
|
DesfireGetCardUID(dctx);
|
||||||
|
}
|
||||||
|
|
||||||
bool isosw = false;
|
bool isosw = false;
|
||||||
if (dctx->cmdSet == DCCISO) {
|
if (dctx->cmdSet == DCCISO) {
|
||||||
dctx->cmdSet = DCCNativeISO;
|
dctx->cmdSet = DCCNativeISO;
|
||||||
isosw = true;
|
isosw = true;
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Switch to " _CYAN_("native") " for select");
|
PrintAndLogEx(INFO, "Switch to " _CYAN_("native") " for select");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
if (aid == 0x000000) {
|
if (aid == 0x000000) {
|
||||||
res = DesfireAnticollision(verbose);
|
res = DesfireAnticollision(verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire anticollision " _RED_("error") ".");
|
PrintAndLogEx(ERR, "Desfire anticollision " _RED_("fail"));
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
if (verbose)
|
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Anticollision " _GREEN_("ok"));
|
PrintAndLogEx(INFO, "Anticollision " _GREEN_("ok"));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res = DesfireSelectAIDHex(dctx, aid, false, 0);
|
res = DesfireSelectAIDHex(dctx, aid, false, 0);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire select " _RED_("error") ".");
|
PrintAndLogEx(ERR, "Desfire select " _RED_("fail"));
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
if (verbose)
|
|
||||||
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "App %06x " _GREEN_("selected"), aid);
|
PrintAndLogEx(INFO, "App %06x " _GREEN_("selected"), aid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isosw)
|
if (isosw) {
|
||||||
dctx->cmdSet = DCCISO;
|
dctx->cmdSet = DCCISO;
|
||||||
|
}
|
||||||
|
|
||||||
if (noauth == false) {
|
if (noauth == false) {
|
||||||
|
|
||||||
res = DesfireAuthenticate(dctx, secureChannel, verbose);
|
res = DesfireAuthenticate(dctx, secureChannel, verbose);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire authenticate " _RED_("error") ". Result: [%d] %s", res, DesfireAuthErrorToStr(res));
|
PrintAndLogEx(ERR, "Desfire authenticate " _RED_("fail") ". Result: [%d] %s", res, DesfireAuthErrorToStr(res));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DesfireIsAuthenticated(dctx)) {
|
if (DesfireIsAuthenticated(dctx)) {
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Desfire " _GREEN_("authenticated"));
|
PrintAndLogEx(INFO, "Desfire " _GREEN_("authenticated"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return 201;
|
return 201;
|
||||||
}
|
}
|
||||||
|
@ -1087,7 +1098,7 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||||
|
|
||||||
res = DesfireSelectAIDHex(dctx, id, false, 0);
|
res = DesfireSelectAIDHex(dctx, id, false, 0);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire select " _RED_("error") ".");
|
PrintAndLogEx(ERR, "Desfire select " _RED_("error"));
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -1097,7 +1108,7 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||||
} else {
|
} else {
|
||||||
res = DesfireSelectEx(dctx, true, way, id, NULL);
|
res = DesfireSelectEx(dctx, true, way, id, NULL);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire %s select " _RED_("error") ".", DesfireSelectWayToStr(way));
|
PrintAndLogEx(ERR, "Desfire %s select " _RED_("error"), DesfireSelectWayToStr(way));
|
||||||
return 202;
|
return 202;
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -1107,13 +1118,14 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||||
if (selectfile) {
|
if (selectfile) {
|
||||||
res = DesfireSelectEx(dctx, false, ISWIsoID, isofileid, NULL);
|
res = DesfireSelectEx(dctx, false, ISWIsoID, isofileid, NULL);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Desfire iso file select " _RED_("error") ".");
|
PrintAndLogEx(ERR, "Desfire iso file select " _RED_("error"));
|
||||||
return 203;
|
return 203;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Application %s file iso id %04x is " _GREEN_("selected"), DesfireWayIDStr(way, id), isofileid);
|
PrintAndLogEx(INFO, "Application %s file iso id %04x is " _GREEN_("selected"), DesfireWayIDStr(way, id), isofileid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!noauth) {
|
if (!noauth) {
|
||||||
res = DesfireAuthenticate(dctx, secureChannel, verbose);
|
res = DesfireAuthenticate(dctx, secureChannel, verbose);
|
||||||
|
@ -1123,8 +1135,9 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DesfireIsAuthenticated(dctx)) {
|
if (DesfireIsAuthenticated(dctx)) {
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(INFO, "Desfire " _GREEN_("authenticated"));
|
PrintAndLogEx(INFO, "Desfire " _GREEN_("authenticated"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return 201;
|
return 201;
|
||||||
}
|
}
|
||||||
|
@ -1864,17 +1877,21 @@ int DesfireFillAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS ap
|
||||||
|
|
||||||
void DesfirePrintPICCInfo(DesfireContext_t *dctx, PICCInfo_t *PICCInfo) {
|
void DesfirePrintPICCInfo(DesfireContext_t *dctx, PICCInfo_t *PICCInfo) {
|
||||||
PrintAndLogEx(SUCCESS, "------------------------------------ " _CYAN_("PICC level") " -------------------------------------");
|
PrintAndLogEx(SUCCESS, "------------------------------------ " _CYAN_("PICC level") " -------------------------------------");
|
||||||
if (PICCInfo->freemem == 0xffffffff)
|
if (PICCInfo->freemem == 0xffffffff) {
|
||||||
PrintAndLogEx(SUCCESS, "Applications count: " _GREEN_("%zu") " free memory " _YELLOW_("n/a"), PICCInfo->appCount);
|
PrintAndLogEx(SUCCESS, "# applications....... " _YELLOW_("%zu"), PICCInfo->appCount);
|
||||||
else
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "Applications count: " _GREEN_("%zu") " free memory " _GREEN_("%d") " bytes", PICCInfo->appCount, PICCInfo->freemem);
|
PrintAndLogEx(SUCCESS, "# applications....... " _YELLOW_("%zu"), PICCInfo->appCount);
|
||||||
|
}
|
||||||
|
PrintAndLogEx(SUCCESS, "");
|
||||||
|
|
||||||
if (PICCInfo->authCmdCheck.checked) {
|
if (PICCInfo->authCmdCheck.checked) {
|
||||||
PrintAndLogEx(SUCCESS, "PICC level auth commands: ");
|
PrintAndLogEx(SUCCESS, "PICC level auth commands");
|
||||||
DesfireCheckAuthCommandsPrint(&PICCInfo->authCmdCheck);
|
DesfireCheckAuthCommandsPrint(&PICCInfo->authCmdCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PICCInfo->numberOfKeys > 0) {
|
if (PICCInfo->numberOfKeys > 0) {
|
||||||
PrintKeySettings(PICCInfo->keySettings, PICCInfo->numKeysRaw, false, true);
|
PrintKeySettings(PICCInfo->keySettings, PICCInfo->numKeysRaw, false, true);
|
||||||
PrintAndLogEx(SUCCESS, "PICC key 0 version: %d (0x%02x)", PICCInfo->keyVersion0, PICCInfo->keyVersion0);
|
PrintAndLogEx(SUCCESS, "PICC key "_YELLOW_("0") " version: %d (0x%02x)", PICCInfo->keyVersion0, PICCInfo->keyVersion0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1886,14 +1903,14 @@ void DesfirePrintAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS
|
||||||
PrintAndLogEx(SUCCESS, "--------------------------------- " _CYAN_("Applications list") " ---------------------------------");
|
PrintAndLogEx(SUCCESS, "--------------------------------- " _CYAN_("Applications list") " ---------------------------------");
|
||||||
|
|
||||||
for (int i = 0; i < PICCInfo->appCount; i++) {
|
for (int i = 0; i < PICCInfo->appCount; i++) {
|
||||||
PrintAndLogEx(SUCCESS, _CYAN_("Application number: 0x%02X"), appList[i].appNum);
|
PrintAndLogEx(SUCCESS, "Application ID....... " _CYAN_("0x%02X"), appList[i].appNum);
|
||||||
PrintAndLogEx(SUCCESS, " ISO id.... " _GREEN_("0x%04X"), appList[i].appISONum);
|
PrintAndLogEx(SUCCESS, " ISO id............ " _GREEN_("0x%04X"), appList[i].appISONum);
|
||||||
PrintAndLogEx(SUCCESS, " DF name... " _GREEN_("%s") " ( %s)", appList[i].appDFName, sprint_hex((uint8_t *)appList[i].appDFName, sizeof(appList[i].appDFName)));
|
PrintAndLogEx(SUCCESS, " DF name........... " _GREEN_("%s") " ( %s )", appList[i].appDFName, sprint_hex_inrow((uint8_t *)appList[i].appDFName, sizeof(appList[i].appDFName)));
|
||||||
|
|
||||||
DesfirePrintAIDFunctions(appList[i].appNum);
|
DesfirePrintAIDFunctions(appList[i].appNum);
|
||||||
|
|
||||||
if (PICCInfo->authCmdCheck.checked) {
|
if (PICCInfo->authCmdCheck.checked) {
|
||||||
PrintAndLogEx(SUCCESS, "Auth commands: ");
|
PrintAndLogEx(SUCCESS, "Auth commands");
|
||||||
DesfireCheckAuthCommandsPrint(&appList[i].authCmdCheck);
|
DesfireCheckAuthCommandsPrint(&appList[i].authCmdCheck);
|
||||||
PrintAndLogEx(SUCCESS, "");
|
PrintAndLogEx(SUCCESS, "");
|
||||||
}
|
}
|
||||||
|
@ -1902,7 +1919,7 @@ void DesfirePrintAppList(DesfireContext_t *dctx, PICCInfo_t *PICCInfo, AppListS
|
||||||
PrintKeySettings(appList[i].keySettings, appList[i].numKeysRaw, true, true);
|
PrintKeySettings(appList[i].keySettings, appList[i].numKeysRaw, true, true);
|
||||||
|
|
||||||
if (appList[i].numberOfKeys > 0) {
|
if (appList[i].numberOfKeys > 0) {
|
||||||
PrintAndLogEx(SUCCESS, "Key versions [0..%d]: " NOLF, appList[i].numberOfKeys - 1);
|
PrintAndLogEx(SUCCESS, "Key versions [0..%d] " NOLF, appList[i].numberOfKeys - 1);
|
||||||
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
||||||
PrintAndLogEx(NORMAL, "%s %02x" NOLF, (keyn == 0) ? "" : ",", appList[i].keyVersions[keyn]);
|
PrintAndLogEx(NORMAL, "%s %02x" NOLF, (keyn == 0) ? "" : ",", appList[i].keyVersions[keyn]);
|
||||||
}
|
}
|
||||||
|
@ -2254,7 +2271,7 @@ int DesfireUpdateRecord(DesfireContext_t *dctx, uint8_t fnum, uint32_t recnum, u
|
||||||
}
|
}
|
||||||
|
|
||||||
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") : _RED_("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");
|
||||||
|
@ -2263,27 +2280,27 @@ static void PrintKeySettingsPICC(uint8_t keysettings, uint8_t numkeys, bool prin
|
||||||
|
|
||||||
if (print2ndbyte) {
|
if (print2ndbyte) {
|
||||||
DesfirePrintCardKeyType(numkeys >> 6);
|
DesfirePrintCardKeyType(numkeys >> 6);
|
||||||
PrintAndLogEx(SUCCESS, "key count: %d", numkeys & 0x0f);
|
PrintAndLogEx(SUCCESS, "Key cnt.... " _YELLOW_("%d"), numkeys & 0x0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print2ndbyte) {
|
static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print2ndbyte) {
|
||||||
// Access rights.
|
// Access rights.
|
||||||
PrintAndLogEx(SUCCESS, "Application level rights:");
|
PrintAndLogEx(SUCCESS, "Application level rights");
|
||||||
uint8_t rights = ((keysettings >> 4) & 0x0F);
|
uint8_t rights = ((keysettings >> 4) & 0x0F);
|
||||||
switch (rights) {
|
switch (rights) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
PrintAndLogEx(SUCCESS, "-- AMK authentication is necessary to change any key (default)");
|
PrintAndLogEx(SUCCESS, " - AMK authentication is necessary to change any key (default)");
|
||||||
break;
|
break;
|
||||||
case 0xE:
|
case 0xE:
|
||||||
PrintAndLogEx(SUCCESS, "-- Authentication with the key to be changed (same KeyNo) is necessary to change a key");
|
PrintAndLogEx(SUCCESS, " - Authentication with the key to be changed (same KeyNo) is necessary to change a key");
|
||||||
break;
|
break;
|
||||||
case 0xF:
|
case 0xF:
|
||||||
PrintAndLogEx(SUCCESS, "-- All keys (except AMK,see Bit0) within this application are frozen");
|
PrintAndLogEx(SUCCESS, " - All keys (except AMK,see Bit0) within this application are frozen");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(SUCCESS,
|
PrintAndLogEx(SUCCESS,
|
||||||
"-- Authentication with the specified key " _YELLOW_("(0x%02x)") " is necessary to change any key.\n"
|
" - Authentication with the specified key " _YELLOW_("(0x%02x)") " is necessary to change any key.\n"
|
||||||
"A change key and a PICC master key (CMK) can only be changed after authentication with the master key.\n"
|
"A change key and a PICC master key (CMK) can only be changed after authentication with the master key.\n"
|
||||||
"For keys other then the master or change key, an authentication with the same key is needed.",
|
"For keys other then the master or change key, an authentication with the same key is needed.",
|
||||||
rights & 0x0f
|
rights & 0x0f
|
||||||
|
@ -2299,10 +2316,10 @@ static void PrintKeySettingsApp(uint8_t keysettings, uint8_t numkeys, bool print
|
||||||
|
|
||||||
if (print2ndbyte) {
|
if (print2ndbyte) {
|
||||||
DesfirePrintCardKeyType(numkeys >> 6);
|
DesfirePrintCardKeyType(numkeys >> 6);
|
||||||
PrintAndLogEx(SUCCESS, "key count: %d", numkeys & 0x0f);
|
PrintAndLogEx(SUCCESS, "Key cnt.... " _YELLOW_("%d"), numkeys & 0x0F);
|
||||||
if (numkeys & 0x20)
|
if (numkeys & 0x20) {
|
||||||
PrintAndLogEx(SUCCESS, "iso file id: enabled");
|
PrintAndLogEx(SUCCESS, "iso file id: enabled");
|
||||||
PrintAndLogEx(SUCCESS, "");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -504,16 +504,16 @@ uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorithm keyType) {
|
||||||
void DesfirePrintCardKeyType(uint8_t keyType) {
|
void DesfirePrintCardKeyType(uint8_t keyType) {
|
||||||
switch (keyType) {
|
switch (keyType) {
|
||||||
case 00:
|
case 00:
|
||||||
PrintAndLogEx(SUCCESS, "Key: 2TDEA");
|
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("2TDEA"));
|
||||||
break;
|
break;
|
||||||
case 01:
|
case 01:
|
||||||
PrintAndLogEx(SUCCESS, "Key: 3TDEA");
|
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("3TDEA"));
|
||||||
break;
|
break;
|
||||||
case 02:
|
case 02:
|
||||||
PrintAndLogEx(SUCCESS, "Key: AES");
|
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("AES"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(SUCCESS, "Key: unknown: 0x%02x", keyType);
|
PrintAndLogEx(SUCCESS, "Key type... " _YELLOW_("unknown") " - 0x%02x", keyType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,13 @@ static int open_mad_file(json_t **root, bool verbose) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Loaded file " _YELLOW_("`%s`") " (%s) %zu records.", path, _GREEN_("ok"), json_array_size(*root));
|
PrintAndLogEx(SUCCESS, "Loaded file `" _YELLOW_("%s") "` " _GREEN_("%zu") " records ( " _GREEN_("ok") " )"
|
||||||
|
, path
|
||||||
|
, json_array_size(*root)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(path);
|
free(path);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -415,7 +420,7 @@ int MADDFDecodeAndPrint(uint32_t short_aid, bool verbose) {
|
||||||
open_mad_file(&mad_known_aids, false);
|
open_mad_file(&mad_known_aids, false);
|
||||||
|
|
||||||
char fmt[128];
|
char fmt[128];
|
||||||
snprintf(fmt, sizeof(fmt), " MAD AID Function 0x%04X :" _YELLOW_("%s"), short_aid, "%s");
|
snprintf(fmt, sizeof(fmt), " MAD AID Function 0x%04X... " _YELLOW_("%s"), short_aid, "%s");
|
||||||
print_aid_description(mad_known_aids, short_aid, fmt, verbose);
|
print_aid_description(mad_known_aids, short_aid, fmt, verbose);
|
||||||
close_mad_file(mad_known_aids);
|
close_mad_file(mad_known_aids);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -429,8 +434,9 @@ bool HasMADKey(uint8_t *d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DetectHID(uint8_t *d, uint16_t manufacture) {
|
int DetectHID(uint8_t *d, uint16_t manufacture) {
|
||||||
if (d == NULL)
|
if (d == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// find HID
|
// find HID
|
||||||
for (int i = 1; i < 16; i++) {
|
for (int i = 1; i < 16; i++) {
|
||||||
|
|
|
@ -291,9 +291,16 @@ int mf_check_keys_fast_ex(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastCh
|
||||||
|
|
||||||
if ((singleSectorParams >> 15) & 1) {
|
if ((singleSectorParams >> 15) & 1) {
|
||||||
if (curr_keys) {
|
if (curr_keys) {
|
||||||
uint64_t foo = bytes_to_num(resp.data.asBytes, 6);
|
// uint64_t foo = bytes_to_num(resp.data.asBytes, 6);
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(SUCCESS, _GREEN_("Key %s for block %2i found: %012" PRIx64), (singleSectorParams >> 8) & 1 ? "B" : "A", singleSectorParams & 0xFF, foo);
|
// PrintAndLogEx(SUCCESS, "found Key %s for block %2i found: " _GREEN_("%012" PRIx64), (singleSectorParams >> 8) & 1 ? "B" : "A", singleSectorParams & 0xFF, foo);
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c -- found valid key [ " _GREEN_("%s") " ]",
|
||||||
|
singleSectorParams & 0xFF,
|
||||||
|
((singleSectorParams >> 8) & 1) ? 'B' : 'A',
|
||||||
|
sprint_hex_inrow(resp.data.asBytes, MIFARE_KEY_SIZE)
|
||||||
|
);
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue