Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
nvx committed Aug 24, 2023
1 parent 42330fc commit a685d92
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 518 deletions.
579 changes: 294 additions & 285 deletions armsrc/Standalone/hf_cardhopper.c

Large diffs are not rendered by default.

69 changes: 40 additions & 29 deletions armsrc/Standalone/hf_reblay.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,22 @@ void RunMod() {
continue;
}

static uint8_t atqar[2] = {0x44, 0x03};
responses[RESP_INDEX_ATQA].response = atqar;

static uint8_t uidc1[5] = {0x88, 0x04, 0x38, 0x8d, 0x39};
responses[RESP_INDEX_UIDC1].response = uidc1;
static uint8_t uidc2[5] = {0x02, 0xc2, 0x61, 0x80, 0x21};
responses[RESP_INDEX_UIDC2].response = uidc2;

static uint8_t sakc1[3] = {0x24, 0xd8, 0x36};
responses[RESP_INDEX_SAKC1].response = sakc1;
static uint8_t sakc2[3] = {0x20, 0xfc, 0x70};
responses[RESP_INDEX_SAKC2].response = sakc2;

static uint8_t rats[8] = {0x06, 0x75, 0x77, 0x81, 0x02, 0x80, 0x02, 0xf0};
responses[RESP_INDEX_RATS].response = rats;

// We need to listen to the high-frequency, peak-detected path.
iso14443a_setup(FPGA_HF_ISO14443A_TAGSIM_LISTEN);

Expand Down Expand Up @@ -313,6 +329,7 @@ void RunMod() {
}
}
}

if (receivedCmd[0] == ISO14443A_CMD_REQA && len == 1) { // Received a REQUEST
// DbpString(_YELLOW_("+") "REQUEST Received");
p_response = &responses[RESP_INDEX_ATQA];
Expand All @@ -330,6 +347,12 @@ void RunMod() {
} else if (receivedCmd[1] == 0x70 && receivedCmd[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT && len == 9) { // Received a SELECT (cascade 1)
// DbpString(_YELLOW_("+") "Request for SELECT S1");
p_response = &responses[RESP_INDEX_SAKC1];
} else if (receivedCmd[1] == 0x20 && receivedCmd[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2 && len == 2) { // Received request for UID (cascade 2)
// DbpString(_YELLOW_("+") "Request for UID C2");
p_response = &responses[RESP_INDEX_UIDC2];
} else if (receivedCmd[1] == 0x70 && receivedCmd[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2 && len == 9) { // Received a SELECT (cascade 2)
// DbpString(_YELLOW_("+") "Request for SELECT S2");
p_response = &responses[RESP_INDEX_SAKC2];
} else if (receivedCmd[0] == ISO14443A_CMD_RATS && len == 4) { // Received a RATS request
// DbpString(_YELLOW_("+") "Request for RATS");
p_response = &responses[RESP_INDEX_RATS];
Expand All @@ -355,36 +378,24 @@ void RunMod() {
DbpString(_GREEN_("[ ") "Card reader command" _GREEN_(" ]"));
Dbhexdump(len - 2, &receivedCmd[1], false);

if ((receivedCmd[0] == 0x02 || receivedCmd[0] == 0x03) && len > 3) { // Process reader commands

if (resp == 1) {
prevcmd = receivedCmd[0];
bufferlen = len - 3;
memcpy(&buffert[0], &bufferlen, 1);
memcpy(&buffert[1], &receivedCmd[1], bufferlen);
resp = 2;
}
if (lenpacket > 0) {
DbpString(_YELLOW_("[ ") "Answering using Bluetooth data!" _YELLOW_(" ]"));
memcpy(&dynamic_response_info.response[1], rpacket, lenpacket);
dynamic_response_info.response[0] = receivedCmd[0];
dynamic_response_info.response_n = lenpacket + 1;
lenpacket = 0;
resp = 1;
} else {
DbpString(_YELLOW_("[ ") "New command: sent it & waiting for Bluetooth response!" _YELLOW_(" ]"));
usart_writebuffer_sync(buffert, bufferlen + 1);
p_response = NULL;
}

if (resp == 1) {
prevcmd = receivedCmd[0];
bufferlen = len - 3;
memcpy(&buffert[0], &bufferlen, 1);
memcpy(&buffert[1], &receivedCmd[1], bufferlen);
resp = 2;
}
if (lenpacket > 0) {
DbpString(_YELLOW_("[ ") "Answering using Bluetooth data!" _YELLOW_(" ]"));
memcpy(&dynamic_response_info.response[1], rpacket, lenpacket);
dynamic_response_info.response[0] = receivedCmd[0];
dynamic_response_info.response_n = lenpacket + 1;
lenpacket = 0;
resp = 1;
} else {
if (lenpacket == 0) {
DbpString(_YELLOW_("!!") "Received unknown command!");
memcpy(dynamic_response_info.response, receivedCmd, len);
dynamic_response_info.response_n = len;
} else {
DbpString(_YELLOW_("!!") "Avoiding unknown command - Bluetooth data already in memory!!");
}
DbpString(_YELLOW_("[ ") "New command: sent it & waiting for Bluetooth response!" _YELLOW_(" ]"));
usart_writebuffer_sync(buffert, bufferlen + 1);
p_response = NULL;
}
}
if (dynamic_response_info.response_n > 0) {
Expand Down
16 changes: 8 additions & 8 deletions armsrc/em4x70.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,27 +376,27 @@ static int bruteforce(const uint8_t address, const uint8_t *rnd, const uint8_t *
uint16_t rev_k = reflect16(k);
switch (address) {
case 9:
c = set_byte(&temp_rnd[0], rev_rnd[0] + ((rev_k ) & 0xFFu));
c = set_byte(&temp_rnd[0], rev_rnd[0] + ((rev_k) & 0xFFu));
c = set_byte(&temp_rnd[1], rev_rnd[1] + c + ((rev_k >> 8) & 0xFFu));
c = set_byte(&temp_rnd[2], rev_rnd[2] + c);
c = set_byte(&temp_rnd[3], rev_rnd[3] + c);
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
c = set_byte(&temp_rnd[5], rev_rnd[5] + c);
set_byte( &temp_rnd[6], rev_rnd[6] + c);
set_byte(&temp_rnd[6], rev_rnd[6] + c);
break;

case 8:
c = set_byte(&temp_rnd[2], rev_rnd[2] + ((rev_k ) & 0xFFu));
c = set_byte(&temp_rnd[2], rev_rnd[2] + ((rev_k) & 0xFFu));
c = set_byte(&temp_rnd[3], rev_rnd[3] + c + ((rev_k >> 8) & 0xFFu));
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
c = set_byte(&temp_rnd[5], rev_rnd[5] + c);
set_byte( &temp_rnd[6], rev_rnd[6] + c);
set_byte(&temp_rnd[6], rev_rnd[6] + c);
break;

case 7:
c = set_byte(&temp_rnd[4], rev_rnd[4] + ((rev_k ) & 0xFFu));
c = set_byte(&temp_rnd[4], rev_rnd[4] + ((rev_k) & 0xFFu));
c = set_byte(&temp_rnd[5], rev_rnd[5] + c + ((rev_k >> 8) & 0xFFu));
set_byte( &temp_rnd[6], rev_rnd[6] + c);
set_byte(&temp_rnd[6], rev_rnd[6] + c);
break;

default:
Expand Down Expand Up @@ -853,8 +853,8 @@ void em4x70_write_pin(const em4x70_data_t *etd, bool ledcontrol) {
if (em4x70_read_id()) {

// Write new PIN
if ((write((etd->pin ) & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
(write((etd->pin >> 16) & 0xFFFF, EM4X70_PIN_WORD_LOWER) == PM3_SUCCESS)) {
if ((write((etd->pin) & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
(write((etd->pin >> 16) & 0xFFFF, EM4X70_PIN_WORD_LOWER) == PM3_SUCCESS)) {

// Now Try to authenticate using the new PIN

Expand Down
42 changes: 21 additions & 21 deletions armsrc/fpgaloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,27 @@ void SetupSpi(int mode) {
AT91C_SPI_NCPHA | // Clock Phase data captured on leading edge, changes on following edge
(0 << 0); // Clock Polarity inactive state is logic 0
break;
/*
case SPI_LCD_MODE:
AT91C_BASE_SPI->SPI_MR =
( 0 << 24) | // Delay between chip selects (take default: 6 MCK periods)
(0xB << 16) | // Peripheral Chip Select (selects LCD SPI_NCS2 or PA10)
( 0 << 7) | // Local Loopback Disabled
( 1 << 4) | // Mode Fault Detection disabled
( 0 << 2) | // Chip selects connected directly to peripheral
( 0 << 1) | // Fixed Peripheral Select
( 1 << 0); // Master Mode
AT91C_BASE_SPI->SPI_CSR[2] =
( 1 << 24) | // Delay between Consecutive Transfers (32 MCK periods)
( 1 << 16) | // Delay Before SPCK (1 MCK period)
( 6 << 8) | // Serial Clock Baud Rate (baudrate = MCK/6 = 24MHz/6 = 4M baud
AT91C_SPI_BITS_9 | // Bits per Transfer (9 bits)
( 0 << 3) | // Chip Select inactive after transfer
( 1 << 1) | // Clock Phase data captured on leading edge, changes on following edge
( 0 << 0); // Clock Polarity inactive state is logic 0
break;
*/
/*
case SPI_LCD_MODE:
AT91C_BASE_SPI->SPI_MR =
( 0 << 24) | // Delay between chip selects (take default: 6 MCK periods)
(0xB << 16) | // Peripheral Chip Select (selects LCD SPI_NCS2 or PA10)
( 0 << 7) | // Local Loopback Disabled
( 1 << 4) | // Mode Fault Detection disabled
( 0 << 2) | // Chip selects connected directly to peripheral
( 0 << 1) | // Fixed Peripheral Select
( 1 << 0); // Master Mode
AT91C_BASE_SPI->SPI_CSR[2] =
( 1 << 24) | // Delay between Consecutive Transfers (32 MCK periods)
( 1 << 16) | // Delay Before SPCK (1 MCK period)
( 6 << 8) | // Serial Clock Baud Rate (baudrate = MCK/6 = 24MHz/6 = 4M baud
AT91C_SPI_BITS_9 | // Bits per Transfer (9 bits)
( 0 << 3) | // Chip Select inactive after transfer
( 1 << 1) | // Clock Phase data captured on leading edge, changes on following edge
( 0 << 0); // Clock Polarity inactive state is logic 0
break;
*/
default:
DisableSpi();
break;
Expand Down
6 changes: 3 additions & 3 deletions armsrc/hitag2_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ uint32_t _hitag2_byte(uint64_t *x) {
}

void hitag2_cipher_reset(struct hitag2_tag *tag, const uint8_t *iv) {
uint64_t key = ((uint64_t)tag->sectors[2][2] ) |
uint64_t key = ((uint64_t)tag->sectors[2][2]) |
((uint64_t)tag->sectors[2][3] << 8) |
((uint64_t)tag->sectors[1][0] << 16) |
((uint64_t)tag->sectors[1][1] << 24) |
((uint64_t)tag->sectors[1][2] << 32) |
((uint64_t)tag->sectors[1][3] << 40);
uint32_t uid = ((uint32_t)tag->sectors[0][0] ) |
uint32_t uid = ((uint32_t)tag->sectors[0][0]) |
((uint32_t)tag->sectors[0][1] << 8) |
((uint32_t)tag->sectors[0][2] << 16) |
((uint32_t)tag->sectors[0][3] << 24);
uint32_t iv_ = (((uint32_t)(iv[0])) ) |
uint32_t iv_ = (((uint32_t)(iv[0]))) |
(((uint32_t)(iv[1])) << 8) |
(((uint32_t)(iv[2])) << 16) |
(((uint32_t)(iv[3])) << 24);
Expand Down
4 changes: 2 additions & 2 deletions armsrc/spiffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int rdv40_spiffs_check(void) {
void write_to_spiffs(const char *filename, const uint8_t *src, uint32_t size) {
spiffs_file fd = SPIFFS_open(&fs, filename, SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0);
// Note: SPIFFS_write() doesn't declare third parameter as const (but should)
if (SPIFFS_write(&fs, fd, (void*)src, size) < 0) {
if (SPIFFS_write(&fs, fd, (void *)src, size) < 0) {
Dbprintf("wr errno %i\n", SPIFFS_errno(&fs));
}
SPIFFS_close(&fs, fd);
Expand All @@ -208,7 +208,7 @@ void write_to_spiffs(const char *filename, const uint8_t *src, uint32_t size) {
void append_to_spiffs(const char *filename, const uint8_t *src, uint32_t size) {
spiffs_file fd = SPIFFS_open(&fs, filename, SPIFFS_APPEND | SPIFFS_RDWR, 0);
// Note: SPIFFS_write() doesn't declare third parameter as const (but should)
if (SPIFFS_write(&fs, fd, (void*)src, size) < 0) {
if (SPIFFS_write(&fs, fd, (void *)src, size) < 0) {
Dbprintf("errno %i\n", SPIFFS_errno(&fs));
}
SPIFFS_close(&fs, fd);
Expand Down
18 changes: 15 additions & 3 deletions client/luascripts/multi_bruteforce.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ local function cardHex(i, f)
bits = bor(bits, lshift(1, 26))
return ('%04x%08x'):format(preamble, bits)
end

local function cardHexHac(cn)
stream = toBits(cn, 15)
low = evenparity(stream) and 1 or 0
bits = bor(lshift(cn, 1), low)
return ('%04x'):format(bits)
end
--
--
local function main(args)
Expand Down Expand Up @@ -214,9 +221,12 @@ local function main(args)
end
facilityrequired = 0 -- Disable the FC required check, as we used it for type instead of FC
elseif rfidtag == 'hid' then
consolecommand = 'lf hid sim -r'
consolecommand = 'lf hid sim -w C1k35s'
rfidtagname = 'HID'
facilityrequired = 1
elseif rfidtag == 'iclass' then
consolecommand = 'hf iclass esetblk -b 7 -d'
rfidtagname = 'iClass'
else -- Display error and exit out if bad RFID tag was supplied
print('Invalid rfid tag (-r) supplied')
print(usage)
Expand Down Expand Up @@ -285,10 +295,12 @@ local function main(args)
for cardnum = baseid, endid, fordirection do

-- If rfid tag is set to HID, convert card to HEX using the stolen code above
if rfidtag == 'hid' then cardnum = cardHex(cardnum, facility) end
--if rfidtag == 'hid' then cardnum = cardHex(cardnum, facility) end

-- send command to proxmark
core.console(consolecommand..' '..facility..' '..cardnum)
core.console(consolecommand..' 000006A61041'..cardHexHac(cardnum))
core.console("msleep -t 100")
core.console("hf iclass sim -t 3")

if timeout == 'pause' then
print('Press enter to continue ...')
Expand Down
14 changes: 7 additions & 7 deletions client/src/proxguiqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ void Plot::Zoom(double factor, uint32_t refX) {
}
}
} else { // Zoom out
if (g_GraphPixelsPerPointNew >= (1.0 / ZOOM_LIMIT) ) {
if (g_GraphPixelsPerPointNew >= (1.0 / ZOOM_LIMIT)) {
g_GraphPixelsPerPoint = g_GraphPixelsPerPointNew;
// shift graph towards refX when zooming out
if (refX > g_GraphStart) {
Expand Down Expand Up @@ -951,7 +951,7 @@ void Plot::wheelEvent(QWheelEvent *event) {
Zoom(1.0 / ZOOM_STEP, x);
}
} else {
Move(PageWidth * delta * move_offset / 120 );
Move(PageWidth * delta * move_offset / 120);
}
this->update();
}
Expand Down Expand Up @@ -981,7 +981,7 @@ void Plot::keyPressEvent(QKeyEvent *event) {
if (event->modifiers() & Qt::ControlModifier)
offset = 1;
else
offset = int(ZOOM_LIMIT/g_GraphPixelsPerPoint);
offset = int(ZOOM_LIMIT / g_GraphPixelsPerPoint);
}

switch (event->key()) {
Expand All @@ -990,13 +990,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
if (event->modifiers() & Qt::ControlModifier) {
Zoom(ZOOM_STEP, CursorBPos);
} else {
Zoom(ZOOM_STEP*2, CursorBPos);
Zoom(ZOOM_STEP * 2, CursorBPos);
}
} else {
if (event->modifiers() & Qt::ControlModifier) {
Zoom(ZOOM_STEP, CursorAPos);
} else {
Zoom(ZOOM_STEP*2, CursorAPos);
Zoom(ZOOM_STEP * 2, CursorAPos);
}
}
break;
Expand All @@ -1006,13 +1006,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
if (event->modifiers() & Qt::ControlModifier) {
Zoom(1.0 / ZOOM_STEP, CursorBPos);
} else {
Zoom(1.0 / (ZOOM_STEP*2), CursorBPos);
Zoom(1.0 / (ZOOM_STEP * 2), CursorBPos);
}
} else {
if (event->modifiers() & Qt::ControlModifier) {
Zoom(1.0 / ZOOM_STEP, CursorAPos);
} else {
Zoom(1.0 / (ZOOM_STEP*2), CursorAPos);
Zoom(1.0 / (ZOOM_STEP * 2), CursorAPos);
}
}
break;
Expand Down
Loading

0 comments on commit a685d92

Please sign in to comment.