mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
commit
5a56504fc1
13 changed files with 500 additions and 481 deletions
|
@ -52,15 +52,15 @@ static void become_reader(void);
|
||||||
static void select_card(void);
|
static void select_card(void);
|
||||||
|
|
||||||
static void become_card(void);
|
static void become_card(void);
|
||||||
static void prepare_emulation(uint8_t*, uint16_t*, uint8_t*, packet_t*);
|
static void prepare_emulation(uint8_t *, uint16_t *, uint8_t *, packet_t *);
|
||||||
static void cook_ats(packet_t*, uint8_t, uint8_t);
|
static void cook_ats(packet_t *, uint8_t, uint8_t);
|
||||||
static bool try_use_canned_response(uint8_t*, int, tag_response_info_t*);
|
static bool try_use_canned_response(uint8_t *, int, tag_response_info_t *);
|
||||||
static void reply_with_packet(packet_t*);
|
static void reply_with_packet(packet_t *);
|
||||||
|
|
||||||
static void read_packet(packet_t*);
|
static void read_packet(packet_t *);
|
||||||
static void write_packet(packet_t*);
|
static void write_packet(packet_t *);
|
||||||
|
|
||||||
static bool GetIso14443aCommandFromReaderInterruptible(uint8_t*, uint8_t*, int*);
|
static bool GetIso14443aCommandFromReaderInterruptible(uint8_t *, uint8_t *, int *);
|
||||||
|
|
||||||
|
|
||||||
void RunMod(void) {
|
void RunMod(void) {
|
||||||
|
@ -113,7 +113,7 @@ static void become_reader(void) {
|
||||||
uint8_t toCard[256] = { 0 };
|
uint8_t toCard[256] = { 0 };
|
||||||
uint8_t parity[MAX_PARITY_SIZE] = { 0 };
|
uint8_t parity[MAX_PARITY_SIZE] = { 0 };
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
read_packet(rx);
|
read_packet(rx);
|
||||||
|
@ -136,7 +136,7 @@ static void become_reader(void) {
|
||||||
|
|
||||||
static void select_card(void) {
|
static void select_card(void) {
|
||||||
iso14a_card_select_t card = { 0 };
|
iso14a_card_select_t card = { 0 };
|
||||||
while(1) {
|
while (1) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
int ret = iso14443a_select_card(NULL, &card, NULL, true, 0, false);
|
int ret = iso14443a_select_card(NULL, &card, NULL, true, 0, false);
|
||||||
|
@ -222,9 +222,12 @@ static void become_card(void) {
|
||||||
|
|
||||||
|
|
||||||
static void prepare_emulation(uint8_t *tagType, uint16_t *flags, uint8_t *data, packet_t *ats) {
|
static void prepare_emulation(uint8_t *tagType, uint16_t *flags, uint8_t *data, packet_t *ats) {
|
||||||
packet_t tagTypeRx = { 0 }; read_packet(&tagTypeRx);
|
packet_t tagTypeRx = { 0 };
|
||||||
packet_t timeModeRx = { 0 }; read_packet(&timeModeRx);
|
read_packet(&tagTypeRx);
|
||||||
packet_t uidRx = { 0 }; read_packet(&uidRx);
|
packet_t timeModeRx = { 0 };
|
||||||
|
read_packet(&timeModeRx);
|
||||||
|
packet_t uidRx = { 0 };
|
||||||
|
read_packet(&uidRx);
|
||||||
read_packet(ats);
|
read_packet(ats);
|
||||||
|
|
||||||
*tagType = tagTypeRx.dat[0];
|
*tagType = tagTypeRx.dat[0];
|
||||||
|
@ -269,13 +272,19 @@ static void cook_ats(packet_t *ats, uint8_t fwi, uint8_t sfgi) {
|
||||||
// Might be better for the phone side to do this tbh
|
// Might be better for the phone side to do this tbh
|
||||||
if (ats->len == 1) {
|
if (ats->len == 1) {
|
||||||
ats->len = 4;
|
ats->len = 4;
|
||||||
ats->dat[0] = 0x04; ats->dat[1] = 0x78; ats->dat[2] = 0x77; ats->dat[3] = 0x80;
|
ats->dat[0] = 0x04;
|
||||||
|
ats->dat[1] = 0x78;
|
||||||
|
ats->dat[2] = 0x77;
|
||||||
|
ats->dat[3] = 0x80;
|
||||||
} else if (ats->len == 2) {
|
} else if (ats->len == 2) {
|
||||||
ats->len = 4;
|
ats->len = 4;
|
||||||
ats->dat[0] = 0x04; ats->dat[2] = 0x77; ats->dat[3] = 0x80;
|
ats->dat[0] = 0x04;
|
||||||
|
ats->dat[2] = 0x77;
|
||||||
|
ats->dat[3] = 0x80;
|
||||||
} else if (ats->len == 3) {
|
} else if (ats->len == 3) {
|
||||||
ats->len = 4;
|
ats->len = 4;
|
||||||
ats->dat[0] = 0x04; ats->dat[3] = 0x80;
|
ats->dat[0] = 0x04;
|
||||||
|
ats->dat[3] = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the SFGI as well as the FWI - needed for some older readers (firmware revs?)
|
// Set the SFGI as well as the FWI - needed for some older readers (firmware revs?)
|
||||||
|
@ -350,14 +359,14 @@ static void reply_with_packet(packet_t *packet) {
|
||||||
|
|
||||||
|
|
||||||
static void read_packet(packet_t *packet) {
|
static void read_packet(packet_t *packet) {
|
||||||
while(!usart_rxdata_available()) {
|
while (!usart_rxdata_available()) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
SpinDelayUs(100);
|
SpinDelayUs(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t dataReceived = usart_read_ng((uint8_t*) packet, sizeof(packet_t)) - 1;
|
uint32_t dataReceived = usart_read_ng((uint8_t *) packet, sizeof(packet_t)) - 1;
|
||||||
while(dataReceived != packet->len) {
|
while (dataReceived != packet->len) {
|
||||||
while(!usart_rxdata_available()) WDT_HIT();
|
while (!usart_rxdata_available()) WDT_HIT();
|
||||||
|
|
||||||
dataReceived += usart_read_ng(packet->dat + dataReceived, 255 - dataReceived);
|
dataReceived += usart_read_ng(packet->dat + dataReceived, 255 - dataReceived);
|
||||||
}
|
}
|
||||||
|
@ -366,7 +375,7 @@ static void read_packet(packet_t *packet) {
|
||||||
|
|
||||||
|
|
||||||
static void write_packet(packet_t *packet) {
|
static void write_packet(packet_t *packet) {
|
||||||
usart_writebuffer_sync((uint8_t*) packet, packet->len + 1);
|
usart_writebuffer_sync((uint8_t *) packet, packet->len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -376,27 +376,27 @@ static int bruteforce(const uint8_t address, const uint8_t *rnd, const uint8_t *
|
||||||
uint16_t rev_k = reflect16(k);
|
uint16_t rev_k = reflect16(k);
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case 9:
|
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[1], rev_rnd[1] + c + ((rev_k >> 8) & 0xFFu));
|
||||||
c = set_byte(&temp_rnd[2], rev_rnd[2] + c);
|
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[3], rev_rnd[3] + c);
|
||||||
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
|
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
|
||||||
c = set_byte(&temp_rnd[5], rev_rnd[5] + 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;
|
break;
|
||||||
|
|
||||||
case 8:
|
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[3], rev_rnd[3] + c + ((rev_k >> 8) & 0xFFu));
|
||||||
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
|
c = set_byte(&temp_rnd[4], rev_rnd[4] + c);
|
||||||
c = set_byte(&temp_rnd[5], rev_rnd[5] + 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;
|
break;
|
||||||
|
|
||||||
case 7:
|
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));
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -853,7 +853,7 @@ void em4x70_write_pin(const em4x70_data_t *etd, bool ledcontrol) {
|
||||||
if (em4x70_read_id()) {
|
if (em4x70_read_id()) {
|
||||||
|
|
||||||
// Write new PIN
|
// Write new PIN
|
||||||
if ((write((etd->pin ) & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
|
if ((write((etd->pin) & 0xFFFF, EM4X70_PIN_WORD_UPPER) == PM3_SUCCESS) &&
|
||||||
(write((etd->pin >> 16) & 0xFFFF, EM4X70_PIN_WORD_LOWER) == PM3_SUCCESS)) {
|
(write((etd->pin >> 16) & 0xFFFF, EM4X70_PIN_WORD_LOWER) == PM3_SUCCESS)) {
|
||||||
|
|
||||||
// Now Try to authenticate using the new PIN
|
// Now Try to authenticate using the new PIN
|
||||||
|
|
|
@ -111,7 +111,7 @@ void SetupSpi(int mode) {
|
||||||
AT91C_SPI_NCPHA | // Clock Phase data captured on leading edge, changes on following edge
|
AT91C_SPI_NCPHA | // Clock Phase data captured on leading edge, changes on following edge
|
||||||
(0 << 0); // Clock Polarity inactive state is logic 0
|
(0 << 0); // Clock Polarity inactive state is logic 0
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case SPI_LCD_MODE:
|
case SPI_LCD_MODE:
|
||||||
AT91C_BASE_SPI->SPI_MR =
|
AT91C_BASE_SPI->SPI_MR =
|
||||||
( 0 << 24) | // Delay between chip selects (take default: 6 MCK periods)
|
( 0 << 24) | // Delay between chip selects (take default: 6 MCK periods)
|
||||||
|
@ -131,7 +131,7 @@ void SetupSpi(int mode) {
|
||||||
( 1 << 1) | // Clock Phase data captured on leading edge, changes on following edge
|
( 1 << 1) | // Clock Phase data captured on leading edge, changes on following edge
|
||||||
( 0 << 0); // Clock Polarity inactive state is logic 0
|
( 0 << 0); // Clock Polarity inactive state is logic 0
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
DisableSpi();
|
DisableSpi();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -90,17 +90,17 @@ uint32_t _hitag2_byte(uint64_t *x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void hitag2_cipher_reset(struct hitag2_tag *tag, const uint8_t *iv) {
|
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[2][3] << 8) |
|
||||||
((uint64_t)tag->sectors[1][0] << 16) |
|
((uint64_t)tag->sectors[1][0] << 16) |
|
||||||
((uint64_t)tag->sectors[1][1] << 24) |
|
((uint64_t)tag->sectors[1][1] << 24) |
|
||||||
((uint64_t)tag->sectors[1][2] << 32) |
|
((uint64_t)tag->sectors[1][2] << 32) |
|
||||||
((uint64_t)tag->sectors[1][3] << 40);
|
((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][1] << 8) |
|
||||||
((uint32_t)tag->sectors[0][2] << 16) |
|
((uint32_t)tag->sectors[0][2] << 16) |
|
||||||
((uint32_t)tag->sectors[0][3] << 24);
|
((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[1])) << 8) |
|
||||||
(((uint32_t)(iv[2])) << 16) |
|
(((uint32_t)(iv[2])) << 16) |
|
||||||
(((uint32_t)(iv[3])) << 24);
|
(((uint32_t)(iv[3])) << 24);
|
||||||
|
|
|
@ -199,7 +199,7 @@ int rdv40_spiffs_check(void) {
|
||||||
void write_to_spiffs(const char *filename, const uint8_t *src, uint32_t size) {
|
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);
|
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)
|
// 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));
|
Dbprintf("wr errno %i\n", SPIFFS_errno(&fs));
|
||||||
}
|
}
|
||||||
SPIFFS_close(&fs, fd);
|
SPIFFS_close(&fs, fd);
|
||||||
|
@ -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) {
|
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);
|
spiffs_file fd = SPIFFS_open(&fs, filename, SPIFFS_APPEND | SPIFFS_RDWR, 0);
|
||||||
// Note: SPIFFS_write() doesn't declare third parameter as const (but should)
|
// 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));
|
Dbprintf("errno %i\n", SPIFFS_errno(&fs));
|
||||||
}
|
}
|
||||||
SPIFFS_close(&fs, fd);
|
SPIFFS_close(&fs, fd);
|
||||||
|
|
|
@ -42,8 +42,10 @@
|
||||||
|
|
||||||
#define PICOPASS_BLOCK_SIZE 8
|
#define PICOPASS_BLOCK_SIZE 8
|
||||||
#define NUM_CSNS 9
|
#define NUM_CSNS 9
|
||||||
|
#define MAC_ITEM_SIZE 24 // csn(8) + epurse(8) + nr(4) + mac(4) = 24 bytes
|
||||||
#define ICLASS_KEYS_MAX 8
|
#define ICLASS_KEYS_MAX 8
|
||||||
#define ICLASS_AUTH_RETRY 10
|
#define ICLASS_AUTH_RETRY 10
|
||||||
|
#define ICLASS_CFG_BLK_SR_BIT 0xA0 // indicates SIO present when set in block6[0] (legacy tags)
|
||||||
#define ICLASS_DECRYPTION_BIN "iclass_decryptionkey.bin"
|
#define ICLASS_DECRYPTION_BIN "iclass_decryptionkey.bin"
|
||||||
|
|
||||||
static void print_picopass_info(const picopass_hdr_t *hdr);
|
static void print_picopass_info(const picopass_hdr_t *hdr);
|
||||||
|
@ -54,13 +56,13 @@ static void iclass_set_last_known_card(picopass_hdr_t *card) {
|
||||||
memcpy(&iclass_last_known_card, card, sizeof(picopass_hdr_t));
|
memcpy(&iclass_last_known_card, card, sizeof(picopass_hdr_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t empty[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
static uint8_t empty[PICOPASS_BLOCK_SIZE] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
static uint8_t zeros[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
static uint8_t zeros[PICOPASS_BLOCK_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
static void printIclassSIO(uint8_t *iclass_dump);
|
static void printIclassSIO(uint8_t *iclass_dump);
|
||||||
|
|
||||||
static uint8_t iClass_Key_Table[ICLASS_KEYS_MAX][8] = {
|
static uint8_t iClass_Key_Table[ICLASS_KEYS_MAX][PICOPASS_BLOCK_SIZE] = {
|
||||||
{ 0xAE, 0xA6, 0x84, 0xA6, 0xDA, 0xB2, 0x32, 0x78 },
|
{ 0xAE, 0xA6, 0x84, 0xA6, 0xDA, 0xB2, 0x32, 0x78 },
|
||||||
{ 0xFD, 0xCB, 0x5A, 0x52, 0xEA, 0x8F, 0x30, 0x90 },
|
{ 0xFD, 0xCB, 0x5A, 0x52, 0xEA, 0x8F, 0x30, 0x90 },
|
||||||
{ 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87 },
|
{ 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87 },
|
||||||
|
@ -747,7 +749,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
// remember to change the define NUM_CSNS to match.
|
// remember to change the define NUM_CSNS to match.
|
||||||
|
|
||||||
// pre-defined 9 CSN by iceman
|
// pre-defined 9 CSN by iceman
|
||||||
uint8_t csns[8 * NUM_CSNS] = {
|
uint8_t csns[NUM_CSNS * PICOPASS_BLOCK_SIZE] = {
|
||||||
0x01, 0x0A, 0x0F, 0xFF, 0xF7, 0xFF, 0x12, 0xE0,
|
0x01, 0x0A, 0x0F, 0xFF, 0xF7, 0xFF, 0x12, 0xE0,
|
||||||
0x0C, 0x06, 0x0C, 0xFE, 0xF7, 0xFF, 0x12, 0xE0,
|
0x0C, 0x06, 0x0C, 0xFE, 0xF7, 0xFF, 0x12, 0xE0,
|
||||||
0x10, 0x97, 0x83, 0x7B, 0xF7, 0xFF, 0x12, 0xE0,
|
0x10, 0x97, 0x83, 0x7B, 0xF7, 0xFF, 0x12, 0xE0,
|
||||||
|
@ -779,7 +781,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "press " _YELLOW_("`enter`") " to cancel");
|
PrintAndLogEx(INFO, "press " _YELLOW_("`enter`") " to cancel");
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_ICLASS_SIMULATE, sim_type, NUM_CSNS, 1, csns, 8 * NUM_CSNS);
|
SendCommandMIX(CMD_HF_ICLASS_SIMULATE, sim_type, NUM_CSNS, 1, csns, NUM_CSNS * PICOPASS_BLOCK_SIZE);
|
||||||
|
|
||||||
while (WaitForResponseTimeout(CMD_ACK, &resp, 2000) == false) {
|
while (WaitForResponseTimeout(CMD_ACK, &resp, 2000) == false) {
|
||||||
tries++;
|
tries++;
|
||||||
|
@ -799,7 +801,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
if (num_mac == 0)
|
if (num_mac == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
size_t datalen = NUM_CSNS * 24;
|
size_t datalen = NUM_CSNS * MAC_ITEM_SIZE;
|
||||||
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
|
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
|
||||||
if (!dump) {
|
if (!dump) {
|
||||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||||
|
@ -811,11 +813,11 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
for (i = 0 ; i < NUM_CSNS ; i++) {
|
for (i = 0 ; i < NUM_CSNS ; i++) {
|
||||||
//copy CSN
|
//copy CSN
|
||||||
memcpy(dump + i * 24, csns + i * 8, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE), csns + i * 8, 8);
|
||||||
//copy epurse
|
//copy epurse
|
||||||
memcpy(dump + i * 24 + 8, resp.data.asBytes + i * 16, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 8, resp.data.asBytes + i * 16, 8);
|
||||||
// NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
|
// NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
|
||||||
memcpy(dump + i * 24 + 16, resp.data.asBytes + i * 16 + 8, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 16, resp.data.asBytes + i * 16 + 8, 8);
|
||||||
}
|
}
|
||||||
/** Now, save to dumpfile **/
|
/** Now, save to dumpfile **/
|
||||||
saveFile("iclass_mac_attack", ".bin", dump, datalen);
|
saveFile("iclass_mac_attack", ".bin", dump, datalen);
|
||||||
|
@ -830,7 +832,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "press Enter to cancel");
|
PrintAndLogEx(INFO, "press Enter to cancel");
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_HF_ICLASS_SIMULATE, sim_type, NUM_CSNS, 1, csns, 8 * NUM_CSNS);
|
SendCommandMIX(CMD_HF_ICLASS_SIMULATE, sim_type, NUM_CSNS, 1, csns, NUM_CSNS * PICOPASS_BLOCK_SIZE);
|
||||||
|
|
||||||
while (WaitForResponseTimeout(CMD_ACK, &resp, 2000) == false) {
|
while (WaitForResponseTimeout(CMD_ACK, &resp, 2000) == false) {
|
||||||
tries++;
|
tries++;
|
||||||
|
@ -850,25 +852,23 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
if (num_mac == 0)
|
if (num_mac == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
size_t datalen = NUM_CSNS * 24;
|
size_t datalen = NUM_CSNS * MAC_ITEM_SIZE;
|
||||||
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
|
uint8_t *dump = calloc(datalen, sizeof(uint8_t));
|
||||||
if (!dump) {
|
if (!dump) {
|
||||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||||
return PM3_EMALLOC;
|
return PM3_EMALLOC;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAC_ITEM_SIZE 24
|
|
||||||
|
|
||||||
//KEYROLL 1
|
//KEYROLL 1
|
||||||
//Need zeroes for the CC-field
|
//Need zeroes for the CC-field
|
||||||
memset(dump, 0, datalen);
|
memset(dump, 0, datalen);
|
||||||
for (uint8_t i = 0; i < NUM_CSNS ; i++) {
|
for (uint8_t i = 0; i < NUM_CSNS ; i++) {
|
||||||
// copy CSN
|
// copy CSN
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE, csns + i * 8, 8); //CSN
|
memcpy(dump + (i * MAC_ITEM_SIZE), csns + i * 8, 8); //CSN
|
||||||
// copy EPURSE
|
// copy EPURSE
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.data.asBytes + i * 16, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 8, resp.data.asBytes + i * 16, 8);
|
||||||
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
|
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.data.asBytes + i * 16 + 8, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 16, resp.data.asBytes + i * 16 + 8, 8);
|
||||||
}
|
}
|
||||||
saveFile("iclass_mac_attack_keyroll_A", ".bin", dump, datalen);
|
saveFile("iclass_mac_attack_keyroll_A", ".bin", dump, datalen);
|
||||||
|
|
||||||
|
@ -877,11 +877,11 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||||
for (uint8_t i = 0; i < NUM_CSNS; i++) {
|
for (uint8_t i = 0; i < NUM_CSNS; i++) {
|
||||||
uint8_t resp_index = (i + NUM_CSNS) * 16;
|
uint8_t resp_index = (i + NUM_CSNS) * 16;
|
||||||
// Copy CSN
|
// Copy CSN
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE, csns + i * 8, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE), csns + i * 8, 8);
|
||||||
// copy EPURSE
|
// copy EPURSE
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.data.asBytes + resp_index, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 8, resp.data.asBytes + resp_index, 8);
|
||||||
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8 epurse == 16)
|
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8 epurse == 16)
|
||||||
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.data.asBytes + resp_index + 8, 8);
|
memcpy(dump + (i * MAC_ITEM_SIZE) + 16, resp.data.asBytes + resp_index + 8, 8);
|
||||||
resp_index++;
|
resp_index++;
|
||||||
}
|
}
|
||||||
saveFile("iclass_mac_attack_keyroll_B", ".bin", dump, datalen);
|
saveFile("iclass_mac_attack_keyroll_B", ".bin", dump, datalen);
|
||||||
|
@ -2638,7 +2638,7 @@ static void detect_credential(uint8_t *data, bool *legacy, bool *se, bool *sr) {
|
||||||
*legacy = true;
|
*legacy = true;
|
||||||
|
|
||||||
// SR bit set in legacy config block
|
// SR bit set in legacy config block
|
||||||
if ((data[6 * PICOPASS_BLOCK_SIZE] & 0xA0) == 0xA0) {
|
if ((data[6 * PICOPASS_BLOCK_SIZE] & ICLASS_CFG_BLK_SR_BIT) == ICLASS_CFG_BLK_SR_BIT) {
|
||||||
// If the card is blank (all FF's) then we'll reach here too, so check for an empty block 10
|
// If the card is blank (all FF's) then we'll reach here too, so check for an empty block 10
|
||||||
// to avoid false positivies
|
// to avoid false positivies
|
||||||
if (memcmp(data + (10 * PICOPASS_BLOCK_SIZE), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", PICOPASS_BLOCK_SIZE)) {
|
if (memcmp(data + (10 * PICOPASS_BLOCK_SIZE), "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", PICOPASS_BLOCK_SIZE)) {
|
||||||
|
@ -2898,12 +2898,14 @@ static int CmdHFiClassView(const char *Cmd) {
|
||||||
CLIParserInit(&ctx, "hf iclass view",
|
CLIParserInit(&ctx, "hf iclass view",
|
||||||
"Print a iCLASS tag dump file (bin/eml/json)",
|
"Print a iCLASS tag dump file (bin/eml/json)",
|
||||||
"hf iclass view -f hf-iclass-AA162D30F8FF12F1-dump.bin\n"
|
"hf iclass view -f hf-iclass-AA162D30F8FF12F1-dump.bin\n"
|
||||||
"hf iclass view --first 1 -f hf-iclass-AA162D30F8FF12F1-dump.bin\n");
|
"hf iclass view --first 1 -f hf-iclass-AA162D30F8FF12F1-dump.bin\n\n"
|
||||||
|
"If --first is not specified it will default to the first user block\n"
|
||||||
|
"which is block 6 for secured chips or block 3 for non-secured chips");
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
|
arg_str1("f", "file", "<fn>", "filename of dump (bin/eml/json)"),
|
||||||
arg_int0(NULL, "first", "<dec>", "Begin printing from this block (default first user block - 6 or 3 on non secured chips)"),
|
arg_int0(NULL, "first", "<dec>", "Begin printing from this block (default first user block)"),
|
||||||
arg_int0(NULL, "last", "<dec>", "End printing at this block (default 0, ALL)"),
|
arg_int0(NULL, "last", "<dec>", "End printing at this block (default 0, ALL)"),
|
||||||
arg_lit0("v", "verbose", "verbose output"),
|
arg_lit0("v", "verbose", "verbose output"),
|
||||||
arg_lit0("z", "dense", "dense dump output style"),
|
arg_lit0("z", "dense", "dense dump output style"),
|
||||||
|
|
|
@ -854,7 +854,7 @@ void Plot::Zoom(double factor, uint32_t refX) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Zoom out
|
} else { // Zoom out
|
||||||
if (g_GraphPixelsPerPointNew >= (1.0 / ZOOM_LIMIT) ) {
|
if (g_GraphPixelsPerPointNew >= (1.0 / ZOOM_LIMIT)) {
|
||||||
g_GraphPixelsPerPoint = g_GraphPixelsPerPointNew;
|
g_GraphPixelsPerPoint = g_GraphPixelsPerPointNew;
|
||||||
// shift graph towards refX when zooming out
|
// shift graph towards refX when zooming out
|
||||||
if (refX > g_GraphStart) {
|
if (refX > g_GraphStart) {
|
||||||
|
@ -951,7 +951,7 @@ void Plot::wheelEvent(QWheelEvent *event) {
|
||||||
Zoom(1.0 / ZOOM_STEP, x);
|
Zoom(1.0 / ZOOM_STEP, x);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Move(PageWidth * delta * move_offset / 120 );
|
Move(PageWidth * delta * move_offset / 120);
|
||||||
}
|
}
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
@ -981,7 +981,7 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
if (event->modifiers() & Qt::ControlModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
offset = 1;
|
offset = 1;
|
||||||
else
|
else
|
||||||
offset = int(ZOOM_LIMIT/g_GraphPixelsPerPoint);
|
offset = int(ZOOM_LIMIT / g_GraphPixelsPerPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
@ -990,13 +990,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(ZOOM_STEP, CursorBPos);
|
Zoom(ZOOM_STEP, CursorBPos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(ZOOM_STEP*2, CursorBPos);
|
Zoom(ZOOM_STEP * 2, CursorBPos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(ZOOM_STEP, CursorAPos);
|
Zoom(ZOOM_STEP, CursorAPos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(ZOOM_STEP*2, CursorAPos);
|
Zoom(ZOOM_STEP * 2, CursorAPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1006,13 +1006,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(1.0 / ZOOM_STEP, CursorBPos);
|
Zoom(1.0 / ZOOM_STEP, CursorBPos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(1.0 / (ZOOM_STEP*2), CursorBPos);
|
Zoom(1.0 / (ZOOM_STEP * 2), CursorBPos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(1.0 / ZOOM_STEP, CursorAPos);
|
Zoom(1.0 / ZOOM_STEP, CursorAPos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(1.0 / (ZOOM_STEP*2), CursorAPos);
|
Zoom(1.0 / (ZOOM_STEP * 2), CursorAPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1266,6 +1266,8 @@ inline uint64_t leadingzeros64(uint64_t a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// byte_strstr searches for the first occurrence of pattern in src
|
||||||
|
// returns the byte offset the pattern is found at, or -1 if not found
|
||||||
int byte_strstr(const uint8_t *src, size_t srclen, const uint8_t *pattern, size_t plen) {
|
int byte_strstr(const uint8_t *src, size_t srclen, const uint8_t *pattern, size_t plen) {
|
||||||
|
|
||||||
size_t max = srclen - plen + 1;
|
size_t max = srclen - plen + 1;
|
||||||
|
@ -1289,6 +1291,9 @@ int byte_strstr(const uint8_t *src, size_t srclen, const uint8_t *pattern, size_
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// byte_strrstr is like byte_strstr except searches in reverse
|
||||||
|
// ie it returns the last occurrence of the pattern in src instead of the first
|
||||||
|
// returns the byte offset the pattern is found at, or -1 if not found
|
||||||
int byte_strrstr(const uint8_t *src, size_t srclen, const uint8_t *pattern, size_t plen) {
|
int byte_strrstr(const uint8_t *src, size_t srclen, const uint8_t *pattern, size_t plen) {
|
||||||
for (int i = srclen - plen; i >= 0; i--) {
|
for (int i = srclen - plen; i >= 0; i--) {
|
||||||
// compare only first byte
|
// compare only first byte
|
||||||
|
|
|
@ -162,254 +162,254 @@ uint64_t bytes_to_num(const uint8_t *src, size_t len) {
|
||||||
|
|
||||||
uint16_t MemLeToUint2byte(const uint8_t *data) {
|
uint16_t MemLeToUint2byte(const uint8_t *data) {
|
||||||
return (uint16_t)(
|
return (uint16_t)(
|
||||||
(((uint16_t)(data[1])) << (8*1)) +
|
(((uint16_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint16_t)(data[0])) << (8*0))
|
(((uint16_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MemLeToUint3byte(const uint8_t *data) {
|
uint32_t MemLeToUint3byte(const uint8_t *data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
(((uint32_t)(data[2])) << (8*2)) +
|
(((uint32_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint32_t)(data[1])) << (8*1)) +
|
(((uint32_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint32_t)(data[0])) << (8*0))
|
(((uint32_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MemLeToUint4byte(const uint8_t *data) {
|
uint32_t MemLeToUint4byte(const uint8_t *data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
(((uint32_t)(data[3])) << (8*3)) +
|
(((uint32_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint32_t)(data[2])) << (8*2)) +
|
(((uint32_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint32_t)(data[1])) << (8*1)) +
|
(((uint32_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint32_t)(data[0])) << (8*0))
|
(((uint32_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemLeToUint5byte(const uint8_t *data) {
|
uint64_t MemLeToUint5byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[4])) << (8*4)) +
|
(((uint64_t)(data[4])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[3])) << (8*3)) +
|
(((uint64_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[2])) << (8*2)) +
|
(((uint64_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[1])) << (8*1)) +
|
(((uint64_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[0])) << (8*0))
|
(((uint64_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemLeToUint6byte(const uint8_t *data) {
|
uint64_t MemLeToUint6byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[5])) << (8*5)) +
|
(((uint64_t)(data[5])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[4])) << (8*4)) +
|
(((uint64_t)(data[4])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[3])) << (8*3)) +
|
(((uint64_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[2])) << (8*2)) +
|
(((uint64_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[1])) << (8*1)) +
|
(((uint64_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[0])) << (8*0))
|
(((uint64_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemLeToUint7byte(const uint8_t *data) {
|
uint64_t MemLeToUint7byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[6])) << (8*6)) +
|
(((uint64_t)(data[6])) << (8 * 6)) +
|
||||||
(((uint64_t)(data[5])) << (8*5)) +
|
(((uint64_t)(data[5])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[4])) << (8*4)) +
|
(((uint64_t)(data[4])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[3])) << (8*3)) +
|
(((uint64_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[2])) << (8*2)) +
|
(((uint64_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[1])) << (8*1)) +
|
(((uint64_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[0])) << (8*0))
|
(((uint64_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemLeToUint8byte(const uint8_t *data) {
|
uint64_t MemLeToUint8byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[7])) << (8*7)) +
|
(((uint64_t)(data[7])) << (8 * 7)) +
|
||||||
(((uint64_t)(data[6])) << (8*6)) +
|
(((uint64_t)(data[6])) << (8 * 6)) +
|
||||||
(((uint64_t)(data[5])) << (8*5)) +
|
(((uint64_t)(data[5])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[4])) << (8*4)) +
|
(((uint64_t)(data[4])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[3])) << (8*3)) +
|
(((uint64_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[2])) << (8*2)) +
|
(((uint64_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[1])) << (8*1)) +
|
(((uint64_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[0])) << (8*0))
|
(((uint64_t)(data[0])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t MemBeToUint2byte(const uint8_t *data) {
|
uint16_t MemBeToUint2byte(const uint8_t *data) {
|
||||||
return (uint16_t)(
|
return (uint16_t)(
|
||||||
(((uint16_t)(data[0])) << (8*1)) +
|
(((uint16_t)(data[0])) << (8 * 1)) +
|
||||||
(((uint16_t)(data[1])) << (8*0))
|
(((uint16_t)(data[1])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MemBeToUint3byte(const uint8_t *data) {
|
uint32_t MemBeToUint3byte(const uint8_t *data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
(((uint32_t)(data[0])) << (8*2)) +
|
(((uint32_t)(data[0])) << (8 * 2)) +
|
||||||
(((uint32_t)(data[1])) << (8*1)) +
|
(((uint32_t)(data[1])) << (8 * 1)) +
|
||||||
(((uint32_t)(data[2])) << (8*0))
|
(((uint32_t)(data[2])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MemBeToUint4byte(const uint8_t *data) {
|
uint32_t MemBeToUint4byte(const uint8_t *data) {
|
||||||
return (uint32_t)(
|
return (uint32_t)(
|
||||||
(((uint32_t)(data[0])) << (8*3)) +
|
(((uint32_t)(data[0])) << (8 * 3)) +
|
||||||
(((uint32_t)(data[1])) << (8*2)) +
|
(((uint32_t)(data[1])) << (8 * 2)) +
|
||||||
(((uint32_t)(data[2])) << (8*1)) +
|
(((uint32_t)(data[2])) << (8 * 1)) +
|
||||||
(((uint32_t)(data[3])) << (8*0))
|
(((uint32_t)(data[3])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemBeToUint5byte(const uint8_t *data) {
|
uint64_t MemBeToUint5byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[0])) << (8*4)) +
|
(((uint64_t)(data[0])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[1])) << (8*3)) +
|
(((uint64_t)(data[1])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[2])) << (8*2)) +
|
(((uint64_t)(data[2])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[3])) << (8*1)) +
|
(((uint64_t)(data[3])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[4])) << (8*0))
|
(((uint64_t)(data[4])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemBeToUint6byte(const uint8_t *data) {
|
uint64_t MemBeToUint6byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[0])) << (8*5)) +
|
(((uint64_t)(data[0])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[1])) << (8*4)) +
|
(((uint64_t)(data[1])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[2])) << (8*3)) +
|
(((uint64_t)(data[2])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[3])) << (8*2)) +
|
(((uint64_t)(data[3])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[4])) << (8*1)) +
|
(((uint64_t)(data[4])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[5])) << (8*0))
|
(((uint64_t)(data[5])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemBeToUint7byte(const uint8_t *data) {
|
uint64_t MemBeToUint7byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[0])) << (8*6)) +
|
(((uint64_t)(data[0])) << (8 * 6)) +
|
||||||
(((uint64_t)(data[1])) << (8*5)) +
|
(((uint64_t)(data[1])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[2])) << (8*4)) +
|
(((uint64_t)(data[2])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[3])) << (8*3)) +
|
(((uint64_t)(data[3])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[4])) << (8*2)) +
|
(((uint64_t)(data[4])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[5])) << (8*1)) +
|
(((uint64_t)(data[5])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[6])) << (8*0))
|
(((uint64_t)(data[6])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t MemBeToUint8byte(const uint8_t *data) {
|
uint64_t MemBeToUint8byte(const uint8_t *data) {
|
||||||
return (uint64_t)(
|
return (uint64_t)(
|
||||||
(((uint64_t)(data[0])) << (8*7)) +
|
(((uint64_t)(data[0])) << (8 * 7)) +
|
||||||
(((uint64_t)(data[1])) << (8*6)) +
|
(((uint64_t)(data[1])) << (8 * 6)) +
|
||||||
(((uint64_t)(data[2])) << (8*5)) +
|
(((uint64_t)(data[2])) << (8 * 5)) +
|
||||||
(((uint64_t)(data[3])) << (8*4)) +
|
(((uint64_t)(data[3])) << (8 * 4)) +
|
||||||
(((uint64_t)(data[4])) << (8*3)) +
|
(((uint64_t)(data[4])) << (8 * 3)) +
|
||||||
(((uint64_t)(data[5])) << (8*2)) +
|
(((uint64_t)(data[5])) << (8 * 2)) +
|
||||||
(((uint64_t)(data[6])) << (8*1)) +
|
(((uint64_t)(data[6])) << (8 * 1)) +
|
||||||
(((uint64_t)(data[7])) << (8*0))
|
(((uint64_t)(data[7])) << (8 * 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint2byteToMemLe(uint8_t *data, uint16_t value) {
|
void Uint2byteToMemLe(uint8_t *data, uint16_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint3byteToMemLe(uint8_t *data, uint32_t value) {
|
void Uint3byteToMemLe(uint8_t *data, uint32_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint4byteToMemLe(uint8_t *data, uint32_t value) {
|
void Uint4byteToMemLe(uint8_t *data, uint32_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint5byteToMemLe(uint8_t *data, uint64_t value) {
|
void Uint5byteToMemLe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint6byteToMemLe(uint8_t *data, uint64_t value) {
|
void Uint6byteToMemLe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint7byteToMemLe(uint8_t *data, uint64_t value) {
|
void Uint7byteToMemLe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
data[6] = (uint8_t)((value >> (8*6)) & 0xffu);
|
data[6] = (uint8_t)((value >> (8 * 6)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint8byteToMemLe(uint8_t *data, uint64_t value) {
|
void Uint8byteToMemLe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
data[6] = (uint8_t)((value >> (8*6)) & 0xffu);
|
data[6] = (uint8_t)((value >> (8 * 6)) & 0xffu);
|
||||||
data[7] = (uint8_t)((value >> (8*7)) & 0xffu);
|
data[7] = (uint8_t)((value >> (8 * 7)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint2byteToMemBe(uint8_t *data, uint16_t value) {
|
void Uint2byteToMemBe(uint8_t *data, uint16_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint3byteToMemBe(uint8_t *data, uint32_t value) {
|
void Uint3byteToMemBe(uint8_t *data, uint32_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint4byteToMemBe(uint8_t *data, uint32_t value) {
|
void Uint4byteToMemBe(uint8_t *data, uint32_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint5byteToMemBe(uint8_t *data, uint64_t value) {
|
void Uint5byteToMemBe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint6byteToMemBe(uint8_t *data, uint64_t value) {
|
void Uint6byteToMemBe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint7byteToMemBe(uint8_t *data, uint64_t value) {
|
void Uint7byteToMemBe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*6)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 6)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[6] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[6] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uint8byteToMemBe(uint8_t *data, uint64_t value) {
|
void Uint8byteToMemBe(uint8_t *data, uint64_t value) {
|
||||||
data[0] = (uint8_t)((value >> (8*7)) & 0xffu);
|
data[0] = (uint8_t)((value >> (8 * 7)) & 0xffu);
|
||||||
data[1] = (uint8_t)((value >> (8*6)) & 0xffu);
|
data[1] = (uint8_t)((value >> (8 * 6)) & 0xffu);
|
||||||
data[2] = (uint8_t)((value >> (8*5)) & 0xffu);
|
data[2] = (uint8_t)((value >> (8 * 5)) & 0xffu);
|
||||||
data[3] = (uint8_t)((value >> (8*4)) & 0xffu);
|
data[3] = (uint8_t)((value >> (8 * 4)) & 0xffu);
|
||||||
data[4] = (uint8_t)((value >> (8*3)) & 0xffu);
|
data[4] = (uint8_t)((value >> (8 * 3)) & 0xffu);
|
||||||
data[5] = (uint8_t)((value >> (8*2)) & 0xffu);
|
data[5] = (uint8_t)((value >> (8 * 2)) & 0xffu);
|
||||||
data[6] = (uint8_t)((value >> (8*1)) & 0xffu);
|
data[6] = (uint8_t)((value >> (8 * 1)) & 0xffu);
|
||||||
data[7] = (uint8_t)((value >> (8*0)) & 0xffu);
|
data[7] = (uint8_t)((value >> (8 * 0)) & 0xffu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RotateLeft - Ultralight, Desfire
|
// RotateLeft - Ultralight, Desfire
|
||||||
|
|
|
@ -3397,13 +3397,16 @@
|
||||||
"description": "Print a iCLASS tag dump file (bin/eml/json)",
|
"description": "Print a iCLASS tag dump file (bin/eml/json)",
|
||||||
"notes": [
|
"notes": [
|
||||||
"hf iclass view -f hf-iclass-AA162D30F8FF12F1-dump.bin",
|
"hf iclass view -f hf-iclass-AA162D30F8FF12F1-dump.bin",
|
||||||
"hf iclass view --first 1 -f hf-iclass-AA162D30F8FF12F1-dump.bin"
|
"hf iclass view --first 1 -f hf-iclass-AA162D30F8FF12F1-dump.bin",
|
||||||
|
"",
|
||||||
|
"If --first is not specified it will default to the first user block",
|
||||||
|
"which is block 6 for secured chips or block 3 for non-secured chips"
|
||||||
],
|
],
|
||||||
"offline": true,
|
"offline": true,
|
||||||
"options": [
|
"options": [
|
||||||
"-h, --help This help",
|
"-h, --help This help",
|
||||||
"-f, --file <fn> filename of dump (bin/eml/json)",
|
"-f, --file <fn> filename of dump (bin/eml/json)",
|
||||||
"--first <dec> Begin printing from this block (default first user block - 6 or 3 on non secured chips)",
|
"--first <dec> Begin printing from this block (default first user block)",
|
||||||
"--last <dec> End printing at this block (default 0, ALL)",
|
"--last <dec> End printing at this block (default 0, ALL)",
|
||||||
"-v, --verbose verbose output",
|
"-v, --verbose verbose output",
|
||||||
"-z, --dense dense dump output style"
|
"-z, --dense dense dump output style"
|
||||||
|
@ -11834,6 +11837,6 @@
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"commands_extracted": 686,
|
"commands_extracted": 686,
|
||||||
"extracted_by": "PM3Help2JSON v1.00",
|
"extracted_by": "PM3Help2JSON v1.00",
|
||||||
"extracted_on": "2023-08-22T23:15:58"
|
"extracted_on": "2023-08-24T05:14:06"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue