mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-11 01:55:38 +08:00
commit
d1bbab7dc4
3 changed files with 54 additions and 27 deletions
|
@ -292,7 +292,10 @@ static int PrintATR(uint8_t *atr, size_t atrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool smart_select(bool silent) {
|
||||
bool smart_select(bool silent, smart_card_atr_t *atr) {
|
||||
if (atr)
|
||||
memset(atr, 0, sizeof(smart_card_atr_t));
|
||||
|
||||
UsbCommand c = {CMD_SMART_ATR, {0, 0, 0}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -308,12 +311,14 @@ static bool smart_select(bool silent) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
smart_card_atr_t card;
|
||||
memcpy(&card, (smart_card_atr_t *)resp.d.asBytes, sizeof(smart_card_atr_t));
|
||||
|
||||
smart_card_atr_t card;
|
||||
memcpy(&card, (smart_card_atr_t *)resp.d.asBytes, sizeof(smart_card_atr_t));
|
||||
|
||||
if (atr)
|
||||
memcpy(atr, &card, sizeof(smart_card_atr_t));
|
||||
|
||||
if (!silent)
|
||||
PrintAndLogEx(INFO, "ISO7816-3 ATR : %s", sprint_hex(card.atr, card.atr_len));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -518,7 +523,7 @@ int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leave
|
|||
*dataoutlen = 0;
|
||||
|
||||
if (activateCard)
|
||||
smart_select(false);
|
||||
smart_select(false, NULL);
|
||||
|
||||
PrintAndLogEx(DEBUG, "APDU SC");
|
||||
|
||||
|
@ -1017,7 +1022,7 @@ int CmdSmartBruteforceSFI(const char *Cmd) {
|
|||
return 1;
|
||||
|
||||
PrintAndLogEx(INFO, "Selecting card");
|
||||
if ( !smart_select(false) )
|
||||
if ( !smart_select(false, NULL) )
|
||||
return 1;
|
||||
|
||||
char* caid = NULL;
|
||||
|
|
|
@ -33,6 +33,7 @@ extern int CmdSmartUpgrade(const char* cmd);
|
|||
extern int CmdSmartInfo(const char* cmd);
|
||||
extern int CmdSmartReader(const char *Cmd);
|
||||
|
||||
extern bool smart_select(bool silent, smart_card_atr_t *atr);
|
||||
extern int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||
|
||||
extern int usage_sm_raw(void);
|
||||
|
|
|
@ -792,6 +792,14 @@ int CmdEMVExec(const char *cmd) {
|
|||
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;
|
||||
CLIParserFree();
|
||||
|
||||
#ifndef WITH_SMARTCARD
|
||||
// not compiled with smartcard functionality, we need to exit
|
||||
if ( channel == ECC_CONTACT ) {
|
||||
PrintAndLogEx(WARNING, "PM3 Client is not compiled with support for SMARTCARD. Exiting.");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetAPDULogging(showAPDU);
|
||||
|
||||
// init applets list tree
|
||||
|
@ -1380,13 +1388,15 @@ int CmdEMVScan(const char *cmd) {
|
|||
CLIGetStrWithReturn(12, relfname, &relfnamelen);
|
||||
CLIParserFree();
|
||||
|
||||
SetAPDULogging(showAPDU);
|
||||
|
||||
// TODO
|
||||
if (channel == ECC_CONTACT) {
|
||||
PrintAndLogEx(ERR, "Do not use contact interface. Exit.");
|
||||
return 1;
|
||||
#ifndef WITH_SMARTCARD
|
||||
// not compiled with smartcard functionality, we need to exit
|
||||
if ( channel == ECC_CONTACT ) {
|
||||
PrintAndLogEx(WARNING, "PM3 Client is not compiled with support for SMARTCARD. Exiting.");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetAPDULogging(showAPDU);
|
||||
|
||||
// current path + file name
|
||||
if (!strstr(crelfname, ".json"))
|
||||
|
@ -1413,21 +1423,31 @@ int CmdEMVScan(const char *cmd) {
|
|||
// drop field at start
|
||||
DropFieldEx( channel );
|
||||
|
||||
// iso 14443 select
|
||||
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
|
||||
|
||||
iso14a_card_select_t card;
|
||||
if (Hf14443_4aGetCardData(&card)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
JsonSaveStr(root, "$.File.Created", "proxmark3 `emv scan`");
|
||||
|
||||
JsonSaveStr(root, "$.Card.Communication", "iso14443-4a");
|
||||
JsonSaveBufAsHex(root, "$.Card.UID", (uint8_t *)&card.uid, card.uidlen);
|
||||
JsonSaveHex(root, "$.Card.ATQA", card.atqa[0] + (card.atqa[1] << 2), 2);
|
||||
JsonSaveHex(root, "$.Card.SAK", card.sak, 0);
|
||||
JsonSaveBufAsHex(root, "$.Card.ATS", (uint8_t *)card.ats, card.ats_len);
|
||||
if (channel == ECC_CONTACTLESS) {
|
||||
// iso 14443 select
|
||||
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
|
||||
|
||||
iso14a_card_select_t card;
|
||||
if (Hf14443_4aGetCardData(&card)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
JsonSaveStr(root, "$.Card.Contactless.Communication", "iso14443-4a");
|
||||
JsonSaveBufAsHex(root, "$.Card.Contactless.UID", (uint8_t *)&card.uid, card.uidlen);
|
||||
JsonSaveHex(root, "$.Card.Contactless.ATQA", card.atqa[0] + (card.atqa[1] << 2), 2);
|
||||
JsonSaveHex(root, "$.Card.Contactless.SAK", card.sak, 0);
|
||||
JsonSaveBufAsHex(root, "$.Card.Contactless.ATS", (uint8_t *)card.ats, card.ats_len);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "--> GET ATR.");
|
||||
|
||||
smart_card_atr_t card;
|
||||
smart_select(true, &card);
|
||||
|
||||
JsonSaveStr(root, "$.Card.Contact.Communication", "iso7816");
|
||||
JsonSaveBufAsHex(root, "$.Card.Contact.ATR", (uint8_t *)card.atr, card.atr_len);
|
||||
}
|
||||
|
||||
// init applets list tree
|
||||
const char *al = "Applets list";
|
||||
|
@ -1695,6 +1715,7 @@ int CmdEMVRoca(const char *cmd) {
|
|||
if (arg_get_lit(2))
|
||||
channel = ECC_CONTACT;
|
||||
PrintChannel(channel);
|
||||
CLIParserFree();
|
||||
|
||||
#ifndef WITH_SMARTCARD
|
||||
// not compiled with smartcard functionality, we need to exit
|
||||
|
|
Loading…
Reference in a new issue