This commit is contained in:
iceman1001 2020-06-10 09:02:58 +02:00
commit ea73746d32

View file

@ -119,7 +119,7 @@ static uint8_t treatPDOL(uint8_t *apdu) { //Generate GET PROCES
void RunMod(void) { void RunMod(void) {
StandAloneMode(); StandAloneMode();
Dbprintf(_YELLOW_(">>") "Reading Visa cards & Emulating a Visa MSD Transaction a.k.a. MSDSal Started<<"); DbpString(_YELLOW_(">>") "Reading Visa cards & Emulating a Visa MSD Transaction a.k.a. MSDSal Started " _YELLOW_("<<"));
FpgaDownloadAndGo(FPGA_BITSTREAM_HF); FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
//For reading process //For reading process
@ -206,10 +206,10 @@ void RunMod(void) {
//Checking if the user wants to go directly to emulation mode using a hardcoded track 2 //Checking if the user wants to go directly to emulation mode using a hardcoded track 2
if (chktoken == true && token[0] != 0x00) { if (chktoken == true && token[0] != 0x00) {
state = STATE_EMU; state = STATE_EMU;
Dbprintf(_YELLOW_("[") "Initialized emulation mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Initialized emulation mode" _YELLOW_(" ]"));
DbpString("\n"_YELLOW_("!!") "Waiting for a card reader..."); DbpString("\n"_YELLOW_("!!") "Waiting for a card reader...");
} else { } else {
DbpString(_YELLOW_("[") "Initialized reading mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
DbpString("\n"_YELLOW_("!!") "Waiting for a Visa card..."); DbpString("\n"_YELLOW_("!!") "Waiting for a Visa card...");
} }
@ -228,12 +228,12 @@ void RunMod(void) {
if (state == STATE_READ) { if (state == STATE_READ) {
if (chktoken == true && token[0] != 0x00) { //Only change to emulation if it saved a track 2 in memory if (chktoken == true && token[0] != 0x00) { //Only change to emulation if it saved a track 2 in memory
state = STATE_EMU; state = STATE_EMU;
Dbprintf(_YELLOW_("[") "In emulation mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "In emulation mode" _YELLOW_(" ]"));
} else } else
Dbprintf(_YELLOW_("!!") "Nothing in memory to emulate"); DbpString(_YELLOW_("!!") "Nothing in memory to emulate");
} else { } else {
state = STATE_READ; state = STATE_READ;
Dbprintf(_YELLOW_("[") "In reading mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "In reading mode" _YELLOW_(" ]"));
} }
} }
@ -248,7 +248,7 @@ void RunMod(void) {
if (iso14443a_select_card(NULL, &card_a_info, NULL, true, 0, false)) { if (iso14443a_select_card(NULL, &card_a_info, NULL, true, 0, false)) {
Dbprintf(_YELLOW_("+") "Found ISO 14443 Type A!"); DbpString(_YELLOW_("+") "Found ISO 14443 Type A!");
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
chktoken = false; chktoken = false;
@ -257,11 +257,11 @@ void RunMod(void) {
uint8_t apdulen = iso14_apdu(apdus[i], (uint16_t) apdusLen[i], false, apdubuffer, NULL); uint8_t apdulen = iso14_apdu(apdus[i], (uint16_t) apdusLen[i], false, apdubuffer, NULL);
if (apdulen > 0) { if (apdulen > 0) {
Dbprintf(_YELLOW_("[") "Proxmark command " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Proxmark command" _YELLOW_(" ]"));
Dbhexdump(apdusLen[i], apdus[i], false); Dbhexdump(apdusLen[i], apdus[i], false);
Dbprintf(_GREEN_("[") "Card answer " _GREEN_("]")); DbpString(_GREEN_("[ ") "Card answer" _GREEN_(" ]"));
Dbhexdump(apdulen - 2, apdubuffer, false); Dbhexdump(apdulen - 2, apdubuffer, false);
Dbprintf("----"); DbpString("----");
for (uint8_t u = 0; u < apdulen; u++) { for (uint8_t u = 0; u < apdulen; u++) {
if (i == 1) { if (i == 1) {
@ -284,24 +284,24 @@ void RunMod(void) {
} }
if (i == 1) { if (i == 1) {
Dbprintf(_GREEN_("[") "Challenge generated " _GREEN_("]")); DbpString(_GREEN_("[ ") "Challenge generated" _GREEN_(" ]"));
Dbhexdump(plen, existpdol ? ppdol : processing, false); Dbhexdump(plen, existpdol ? ppdol : processing, false);
} }
} else { } else {
Dbprintf(_YELLOW_("!!") "Error reading the card"); DbpString(_YELLOW_("!!") "Error reading the card");
} }
LED_B_OFF(); LED_B_OFF();
} }
if (chktoken) { if (chktoken) {
Dbprintf(_RED_("[") "Track 2 " _RED_("]")); DbpString(_RED_("[ ") "Track 2" _RED_(" ]"));
Dbhexdump(19, (uint8_t *)token, false); Dbhexdump(19, (uint8_t *)token, false);
Dbprintf(_YELLOW_("!!") "Card number"); DbpString(_YELLOW_("!!") "Card number");
Dbhexdump(8, (uint8_t *)token, false); Dbhexdump(8, (uint8_t *)token, false);
DbpString("---"); DbpString("---");
LED_C_ON(); LED_C_ON();
state = STATE_EMU; state = STATE_EMU;
Dbprintf(_YELLOW_("[") "Initialized emulation mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Initialized emulation mode" _YELLOW_(" ]"));
DbpString("\n"_YELLOW_("!!") "Waiting for a card reader..."); DbpString("\n"_YELLOW_("!!") "Waiting for a card reader...");
} }
} }
@ -318,7 +318,7 @@ void RunMod(void) {
DbpString(_YELLOW_("!!") "Error initializing the emulation process!"); DbpString(_YELLOW_("!!") "Error initializing the emulation process!");
SpinDelay(500); SpinDelay(500);
state = STATE_READ; state = STATE_READ;
DbpString(_YELLOW_("[") "Initialized reading mode " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
DbpString("\n" _YELLOW_("!!") "Waiting for a Visa card..."); DbpString("\n" _YELLOW_("!!") "Waiting for a Visa card...");
break; break;
} }
@ -336,7 +336,7 @@ void RunMod(void) {
LED_B_OFF(); LED_B_OFF();
// Clean receive command buffer // Clean receive command buffer
if (!GetIso14443aCommandFromReader(receivedCmd, receivedCmdPar, &len)) { if (!GetIso14443aCommandFromReader(receivedCmd, receivedCmdPar, &len)) {
Dbprintf(_YELLOW_("!!") "Emulator stopped"); DbpString(_YELLOW_("!!") "Emulator stopped");
retval = PM3_EOPABORTED; retval = PM3_EOPABORTED;
break; break;
} }
@ -367,7 +367,7 @@ void RunMod(void) {
DbpString(_YELLOW_("+") "Request for RATS"); DbpString(_YELLOW_("+") "Request for RATS");
p_response = &responses[RATS]; p_response = &responses[RATS];
} else { } else {
Dbprintf(_YELLOW_("[") "Card reader command " _YELLOW_("]")); DbpString(_YELLOW_("[ ") "Card reader command" _YELLOW_(" ]"));
Dbhexdump(len, receivedCmd, false); Dbhexdump(len, receivedCmd, false);
if (receivedCmd[0] == 0x02 || receivedCmd[0] == 0x03) { //Emulate a Visa MSD(Magnetic stripe data) card if (receivedCmd[0] == 0x02 || receivedCmd[0] == 0x03) { //Emulate a Visa MSD(Magnetic stripe data) card
@ -408,7 +408,7 @@ void RunMod(void) {
} }
} }
} else { } else {
Dbprintf(_YELLOW_("!!") "Received unknown command!"); DbpString(_YELLOW_("!!") "Received unknown command!");
if (prevCmd < 4) { if (prevCmd < 4) {
memcpy(dynamic_response_info.response, receivedCmd, len); memcpy(dynamic_response_info.response, receivedCmd, len);
dynamic_response_info.response_n = len; dynamic_response_info.response_n = len;
@ -418,9 +418,9 @@ void RunMod(void) {
} }
} }
if (dynamic_response_info.response_n > 0) { if (dynamic_response_info.response_n > 0) {
Dbprintf(_GREEN_("[") "Proxmark3 answer " _GREEN_("]")); DbpString(_GREEN_("[ ") "Proxmark3 answer" _GREEN_(" ]"));
Dbhexdump(dynamic_response_info.response_n, dynamic_response_info.response, false); Dbhexdump(dynamic_response_info.response_n, dynamic_response_info.response, false);
Dbprintf("----"); DbpString("----");
// Add CRC bytes, always used in ISO 14443A-4 compliant cards // Add CRC bytes, always used in ISO 14443A-4 compliant cards
AddCrc14A(dynamic_response_info.response, dynamic_response_info.response_n); AddCrc14A(dynamic_response_info.response, dynamic_response_info.response_n);