mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Merge pull request #2958 from kormax/mfdes-dfname-param
Support VC card reading by adding `--dfname` argument to more `mfdes` commands
This commit is contained in:
+111
-64
File diff suppressed because it is too large
Load Diff
@@ -1100,7 +1100,57 @@ int DesfireSelectAndAuthenticateW(DesfireContext_t *dctx, DesfireSecureChannel s
|
||||
DesfirePrintContext(dctx);
|
||||
|
||||
int res = 0;
|
||||
if (way == ISW6bAID && dctx->cmdSet == DCCISO) {
|
||||
|
||||
// Handle DF Name selection if it's present in the context
|
||||
if (dctx->selectedDFNameLen > 0) {
|
||||
// Select DF by name using ISO7816 SELECT
|
||||
uint8_t resp[250] = {0};
|
||||
size_t resplen = 0;
|
||||
res = DesfireISOSelect(dctx, ISSDFName, dctx->selectedDFName, dctx->selectedDFNameLen, resp, &resplen);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Desfire DF name select " _RED_("error"));
|
||||
return 200;
|
||||
}
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "DF %s is " _GREEN_("selected"), sprint_hex(dctx->selectedDFName, dctx->selectedDFNameLen));
|
||||
}
|
||||
|
||||
// If both dfname and aid are specified, now also select by AID
|
||||
if (way == ISW6bAID && id != 0x000000) {
|
||||
if (dctx->cmdSet == DCCISO) {
|
||||
dctx->cmdSet = DCCNativeISO;
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Select via " _CYAN_("native iso wrapping") " interface");
|
||||
|
||||
res = DesfireSelectAIDHex(dctx, id, false, 0);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Desfire select " _RED_("error"));
|
||||
return 200;
|
||||
}
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "App %06x via native iso channel is " _GREEN_("selected"), id);
|
||||
|
||||
dctx->cmdSet = DCCISO;
|
||||
} else {
|
||||
res = DesfireSelectEx(dctx, false, way, id, NULL);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Desfire %s select " _RED_("error"), DesfireSelectWayToStr(way));
|
||||
return 202;
|
||||
}
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "%s is " _GREEN_("selected"), DesfireWayIDStr(way, id));
|
||||
}
|
||||
} else if (way == ISWIsoID && id != 0x0000) {
|
||||
// Also select by ISO ID if specified
|
||||
res = DesfireSelectEx(dctx, false, way, id, NULL);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Desfire %s select " _RED_("error"), DesfireSelectWayToStr(way));
|
||||
return 202;
|
||||
}
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "%s is " _GREEN_("selected"), DesfireWayIDStr(way, id));
|
||||
}
|
||||
} else if (way == ISW6bAID && dctx->cmdSet == DCCISO) {
|
||||
dctx->cmdSet = DCCNativeISO;
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "Select via " _CYAN_("native iso wrapping") " interface");
|
||||
|
||||
@@ -101,8 +101,17 @@ void DesfireSetCommMode(DesfireContext_t *ctx, DesfireCommunicationMode commMode
|
||||
void DesfireSetKdf(DesfireContext_t *ctx, uint8_t kdfAlgo, uint8_t *kdfInput, uint8_t kdfInputLen) {
|
||||
ctx->kdfAlgo = kdfAlgo;
|
||||
ctx->kdfInputLen = kdfInputLen;
|
||||
if (kdfInputLen) {
|
||||
if (kdfInputLen)
|
||||
memcpy(ctx->kdfInput, kdfInput, kdfInputLen);
|
||||
}
|
||||
|
||||
void DesfireSetDFName(DesfireContext_t *ctx, uint8_t *dfname, uint8_t dfnameLen) {
|
||||
ctx->selectedDFNameLen = 0;
|
||||
memset(ctx->selectedDFName, 0, sizeof(ctx->selectedDFName));
|
||||
|
||||
if (dfname && dfnameLen > 0 && dfnameLen <= 16) {
|
||||
ctx->selectedDFNameLen = dfnameLen;
|
||||
memcpy(ctx->selectedDFName, dfname, dfnameLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ typedef struct {
|
||||
bool isoChaining;
|
||||
bool appSelected; // for iso auth
|
||||
uint32_t selectedAID;
|
||||
|
||||
uint8_t selectedDFName[16];
|
||||
uint8_t selectedDFNameLen;
|
||||
|
||||
uint8_t uid[10];
|
||||
uint8_t uidlen;
|
||||
@@ -97,6 +100,7 @@ void DesfireSetCommandSet(DesfireContext_t *ctx, DesfireCommandSet cmdSet);
|
||||
void DesfireSetCommMode(DesfireContext_t *ctx, DesfireCommunicationMode commMode);
|
||||
void DesfireSetSecureChannel(DesfireContext_t *ctx, DesfireSecureChannel schann);
|
||||
void DesfireSetKdf(DesfireContext_t *ctx, uint8_t kdfAlgo, uint8_t *kdfInput, uint8_t kdfInputLen);
|
||||
void DesfireSetDFName(DesfireContext_t *ctx, uint8_t *dfname, uint8_t dfnameLen);
|
||||
bool DesfireIsAuthenticated(DesfireContext_t *dctx);
|
||||
size_t DesfireGetMACLength(DesfireContext_t *ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user