Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Jan 14, 2025
1 parent 6af2df5 commit 1040fa8
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 53 deletions.
30 changes: 15 additions & 15 deletions armsrc/emvsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static bool MifareSimInit(uint16_t flags, uint8_t *datain, uint16_t atqa, uint8_
rSAK[0] = block0[5];
memcpy(rATQA, &block0[6], sizeof(rATQA));
}
// Check for 7 bytes UID: double size uid bits in ATQA
// Check for 7 bytes UID: double size uid bits in ATQA
else if ((block0[8] & 0xc0) == 0x40) {
flags |= FLAG_7B_UID_IN_DATA_OLD;
memcpy(datain, block0, 7);
Expand Down Expand Up @@ -497,17 +497,17 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
break;
}

// The anti-collision sequence, which is a mandatory part of the card activation sequence.
// It auto with 4-byte UID (= Single Size UID),
// 7 -byte UID (= Double Size UID) or 10-byte UID (= Triple Size UID).
// For details see chapter 2 of AN10927.pdf
//
// This case is used for all Cascade Levels, because:
// 1) Any devices (under Android for example) after full select procedure completed,
// when UID is known, uses "fast-selection" method. In this case reader ignores
// first cascades and tries to select tag by last bytes of UID of last cascade
// 2) Any readers (like ACR122U) uses bit oriented anti-collision frames during selectin,
// same as multiple tags. For details see chapter 6.1.5.3 of ISO/IEC 14443-3
// The anti-collision sequence, which is a mandatory part of the card activation sequence.
// It auto with 4-byte UID (= Single Size UID),
// 7 -byte UID (= Double Size UID) or 10-byte UID (= Triple Size UID).
// For details see chapter 2 of AN10927.pdf
//
// This case is used for all Cascade Levels, because:
// 1) Any devices (under Android for example) after full select procedure completed,
// when UID is known, uses "fast-selection" method. In this case reader ignores
// first cascades and tries to select tag by last bytes of UID of last cascade
// 2) Any readers (like ACR122U) uses bit oriented anti-collision frames during selectin,
// same as multiple tags. For details see chapter 6.1.5.3 of ISO/IEC 14443-3
case MFEMUL_SELECT: {

int uid_index = -1;
Expand Down Expand Up @@ -591,7 +591,7 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a
break;
}

// WORK
// WORK
case MFEMUL_WORK: {

if (receivedCmd_len == 0) {
Expand Down Expand Up @@ -700,7 +700,7 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a

// We want to modify corrupted request
if ((receivedCmd_len > 5 && receivedCmd[0] != 0x03 && receivedCmd[0] != 0x02 && receivedCmd[1] == 0 && receivedCmd[4] == 0) || (receivedCmd[2] == 0xa8)) {
//if (receivedCmd[2] == 0xa8) {
//if (receivedCmd[2] == 0xa8) {
Dbprintf("We saw signing request... modifying it into a generate ac transaction !!!!");
receivedCmd[0] = 0x03;
receivedCmd[1] = 0x80;
Expand Down Expand Up @@ -752,7 +752,7 @@ void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t a

// This is minus 3 because we don't include the first byte (prepend), plus we don't want to send the
// last two bytes (CRC) to the card
CmdSmartRaw(receivedCmd_copy[0], &(receivedCmd_copy[1]), receivedCmd_len_copy-3, (&responseToReader[0]), &responseToReader_len);
CmdSmartRaw(receivedCmd_copy[0], &(receivedCmd_copy[1]), receivedCmd_len_copy - 3, (&responseToReader[0]), &responseToReader_len);
EmSendCmd(responseToReader, responseToReader_len);

Dbprintf("Sent delayed command to card...");
Expand Down
2 changes: 1 addition & 1 deletion armsrc/emvsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

void EMVsim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint16_t atqa, uint8_t sak);

#endif
#endif
29 changes: 14 additions & 15 deletions armsrc/i2c_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static uint8_t fci_template[] = {0x02, 0x6f, 0x5e, 0x84, 0x07, 0xa0, 0x00, 0x00,
static uint8_t pay1_response[] = { 0x6F, 0x1E, 0x84, 0x0E, 0x31, 0x50, 0x41, 0x59 };
static uint8_t pay2_response[] = { 0x03, 0x6f, 0x3e, 0x84, 0x0e, 0x32, 0x50, 0x41, 0x59, 0x2e, 0x53, 0x59, 0x53, 0x2e, 0x44, 0x44, 0x46, 0x30, 0x31, 0xa5, 0x2c, 0xbf, 0x0c, 0x29, 0x61, 0x27, 0x4f, 0x07, 0xa0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10, 0x50, 0x0a, 0x56, 0x69, 0x73, 0x61, 0x20, 0x44, 0x65, 0x62, 0x69, 0x74, 0x9f, 0x0a, 0x08, 0x00, 0x01, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x63, 0x04, 0xdf, 0x20, 0x01, 0x80, 0x90, 0x00, 0x07, 0x9d};

void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *output, uint16_t *olen) {
static void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *output, uint16_t *olen) {
LED_D_ON();

uint16_t len = 0;
Expand Down Expand Up @@ -85,11 +85,11 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou
LogTrace(p->data, p->len, 0, 0, NULL, true);

bool res = I2C_BufferWrite(
p->data,
p->len,
(((flags & SC_RAW_T0) == SC_RAW_T0) ? I2C_DEVICE_CMD_SEND_T0 : I2C_DEVICE_CMD_SEND),
I2C_DEVICE_ADDRESS_MAIN
);
p->data,
p->len,
(((flags & SC_RAW_T0) == SC_RAW_T0) ? I2C_DEVICE_CMD_SEND_T0 : I2C_DEVICE_CMD_SEND),
I2C_DEVICE_ADDRESS_MAIN
);

if (res == false && g_dbglevel > 3) {
//DbpString(I2C_ERROR);
Expand Down Expand Up @@ -126,7 +126,7 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou
Dbhexdump(3, &resp[0], false);
resp[0] = prepend;
resp[1] = 0x6a;
resp[2] =0x82;
resp[2] = 0x82;
AddCrc14A(resp, 3);

//Dbhexdump(5, &resp[0], false); // special print
Expand All @@ -139,7 +139,7 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou
Dbprintf("***** bad response from card (file not found)...");
resp[0] = prepend;
resp[1] = 0x6a;
resp[2] =0x82;
resp[2] = 0x82;
AddCrc14A(resp, 3);

//Dbhexdump(5, &resp[0], false); // special print
Expand Down Expand Up @@ -198,22 +198,22 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou
len = sizeof(template);
Dbhexdump(len, &template[0], false); // special print

AddCrc14A(&template[1], len-3);
AddCrc14A(&template[1], len - 3);
Dbprintf("\nafter crc rearranged is: ");
Dbhexdump(len, &template[0], false); // special print
Dbprintf("\n");

//EmSendCmd(&template[1], len-1);
memcpy(output, &template[1], len-1);
*olen = len-1;
memcpy(output, &template[1], len - 1);
*olen = len - 1;

BigBuf_free();
return;
}

//Dbhexdump(len, &resp[1], false); // special print
AddCrc14A(&resp[1], len);
Dbhexdump(len+2, &resp[1], false); // special print
Dbhexdump(len + 2, &resp[1], false); // special print

// Check we don't want to modify the response (application profile response)
//uint8_t modifyme[] = {0x03, 0x77, 0x0e, 0x82, 0x02};
Expand All @@ -230,8 +230,7 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou
//EmSendCmd(&pay2_response[0], sizeof(pay2_response));
memcpy(output, &pay2_response[0], sizeof(pay2_response));
*olen = sizeof(pay2_response);
}
else if (memcmp(&resp[1], &fci_template[0], 2) == 0 && true) {
} else if (memcmp(&resp[1], &fci_template[0], 2) == 0 && true) {
Dbprintf("***** modifying response to have full fci template...!");
//EmSendCmd(&fci_template[0], sizeof(fci_template));
memcpy(output, &fci_template[0], sizeof(fci_template));
Expand All @@ -254,7 +253,7 @@ void SmartCardDirectSend(uint8_t prepend, const smart_card_raw_t *p, uint8_t *ou

//reply_ng(CMD_SMART_RAW, PM3_SUCCESS, resp, len);

OUT:
OUT:
//BigBuf_free();
//set_tracing(false);
LEDsoff();
Expand Down
2 changes: 1 addition & 1 deletion client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
if (is_ev1) {
// hidden sectors on MFC EV1
sector_cnt += 2;

// bandaid fix
block_cnt += 8;
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/emv/cmdemv.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ static int CmdEMVSmartToNFC(const char *Cmd) {
"emv smart2nfc -t -> test that the attached card is working (must be VISA)\n");

void *argtable[] = {
arg_param_begin,
arg_lit0("t", "test", "test that the attached card is working (must be VISA)"),
arg_str0("u", "uid", "<hex>", "optional 7 hex bytes UID"),
arg_param_end
arg_param_begin,
arg_lit0("t", "test", "test that the attached card is working (must be VISA)"),
arg_str0("u", "uid", "<hex>", "optional 7 hex bytes UID"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);

Expand Down
10 changes: 8 additions & 2 deletions client/src/pm3line_vocabulary.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "emv scan" },
{ 0, "emv search" },
{ 0, "emv select" },
{ 0, "emv smart2nfc" },
{ 1, "hf help" },
{ 1, "hf list" },
{ 0, "hf plot" },
Expand Down Expand Up @@ -388,7 +389,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf mf gen3uid" },
{ 0, "hf mf gen3blk" },
{ 0, "hf mf gen3freeze" },
{ 0, "hf mf ginfo" },
{ 1, "hf mf ginfo" },
{ 0, "hf mf ggetblk" },
{ 0, "hf mf gload" },
{ 0, "hf mf gsave" },
Expand Down Expand Up @@ -493,8 +494,13 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf ntag424 changefs" },
{ 0, "hf ntag424 changekey" },
{ 1, "hf seos help" },
{ 0, "hf seos info" },
{ 1, "hf seos list" },
{ 0, "hf seos sam" },
{ 0, "hf seos info" },
{ 1, "hf seos pacs" },
{ 1, "hf seos adf" },
{ 1, "hf seos gdf" },
{ 1, "hf seos managekeys" },
{ 1, "hf st25ta help" },
{ 0, "hf st25ta info" },
{ 1, "hf st25ta list" },
Expand Down
Loading

0 comments on commit 1040fa8

Please sign in to comment.