mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
make style
This commit is contained in:
parent
7bc3067fa4
commit
8d4acbe3a6
13 changed files with 78 additions and 79 deletions
|
@ -158,17 +158,17 @@ static void download_instructions(uint8_t t) {
|
||||||
|
|
||||||
// Save to flash if file doesn't exist.
|
// Save to flash if file doesn't exist.
|
||||||
// Write over file if size of flash file is less than new datalen
|
// Write over file if size of flash file is less than new datalen
|
||||||
static void save_to_flash(uint8_t *data, uint16_t datalen, char * filename) {
|
static void save_to_flash(uint8_t *data, uint16_t datalen, char *filename) {
|
||||||
|
|
||||||
rdv40_spiffs_lazy_mount();
|
rdv40_spiffs_lazy_mount();
|
||||||
|
|
||||||
char fn[SPIFFS_OBJ_NAME_LEN];
|
char fn[SPIFFS_OBJ_NAME_LEN];
|
||||||
|
|
||||||
if (filename == NULL){
|
if (filename == NULL) {
|
||||||
sprintf(fn, "iclass-%02X%02X%02X%02X%02X%02X%02X%02X.bin",
|
sprintf(fn, "iclass-%02X%02X%02X%02X%02X%02X%02X%02X.bin",
|
||||||
data[0], data[1], data[2], data[3],
|
data[0], data[1], data[2], data[3],
|
||||||
data[4], data[5], data[6], data[7]
|
data[4], data[5], data[6], data[7]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
int name_len = SPIFFS_OBJ_NAME_LEN;
|
int name_len = SPIFFS_OBJ_NAME_LEN;
|
||||||
int filename_len = strlen(filename);
|
int filename_len = strlen(filename);
|
||||||
|
@ -176,7 +176,7 @@ static void save_to_flash(uint8_t *data, uint16_t datalen, char * filename) {
|
||||||
// if the given name len longer than buffer allows, cut it down to size
|
// if the given name len longer than buffer allows, cut it down to size
|
||||||
name_len = (name_len >= SPIFFS_OBJ_NAME_LEN) ? SPIFFS_OBJ_NAME_LEN : filename_len;
|
name_len = (name_len >= SPIFFS_OBJ_NAME_LEN) ? SPIFFS_OBJ_NAME_LEN : filename_len;
|
||||||
memcpy(fn, filename, name_len);
|
memcpy(fn, filename, name_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int res;
|
int res;
|
||||||
if (exists_in_spiffs(fn) == false) {
|
if (exists_in_spiffs(fn) == false) {
|
||||||
|
@ -558,12 +558,12 @@ static int dump_sim_mode(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_off();
|
switch_off();
|
||||||
char * temp_file = HF_ICALSSS_READSIM_TEMP_BIN;
|
char *temp_file = HF_ICALSSS_READSIM_TEMP_BIN;
|
||||||
save_to_flash(card_data, (start_block + dumped) * 8, temp_file);
|
save_to_flash(card_data, (start_block + dumped) * 8, temp_file);
|
||||||
Dbprintf("%u bytes saved", (start_block + dumped) * 8);
|
Dbprintf("%u bytes saved", (start_block + dumped) * 8);
|
||||||
|
|
||||||
if (((start_block + dumped) * 8) > 0) {
|
if (((start_block + dumped) * 8) > 0) {
|
||||||
break; //switch to sim mode
|
break; //switch to sim mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ static int dump_sim_mode(void) {
|
||||||
if (res == SPIFFS_OK) {
|
if (res == SPIFFS_OK) {
|
||||||
Dbprintf("loaded " _GREEN_(HF_ICALSSS_READSIM_TEMP_BIN) " (%u bytes)", fsize);
|
Dbprintf("loaded " _GREEN_(HF_ICALSSS_READSIM_TEMP_BIN) " (%u bytes)", fsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dbprintf("simming " _GREEN_(HF_ICALSSS_READSIM_TEMP_BIN));
|
Dbprintf("simming " _GREEN_(HF_ICALSSS_READSIM_TEMP_BIN));
|
||||||
iclass_simulate(ICLASS_SIM_MODE_FULL, 0, false, NULL, NULL, NULL);
|
iclass_simulate(ICLASS_SIM_MODE_FULL, 0, false, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
@ -190,9 +190,9 @@ static uint32_t get_rising_pulse_length(void) {
|
||||||
|
|
||||||
static uint32_t get_pulse_length(edge_detection_t edge) {
|
static uint32_t get_pulse_length(edge_detection_t edge) {
|
||||||
|
|
||||||
if(edge == RISING_EDGE)
|
if (edge == RISING_EDGE)
|
||||||
return get_rising_pulse_length();
|
return get_rising_pulse_length();
|
||||||
else if(edge == FALLING_EDGE)
|
else if (edge == FALLING_EDGE)
|
||||||
return get_falling_pulse_length();
|
return get_falling_pulse_length();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -292,11 +292,11 @@ static bool check_ack(void) {
|
||||||
// ACK 64 + 64
|
// ACK 64 + 64
|
||||||
// NACK 64 + 48
|
// NACK 64 + 48
|
||||||
if (check_pulse_length(get_pulse_length(FALLING_EDGE), 2 * EM4X70_T_TAG_FULL_PERIOD) &&
|
if (check_pulse_length(get_pulse_length(FALLING_EDGE), 2 * EM4X70_T_TAG_FULL_PERIOD) &&
|
||||||
check_pulse_length(get_pulse_length(FALLING_EDGE), 2 * EM4X70_T_TAG_FULL_PERIOD)) {
|
check_pulse_length(get_pulse_length(FALLING_EDGE), 2 * EM4X70_T_TAG_FULL_PERIOD)) {
|
||||||
// ACK
|
// ACK
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Othewise it was a NACK or Listen Window
|
// Othewise it was a NACK or Listen Window
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -426,10 +426,10 @@ static bool find_listen_window(bool command) {
|
||||||
96 ( 64 + 32 )
|
96 ( 64 + 32 )
|
||||||
64 ( 32 + 16 +16 )*/
|
64 ( 32 + 16 +16 )*/
|
||||||
|
|
||||||
if (check_pulse_length(get_pulse_length(RISING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
if (check_pulse_length(get_pulse_length(RISING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||||
check_pulse_length(get_pulse_length(RISING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
check_pulse_length(get_pulse_length(RISING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_HALF_PERIOD) &&
|
||||||
check_pulse_length(get_pulse_length(FALLING_EDGE), (2*EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_FULL_PERIOD) &&
|
check_pulse_length(get_pulse_length(FALLING_EDGE), (2 * EM4X70_T_TAG_FULL_PERIOD) + EM4X70_T_TAG_FULL_PERIOD) &&
|
||||||
check_pulse_length(get_pulse_length(FALLING_EDGE), EM4X70_T_TAG_FULL_PERIOD + (2*EM4X70_T_TAG_HALF_PERIOD))) {
|
check_pulse_length(get_pulse_length(FALLING_EDGE), EM4X70_T_TAG_FULL_PERIOD + (2 * EM4X70_T_TAG_HALF_PERIOD))) {
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
/* Here we are after the 64 duration edge.
|
/* Here we are after the 64 duration edge.
|
||||||
|
@ -438,7 +438,7 @@ static bool find_listen_window(bool command) {
|
||||||
*
|
*
|
||||||
* I've found between 4-5 quarter periods (32-40) works best
|
* I've found between 4-5 quarter periods (32-40) works best
|
||||||
*/
|
*/
|
||||||
WaitTicks( 4 * EM4X70_T_TAG_QUARTER_PERIOD );
|
WaitTicks(4 * EM4X70_T_TAG_QUARTER_PERIOD);
|
||||||
// Send RM Command
|
// Send RM Command
|
||||||
em4x70_send_bit(0);
|
em4x70_send_bit(0);
|
||||||
em4x70_send_bit(0);
|
em4x70_send_bit(0);
|
||||||
|
@ -559,7 +559,7 @@ static int em4x70_receive(uint8_t *bits, size_t length) {
|
||||||
WaitTicks(6 * EM4X70_T_TAG_FULL_PERIOD);
|
WaitTicks(6 * EM4X70_T_TAG_FULL_PERIOD);
|
||||||
|
|
||||||
// wait until we get the transition from 1's to 0's which is 1.5 full windows
|
// wait until we get the transition from 1's to 0's which is 1.5 full windows
|
||||||
for(int i = 0; i < EM4X70_T_READ_HEADER_LEN; i++) {
|
for (int i = 0; i < EM4X70_T_READ_HEADER_LEN; i++) {
|
||||||
pl = get_pulse_length(edge);
|
pl = get_pulse_length(edge);
|
||||||
if (check_pulse_length(pl, 3 * EM4X70_T_TAG_HALF_PERIOD)) {
|
if (check_pulse_length(pl, 3 * EM4X70_T_TAG_HALF_PERIOD)) {
|
||||||
foundheader = true;
|
foundheader = true;
|
||||||
|
@ -575,7 +575,7 @@ static int em4x70_receive(uint8_t *bits, size_t length) {
|
||||||
// Skip next 3 0's, header check consumes the first 0
|
// Skip next 3 0's, header check consumes the first 0
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
// If pulse length is not 1 bit, then abort early
|
// If pulse length is not 1 bit, then abort early
|
||||||
if(!check_pulse_length(get_pulse_length(edge), EM4X70_T_TAG_FULL_PERIOD)) {
|
if (!check_pulse_length(get_pulse_length(edge), EM4X70_T_TAG_FULL_PERIOD)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,8 +745,8 @@ void em4x70_write_pin(em4x70_data_t *etd) {
|
||||||
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
|
||||||
|
|
||||||
|
@ -784,13 +784,13 @@ void em4x70_write_key(em4x70_data_t *etd) {
|
||||||
// Read ID to ensure we can write to card
|
// Read ID to ensure we can write to card
|
||||||
if (em4x70_read_id()) {
|
if (em4x70_read_id()) {
|
||||||
status = 1;
|
status = 1;
|
||||||
|
|
||||||
// Write each crypto block
|
|
||||||
for(int i = 0; i < 6; i++) {
|
|
||||||
|
|
||||||
uint16_t key_word = (etd->crypt_key[(i*2)+1] << 8) + etd->crypt_key[i*2];
|
// Write each crypto block
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
|
||||||
|
uint16_t key_word = (etd->crypt_key[(i * 2) + 1] << 8) + etd->crypt_key[i * 2];
|
||||||
// Write each word, abort if any failure occurs
|
// Write each word, abort if any failure occurs
|
||||||
if (write(key_word, 9-i) != PM3_SUCCESS) {
|
if (write(key_word, 9 - i) != PM3_SUCCESS) {
|
||||||
status = 0;
|
status = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ typedef struct {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
RISING_EDGE,
|
RISING_EDGE,
|
||||||
FALLING_EDGE
|
FALLING_EDGE
|
||||||
}edge_detection_t;
|
} edge_detection_t;
|
||||||
|
|
||||||
void em4x70_info(em4x70_data_t *etd);
|
void em4x70_info(em4x70_data_t *etd);
|
||||||
void em4x70_write(em4x70_data_t *etd);
|
void em4x70_write(em4x70_data_t *etd);
|
||||||
|
|
|
@ -53,7 +53,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||||
"Will try to find a HF read out of the unknown tag.\n"
|
"Will try to find a HF read out of the unknown tag.\n"
|
||||||
"Continues to search for all different HF protocols.",
|
"Continues to search for all different HF protocols.",
|
||||||
"hf sniff"
|
"hf sniff"
|
||||||
);
|
);
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_param_end
|
arg_param_end
|
||||||
|
@ -244,7 +244,7 @@ int CmdHFTune(const char *Cmd) {
|
||||||
max = (volt * 1.03);
|
max = (volt * 1.03);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if ( volt > max) {
|
if (volt > max) {
|
||||||
max = (volt * 1.03);
|
max = (volt * 1.03);
|
||||||
}
|
}
|
||||||
print_progress(volt, max, style);
|
print_progress(volt, max, style);
|
||||||
|
@ -274,7 +274,7 @@ int CmdHFSniff(const char *Cmd) {
|
||||||
"Press button to quit the sniffing.",
|
"Press button to quit the sniffing.",
|
||||||
"hf sniff\n"
|
"hf sniff\n"
|
||||||
"hf sniff --sp 1000 --st 0 -> skip 1000 pairs, skip 0 triggers"
|
"hf sniff --sp 1000 --st 0 -> skip 1000 pairs, skip 0 triggers"
|
||||||
);
|
);
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_u64_0(NULL, "sp", "<dec>", "skip sample pairs"),
|
arg_u64_0(NULL, "sp", "<dec>", "skip sample pairs"),
|
||||||
|
|
|
@ -2001,7 +2001,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||||
|
|
||||||
if (do_aid_search) {
|
if (do_aid_search) {
|
||||||
|
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "-------------------- " _CYAN_("AID Search") " --------------------");
|
PrintAndLogEx(INFO, "-------------------- " _CYAN_("AID Search") " --------------------");
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
|
@ -82,9 +82,9 @@ static void hf14b_aid_search(bool verbose) {
|
||||||
bool activate_field = true;
|
bool activate_field = true;
|
||||||
for (elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
for (elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
||||||
|
|
||||||
if (kbd_enter_pressed()) {
|
if (kbd_enter_pressed()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_t *data = AIDSearchGetElm(root, elmindx);
|
json_t *data = AIDSearchGetElm(root, elmindx);
|
||||||
uint8_t vaid[200] = {0};
|
uint8_t vaid[200] = {0};
|
||||||
|
|
|
@ -61,7 +61,7 @@ static int emrtd_print_ef_dg12_info(uint8_t *data, size_t datalen);
|
||||||
static int emrtd_print_ef_sod_info(uint8_t *data, size_t datalen);
|
static int emrtd_print_ef_sod_info(uint8_t *data, size_t datalen);
|
||||||
|
|
||||||
typedef enum { // list must match dg_table
|
typedef enum { // list must match dg_table
|
||||||
EF_COM=0,
|
EF_COM = 0,
|
||||||
EF_DG1,
|
EF_DG1,
|
||||||
EF_DG2,
|
EF_DG2,
|
||||||
EF_DG3,
|
EF_DG3,
|
||||||
|
@ -109,7 +109,7 @@ static emrtd_dg_t dg_table[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static emrtd_dg_t *emrtd_tag_to_dg(uint8_t tag) {
|
static emrtd_dg_t *emrtd_tag_to_dg(uint8_t tag) {
|
||||||
for (int dgi=0; dg_table[dgi].filename != NULL; dgi++) {
|
for (int dgi = 0; dg_table[dgi].filename != NULL; dgi++) {
|
||||||
if (dg_table[dgi].tag == tag) {
|
if (dg_table[dgi].tag == tag) {
|
||||||
return &dg_table[dgi];
|
return &dg_table[dgi];
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ static emrtd_dg_t *emrtd_tag_to_dg(uint8_t tag) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static emrtd_dg_t *emrtd_fileid_to_dg(const char *file_id) {
|
static emrtd_dg_t *emrtd_fileid_to_dg(const char *file_id) {
|
||||||
for (int dgi=0; dg_table[dgi].filename != NULL; dgi++) {
|
for (int dgi = 0; dg_table[dgi].filename != NULL; dgi++) {
|
||||||
if (strcmp(dg_table[dgi].fileid, file_id) == 0) {
|
if (strcmp(dg_table[dgi].fileid, file_id) == 0) {
|
||||||
return &dg_table[dgi];
|
return &dg_table[dgi];
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ static int emrtd_dump_ef_dg2(uint8_t *file_contents, size_t file_length) {
|
||||||
// Note: Doing file_length - 6 to account for the longest data we're checking.
|
// Note: Doing file_length - 6 to account for the longest data we're checking.
|
||||||
for (offset = 0; offset < file_length - 6; offset++) {
|
for (offset = 0; offset < file_length - 6; offset++) {
|
||||||
if ((file_contents[offset] == 0xFF && file_contents[offset + 1] == 0xD8 && file_contents[offset + 2] == 0xFF && file_contents[offset + 3] == 0xE0) ||
|
if ((file_contents[offset] == 0xFF && file_contents[offset + 1] == 0xD8 && file_contents[offset + 2] == 0xFF && file_contents[offset + 3] == 0xE0) ||
|
||||||
(file_contents[offset] == 0x00 && file_contents[offset + 1] == 0x00 && file_contents[offset + 2] == 0x00 && file_contents[offset + 3] == 0x0C && file_contents[offset + 4] == 0x6A && file_contents[offset + 5] == 0x50)) {
|
(file_contents[offset] == 0x00 && file_contents[offset + 1] == 0x00 && file_contents[offset + 2] == 0x00 && file_contents[offset + 3] == 0x0C && file_contents[offset + 4] == 0x6A && file_contents[offset + 5] == 0x50)) {
|
||||||
datalen = file_length - offset;
|
datalen = file_length - offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ static int emrtd_dump_ef_dg7(uint8_t *file_contents, size_t file_length) {
|
||||||
static int emrtd_dump_ef_sod(uint8_t *file_contents, size_t file_length) {
|
static int emrtd_dump_ef_sod(uint8_t *file_contents, size_t file_length) {
|
||||||
int fieldlen = emrtd_get_asn1_field_length(file_contents, file_length, 1);
|
int fieldlen = emrtd_get_asn1_field_length(file_contents, file_length, 1);
|
||||||
int datalen = emrtd_get_asn1_data_length(file_contents, file_length, 1);
|
int datalen = emrtd_get_asn1_data_length(file_contents, file_length, 1);
|
||||||
|
|
||||||
if (fieldlen + 1 > EMRTD_MAX_FILE_SIZE) {
|
if (fieldlen + 1 > EMRTD_MAX_FILE_SIZE) {
|
||||||
PrintAndLogEx(ERR, "error (emrtd_dump_ef_sod) fieldlen out-of-bounds");
|
PrintAndLogEx(ERR, "error (emrtd_dump_ef_sod) fieldlen out-of-bounds");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -766,7 +766,7 @@ static bool emrtd_dump_file(uint8_t *ks_enc, uint8_t *ks_mac, uint8_t *ssc, cons
|
||||||
PrintAndLogEx(INFO, "Read %s, len: %i.", name, resplen);
|
PrintAndLogEx(INFO, "Read %s, len: %i.", name, resplen);
|
||||||
PrintAndLogEx(DEBUG, "Contents (may be incomplete over 2k chars): %s", sprint_hex_inrow(response, resplen));
|
PrintAndLogEx(DEBUG, "Contents (may be incomplete over 2k chars): %s", sprint_hex_inrow(response, resplen));
|
||||||
saveFile(name, ".BIN", response, resplen);
|
saveFile(name, ".BIN", response, resplen);
|
||||||
emrtd_dg_t * dg = emrtd_fileid_to_dg(file);
|
emrtd_dg_t *dg = emrtd_fileid_to_dg(file);
|
||||||
if ((dg != NULL) && (dg->dumper != NULL)) {
|
if ((dg != NULL) && (dg->dumper != NULL)) {
|
||||||
dg->dumper(response, resplen);
|
dg->dumper(response, resplen);
|
||||||
}
|
}
|
||||||
|
@ -778,7 +778,7 @@ static void rng(int length, uint8_t *dataout) {
|
||||||
//for (int i = 0; i < (length / 4); i++) {
|
//for (int i = 0; i < (length / 4); i++) {
|
||||||
// num_to_bytes(prng_successor(msclock() + i, 32), 4, &dataout[i * 4]);
|
// num_to_bytes(prng_successor(msclock() + i, 32), 4, &dataout[i * 4]);
|
||||||
//}
|
//}
|
||||||
memset(dataout, 0x00, length);
|
memset(dataout, 0x00, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool emrtd_do_bac(char *documentnumber, char *dob, char *expiry, uint8_t *ssc, uint8_t *ks_enc, uint8_t *ks_mac, bool use_14b) {
|
static bool emrtd_do_bac(char *documentnumber, char *dob, char *expiry, uint8_t *ssc, uint8_t *ks_enc, uint8_t *ks_mac, bool use_14b) {
|
||||||
|
@ -1006,7 +1006,7 @@ int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
||||||
filelist[filelistlen++] = 0x77;
|
filelist[filelistlen++] = 0x77;
|
||||||
// Dump all files in the file list
|
// Dump all files in the file list
|
||||||
for (int i = 0; i < filelistlen; i++) {
|
for (int i = 0; i < filelistlen; i++) {
|
||||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||||
if (dg == NULL) {
|
if (dg == NULL) {
|
||||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1027,9 +1027,9 @@ static bool emrtd_compare_check_digit(char *datain, int datalen, char expected_c
|
||||||
uint8_t check_digit = emrtd_calculate_check_digit(tempdata) + 0x30;
|
uint8_t check_digit = emrtd_calculate_check_digit(tempdata) + 0x30;
|
||||||
bool res = check_digit == expected_check_digit;
|
bool res = check_digit == expected_check_digit;
|
||||||
PrintAndLogEx(DEBUG, "emrtd_compare_check_digit, expected %c == %c calculated ( %s )"
|
PrintAndLogEx(DEBUG, "emrtd_compare_check_digit, expected %c == %c calculated ( %s )"
|
||||||
, expected_check_digit
|
, expected_check_digit
|
||||||
, check_digit
|
, check_digit
|
||||||
, (res) ? _GREEN_("ok") : _RED_("fail"));
|
, (res) ? _GREEN_("ok") : _RED_("fail"));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,7 +1231,7 @@ static int emrtd_print_ef_com_info(uint8_t *data, size_t datalen) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "-------------------- " _CYAN_("EF_COM") " --------------------");
|
PrintAndLogEx(INFO, "-------------------- " _CYAN_("EF_COM") " --------------------");
|
||||||
for (int i = 0; i < filelistlen; i++) {
|
for (int i = 0; i < filelistlen; i++) {
|
||||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||||
if (dg == NULL) {
|
if (dg == NULL) {
|
||||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1513,7 +1513,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = emrtd_print_ef_com_info(response, resplen);
|
int res = emrtd_print_ef_com_info(response, resplen);
|
||||||
if ( res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
DropField();
|
DropField();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1530,7 +1530,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab
|
||||||
filelist[filelistlen++] = 0x77;
|
filelist[filelistlen++] = 0x77;
|
||||||
// Dump all files in the file list
|
// Dump all files in the file list
|
||||||
for (int i = 0; i < filelistlen; i++) {
|
for (int i = 0; i < filelistlen; i++) {
|
||||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||||
if (dg == NULL) {
|
if (dg == NULL) {
|
||||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1563,7 +1563,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = emrtd_print_ef_com_info(data, datalen);
|
int res = emrtd_print_ef_com_info(data, datalen);
|
||||||
if ( res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
free(data);
|
free(data);
|
||||||
free(filepath);
|
free(filepath);
|
||||||
return res;
|
return res;
|
||||||
|
@ -1583,7 +1583,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
||||||
filelist[filelistlen++] = 0x77;
|
filelist[filelistlen++] = 0x77;
|
||||||
// Read files in the file list
|
// Read files in the file list
|
||||||
for (int i = 0; i < filelistlen; i++) {
|
for (int i = 0; i < filelistlen; i++) {
|
||||||
emrtd_dg_t * dg = emrtd_tag_to_dg(filelist[i]);
|
emrtd_dg_t *dg = emrtd_tag_to_dg(filelist[i]);
|
||||||
if (dg == NULL) {
|
if (dg == NULL) {
|
||||||
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
PrintAndLogEx(INFO, "File tag not found, skipping: %02X", filelist[i]);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1592,8 +1592,7 @@ int infoHF_EMRTD_offline(const char *path) {
|
||||||
strcpy(filepath, path);
|
strcpy(filepath, path);
|
||||||
strncat(filepath, PATHSEP, 2);
|
strncat(filepath, PATHSEP, 2);
|
||||||
strcat(filepath, dg->filename);
|
strcat(filepath, dg->filename);
|
||||||
if (loadFile_safeEx(filepath, ".BIN", (void **)&data, (size_t *)&datalen, false) == PM3_SUCCESS)
|
if (loadFile_safeEx(filepath, ".BIN", (void **)&data, (size_t *)&datalen, false) == PM3_SUCCESS) {
|
||||||
{
|
|
||||||
// we won't halt on parsing errors
|
// we won't halt on parsing errors
|
||||||
if (dg->parser != NULL)
|
if (dg->parser != NULL)
|
||||||
dg->parser(data, datalen);
|
dg->parser(data, datalen);
|
||||||
|
@ -1662,7 +1661,7 @@ static int cmd_hf_emrtd_dump(const char *Cmd) {
|
||||||
memset(docnum + slen, '<', 9 - slen);
|
memset(docnum + slen, '<', 9 - slen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLIParamStrToBuf(arg_get_str(ctx, 2), dob, 6, &slen) != 0 || slen == 0) {
|
if (CLIParamStrToBuf(arg_get_str(ctx, 2), dob, 6, &slen) != 0 || slen == 0) {
|
||||||
BAC = false;
|
BAC = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1672,7 +1671,7 @@ static int cmd_hf_emrtd_dump(const char *Cmd) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLIParamStrToBuf(arg_get_str(ctx, 3), expiry, 6, &slen) != 0 || slen == 0) {
|
if (CLIParamStrToBuf(arg_get_str(ctx, 3), expiry, 6, &slen) != 0 || slen == 0) {
|
||||||
BAC = false;
|
BAC = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1748,7 +1747,7 @@ static int cmd_hf_emrtd_info(const char *Cmd) {
|
||||||
memset(docnum + slen, '<', 9 - slen);
|
memset(docnum + slen, '<', 9 - slen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLIParamStrToBuf(arg_get_str(ctx, 2), dob, 6, &slen) != 0 || slen == 0) {
|
if (CLIParamStrToBuf(arg_get_str(ctx, 2), dob, 6, &slen) != 0 || slen == 0) {
|
||||||
BAC = false;
|
BAC = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1758,7 +1757,7 @@ static int cmd_hf_emrtd_info(const char *Cmd) {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLIParamStrToBuf(arg_get_str(ctx, 3), expiry, 6, &slen) != 0 || slen == 0) {
|
if (CLIParamStrToBuf(arg_get_str(ctx, 3), expiry, 6, &slen) != 0 || slen == 0) {
|
||||||
BAC = false;
|
BAC = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -328,11 +328,11 @@ static int CmdLFTune(const char *Cmd) {
|
||||||
|
|
||||||
uint32_t volt = resp.data.asDwords[0];
|
uint32_t volt = resp.data.asDwords[0];
|
||||||
if (first) {
|
if (first) {
|
||||||
max = (volt * 1.03);
|
max = (volt * 1.03);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if ( volt > max) {
|
if (volt > max) {
|
||||||
max = (volt * 1.03);
|
max = (volt * 1.03);
|
||||||
}
|
}
|
||||||
print_progress(volt, max, style);
|
print_progress(volt, max, style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ int CmdEM4x50EView(const char *Cmd) {
|
||||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// valid em4x50 data?
|
// valid em4x50 data?
|
||||||
uint32_t serial = bytes_to_num(data + 4 * EM4X50_DEVICE_SERIAL, 4);
|
uint32_t serial = bytes_to_num(data + 4 * EM4X50_DEVICE_SERIAL, 4);
|
||||||
uint32_t device_id = bytes_to_num(data + 4 * EM4X50_DEVICE_ID, 4);
|
uint32_t device_id = bytes_to_num(data + 4 * EM4X50_DEVICE_ID, 4);
|
||||||
|
|
|
@ -175,7 +175,7 @@ int CmdRem(const char *Cmd) {
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
|
|
||||||
struct arg_str* foo = arg_get_str(ctx, 1);
|
struct arg_str *foo = arg_get_str(ctx, 1);
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -314,7 +314,7 @@ void preferences_load_callback(json_t *root) {
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
if (json_unpack_ex(root, &up_error, 0, "{s:b}", "os.supports.colors", &b1) == 0)
|
||||||
session.supports_colors = (bool)b1;
|
session.supports_colors = (bool)b1;
|
||||||
|
|
||||||
// bar mode
|
// bar mode
|
||||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.bar.mode", &s1) == 0) {
|
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "show.bar.mode", &s1) == 0) {
|
||||||
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
strncpy(tempStr, s1, sizeof(tempStr) - 1);
|
||||||
str_lower(tempStr);
|
str_lower(tempStr);
|
||||||
|
|
|
@ -632,7 +632,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
static int prev_cols = 0;
|
static int prev_cols = 0;
|
||||||
int rows;
|
int rows;
|
||||||
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
||||||
rl_get_screen_size (&rows, &cols);
|
rl_get_screen_size(&rows, &cols);
|
||||||
(void) rows;
|
(void) rows;
|
||||||
if (prev_cols > cols) {
|
if (prev_cols > cols) {
|
||||||
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
||||||
|
@ -640,9 +640,9 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
prev_cols = cols;
|
prev_cols = cols;
|
||||||
#endif
|
#endif
|
||||||
int width = cols - 35;
|
int width = cols - 35;
|
||||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||||
// x/8 fractional part of the percentage
|
// x/8 fractional part of the percentage
|
||||||
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
||||||
|
|
||||||
const char *smoothtable[] = {
|
const char *smoothtable[] = {
|
||||||
"\xe2\x80\x80",
|
"\xe2\x80\x80",
|
||||||
|
@ -662,13 +662,13 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
const char *space[] = {" ", "\xe2\x80\x80"};
|
const char *space[] = {" ", "\xe2\x80\x80"};
|
||||||
uint8_t unit = strlen(block[mode]);
|
uint8_t unit = strlen(block[mode]);
|
||||||
// +1 for \0
|
// +1 for \0
|
||||||
char *bar = calloc(unit*width + 1, sizeof(uint8_t));
|
char *bar = calloc(unit * width + 1, sizeof(uint8_t));
|
||||||
|
|
||||||
uint8_t value = PERCENTAGE(count, max);
|
uint8_t value = PERCENTAGE(count, max);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// prefix is added already.
|
// prefix is added already.
|
||||||
for (; i < unit*value; i+=unit) {
|
for (; i < unit * value; i += unit) {
|
||||||
memcpy(bar + i, block[mode], unit);
|
memcpy(bar + i, block[mode], unit);
|
||||||
}
|
}
|
||||||
// add last block
|
// add last block
|
||||||
|
@ -679,7 +679,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
}
|
}
|
||||||
i += unit;
|
i += unit;
|
||||||
// add spaces
|
// add spaces
|
||||||
for (; i < unit*width; i+=unit) {
|
for (; i < unit * width; i += unit) {
|
||||||
memcpy(bar + i, space[mode], unit);
|
memcpy(bar + i, space[mode], unit);
|
||||||
}
|
}
|
||||||
// color buffer
|
// color buffer
|
||||||
|
@ -687,24 +687,24 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||||
char *cbar = calloc(collen, sizeof(uint8_t));
|
char *cbar = calloc(collen, sizeof(uint8_t));
|
||||||
|
|
||||||
// Add colors
|
// Add colors
|
||||||
int p60 = unit*(width*60/100);
|
int p60 = unit * (width * 60 / 100);
|
||||||
int p20 = unit*(width*20/100);
|
int p20 = unit * (width * 20 / 100);
|
||||||
snprintf(cbar, collen, _GREEN_("%.*s"), p60, bar);
|
snprintf(cbar, collen, _GREEN_("%.*s"), p60, bar);
|
||||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _CYAN_("%.*s"), p20, bar + p60);
|
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _CYAN_("%.*s"), p20, bar + p60);
|
||||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit*width - p60 - p20, bar + p60 + p20);
|
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit * width - p60 - p20, bar + p60 + p20);
|
||||||
|
|
||||||
size_t len = strlen(cbar) + 32;
|
size_t len = strlen(cbar) + 32;
|
||||||
char *buffer = calloc(len, sizeof(uint8_t));
|
char *buffer = calloc(len, sizeof(uint8_t));
|
||||||
|
|
||||||
switch(style) {
|
switch (style) {
|
||||||
case STYLE_BAR: {
|
case STYLE_BAR: {
|
||||||
sprintf(buffer, "%s", cbar);
|
sprintf(buffer, "%s", cbar);
|
||||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s", 27, buffer);
|
printf("\b%c[2K\r[" _YELLOW_("=")"] %s", 27, buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STYLE_MIXED: {
|
case STYLE_MIXED: {
|
||||||
sprintf(buffer, "%s [ %zu mV / %3u V ]", cbar, count, (uint32_t)(count / 1000));
|
sprintf(buffer, "%s [ %zu mV / %3u V ]", cbar, count, (uint32_t)(count / 1000));
|
||||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s ", 27, buffer);
|
printf("\b%c[2K\r[" _YELLOW_("=")"] %s ", 27, buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STYLE_VALUE: {
|
case STYLE_VALUE: {
|
||||||
|
|
|
@ -198,8 +198,8 @@ Check column "offline" for their availability.
|
||||||
|command |offline |description
|
|command |offline |description
|
||||||
|------- |------- |-----------
|
|------- |------- |-----------
|
||||||
|`hf epa help `|Y |`This help`
|
|`hf epa help `|Y |`This help`
|
||||||
|`hf epa cnonces `|N |`Acquire encrypted PACE nonces of specific size`
|
|`hf epa cnonces `|N |`<m> <n> <d> Acquire n>0 encrypted PACE nonces of size m>0 with d sec pauses`
|
||||||
|`hf epa preplay `|N |`Perform PACE protocol by replaying given APDUs`
|
|`hf epa preplay `|N |`<mse> <get> <map> <pka> <ma> Perform PACE protocol by replaying given APDUs`
|
||||||
|
|
||||||
|
|
||||||
### hf emrtd
|
### hf emrtd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue