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