This commit is contained in:
iceman1001 2021-04-08 10:44:31 +02:00
commit 27184d7f5b
21 changed files with 334 additions and 334 deletions

View file

@ -77,7 +77,7 @@ void RunMod(void) {
flags |= FLAG_4B_UID_IN_DATA;
} else if (card.uidlen == 7) {
flags |= FLAG_7B_UID_IN_DATA;
} else if (card.uidlen == 10){
} else if (card.uidlen == 10) {
flags |= FLAG_10B_UID_IN_DATA;
} else {
Dbprintf("Unusual UID length, something is wrong. Try again please.");

View file

@ -1746,7 +1746,7 @@ static void PacketReceived(PacketCommandNG *packet) {
break;
}
case CMD_SMART_RAW: {
SmartCardRaw((smart_card_raw_t*)packet->data.asBytes);
SmartCardRaw((smart_card_raw_t *)packet->data.asBytes);
break;
}
case CMD_SMART_UPLOAD: {

View file

@ -1005,7 +1005,7 @@ void SniffHitag2(void) {
clear_trace();
set_tracing(true);
/*
/*
lf_init(false, false);
// no logging of the raw signal
@ -1162,15 +1162,15 @@ void SniffHitag2(void) {
auth_table = (uint8_t *)BigBuf_malloc(AUTH_TABLE_LENGTH);
memset(auth_table, 0x00, AUTH_TABLE_LENGTH);
while(BUTTON_PRESS() == false) {
while (BUTTON_PRESS() == false) {
WDT_HIT();
memset(rx, 0x00, sizeof(rx));
// Receive frame, watch for at most T0 * EOF periods
while (AT91C_BASE_TC1->TC_CV < (HITAG_T0 * HITAG_T_EOF) ) {
while (AT91C_BASE_TC1->TC_CV < (HITAG_T0 * HITAG_T_EOF)) {
// Check if rising edge in modulation is detected
if(AT91C_BASE_TC1->TC_SR & AT91C_TC_LDRAS) {
if (AT91C_BASE_TC1->TC_SR & AT91C_TC_LDRAS) {
// Retrieve the new timing values
int ra = (AT91C_BASE_TC1->TC_RA / HITAG_T0);
@ -1198,26 +1198,26 @@ void SniffHitag2(void) {
if (reader_frame) {
LED_B_ON();
// Capture reader frame
if(ra >= HITAG_T_STOP) {
if (ra >= HITAG_T_STOP) {
// if (rxlen != 0) {
//DbpString("wierd0?");
// }
// Capture the T0 periods that have passed since last communication or field drop (reset)
response = (ra - HITAG_T_LOW);
} else if(ra >= HITAG_T_1_MIN ) {
} else if (ra >= HITAG_T_1_MIN) {
// '1' bit
rx[rxlen / 8] |= 1 << (7 - (rxlen % 8));
rxlen++;
} else if(ra >= HITAG_T_0_MIN) {
} else if (ra >= HITAG_T_0_MIN) {
// '0' bit
rx[rxlen / 8] |= 0 << (7-(rxlen%8));
rx[rxlen / 8] |= 0 << (7 - (rxlen % 8));
rxlen++;
}
} else {
LED_C_ON();
// Capture tag frame (manchester decoding using only falling edges)
if(ra >= HITAG_T_EOF) {
if (ra >= HITAG_T_EOF) {
// if (rxlen != 0) {
//DbpString("wierd1?");
// }
@ -1225,14 +1225,14 @@ void SniffHitag2(void) {
// We always recieve a 'one' first, which has the falling edge after a half period |-_|
response = ra - HITAG_T_TAG_HALF_PERIOD;
} else if(ra >= HITAG_T_TAG_CAPTURE_FOUR_HALF) {
} else if (ra >= HITAG_T_TAG_CAPTURE_FOUR_HALF) {
// Manchester coding example |-_|_-|-_| (101)
rx[rxlen / 8] |= 0 << (7 - (rxlen % 8));
rxlen++;
rx[rxlen / 8] |= 1 << (7 - (rxlen % 8));
rxlen++;
} else if(ra >= HITAG_T_TAG_CAPTURE_THREE_HALF) {
} else if (ra >= HITAG_T_TAG_CAPTURE_THREE_HALF) {
// Manchester coding example |_-|...|_-|-_| (0...01)
rx[rxlen / 8] |= 0 << (7 - (rxlen % 8));
rxlen++;
@ -1244,7 +1244,7 @@ void SniffHitag2(void) {
lastbit = !lastbit;
bSkip = !bSkip;
} else if(ra >= HITAG_T_TAG_CAPTURE_TWO_HALF) {
} else if (ra >= HITAG_T_TAG_CAPTURE_TWO_HALF) {
// Manchester coding example |_-|_-| (00) or |-_|-_| (11)
if (tag_sof) {
// Ignore bits that are transmitted during SOF
@ -1260,7 +1260,7 @@ void SniffHitag2(void) {
}
// Check if frame was captured
if(rxlen) {
if (rxlen) {
frame_count++;
LogTrace(rx, nbytes(rxlen), response, 0, NULL, reader_frame);
@ -1301,8 +1301,8 @@ void SniffHitag2(void) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
set_tracing(false);
Dbprintf("frame received: %d",frame_count);
Dbprintf("Authentication Attempts: %d",(auth_table_len / 8));
Dbprintf("frame received: %d", frame_count);
Dbprintf("Authentication Attempts: %d", (auth_table_len / 8));
}

View file

@ -545,15 +545,15 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
counter++;
}
/*
/*
// find reader field
if (cardSTATE == MFEMUL_NOFIELD) {
#if defined RDV4
#if defined RDV4
vHf = (MAX_ADC_HF_VOLTAGE_RDV40 * SumAdc(ADC_CHAN_HF_RDV40, 32)) >> 15;
#else
#else
vHf = (MAX_ADC_HF_VOLTAGE * SumAdc(ADC_CHAN_HF, 32)) >> 15;
#endif
#endif
if (vHf > MF_MINFIELDV) {
cardSTATE_TO_IDLE();

View file

@ -1026,7 +1026,7 @@ int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str)
int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str) {
uint32_t n = 0, i = 0;
for(;;) {
for (;;) {
int res = sscanf(&str[i], "%1u", &n);
if ((res != 1) || (n > 1))
@ -1050,7 +1050,7 @@ int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str)
*/
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, uint8_t *arr, int arrlen) {
int i = 0;
for(; i < arrlen; i++) {
for (; i < arrlen; i++) {
uint8_t n = arr[i];
if (n > 1)
break;

View file

@ -137,7 +137,7 @@ int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
int resp_len = 0;
uint8_t resp[254] = {0};
uint8_t c[] = {0x96, CARD_INS_CC, 0x00, 0x00, 17, typ, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8_t c[] = {0x96, CARD_INS_CC, 0x00, 0x00, 17, typ, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
ExchangeAPDUSC(false, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
if (resp_len < 2) {

View file

@ -216,7 +216,7 @@ static void *brute_thread(void *arguments) {
crypto1_deinit(pcs);
if (CheckCrc14443(CRC_14443_A, dec , 4)) {
if (CheckCrc14443(CRC_14443_A, dec, 4)) {
// check crc-16 in the end
@ -267,7 +267,7 @@ int main(int argc, char *argv[]) {
printf("partial key.. %08x\n", part_key);
printf("nt enc....... %08x\n", nt_enc);
printf("nr enc....... %08x\n", nr_enc);
printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, ENC_LEN ,0));
printf("next encrypted cmd: %s\n", sprint_hex_inrow_ex(enc, ENC_LEN, 0));
clock_t t1 = clock();