mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
make style
This commit is contained in:
parent
45073eb969
commit
3baf595578
8 changed files with 154 additions and 127 deletions
|
@ -1315,23 +1315,23 @@ static int CmdHF14ADesInfo(const char *Cmd) {
|
|||
|
||||
if (major == 0 && minor == 2)
|
||||
PrintAndLogEx(INFO, "\t0.2 - DESFire Light, Originality check, ");
|
||||
|
||||
|
||||
DesfireContext dctx = {0};
|
||||
dctx.commMode = DCMPlain;
|
||||
dctx.cmdSet = DCCNative;
|
||||
res = DesfireSelectAIDHex(&dctx, 0x000000, false, 0);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
|
||||
|
||||
PICCInfoS PICCInfo = {0};
|
||||
|
||||
|
||||
uint8_t aidbuf[250] = {0};
|
||||
size_t aidbuflen = 0;
|
||||
res = DesfireGetAIDList(&dctx, aidbuf, &aidbuflen);
|
||||
if (res == PM3_SUCCESS) {
|
||||
PICCInfo.appCount = aidbuflen / 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cardtype == DESFIRE_EV2 ||
|
||||
cardtype == DESFIRE_LIGHT ||
|
||||
cardtype == DESFIRE_EV3 ||
|
||||
|
@ -1352,16 +1352,16 @@ static int CmdHF14ADesInfo(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "--- Card doesn't support GetSignature cmd");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (aidbuflen > 2) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "--- " _CYAN_("AID list"));
|
||||
PrintAndLogEx(SUCCESS, "AIDs: " NOLF);
|
||||
for (int i = 0; i < aidbuflen; i += 3)
|
||||
PrintAndLogEx(NORMAL, "%s %06x" NOLF, (i == 0) ? "" : ",", DesfireAIDByteToUint(&aidbuf[i]));
|
||||
PrintAndLogEx(NORMAL, "%s %06x" NOLF, (i == 0) ? "" : ",", DesfireAIDByteToUint(&aidbuf[i]));
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
}
|
||||
|
||||
|
||||
DesfireFillPICCInfo(&dctx, &PICCInfo, true);
|
||||
DesfirePrintPICCInfo(&dctx, &PICCInfo);
|
||||
|
||||
|
@ -5450,7 +5450,7 @@ static int CmdHF14ADesLsFiles(const char *Cmd) {
|
|||
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int CmdHF14ADesLsApp(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
|
@ -5494,26 +5494,26 @@ static int CmdHF14ADesLsApp(const char *Cmd) {
|
|||
|
||||
SetAPDULogging(APDULogging);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
|
||||
PrintAndLogEx(INPLACE, _YELLOW_("It may take up to 15 seconds. Processing...."));
|
||||
|
||||
|
||||
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, 0x000000, noauth, verbose);
|
||||
if (res != PM3_SUCCESS) {
|
||||
DropField();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
PICCInfoS PICCInfo = {0};
|
||||
AppListS AppList = {0};
|
||||
DesfireFillAppList(&dctx, &PICCInfo, AppList, !nodeep, scanfiles);
|
||||
|
||||
printf("\33[2K\r"); // clear current line before printing
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
|
||||
// print zone
|
||||
DesfirePrintPICCInfo(&dctx, &PICCInfo);
|
||||
DesfirePrintAppList(&dctx, &PICCInfo, AppList);
|
||||
|
||||
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1266,7 +1266,7 @@ static int DesfireAuthenticateEV2(DesfireContext *dctx, DesfireSecureChannel sec
|
|||
// rotate rndA to check
|
||||
memcpy(rotRndA, RndA, CRYPTO_AES_BLOCK_SIZE);
|
||||
rol(rotRndA, CRYPTO_AES_BLOCK_SIZE);
|
||||
|
||||
|
||||
uint8_t *recRndA = (firstauth) ? &data[4] : data;
|
||||
|
||||
if (memcmp(rotRndA, recRndA, CRYPTO_AES_BLOCK_SIZE) != 0) {
|
||||
|
@ -1375,7 +1375,7 @@ static bool DesfireCheckAuthCmd(uint32_t appAID, uint8_t keyNum, uint8_t authcmd
|
|||
size_t recv_len = 0;
|
||||
uint8_t respcode = 0;
|
||||
uint8_t recv_data[256] = {0};
|
||||
|
||||
|
||||
DesfireContext dctx = {0};
|
||||
dctx.keyNum = keyNum;
|
||||
dctx.commMode = DCMPlain;
|
||||
|
@ -1393,14 +1393,14 @@ static bool DesfireCheckAuthCmd(uint32_t appAID, uint8_t keyNum, uint8_t authcmd
|
|||
}
|
||||
|
||||
static bool DesfireCheckISOAuthCmd(uint32_t appAID, char *dfname, uint8_t keyNum, DesfireCryptoAlgorythm keytype) {
|
||||
|
||||
|
||||
DesfireContext dctx = {0};
|
||||
dctx.keyNum = keyNum;
|
||||
dctx.commMode = DCMPlain;
|
||||
dctx.cmdSet = DCCISO;
|
||||
|
||||
bool app_level = (appAID != 0x000000);
|
||||
int res = 0;
|
||||
int res = 0;
|
||||
if (dfname == NULL || strnlen(dfname, 16) == 0) {
|
||||
if (appAID == 0x000000) {
|
||||
res = DesfireISOSelect(&dctx, ISSMFDFEF, NULL, 0, NULL, NULL);
|
||||
|
@ -1417,21 +1417,21 @@ static bool DesfireCheckISOAuthCmd(uint32_t appAID, char *dfname, uint8_t keyNum
|
|||
return false;
|
||||
app_level = true;
|
||||
}
|
||||
|
||||
|
||||
uint8_t rndlen = DesfireGetRndLenForKey(keytype);
|
||||
|
||||
|
||||
uint8_t piccrnd[64] = {0};
|
||||
size_t xlen = 0;
|
||||
res = DesfireISOGetChallenge(&dctx, keytype, piccrnd, &xlen);
|
||||
if (res != PM3_SUCCESS || xlen != rndlen)
|
||||
return false;
|
||||
|
||||
|
||||
uint8_t resp[250] = {0};
|
||||
size_t resplen = 0;
|
||||
|
||||
|
||||
uint16_t sw = 0;
|
||||
uint8_t p1 = DesfireKeyToISOKey(keytype);
|
||||
uint8_t p2 = ((app_level) ? 0x80 : 0x00) | keyNum;
|
||||
uint8_t p2 = ((app_level) ? 0x80 : 0x00) | keyNum;
|
||||
res = DesfireExchangeISO(false, &dctx, (sAPDU) {0x00, ISO7816_EXTERNAL_AUTHENTICATION, p1, p2, rndlen * 2, piccrnd}, 0, resp, &resplen, &sw);
|
||||
DropField();
|
||||
return (sw == 0x9000 || sw == 0x6982);
|
||||
|
@ -1439,7 +1439,7 @@ static bool DesfireCheckISOAuthCmd(uint32_t appAID, char *dfname, uint8_t keyNum
|
|||
|
||||
void DesfireCheckAuthCommands(uint32_t appAID, char *dfname, uint8_t keyNum, AuthCommandsChk *authCmdCheck) {
|
||||
memset(authCmdCheck, 0, sizeof(AuthCommandsChk));
|
||||
|
||||
|
||||
authCmdCheck->auth = DesfireCheckAuthCmd(appAID, keyNum, MFDES_AUTHENTICATE);
|
||||
authCmdCheck->authISO = DesfireCheckAuthCmd(appAID, keyNum, MFDES_AUTHENTICATE_ISO);
|
||||
authCmdCheck->authAES = DesfireCheckAuthCmd(appAID, keyNum, MFDES_AUTHENTICATE_AES);
|
||||
|
@ -1450,12 +1450,12 @@ void DesfireCheckAuthCommands(uint32_t appAID, char *dfname, uint8_t keyNum, Aut
|
|||
|
||||
void DesfireCheckAuthCommandsPrint(AuthCommandsChk *authCmdCheck) {
|
||||
PrintAndLogEx(NORMAL, "auth: %s auth iso: %s auth aes: %s auth ev2: %s auth iso native: %s",
|
||||
authCmdCheck->auth ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authISO ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authAES ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authEV2 ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authISONative ? _GREEN_("YES") : _RED_("NO")
|
||||
);
|
||||
authCmdCheck->auth ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authISO ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authAES ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authEV2 ? _GREEN_("YES") : _RED_("NO"),
|
||||
authCmdCheck->authISONative ? _GREEN_("YES") : _RED_("NO")
|
||||
);
|
||||
}
|
||||
|
||||
int DesfireFillPICCInfo(DesfireContext *dctx, PICCInfoS *PICCInfo, bool deepmode) {
|
||||
|
@ -1468,7 +1468,7 @@ int DesfireFillPICCInfo(DesfireContext *dctx, PICCInfoS *PICCInfo, bool deepmode
|
|||
PICCInfo->freemem = freemem;
|
||||
else
|
||||
PICCInfo->freemem = 0xffffffff;
|
||||
|
||||
|
||||
PICCInfo->keySettings = 0;
|
||||
PICCInfo->numKeysRaw = 0;
|
||||
PICCInfo->keyVersion0 = 0;
|
||||
|
@ -1489,14 +1489,14 @@ int DesfireFillPICCInfo(DesfireContext *dctx, PICCInfoS *PICCInfo, bool deepmode
|
|||
// field on-off zone
|
||||
if (deepmode)
|
||||
DesfireCheckAuthCommands(0x000000, NULL, 0, &PICCInfo->authCmdCheck);
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int AppListSearchAID(uint32_t appNum, AppListS AppList, size_t appcount) {
|
||||
for (int i = 0; i < appcount; i++)
|
||||
if (AppList[i].appNum == appNum)
|
||||
return i;
|
||||
for (int i = 0; i < appcount; i++)
|
||||
if (AppList[i].appNum == appNum)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -1510,12 +1510,12 @@ int DesfireFillAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS appLi
|
|||
PrintAndLogEx(ERR, "Desfire GetAIDList command " _RED_("error") ". Result: %d", res);
|
||||
DropField();
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PICCInfo->appCount = buflen / 3;
|
||||
for (int i = 0; i < buflen; i += 3)
|
||||
appList[i / 3].appNum = DesfireAIDByteToUint(&buf[i]);
|
||||
|
||||
|
||||
// result bytes: 3, 2, 1-16. total record size = 24
|
||||
res = DesfireGetDFList(dctx, buf, &buflen);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
@ -1549,7 +1549,7 @@ int DesfireFillAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS appLi
|
|||
appList[i].numberOfKeys = appList[i].numKeysRaw & 0x1f;
|
||||
appList[i].isoFileIDEnabled = ((appList[i].numKeysRaw & 0x20) != 0);
|
||||
appList[i].keyType = DesfireKeyTypeToAlgo(appList[i].numKeysRaw >> 6);
|
||||
|
||||
|
||||
if (appList[i].numberOfKeys > 0)
|
||||
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
||||
res = DesfireGetKeyVersion(dctx, &keyn, 1, buf, &buflen);
|
||||
|
@ -1557,7 +1557,7 @@ int DesfireFillAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS appLi
|
|||
appList[i].keyVersions[keyn] = buf[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appList[i].filesReaded = false;
|
||||
if (readFiles) {
|
||||
res = DesfireFillFileList(dctx, appList[i].fileList, &appList[i].filesCount, &appList[i].isoPresent);
|
||||
|
@ -1598,7 +1598,7 @@ void DesfirePrintAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS app
|
|||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "--------------------------------- " _CYAN_("Applications list") " ---------------------------------");
|
||||
|
||||
|
||||
for (int i = 0; i < PICCInfo->appCount; i++) {
|
||||
PrintAndLogEx(SUCCESS, _CYAN_("Application number: 0x%02x") " iso id: " _GREEN_("0x%04x") " name: " _GREEN_("%s"), appList[i].appNum, appList[i].appISONum, appList[i].appDFName);
|
||||
|
||||
|
@ -1609,10 +1609,10 @@ void DesfirePrintAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS app
|
|||
DesfireCheckAuthCommandsPrint(&appList[i].authCmdCheck);
|
||||
PrintAndLogEx(SUCCESS, "");
|
||||
}
|
||||
|
||||
|
||||
if (appList[i].numberOfKeys > 0) {
|
||||
PrintKeySettings(appList[i].keySettings, appList[i].numKeysRaw, true, true);
|
||||
|
||||
|
||||
if (appList[i].numberOfKeys > 0) {
|
||||
PrintAndLogEx(SUCCESS, "Key versions [0..%d]: " NOLF, appList[i].numberOfKeys - 1);
|
||||
for (uint8_t keyn = 0; keyn < appList[i].numberOfKeys; keyn++) {
|
||||
|
@ -1620,7 +1620,7 @@ void DesfirePrintAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS app
|
|||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
}
|
||||
|
||||
|
||||
if (appList[i].filesReaded) {
|
||||
PrintAndLogEx(SUCCESS, "Application have " _GREEN_("%zu") " files", appList[i].filesCount);
|
||||
|
||||
|
@ -1641,7 +1641,7 @@ void DesfirePrintAppList(DesfireContext *dctx, PICCInfoS *PICCInfo, AppListS app
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int DesfireCommandEx(DesfireContext *dctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *resp, size_t *resplen, int checklength, size_t splitbysize) {
|
||||
|
@ -1699,18 +1699,18 @@ int DesfireGetFreeMem(DesfireContext *dctx, uint32_t *freemem) {
|
|||
|
||||
int DesfireReadSignature(DesfireContext *dctx, uint8_t sid, uint8_t *resp, size_t *resplen) {
|
||||
*resplen = 0;
|
||||
|
||||
|
||||
uint8_t xresp[257] = {0};
|
||||
size_t xresplen = 0;
|
||||
uint8_t respcode = 0xff;
|
||||
|
||||
|
||||
int res = DesfireExchange(dctx, MFDES_READSIG, &sid, 1, &respcode, xresp, &xresplen);
|
||||
if (res != PM3_SUCCESS)
|
||||
return res;
|
||||
|
||||
|
||||
if (respcode != 0x90)
|
||||
return PM3_EAPDU_FAIL;
|
||||
|
||||
|
||||
memcpy(resp, xresp, xresplen);
|
||||
*resplen = xresplen;
|
||||
|
||||
|
@ -2080,7 +2080,7 @@ const char *AccessRightShortStr[] = {
|
|||
"keyC",
|
||||
"keyD",
|
||||
"free",
|
||||
"deny"
|
||||
"deny"
|
||||
};
|
||||
|
||||
const char *GetDesfireAccessRightShortStr(uint8_t right) {
|
||||
|
@ -2207,7 +2207,7 @@ static void DesfirePrintShortFileTypeSettings(FileSettingsS *fsettings) {
|
|||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DesfirePrintFileSettingsOneLine(FileSettingsS *fsettings) {
|
||||
|
@ -2228,15 +2228,15 @@ void DesfirePrintFileSettingsTable(bool printheader, uint8_t id, bool isoidavail
|
|||
PrintAndLogEx(SUCCESS, " ID |ISO ID| File type | Mode | Rights: raw, r w rw ch | File settings ");
|
||||
PrintAndLogEx(SUCCESS, "----------------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, " " _GREEN_("%02x") " |" NOLF, id);
|
||||
if (isoidavail) {
|
||||
if (isoid != 0)
|
||||
PrintAndLogEx(NORMAL, " " _CYAN_("%04x") " |" NOLF, isoid);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " " _YELLOW_("n/a ") " |" NOLF);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " |" NOLF);
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, " " _GREEN_("%02x") " |" NOLF, id);
|
||||
if (isoidavail) {
|
||||
if (isoid != 0)
|
||||
PrintAndLogEx(NORMAL, " " _CYAN_("%04x") " |" NOLF, isoid);
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " " _YELLOW_("n/a ") " |" NOLF);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, " |" NOLF);
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "0x%02x " _CYAN_("%-13s") " |" NOLF, fsettings->fileType, GetDesfireFileType(fsettings->fileType));
|
||||
PrintAndLogEx(NORMAL, " %-5s |" NOLF, GetDesfireCommunicationMode(fsettings->fileCommMode));
|
||||
|
@ -2247,7 +2247,7 @@ void DesfirePrintFileSettingsTable(bool printheader, uint8_t id, bool isoidavail
|
|||
GetDesfireAccessRightShortStr(fsettings->wAccess),
|
||||
GetDesfireAccessRightShortStr(fsettings->rwAccess),
|
||||
GetDesfireAccessRightShortStr(fsettings->chAccess));
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, " " NOLF);
|
||||
DesfirePrintShortFileTypeSettings(fsettings);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
|
|
@ -99,15 +99,15 @@ typedef struct {
|
|||
uint16_t appISONum;
|
||||
char appDFName[16];
|
||||
AuthCommandsChk authCmdCheck;
|
||||
|
||||
|
||||
uint8_t keySettings;
|
||||
uint8_t numKeysRaw;
|
||||
bool isoFileIDEnabled; // from numKeysRaw
|
||||
uint8_t numberOfKeys; // from numKeysRaw
|
||||
DesfireCryptoAlgorythm keyType; // from numKeysRaw
|
||||
|
||||
|
||||
uint8_t keyVersions[16];
|
||||
|
||||
|
||||
bool filesReaded;
|
||||
size_t filesCount;
|
||||
bool isoPresent;
|
||||
|
@ -119,11 +119,11 @@ typedef struct {
|
|||
size_t appCount;
|
||||
uint32_t freemem;
|
||||
AuthCommandsChk authCmdCheck;
|
||||
|
||||
|
||||
uint8_t keySettings;
|
||||
uint8_t numKeysRaw;
|
||||
uint8_t numberOfKeys; // from numKeysRaw
|
||||
|
||||
|
||||
uint8_t keyVersion0;
|
||||
} PICCInfoS;
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ void DesfireEV2FillIV(DesfireContext *ctx, bool ivforcommand, uint8_t *iv) {
|
|||
int DesfireEV2CalcCMAC(DesfireContext *ctx, uint8_t cmd, uint8_t *data, size_t datalen, uint8_t *mac) {
|
||||
uint8_t mdata[1050] = {0};
|
||||
size_t mdatalen = 0;
|
||||
|
||||
|
||||
mdata[0] = cmd;
|
||||
Uint2byteToMemLe(&mdata[1], ctx->cmdCntr);
|
||||
memcpy(&mdata[3], ctx->TI, 4);
|
||||
|
|
|
@ -263,7 +263,7 @@ static void DesfireSecureChannelEncodeEV2(DesfireContext *ctx, uint8_t cmd, uint
|
|||
}
|
||||
} else if (ctx->commMode == DCMEncrypted) {
|
||||
DesfireEV2FillIV(ctx, true, NULL); // fill IV to ctx
|
||||
|
||||
|
||||
rlen = padded_data_length(srcdatalen + 1 - hdrlen, desfire_get_key_block_length(ctx->keyType));
|
||||
memcpy(data, &srcdata[hdrlen], srcdatalen - hdrlen);
|
||||
data[hdrlen] = 0x80; // padding
|
||||
|
@ -281,7 +281,7 @@ static void DesfireSecureChannelEncodeEV2(DesfireContext *ctx, uint8_t cmd, uint
|
|||
} else if (ctx->commMode == DCMEncryptedPlain) {
|
||||
if (srcdatalen <= hdrlen)
|
||||
return;
|
||||
|
||||
|
||||
// TODO !!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,8 +277,9 @@ static bool TestEV2MAC(void) {
|
|||
uint8_t key[] = {0x93, 0x66, 0xFA, 0x19, 0x5E, 0xB5, 0x66, 0xF5, 0xBD, 0x2B, 0xAD, 0x40, 0x20, 0xB8, 0x30, 0x02};
|
||||
uint8_t ti[] = {0xE2, 0xD3, 0xAF, 0x69};
|
||||
uint8_t cmd = 0x8D;
|
||||
uint8_t cmddata[] = {0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22};
|
||||
uint8_t cmddata[] = {0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22
|
||||
};
|
||||
uint8_t macres[] = {0x68, 0xF2, 0xC2, 0x8C, 0x57, 0x5A, 0x16, 0x28};
|
||||
|
||||
// init
|
||||
|
@ -300,7 +301,7 @@ static bool TestEV2MAC(void) {
|
|||
ctx.cmdCntr++;
|
||||
DesfireEV2CalcCMAC(&ctx, rc, NULL, 0, mac);
|
||||
res = res && (memcmp(mac, macres2, sizeof(macres2)) == 0);
|
||||
|
||||
|
||||
// tx 2
|
||||
memset(mac, 0, sizeof(mac));
|
||||
cmd = 0xAD;
|
||||
|
@ -312,13 +313,14 @@ static bool TestEV2MAC(void) {
|
|||
// rx 2
|
||||
rc = 0;
|
||||
ctx.cmdCntr++;
|
||||
uint8_t cmddata4[] = {0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t cmddata4[] = {0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
|
||||
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
uint8_t macres4[] = {0xA4, 0x9A, 0x44, 0x22, 0x2D, 0x92, 0x66, 0x66};
|
||||
DesfireEV2CalcCMAC(&ctx, rc, cmddata4, sizeof(cmddata4), mac);
|
||||
res = res && (memcmp(mac, macres4, sizeof(macres4)) == 0);
|
||||
|
||||
|
||||
if (res)
|
||||
PrintAndLogEx(INFO, "EV2 MAC calc...... " _GREEN_("passed"));
|
||||
else
|
||||
|
|
|
@ -973,7 +973,7 @@
|
|||
},
|
||||
"help": {
|
||||
"command": "help",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210731.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"description": "help use `<command> help` for details of a command prefs { edit client/device preferences... } -------- ----------------------- technology ----------------------- analyse { analyse utils... } data { plot window / data buffer manipulation... } emv { emv iso-14443 / iso-7816... } hf { high frequency commands... } hw { hardware commands... } lf { low frequency commands... } nfc { nfc commands... } reveng { crc calculations from reveng software... } smart { smart card iso-7816 commands... } script { scripting commands... } trace { trace manipulation... } wiegand { wiegand format manipulation... } -------- ----------------------- general ----------------------- clear clear screen hints turn hints on / off msleep add a pause in milliseconds rem add a text line in log file quit exit exit program [=] session log e:\\proxspace\\pm3/.proxmark3/logs/log_20210804.txt --------------------------------------------------------------------------------------- auto available offline: no run lf search / hf search / data plot / data save",
|
||||
"notes": [
|
||||
"auto"
|
||||
],
|
||||
|
@ -3990,7 +3990,13 @@
|
|||
"command": "hf mfdes changekey",
|
||||
"description": "change picc/application key. needs to provide keynum/key for a valid authentication (may get from default parameters).",
|
||||
"notes": [
|
||||
"hf mfdes changekey --aid 123456 -> execute with default factory setup"
|
||||
"change crypto algorithm for picc key is possible, but for app keys crypto algorithm is set by createapp command and can't be changed wo application delete",
|
||||
"",
|
||||
"hf mfdes changekey --aid 123456 -> execute with default factory setup. change des key 0 in the app 123456 from 00..00 to 00..00",
|
||||
"hf mfdes changekey -t des --newalgo aes --newkey 11223344556677889900112233445566 --newver a5 -> change card master key to aes one",
|
||||
"hf mfdes changekey --aid 123456 -t aes --key 00000000000000000000000000000000 --newkey 11223344556677889900112233445566 -> change app master key",
|
||||
"hf mfdes changekey --aid 123456 -t des -n 0 --newkeyno 1 --oldkey 5555555555555555 --newkey 1122334455667788 -> change key 1 with auth from key 0",
|
||||
"hf mfdes changekey --aid 123456 -t 3tdea --newkey 11223344556677889900112233445566778899001122334 -> change 3tdea key 0 from default 00..00 to provided"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
|
@ -4342,6 +4348,26 @@
|
|||
],
|
||||
"usage": "hf mfdes createvaluefile [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--fid <file id hex>] [--amode <plain/mac/encrypt>] [--rawrights <access rights hex>] [--rrights <key0/../key13/free/deny>] [--wrights <key0/../key13/free/deny>] [--rwrights <key0/../key13/free/deny>] [--chrights <key0/../key13/free/deny>] [--no-auth] [--lower <hex>] [--upper <hex>] [--value <hex>] [--lcredit <dec>]"
|
||||
},
|
||||
"hf mfdes default": {
|
||||
"command": "hf mfdes default",
|
||||
"description": "set default parameters for access to desfire card.",
|
||||
"notes": [
|
||||
"hf mfdes default -n 0 -t des -k 0000000000000000 -f none -> save to the default parameters"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help this help",
|
||||
"-n, --keyno <keyno> key number",
|
||||
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes",
|
||||
"-k, --key <key> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
|
||||
"-f, --kdf <none/an10922/gallagher> key derivation function (kdf): none, an10922, gallagher",
|
||||
"-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)",
|
||||
"-m, --cmode <plain/mac/encrypt> communicaton mode: plain/mac/encrypt",
|
||||
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso",
|
||||
"-s, --schann <d40/ev1/ev2> secure channel: d40/ev1/ev2"
|
||||
],
|
||||
"usage": "hf mfdes default [-h] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>]"
|
||||
},
|
||||
"hf mfdes deleteapp": {
|
||||
"command": "hf mfdes deleteapp",
|
||||
"description": "delete application by its 3-byte aid. master key needs to be provided.",
|
||||
|
@ -4414,18 +4440,6 @@
|
|||
],
|
||||
"usage": "hf mfdes dump [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--no-auth]"
|
||||
},
|
||||
"hf mfdes enum": {
|
||||
"command": "hf mfdes enum",
|
||||
"description": "enumerate all aid's on mifare desfire tag",
|
||||
"notes": [
|
||||
"hf mfdes enum"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help this help"
|
||||
],
|
||||
"usage": "hf mfdes enum [-h]"
|
||||
},
|
||||
"hf mfdes formatpicc": {
|
||||
"command": "hf mfdes formatpicc",
|
||||
"description": "format card. can be done only if enabled in the configuration. master key needs to be provided.",
|
||||
|
@ -4669,31 +4683,11 @@
|
|||
},
|
||||
"hf mfdes help": {
|
||||
"command": "hf mfdes help",
|
||||
"description": "help this help list list desfire (iso 14443a) history test test crypto --------------------------------------------------------------------------------------- hf mfdes default available offline: no set default parameters for access to desfire card.",
|
||||
"notes": [
|
||||
"hf mfdes default -n 0 -t des -k 0000000000000000 -f none -> save to the default parameters"
|
||||
],
|
||||
"offline": true,
|
||||
"options": [
|
||||
"-h, --help this help",
|
||||
"-n, --keyno <keyno> key number",
|
||||
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes",
|
||||
"-k, --key <key> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
|
||||
"-f, --kdf <none/an10922/gallagher> key derivation function (kdf): none, an10922, gallagher",
|
||||
"-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)",
|
||||
"-m, --cmode <plain/mac/encrypt> communicaton mode: plain/mac/encrypt",
|
||||
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso",
|
||||
"-s, --schann <d40/ev1/ev2> secure channel: d40/ev1/ev2"
|
||||
],
|
||||
"usage": "hf mfdes default [-h] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>]"
|
||||
},
|
||||
"hf mfdes info": {
|
||||
"command": "hf mfdes info",
|
||||
"description": "get info from mifare desfire tags",
|
||||
"description": "help this help list list desfire (iso 14443a) history test test crypto --------------------------------------------------------------------------------------- hf mfdes info available offline: no get info from mifare desfire tags",
|
||||
"notes": [
|
||||
"hf mfdes info"
|
||||
],
|
||||
"offline": false,
|
||||
"offline": true,
|
||||
"options": [
|
||||
"-h, --help this help"
|
||||
],
|
||||
|
@ -4720,6 +4714,32 @@
|
|||
],
|
||||
"usage": "hf mfdes list [-h1fcrux] [--dict <file>]..."
|
||||
},
|
||||
"hf mfdes lsapp": {
|
||||
"command": "hf mfdes lsapp",
|
||||
"description": "show application list. master key needs to be provided or flag --no-auth set (depend on cards settings).",
|
||||
"notes": [
|
||||
"hf mfdes lsapp -> show application list with defaults from `default` command",
|
||||
"hf mfdes lsapp --files -> show application list and show each file type/settings/etc for each application"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
"-h, --help this help",
|
||||
"-a, --apdu show apdu requests and responses",
|
||||
"-v, --verbose show technical data",
|
||||
"-n, --keyno <keyno> key number",
|
||||
"-t, --algo <des/2tdea/3tdea/aes> crypt algo: des, 2tdea, 3tdea, aes",
|
||||
"-k, --key <key> key for authenticate (hex 8(des), 16(2tdea or aes) or 24(3tdea) bytes)",
|
||||
"-f, --kdf <none/an10922/gallagher> key derivation function (kdf): none, an10922, gallagher",
|
||||
"-i, --kdfi <kdfi> kdf input (hex 1-31 bytes)",
|
||||
"-m, --cmode <plain/mac/encrypt> communicaton mode: plain/mac/encrypt",
|
||||
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso",
|
||||
"-s, --schann <d40/ev1/ev2> secure channel: d40/ev1/ev2",
|
||||
"--no-auth execute without authentication",
|
||||
"--no-deep not to check authentication commands that avail for any application",
|
||||
"--files scan files and print file settings for each application"
|
||||
],
|
||||
"usage": "hf mfdes lsapp [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--no-auth] [--no-deep] [--files]"
|
||||
},
|
||||
"hf mfdes lsfiles": {
|
||||
"command": "hf mfdes lsfiles",
|
||||
"description": "show file list. master key needs to be provided or flag --no-auth set (depend on cards settings).",
|
||||
|
@ -4777,7 +4797,10 @@
|
|||
"command": "hf mfdes selectapp",
|
||||
"description": "select application on the card. it selects app if it is a valid one or returns an error.",
|
||||
"notes": [
|
||||
"hf mfdes selectapp --aid 123456 -> select application 123456"
|
||||
"hf mfdes selectapp --aid 123456 -> select application 123456",
|
||||
"hf mfdes selectapp --mf -> select master file (picc level)",
|
||||
"hf mfdes selectapp --dfname aid123456 -> select application aid123456 by df name",
|
||||
"hf mfdes selectapp --isoid 1111 -> select application 1111 by iso id"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
|
@ -4793,9 +4816,11 @@
|
|||
"-c, --ccset <native/niso/iso> communicaton command set: native/niso/iso",
|
||||
"-s, --schann <d40/ev1/ev2> secure channel: d40/ev1/ev2",
|
||||
"--aid <app id hex> application id of application for some parameters (3 hex bytes, big endian)",
|
||||
"--dfname <df name str> application df name (string, max 16 chars). selects application via iso select command"
|
||||
"--dfname <df name str> application df name (string, max 16 chars). selects application via iso select command",
|
||||
"--isoid <isoid hex> application iso id (iso df id) (2 hex bytes, big endian)",
|
||||
"--mf select mf (master file) via iso channel"
|
||||
],
|
||||
"usage": "hf mfdes selectapp [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--dfname <df name str>]"
|
||||
"usage": "hf mfdes selectapp [-hav] [-n <keyno>] [-t <des/2tdea/3tdea/aes>] [-k <key>] [-f <none/an10922/gallagher>] [-i <kdfi>] [-m <plain/mac/encrypt>] [-c <native/niso/iso>] [-s <d40/ev1/ev2>] [--aid <app id hex>] [--dfname <df name str>] [--isoid <isoid hex>] [--mf]"
|
||||
},
|
||||
"hf mfdes setconfig": {
|
||||
"command": "hf mfdes setconfig",
|
||||
|
@ -4825,7 +4850,7 @@
|
|||
},
|
||||
"hf mfdes test": {
|
||||
"command": "hf mfdes test",
|
||||
"description": "[=] ------ desfire tests ------ [!] no space for crc. pos: 1 [=] crc16............. passed [!] no space for crc. pos: 2 [=] crc32............. passed [=] cmac 3tdea........ passed [=] cmac 2tdea........ passed [=] cmac des.......... passed [=] ev2 session keys.. passed [=] ev2 iv calc....... passed [=] --------------------------- [+] tests [ ok ] ======================================================================================= hf seos { seos rfids... } --------------------------------------------------------------------------------------- hf seos help available offline: yes help this help list list seos history --------------------------------------------------------------------------------------- hf seos info available offline: no get info from seos tags",
|
||||
"description": "[=] ------ desfire tests ------ [!] no space for crc. pos: 1 [=] crc16............. passed [!] no space for crc. pos: 2 [=] crc32............. passed [=] cmac 3tdea........ passed [=] cmac 2tdea........ passed [=] cmac des.......... passed [=] ev2 session keys.. passed [=] ev2 iv calc....... passed [=] ev2 mac calc...... passed [=] --------------------------- [+] tests [ ok ] ======================================================================================= hf seos { seos rfids... } --------------------------------------------------------------------------------------- hf seos help available offline: yes help this help list list seos history --------------------------------------------------------------------------------------- hf seos info available offline: no get info from seos tags",
|
||||
"notes": [
|
||||
"hf seos info"
|
||||
],
|
||||
|
@ -9839,6 +9864,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 587,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2021-07-31T13:44:52"
|
||||
"extracted_on": "2021-08-04T12:46:55"
|
||||
}
|
||||
}
|
|
@ -503,26 +503,26 @@ Check column "offline" for their availability.
|
|||
|command |offline |description
|
||||
|------- |------- |-----------
|
||||
|`hf mfdes help `|Y |`This help`
|
||||
|`hf mfdes info `|N |`Tag information`
|
||||
|`hf mfdes getuid `|N |`Get uid from card`
|
||||
|`hf mfdes default `|N |`Set defaults for all the commands`
|
||||
|`hf mfdes auth `|N |`MIFARE DesFire Authentication`
|
||||
|`hf mfdes chk `|N |`[old]Check keys`
|
||||
|`hf mfdes enum `|N |`[old]Tries enumerate all applications`
|
||||
|`hf mfdes formatpicc `|N |`Format PICC`
|
||||
|`hf mfdes freemem `|N |`Get free memory size`
|
||||
|`hf mfdes getuid `|N |`Get uid from card`
|
||||
|`hf mfdes setconfig `|N |`Set card configuration`
|
||||
|`hf mfdes info `|N |`[old]Tag information`
|
||||
|`hf mfdes formatpicc `|N |`Format PICC`
|
||||
|`hf mfdes list `|Y |`List DESFire (ISO 14443A) history`
|
||||
|`hf mfdes changekey `|N |`Change Key`
|
||||
|`hf mfdes chkeysettings `|N |`Change Key Settings`
|
||||
|`hf mfdes getkeysettings`|N |`Get Key Settings`
|
||||
|`hf mfdes getkeyversions`|N |`Get Key Versions`
|
||||
|`hf mfdes lsapp `|N |`Show all applications with files list`
|
||||
|`hf mfdes getaids `|N |`Get Application IDs list`
|
||||
|`hf mfdes getappnames `|N |`Get Applications list`
|
||||
|`hf mfdes bruteaid `|N |`Recover AIDs by bruteforce`
|
||||
|`hf mfdes createapp `|N |`Create Application`
|
||||
|`hf mfdes deleteapp `|N |`Delete Application`
|
||||
|`hf mfdes selectapp `|N |`Select Application ID`
|
||||
|`hf mfdes getaids `|N |`Get Application IDs list`
|
||||
|`hf mfdes getappnames `|N |`Get Applications list`
|
||||
|`hf mfdes changekey `|N |`Change Key`
|
||||
|`hf mfdes chkeysettings `|N |`Change Key Settings`
|
||||
|`hf mfdes getkeysettings`|N |`Get Key Settings`
|
||||
|`hf mfdes getkeyversions`|N |`Get Key Versions`
|
||||
|`hf mfdes getfileids `|N |`Get File IDs list`
|
||||
|`hf mfdes getfileisoids `|N |`Get File ISO IDs list`
|
||||
|`hf mfdes lsfiles `|N |`Show all files list`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue