mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-23 14:45:37 -07:00
app select works
This commit is contained in:
parent
8319953ad7
commit
cefad27487
3 changed files with 33 additions and 11 deletions
|
@ -3053,6 +3053,7 @@ static int CmdHF14ADesSelectApp(const char *Cmd) {
|
||||||
arg_str0("c", "ccset", "<native/niso/iso>", "Communicaton command set: native/niso/iso"),
|
arg_str0("c", "ccset", "<native/niso/iso>", "Communicaton command set: native/niso/iso"),
|
||||||
arg_str0("s", "schann", "<d40/ev1/ev2>", "Secure channel: d40/ev1/ev2"),
|
arg_str0("s", "schann", "<d40/ev1/ev2>", "Secure channel: d40/ev1/ev2"),
|
||||||
arg_str0(NULL, "aid", "<app id hex>", "Application ID of application for some parameters (3 hex bytes, big endian)"),
|
arg_str0(NULL, "aid", "<app id hex>", "Application ID of application for some parameters (3 hex bytes, big endian)"),
|
||||||
|
arg_str0(NULL, "dfname", "<df name str>", "Application DF Name (string, max 16 chars). Selects application via ISO SELECT command"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
@ -3068,18 +3069,39 @@ static int CmdHF14ADesSelectApp(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t dfname[32] = {0};
|
||||||
|
int dfnamelen = 16;
|
||||||
|
CLIGetStrWithReturn(ctx, 12, dfname, &dfnamelen);
|
||||||
|
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, appid, true, verbose);
|
if (dfnamelen > 0) { // dctx.cmdSet == DCCISO ?
|
||||||
if (res != PM3_SUCCESS) {
|
uint8_t resp[250] = {0};
|
||||||
DropField();
|
size_t resplen = 0;
|
||||||
PrintAndLogEx(FAILED, "Select application 0x%06x " _RED_("failed") " ", appid);
|
res = DesfireISOSelect(&dctx, (char *)dfname, resp, &resplen);
|
||||||
return res;
|
if (res != PM3_SUCCESS) {
|
||||||
|
DropField();
|
||||||
|
PrintAndLogEx(FAILED, "ISO Select application " _RED_("failed"));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resplen > 0)
|
||||||
|
PrintAndLogEx(FAILED, "Application " _CYAN_("FCI template") " [%zu]%s", resplen, sprint_hex(resp, resplen));
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "Application `%s` selected " _GREEN_("succesfully") " ", (char *)dfname);
|
||||||
|
} else {
|
||||||
|
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, appid, true, verbose);
|
||||||
|
if (res != PM3_SUCCESS) {
|
||||||
|
DropField();
|
||||||
|
PrintAndLogEx(FAILED, "Select application 0x%06x " _RED_("failed") " ", appid);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "Application 0x%06x selected " _GREEN_("succesfully") " ", appid);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "Application 0x%06x selected " _GREEN_("succesfully") " ", appid);
|
|
||||||
|
|
||||||
DropField();
|
DropField();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -2175,14 +2175,14 @@ int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *para
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DesfireISOSelect(DesfireContext *dctx, bool sel_by_df_name, uint8_t *id, uint8_t idlen, uint8_t *resp, size_t *resplen) {
|
int DesfireISOSelect(DesfireContext *dctx, char *dfname, uint8_t *resp, size_t *resplen) {
|
||||||
sAPDU apdu = {0};
|
sAPDU apdu = {0};
|
||||||
apdu.CLA = 0x00;
|
apdu.CLA = 0x00;
|
||||||
apdu.INS = ISO7816_SELECT_FILE;
|
apdu.INS = ISO7816_SELECT_FILE;
|
||||||
apdu.P1 = (sel_by_df_name) ? 0x04 : 0x00;
|
apdu.P1 = 0x04;
|
||||||
apdu.P2 = 0x00;
|
apdu.P2 = 0x00;
|
||||||
apdu.Lc = idlen;
|
apdu.Lc = strnlen(dfname, 16);
|
||||||
apdu.data = id;
|
apdu.data = (uint8_t *)dfname;
|
||||||
|
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = DesfireExchangeISO(true, dctx, apdu, APDU_INCLUDE_LE_00, resp, resplen, &sw);
|
int res = DesfireExchangeISO(true, dctx, apdu, APDU_INCLUDE_LE_00, resp, resplen, &sw);
|
||||||
|
|
|
@ -167,7 +167,7 @@ int DesfireReadRecords(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint
|
||||||
int DesfireWriteRecord(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *data);
|
int DesfireWriteRecord(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *data);
|
||||||
int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t offset, uint32_t len, uint8_t *data);
|
int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t offset, uint32_t len, uint8_t *data);
|
||||||
|
|
||||||
int DesfireISOSelect(DesfireContext *dctx, bool sel_by_df_name, uint8_t *id, uint8_t idlen, uint8_t *resp, size_t *resplen);
|
int DesfireISOSelect(DesfireContext *dctx, char *dfname, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireISOGetChallenge(DesfireContext *dctx, DesfireCryptoAlgorythm keytype, uint8_t *resp, size_t *resplen);
|
int DesfireISOGetChallenge(DesfireContext *dctx, DesfireCryptoAlgorythm keytype, uint8_t *resp, size_t *resplen);
|
||||||
int DesfireISOExternalAuth(DesfireContext *dctx, uint8_t keynum, DesfireCryptoAlgorythm keytype);
|
int DesfireISOExternalAuth(DesfireContext *dctx, uint8_t keynum, DesfireCryptoAlgorythm keytype);
|
||||||
int DesfireISOInternalAuth(DesfireContext *dctx, uint8_t keynum, DesfireCryptoAlgorythm keytype, uint8_t *data, uint8_t *resp, size_t *resplen);
|
int DesfireISOInternalAuth(DesfireContext *dctx, uint8_t keynum, DesfireCryptoAlgorythm keytype, uint8_t *data, uint8_t *resp, size_t *resplen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue