mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
Astyle update
This commit is contained in:
parent
64c3ae8b34
commit
b66152feb2
1 changed files with 31 additions and 31 deletions
|
@ -478,7 +478,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
button_pushed = BUTTON_PRESS();
|
button_pushed = BUTTON_PRESS();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now, get data
|
//Now, get data
|
||||||
int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par);
|
int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par);
|
||||||
|
|
||||||
|
@ -756,8 +756,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
}
|
}
|
||||||
EmSendCmd(rAUTH_AT, sizeof(rAUTH_AT));
|
EmSendCmd(rAUTH_AT, sizeof(rAUTH_AT));
|
||||||
cardSTATE = MFEMUL_AUTH1;
|
cardSTATE = MFEMUL_AUTH1;
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
||||||
Dbprintf("cardSTATE = MFEMUL_AUTH1");
|
Dbprintf("cardSTATE = MFEMUL_AUTH1");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Commands must be encrypted (authenticated)");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Commands must be encrypted (authenticated)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if Cmd is Read, Write, Inc, Dec, Restore, Transfert
|
// if Cmd is Read, Write, Inc, Dec, Restore, Transfert
|
||||||
if (receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK
|
if (receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK
|
||||||
|| receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK
|
|| receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK
|
||||||
|
@ -785,21 +785,21 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD READ block
|
// CMD READ block
|
||||||
if (receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK) {
|
if (receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK) {
|
||||||
blockNo = receivedCmd_dec[1];
|
blockNo = receivedCmd_dec[1];
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Reader reading block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Reader reading block %d (0x%02x)", blockNo, blockNo);
|
||||||
emlGetMem(response, blockNo, 1);
|
emlGetMem(response, blockNo, 1);
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("Data Block: %02x%02x%02x%02x%02x%02x%02x%02x%02x", response);
|
if (MF_DBGLEVEL >= 2) Dbprintf("Data Block: %02x%02x%02x%02x%02x%02x%02x%02x%02x", response);
|
||||||
|
|
||||||
|
|
||||||
if (IsSectorTrailer(blockNo)) {
|
if (IsSectorTrailer(blockNo)) {
|
||||||
memset(response, 0x00, 6); // keyA can never be read
|
memset(response, 0x00, 6); // keyA can never be read
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyA can never be read - block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyA can never be read - block %d (0x%02x)", blockNo, blockNo);
|
||||||
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_KEYB_READ)) {
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_KEYB_READ)) {
|
||||||
memset(response + 10, 0x00, 6); // keyB cannot be read
|
memset(response + 10, 0x00, 6); // keyB cannot be read
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyB cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyB cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
||||||
}
|
}
|
||||||
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_AC_READ)) {
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_AC_READ)) {
|
||||||
memset(response + 6, 0x00, 4); // AC bits cannot be read
|
memset(response + 6, 0x00, 4); // AC bits cannot be read
|
||||||
|
@ -819,11 +819,11 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
Dbprintf("%d reads done, exiting", numReads);
|
Dbprintf("%d reads done, exiting", numReads);
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[ISO14443A_CMD_READBLOCK] Finish");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[ISO14443A_CMD_READBLOCK] Finish");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD WRITEBLOCK
|
// CMD WRITEBLOCK
|
||||||
if (receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK) {
|
if (receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK) {
|
||||||
blockNo = receivedCmd_dec[1];
|
blockNo = receivedCmd_dec[1];
|
||||||
|
@ -865,7 +865,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TRANSFER
|
// TRANSFER
|
||||||
if (receivedCmd_dec[0] == MIFARE_CMD_TRANSFER) {
|
if (receivedCmd_dec[0] == MIFARE_CMD_TRANSFER) {
|
||||||
blockNo = receivedCmd_dec[1];
|
blockNo = receivedCmd_dec[1];
|
||||||
|
@ -906,7 +906,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("MFEMUL_AUTH1: receivedCmd_len != 8 => cardSTATE_TO_IDLE())");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("MFEMUL_AUTH1: receivedCmd_len != 8 => cardSTATE_TO_IDLE())");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t nr = bytes_to_num(receivedCmd, 4);
|
uint32_t nr = bytes_to_num(receivedCmd, 4);
|
||||||
uint32_t ar = bytes_to_num(&receivedCmd[4], 4);
|
uint32_t ar = bytes_to_num(&receivedCmd[4], 4);
|
||||||
|
|
||||||
|
@ -988,14 +988,14 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
, nonce // nt
|
, nonce // nt
|
||||||
, prng_successor(nonce, 64)
|
, prng_successor(nonce, 64)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
cardAUTHKEY = AUTHKEYNONE; // not authenticated
|
|
||||||
LogTrace(Uart.output, Uart.len, Uart.startTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.endTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.parity, true);
|
|
||||||
cardSTATE_TO_IDLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cardAUTHKEY = AUTHKEYNONE; // not authenticated
|
||||||
|
LogTrace(Uart.output, Uart.len, Uart.startTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.endTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.parity, true);
|
||||||
|
cardSTATE_TO_IDLE();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ans = prng_successor(nonce, 96) ^ crypto1_word(pcs, 0, 0);
|
ans = prng_successor(nonce, 96) ^ crypto1_word(pcs, 0, 0);
|
||||||
num_to_bytes(ans, 4, rAUTH_AT);
|
num_to_bytes(ans, 4, rAUTH_AT);
|
||||||
EmSendCmd(rAUTH_AT, sizeof(rAUTH_AT));
|
EmSendCmd(rAUTH_AT, sizeof(rAUTH_AT));
|
||||||
|
@ -1008,7 +1008,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
}
|
}
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
//cardSTATE = MFEMUL_WORK;
|
//cardSTATE = MFEMUL_WORK;
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf ("cardSTATE = MFEMUL_WORK");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("cardSTATE = MFEMUL_WORK");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,7 +1095,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
} // End Switch Loop
|
} // End Switch Loop
|
||||||
|
|
||||||
button_pushed = BUTTON_PRESS();
|
button_pushed = BUTTON_PRESS();
|
||||||
|
|
||||||
} // End While Loop
|
} // End While Loop
|
||||||
|
|
||||||
|
|
||||||
|
@ -1115,7 +1115,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = ATTACK_KEY_COUNT; i < ATTACK_KEY_COUNT * 2; i++) {
|
for (uint8_t i = ATTACK_KEY_COUNT; i < ATTACK_KEY_COUNT * 2; i++) {
|
||||||
if (ar_nr_collected[i] == 2) {
|
if (ar_nr_collected[i] == 2) {
|
||||||
Dbprintf("Collected two pairs of AR/NR which can be used to extract %s from reader for sector %d:", (i < ATTACK_KEY_COUNT / 2) ? "keyA" : "keyB", ar_nr_resp[i].sector);
|
Dbprintf("Collected two pairs of AR/NR which can be used to extract %s from reader for sector %d:", (i < ATTACK_KEY_COUNT / 2) ? "keyA" : "keyB", ar_nr_resp[i].sector);
|
||||||
|
@ -1131,19 +1131,19 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MF_DBGLEVEL >= 1) {
|
if (MF_DBGLEVEL >= 1) {
|
||||||
Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen());
|
Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to be debug - Card not recognize by my phone if uncommented
|
// Need to be debug - Card not recognize by my phone if uncommented
|
||||||
//if ((flags &FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
|
//if ((flags &FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
|
||||||
//Send the collected ar_nr in the response
|
//Send the collected ar_nr in the response
|
||||||
|
|
||||||
// cmd_send(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
// cmd_send(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
set_tracing(false);
|
set_tracing(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue