mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-22 08:16:16 +08:00
app select works
This commit is contained in:
parent
8319953ad7
commit
cefad27487
|
@ -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("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, "dfname", "<df name str>", "Application DF Name (string, max 16 chars). Selects application via ISO SELECT command"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
|
@ -3068,18 +3069,39 @@ static int CmdHF14ADesSelectApp(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t dfname[32] = {0};
|
||||
int dfnamelen = 16;
|
||||
CLIGetStrWithReturn(ctx, 12, dfname, &dfnamelen);
|
||||
|
||||
SetAPDULogging(APDULogging);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
res = DesfireSelectAndAuthenticateEx(&dctx, securechann, appid, true, verbose);
|
||||
if (res != PM3_SUCCESS) {
|
||||
DropField();
|
||||
PrintAndLogEx(FAILED, "Select application 0x%06x " _RED_("failed") " ", appid);
|
||||
return res;
|
||||
if (dfnamelen > 0) { // dctx.cmdSet == DCCISO ?
|
||||
uint8_t resp[250] = {0};
|
||||
size_t resplen = 0;
|
||||
res = DesfireISOSelect(&dctx, (char *)dfname, resp, &resplen);
|
||||
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();
|
||||
return res;
|
||||
|
|
|
@ -2175,14 +2175,14 @@ int DesfireSetConfiguration(DesfireContext *dctx, uint8_t paramid, uint8_t *para
|
|||
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};
|
||||
apdu.CLA = 0x00;
|
||||
apdu.INS = ISO7816_SELECT_FILE;
|
||||
apdu.P1 = (sel_by_df_name) ? 0x04 : 0x00;
|
||||
apdu.P1 = 0x04;
|
||||
apdu.P2 = 0x00;
|
||||
apdu.Lc = idlen;
|
||||
apdu.data = id;
|
||||
apdu.Lc = strnlen(dfname, 16);
|
||||
apdu.data = (uint8_t *)dfname;
|
||||
|
||||
uint16_t sw = 0;
|
||||
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 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 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);
|
||||
|
|
Loading…
Reference in a new issue