mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
style
This commit is contained in:
parent
8d6bde0d63
commit
ffa3e2a0f8
5 changed files with 72 additions and 72 deletions
|
@ -54,15 +54,15 @@ void RunMod() {
|
||||||
|
|
||||||
// Was our button held down or pressed?
|
// Was our button held down or pressed?
|
||||||
int button_pressed = BUTTON_HELD(280);
|
int button_pressed = BUTTON_HELD(280);
|
||||||
if ( button_pressed != BUTTON_HOLD )
|
if (button_pressed != BUTTON_HOLD)
|
||||||
continue;
|
continue;
|
||||||
/*
|
/*
|
||||||
#define BUTTON_NO_CLICK 0
|
#define BUTTON_NO_CLICK 0
|
||||||
#define BUTTON_SINGLE_CLICK -1
|
#define BUTTON_SINGLE_CLICK -1
|
||||||
#define BUTTON_DOUBLE_CLICK -2
|
#define BUTTON_DOUBLE_CLICK -2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( state == STATE_READ ) {
|
if (state == STATE_READ) {
|
||||||
|
|
||||||
if (selected == 0) {
|
if (selected == 0) {
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
@ -89,17 +89,17 @@ void RunMod() {
|
||||||
Dbprintf("[=] recorded %x | %x%08x", selected, high[selected], low[selected]);
|
Dbprintf("[=] recorded %x | %x%08x", selected, high[selected], low[selected]);
|
||||||
|
|
||||||
// got nothing. blink and loop.
|
// got nothing. blink and loop.
|
||||||
if ( hi == 0 && lo == 0 ) {
|
if (hi == 0 && lo == 0) {
|
||||||
SpinErr( (selected == 0) ? LED_A : LED_B, 100, 12);
|
SpinErr((selected == 0) ? LED_A : LED_B, 100, 12);
|
||||||
DbpString("[=] only got zeros, retry recording after click");
|
DbpString("[=] only got zeros, retry recording after click");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinErr( (selected == 0) ? LED_A : LED_B, 250, 2);
|
SpinErr((selected == 0) ? LED_A : LED_B, 250, 2);
|
||||||
state = STATE_SIM;
|
state = STATE_SIM;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if ( state == STATE_SIM ) {
|
} else if (state == STATE_SIM) {
|
||||||
|
|
||||||
LED_C_ON(); // Simulate
|
LED_C_ON(); // Simulate
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
@ -113,11 +113,11 @@ void RunMod() {
|
||||||
DbpString("[=] simulating done");
|
DbpString("[=] simulating done");
|
||||||
|
|
||||||
uint8_t leds = ((selected == 0) ? LED_A : LED_B) | LED_C;
|
uint8_t leds = ((selected == 0) ? LED_A : LED_B) | LED_C;
|
||||||
SpinErr( leds , 250, 2);
|
SpinErr(leds, 250, 2);
|
||||||
state = STATE_CLONE;
|
state = STATE_CLONE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else if ( state == STATE_CLONE ) {
|
} else if (state == STATE_CLONE) {
|
||||||
|
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_ON(); // clone
|
LED_D_ON(); // clone
|
||||||
|
@ -138,7 +138,7 @@ void RunMod() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinErr( (LED_A | LED_B | LED_C | LED_D), 250, 5);
|
SpinErr((LED_A | LED_B | LED_C | LED_D), 250, 5);
|
||||||
DbpString("[=] You can take shell back :) ...");
|
DbpString("[=] You can take shell back :) ...");
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
}
|
}
|
||||||
|
|
|
@ -962,7 +962,7 @@ void RAMFUNC SniffIClass(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
uint8_t tag_byte = ((previous_data & 0xF) << 4 ) | (*data & 0xF);
|
uint8_t tag_byte = ((previous_data & 0xF) << 4) | (*data & 0xF);
|
||||||
if (ManchesterDecoding_iclass(tag_byte)) {
|
if (ManchesterDecoding_iclass(tag_byte)) {
|
||||||
time_stop = GetCountSspClk() - time_0;
|
time_stop = GetCountSspClk() - time_0;
|
||||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false);
|
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false);
|
||||||
|
@ -976,12 +976,12 @@ void RAMFUNC SniffIClass(void) {
|
||||||
}
|
}
|
||||||
} // end main loop
|
} // end main loop
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (DBGLEVEL >= 1) {
|
if (DBGLEVEL >= 1) {
|
||||||
DbpString("[+] Sniff statistics:");
|
DbpString("[+] Sniff statistics:");
|
||||||
Dbhexdump(ICLASS_DMA_BUFFER_SIZE, data, false);
|
Dbhexdump(ICLASS_DMA_BUFFER_SIZE, data, false);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
switch_off();
|
switch_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1522,7 +1522,7 @@ int doIClassSimulation(int simulationMode, uint8_t *reader_mac_buf) {
|
||||||
trace_data = csn_data;
|
trace_data = csn_data;
|
||||||
trace_data_size = sizeof(csn_data);
|
trace_data_size = sizeof(csn_data);
|
||||||
goto send;
|
goto send;
|
||||||
} else if (cmd == ICLASS_CMD_READCHECK ) { // 0x88
|
} else if (cmd == ICLASS_CMD_READCHECK) { // 0x88
|
||||||
// Read e-purse KD (88 02) KC (18 02)
|
// Read e-purse KD (88 02) KC (18 02)
|
||||||
modulated_response = resp_cc;
|
modulated_response = resp_cc;
|
||||||
modulated_response_size = resp_cc_len; //order = 4;
|
modulated_response_size = resp_cc_len; //order = 4;
|
||||||
|
@ -1898,7 +1898,7 @@ bool sendCmdGetResponseWithRetries(uint8_t *command, size_t cmdsize, uint8_t *re
|
||||||
|
|
||||||
// update/write command takes 4ms to 15ms before responding
|
// update/write command takes 4ms to 15ms before responding
|
||||||
int old_wait = g_wait;
|
int old_wait = g_wait;
|
||||||
if ( (command[0] & 0xF) == ICLASS_CMD_UPDATE)
|
if ((command[0] & 0xF) == ICLASS_CMD_UPDATE)
|
||||||
g_wait = 3900;
|
g_wait = 3900;
|
||||||
|
|
||||||
uint8_t got_n = ReaderReceiveIClass(resp);
|
uint8_t got_n = ReaderReceiveIClass(resp);
|
||||||
|
@ -1952,7 +1952,7 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) {
|
||||||
ReaderTransmitIClass(identify, 1);
|
ReaderTransmitIClass(identify, 1);
|
||||||
|
|
||||||
//We expect a 10-byte response here, 8 byte anticollision-CSN and 2 byte CRC
|
//We expect a 10-byte response here, 8 byte anticollision-CSN and 2 byte CRC
|
||||||
if ( ReaderReceiveIClass(resp) != 10 )
|
if (ReaderReceiveIClass(resp) != 10)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//Copy the Anti-collision CSN to our select-packet
|
//Copy the Anti-collision CSN to our select-packet
|
||||||
|
@ -1962,10 +1962,10 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) {
|
||||||
ReaderTransmitIClass(select, sizeof(select));
|
ReaderTransmitIClass(select, sizeof(select));
|
||||||
|
|
||||||
//We expect a 10-byte response here, 8 byte CSN and 2 byte CRC
|
//We expect a 10-byte response here, 8 byte CSN and 2 byte CRC
|
||||||
if ( ReaderReceiveIClass(resp) != 10)
|
if (ReaderReceiveIClass(resp) != 10)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Card selected, now read e-purse (cc) (block2) (only 8 bytes no CRC)
|
// Card selected, now read e-purse (cc) (block2) (only 8 bytes no CRC)
|
||||||
// ReaderTransmitIClass(readcheck_cc, sizeof(readcheck_cc));
|
// ReaderTransmitIClass(readcheck_cc, sizeof(readcheck_cc));
|
||||||
// if (ReaderReceiveIClass(resp) == 8) {
|
// if (ReaderReceiveIClass(resp) == 8) {
|
||||||
// //Save CC (e-purse) in response data
|
// //Save CC (e-purse) in response data
|
||||||
|
@ -1980,7 +1980,7 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key) {
|
||||||
bool isBlk_2 = sendCmdGetResponseWithRetries(readcheck_cc, sizeof(readcheck_cc), resp, 8, 3);
|
bool isBlk_2 = sendCmdGetResponseWithRetries(readcheck_cc, sizeof(readcheck_cc), resp, 8, 3);
|
||||||
|
|
||||||
//Flag that we got to at least stage 1, read CSN
|
//Flag that we got to at least stage 1, read CSN
|
||||||
if ( isBlk_2 == false) {
|
if (isBlk_2 == false) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2283,7 +2283,7 @@ void iClass_Authentication(uint8_t *mac) {
|
||||||
|
|
||||||
// 6 retries
|
// 6 retries
|
||||||
uint8_t isOK = sendCmdGetResponseWithRetries(check, sizeof(check), resp, 4, 6);
|
uint8_t isOK = sendCmdGetResponseWithRetries(check, sizeof(check), resp, 4, 6);
|
||||||
reply_ng(CMD_HF_ICLASS_AUTH, PM3_SUCCESS, (uint8_t*)&isOK ,sizeof(uint8_t));
|
reply_ng(CMD_HF_ICLASS_AUTH, PM3_SUCCESS, (uint8_t *)&isOK, sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct iclass_premac {
|
typedef struct iclass_premac {
|
||||||
|
@ -2460,7 +2460,7 @@ bool iClass_WriteBlock_ext(uint8_t blockno, uint8_t *data) {
|
||||||
void iClass_WriteBlock(uint8_t blockno, uint8_t *data) {
|
void iClass_WriteBlock(uint8_t blockno, uint8_t *data) {
|
||||||
uint8_t isOK = iClass_WriteBlock_ext(blockno, data);
|
uint8_t isOK = iClass_WriteBlock_ext(blockno, data);
|
||||||
switch_off();
|
switch_off();
|
||||||
reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_SUCCESS, (uint8_t*)&isOK, sizeof(uint8_t));
|
reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_SUCCESS, (uint8_t *)&isOK, sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn off afterwards
|
// turn off afterwards
|
||||||
|
|
|
@ -2000,15 +2000,15 @@ void MifareCIdent() {
|
||||||
|
|
||||||
if (ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
if (ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
||||||
|
|
||||||
ReaderTransmit(wupC2, sizeof(wupC2), NULL);
|
ReaderTransmit(wupC2, sizeof(wupC2), NULL);
|
||||||
|
|
||||||
if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
if (!ReaderReceive(rec, recpar) || (rec[0] != 0x0a)) {
|
||||||
isGen = GEN_1B;
|
isGen = GEN_1B;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
};
|
};
|
||||||
isGen = GEN_1A;
|
isGen = GEN_1A;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset card
|
// reset card
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
@ -2017,7 +2017,7 @@ void MifareCIdent() {
|
||||||
|
|
||||||
int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true);
|
int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true);
|
||||||
if (res == 2) {
|
if (res == 2) {
|
||||||
Dbprintf("cident AA55C396 == %08X", cuid);
|
Dbprintf("cident AA55C396 == %08X", cuid);
|
||||||
if (cuid == 0xAA55C396) {
|
if (cuid == 0xAA55C396) {
|
||||||
isGen = GEN_UNFUSED;
|
isGen = GEN_UNFUSED;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
|
|
|
@ -95,7 +95,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
// Error
|
// Error
|
||||||
if (++warnings > 10) {
|
if (++warnings > 10) {
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_EXTENDED )
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
Dbprintf("Error: too many detection errors, aborting.");
|
Dbprintf("Error: too many detection errors, aborting.");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -139,9 +139,9 @@ bool IsBlock0PCF7931(uint8_t *block) {
|
||||||
// if PAC is enabled password is set to 0
|
// if PAC is enabled password is set to 0
|
||||||
if (block[7] == 0x01) {
|
if (block[7] == 0x01) {
|
||||||
if (!memcmp(block, "\x00\x00\x00\x00\x00\x00\x00", 7)
|
if (!memcmp(block, "\x00\x00\x00\x00\x00\x00\x00", 7)
|
||||||
&& !memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) {
|
&& !memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (block[7] == 0x00) {
|
} else if (block[7] == 0x00) {
|
||||||
if (!memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) {
|
if (!memcmp(block + 9, "\x00\x00\x00\x00\x00\x00\x00", 7)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -158,14 +158,14 @@ bool IsBlock1PCF7931(uint8_t *block) {
|
||||||
uint8_t rlb = block[15];
|
uint8_t rlb = block[15];
|
||||||
|
|
||||||
if (block[10] == 0
|
if (block[10] == 0
|
||||||
&& block[11] == 0
|
&& block[11] == 0
|
||||||
&& block[12] == 0
|
&& block[12] == 0
|
||||||
&& block[13] == 0) {
|
&& block[13] == 0) {
|
||||||
// block 1 is sent only if (RLB >= 1 && RFB <= 1) or RB1 enabled
|
// block 1 is sent only if (RLB >= 1 && RFB <= 1) or RB1 enabled
|
||||||
if (rfb <= rlb
|
if (rfb <= rlb
|
||||||
&& rfb <= 9
|
&& rfb <= 9
|
||||||
&& rlb <= 9
|
&& rlb <= 9
|
||||||
&& ((rfb <= 1 && rlb >= 1) || rb1)) {
|
&& ((rfb <= 1 && rlb >= 1) || rb1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ void ReadPCF7931() {
|
||||||
// exit if no block is received
|
// exit if no block is received
|
||||||
if (errors >= 10 && found_blocks == 0 && single_blocks_cnt == 0) {
|
if (errors >= 10 && found_blocks == 0 && single_blocks_cnt == 0) {
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_INFO )
|
if (DBGLEVEL >= DBG_INFO)
|
||||||
Dbprintf("[!!] Error, no tag or bad tag");
|
Dbprintf("[!!] Error, no tag or bad tag");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -211,7 +211,7 @@ void ReadPCF7931() {
|
||||||
// exit if too many errors during reading
|
// exit if too many errors during reading
|
||||||
if (tries > 50 && (2 * errors > tries)) {
|
if (tries > 50 && (2 * errors > tries)) {
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_INFO )
|
if (DBGLEVEL >= DBG_INFO)
|
||||||
Dbprintf("[!!] Error reading the tag, only partial content");
|
Dbprintf("[!!] Error reading the tag, only partial content");
|
||||||
|
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -242,7 +242,7 @@ void ReadPCF7931() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_EXTENDED )
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
Dbprintf("(dbg) got %d blocks (%d/%d found) (%d tries, %d errors)", n, found_blocks, (max_blocks == 0 ? found_blocks : max_blocks), tries, errors);
|
Dbprintf("(dbg) got %d blocks (%d/%d found) (%d tries, %d errors)", n, found_blocks, (max_blocks == 0 ? found_blocks : max_blocks), tries, errors);
|
||||||
|
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
|
@ -306,7 +306,7 @@ void ReadPCF7931() {
|
||||||
}
|
}
|
||||||
++tries;
|
++tries;
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
if ( DBGLEVEL >= DBG_EXTENDED)
|
if (DBGLEVEL >= DBG_EXTENDED)
|
||||||
Dbprintf("Button pressed, stopping.");
|
Dbprintf("Button pressed, stopping.");
|
||||||
|
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -421,7 +421,7 @@ static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int3
|
||||||
*/
|
*/
|
||||||
void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
|
void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, uint8_t pass5, uint8_t pass6, uint8_t pass7, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_INFO ) {
|
if (DBGLEVEL >= DBG_INFO) {
|
||||||
Dbprintf("Initialization delay : %d us", init_delay);
|
Dbprintf("Initialization delay : %d us", init_delay);
|
||||||
Dbprintf("Offsets : %d us on the low pulses width, %d us on the low pulses positions", l, p);
|
Dbprintf("Offsets : %d us on the low pulses width, %d us on the low pulses positions", l, p);
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ void WritePCF7931(uint8_t pass1, uint8_t pass2, uint8_t pass3, uint8_t pass4, ui
|
||||||
void SendCmdPCF7931(uint32_t *tab) {
|
void SendCmdPCF7931(uint32_t *tab) {
|
||||||
uint16_t u = 0, tempo = 0;
|
uint16_t u = 0, tempo = 0;
|
||||||
|
|
||||||
if ( DBGLEVEL >= DBG_INFO ) {
|
if (DBGLEVEL >= DBG_INFO) {
|
||||||
Dbprintf("Sending data frame...");
|
Dbprintf("Sending data frame...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ uint32_t RAMFUNC GetCountSspClk(void) {
|
||||||
|
|
||||||
uint32_t RAMFUNC GetCountSspClkDelta(uint32_t start) {
|
uint32_t RAMFUNC GetCountSspClkDelta(uint32_t start) {
|
||||||
uint32_t stop = GetCountSspClk();
|
uint32_t stop = GetCountSspClk();
|
||||||
if ( stop >= start )
|
if (stop >= start)
|
||||||
return stop - start;
|
return stop - start;
|
||||||
return (UINT32_MAX - start) + stop;
|
return (UINT32_MAX - start) + stop;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue