mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 14:23:50 -07:00
working still
This commit is contained in:
parent
973350cb6d
commit
305534dd32
1 changed files with 33 additions and 27 deletions
|
@ -825,7 +825,7 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
uint32_t cuid = 0, authTimer = 0;
|
uint32_t cuid = 0, authTimer = 0;
|
||||||
uint32_t nr, ar;
|
uint32_t nr, ar;
|
||||||
//uint8_t blockNo;
|
//uint8_t blockNo;
|
||||||
bool encrypted_data;
|
//bool encrypted_data;
|
||||||
|
|
||||||
uint8_t cardWRBL = 0;
|
uint8_t cardWRBL = 0;
|
||||||
uint8_t cardAUTHSC = 0;
|
uint8_t cardAUTHSC = 0;
|
||||||
|
@ -1129,15 +1129,16 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
encrypted_data = (cardAUTHKEY != AUTHKEYNONE);
|
//encrypted_data = (cardAUTHKEY != AUTHKEYNONE);
|
||||||
if (encrypted_data) {
|
//if (encrypted_data) {
|
||||||
Dbprintf("[MFEMUL_WORK] Not expecting encrypted data. Quitting");
|
// Dbprintf("[MFEMUL_WORK] Not expecting encrypted data. Quitting");
|
||||||
break;
|
// break;
|
||||||
} else {
|
//} else {
|
||||||
// Data in clear
|
// // Data in clear
|
||||||
memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len);
|
// memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len);
|
||||||
// Dbprintf("001 [MFEMUL_WORK] Data in clear(!!)"); // huuton disable comment
|
// // Dbprintf("001 [MFEMUL_WORK] Data in clear(!!)"); // huuton disable comment
|
||||||
}
|
//}
|
||||||
|
memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len);
|
||||||
|
|
||||||
// all commands must have a valid CRC
|
// all commands must have a valid CRC
|
||||||
if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) {
|
if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) {
|
||||||
|
@ -1224,7 +1225,8 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
// BUT... ACK --> NACK
|
// BUT... ACK --> NACK
|
||||||
if (receivedCmd_len == 1 && receivedCmd_dec[0] == CARD_ACK) {
|
if (receivedCmd_len == 1 && receivedCmd_dec[0] == CARD_ACK) {
|
||||||
Dbprintf("[MFEMUL_WORK] ACK --> NACK !!");
|
Dbprintf("[MFEMUL_WORK] ACK --> NACK !!");
|
||||||
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
//EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
||||||
|
EmSend4bit(CARD_NACK_NA);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1232,7 +1234,8 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
// rule 12 of 7.5.3. in ISO 14443-4. R(NAK) --> R(ACK)
|
// rule 12 of 7.5.3. in ISO 14443-4. R(NAK) --> R(ACK)
|
||||||
if (receivedCmd_len == 1 && receivedCmd_dec[0] == CARD_NACK_NA) {
|
if (receivedCmd_len == 1 && receivedCmd_dec[0] == CARD_NACK_NA) {
|
||||||
Dbprintf("[MFEMUL_WORK] NACK --> NACK !!");
|
Dbprintf("[MFEMUL_WORK] NACK --> NACK !!");
|
||||||
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_ACK) : CARD_ACK);
|
//EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_ACK) : CARD_ACK);
|
||||||
|
EmSend4bit(CARD_ACK);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1482,18 +1485,20 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
// case MFEMUL_WORK => CMD RATS
|
// case MFEMUL_WORK => CMD RATS
|
||||||
if (receivedCmd_len == 4 && receivedCmd_dec[0] == ISO14443A_CMD_RATS && receivedCmd_dec[1] == 0x80) {
|
if (receivedCmd_len == 4 && receivedCmd_dec[0] == ISO14443A_CMD_RATS && receivedCmd_dec[1] == 0x80) {
|
||||||
if (rats && rats_len) {
|
if (rats && rats_len) {
|
||||||
if (encrypted_data) {
|
//if (encrypted_data) {
|
||||||
memcpy(response, rats, rats_len);
|
// memcpy(response, rats, rats_len);
|
||||||
mf_crypto1_encrypt(pcs, response, rats_len, response_par);
|
// mf_crypto1_encrypt(pcs, response, rats_len, response_par);
|
||||||
EmSendCmdPar(response, rats_len, response_par);
|
// EmSendCmdPar(response, rats_len, response_par);
|
||||||
} else {
|
//} else {
|
||||||
EmSendCmd(rats, rats_len);
|
// EmSendCmd(rats, rats_len);
|
||||||
}
|
//}
|
||||||
|
EmSendCmd(rats, rats_len);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
//if (999 >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] RCV RATS => ACK"); // nathan print
|
//if (999 >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] RCV RATS => ACK"); // nathan print
|
||||||
} else {
|
} else {
|
||||||
Dbprintf("Rats and rats len is: %d, %d", rats[0], rats_len);
|
Dbprintf("Rats and rats len is: %d, %d", rats[0], rats_len);
|
||||||
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
//EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
||||||
|
EmSend4bit(CARD_NACK_NA);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
cardSTATE_TO_IDLE();
|
cardSTATE_TO_IDLE();
|
||||||
if (999 >= DBG_EXTENDED)
|
if (999 >= DBG_EXTENDED)
|
||||||
|
@ -1506,18 +1511,19 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
|
||||||
if (receivedCmd_len == 3 && receivedCmd_dec[0] == ISO14443A_CMD_NXP_DESELECT) {
|
if (receivedCmd_len == 3 && receivedCmd_dec[0] == ISO14443A_CMD_NXP_DESELECT) {
|
||||||
if (rats && rats_len) {
|
if (rats && rats_len) {
|
||||||
// response back NXP_DESELECT
|
// response back NXP_DESELECT
|
||||||
if (encrypted_data) {
|
//if (encrypted_data) {
|
||||||
memcpy(response, receivedCmd_dec, receivedCmd_len);
|
// memcpy(response, receivedCmd_dec, receivedCmd_len);
|
||||||
mf_crypto1_encrypt(pcs, response, receivedCmd_len, response_par);
|
// mf_crypto1_encrypt(pcs, response, receivedCmd_len, response_par);
|
||||||
EmSendCmdPar(response, receivedCmd_len, response_par);
|
// EmSendCmdPar(response, receivedCmd_len, response_par);
|
||||||
} else
|
//} else
|
||||||
EmSendCmd(receivedCmd_dec, receivedCmd_len);
|
EmSendCmd(receivedCmd_dec, receivedCmd_len);
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
if (999 >= DBG_EXTENDED)
|
if (999 >= DBG_EXTENDED)
|
||||||
Dbprintf("[MFEMUL_WORK] RCV NXP DESELECT => ACK");
|
Dbprintf("[MFEMUL_WORK] RCV NXP DESELECT => ACK");
|
||||||
} else {
|
} else {
|
||||||
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
//EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
||||||
|
EmSend4bit(CARD_NACK_NA);
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
cardSTATE_TO_IDLE();
|
cardSTATE_TO_IDLE();
|
||||||
if (999 >= DBG_EXTENDED)
|
if (999 >= DBG_EXTENDED)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue