make style

This commit is contained in:
iceman1001 2025-06-04 18:05:30 +02:00
commit 186ed6fb07
3 changed files with 75 additions and 75 deletions

View file

@ -400,7 +400,7 @@ int do_iclass_simulation(int simulationMode, uint8_t *reader_mac_buf) {
int trace_data_size;
// Respond SOF -- takes 1 bytes
uint8_t resp_sof[1] = {0};
uint8_t resp_sof[2] = {0};
int resp_sof_len;
// Anticollision CSN (rotated CSN)
@ -2333,7 +2333,7 @@ void iClass_TearBlock(iclass_tearblock_req_t *msg) {
if (memcmp(data_read, ff_data, PICOPASS_BLOCK_SIZE) == 0 &&
memcmp(data_read_orig, ff_data, PICOPASS_BLOCK_SIZE) != 0) {
if(erase_phase == false){
if (erase_phase == false) {
DbpString("");
DbpString(_CYAN_("Erase phase hit... ALL ONES"));
@ -2679,44 +2679,44 @@ void iClass_Recover(iclass_recover_req_t *msg) {
uint8_t original_mac[8] = {0};
uint8_t mac1[4] = {0};
while (!card_select || !card_auth) {
while (!card_select || !card_auth) {
Iso15693InitReader(); //has to be at the top as it starts tracing
if (!msg->debug) {
set_tracing(false); //disable tracing to prevent crashes - set to true for debugging
} else {
if (loops == 1) {
clear_trace(); //if we're debugging better to clear the trace but do it only on the first loop
}
}
//Step0 Card Select Routine
eof_time = 0; //reset eof time
res = select_iclass_tag(&hdr, false, &eof_time, shallow_mod);
if (res) {
status_message = 1; //card select successful
card_select = true;
}
//Step1 Authenticate with AA1 using trace
if (card_select) {
memcpy(original_mac, msg->req.key, 8);
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
res = authenticate_iclass_tag(&msg->req, &hdr, &start_time, &eof_time, mac1);
if (res) {
status_message = 2; //authentication with AA1 macs successful
card_auth = true;
}
}
if (!card_auth || !card_select) {
reinit_tentatives++;
switch_off();
}
if (reinit_tentatives == 5) {
DbpString("");
DbpString(_RED_("Unable to select or authenticate with card multiple times! Stopping."));
goto out;
Iso15693InitReader(); //has to be at the top as it starts tracing
if (!msg->debug) {
set_tracing(false); //disable tracing to prevent crashes - set to true for debugging
} else {
if (loops == 1) {
clear_trace(); //if we're debugging better to clear the trace but do it only on the first loop
}
}
//Step0 Card Select Routine
eof_time = 0; //reset eof time
res = select_iclass_tag(&hdr, false, &eof_time, shallow_mod);
if (res) {
status_message = 1; //card select successful
card_select = true;
}
//Step1 Authenticate with AA1 using trace
if (card_select) {
memcpy(original_mac, msg->req.key, 8);
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
res = authenticate_iclass_tag(&msg->req, &hdr, &start_time, &eof_time, mac1);
if (res) {
status_message = 2; //authentication with AA1 macs successful
card_auth = true;
}
}
if (!card_auth || !card_select) {
reinit_tentatives++;
switch_off();
}
if (reinit_tentatives == 5) {
DbpString("");
DbpString(_RED_("Unable to select or authenticate with card multiple times! Stopping."));
goto out;
}
}
while (bits_found == -1) {
@ -2728,9 +2728,9 @@ void iClass_Recover(iclass_recover_req_t *msg) {
uint16_t resp_len = 0;
if (BUTTON_PRESS() || loops > msg->loop) {
if(loops > msg->loop){
if (loops > msg->loop) {
completed = true;
}else{
} else {
interrupted = true;
}
goto out;
@ -2738,9 +2738,9 @@ void iClass_Recover(iclass_recover_req_t *msg) {
if (msg->test) {
Dbprintf(_YELLOW_("*Cycled Reader*") " TEST Index - Loops: "_YELLOW_("%3d / %3d") " *", loops, msg->loop);
}else if (msg->debug || (!card_select && !card_auth)){
} else if (msg->debug || (!card_select && !card_auth)) {
Dbprintf(_YELLOW_("*Cycled Reader*") " Index: "_RED_("%3d")" Loops: "_YELLOW_("%3d / %3d") " *", index, loops, msg->loop);
}else{
} else {
DbprintfEx(FLAG_INPLACE, "[" _BLUE_("#") "] Index: "_CYAN_("%3d")" Loops: "_YELLOW_("%3d / %3d")" ", index, loops, msg->loop);
}
@ -2798,7 +2798,7 @@ void iClass_Recover(iclass_recover_req_t *msg) {
goto out;
}
}
if(priv_esc && status_message != 3){
if (priv_esc && status_message != 3) {
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
iclass_send_as_reader(read_check_cc, sizeof(read_check_cc), &start_time, &eof_time, shallow_mod);
status_message = 3;
@ -2851,7 +2851,7 @@ void iClass_Recover(iclass_recover_req_t *msg) {
}
}
if (!write_error) {
if (write_error == false) {
//Step6 Perform 8 authentication attempts + 1 to verify if we found the weak key
for (int i = 0; i < 8 ; ++i) {
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
@ -2869,7 +2869,7 @@ void iClass_Recover(iclass_recover_req_t *msg) {
//regardless of bits being found, restore the original key and verify it
bool reverted = false;
uint8_t revert_retries = 0;
while (!reverted) {
while (reverted == false) {
//Regain privilege escalation with a readcheck
start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
iclass_send_as_reader(read_check_cc, sizeof(read_check_cc), &start_time, &eof_time, shallow_mod);
@ -2908,28 +2908,28 @@ void iClass_Recover(iclass_recover_req_t *msg) {
}
if(msg->debug){
if(status_message >= 1){
if (msg->debug) {
if (status_message >= 1) {
DbpString("");
DbpString("Card Select:............."_GREEN_("Ok!"));
}
if(status_message >= 2){
if (status_message >= 2) {
DbpString("AA1 macs authentication:."_GREEN_("Ok!"));
}
if(status_message >= 3){
if (status_message >= 3) {
DbpString("Privilege Escalation:...."_GREEN_("Ok!"));
}
if(status_message >= 4){
if (status_message >= 4) {
DbpString("Wrote key: ");
Dbhexdump(8, genkeyblock, false);
}
if(status_message >= 5){
if (status_message >= 5) {
DbpString("Key Update:.............."_GREEN_("Verified!"));
}
if(status_message >= 6){
if (status_message >= 6) {
DbpString("Original Key Restore:...."_GREEN_("Ok!"));
}
if(status_message >= 7){
if (status_message >= 7) {
DbpString("Original Key Restore:...."_GREEN_("Verified!"));
}
}
@ -2939,7 +2939,7 @@ void iClass_Recover(iclass_recover_req_t *msg) {
card_select = false;
card_auth = false;
priv_esc = false;
}else{
} else {
loops++;
index++;
status_message = 2;
@ -2974,7 +2974,7 @@ out:
switch_off();
if (completed) {
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_EINVARG, NULL, 0);
} else if (interrupted){
} else if (interrupted) {
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_EOPABORTED, NULL, 0);
} else {
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_ESOFT, NULL, 0);

View file

@ -704,7 +704,7 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
uint8_t app2_limit = card_app2_limit[type];
uint8_t pagemap = get_pagemap(hdr);
PrintAndLogEx(INFO, "-------------------------- " _CYAN_("Memory") " --------------------------");
PrintAndLogEx(INFO, "------------------------ " _CYAN_("Memory") " -------------------------");
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {
PrintAndLogEx(INFO, " %u KBits ( " _YELLOW_("%u") " bytes )", kb, app2_limit * 8);
@ -733,7 +733,7 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
[=] AA2 blocks 5 { 0x100 - 0xFF (256 - 255) }
*/
PrintAndLogEx(INFO, "------------------------- " _CYAN_("KeyAccess") " ------------------------");
PrintAndLogEx(INFO, "----------------------- " _CYAN_("KeyAccess") " -----------------------");
PrintAndLogEx(INFO, " * Kd, Debit key, AA1 Kc, Credit key, AA2 *");
uint8_t keyAccess = isset(mem, 0x01);
if (keyAccess) {
@ -754,13 +754,13 @@ static void mem_app_config(const picopass_hdr_t *hdr) {
}
void print_picopass_info(const picopass_hdr_t *hdr) {
PrintAndLogEx(INFO, "-------------------- " _CYAN_("Card configuration") " --------------------");
PrintAndLogEx(INFO, "------------------- " _CYAN_("Card configuration") " ------------------");
fuse_config(hdr);
mem_app_config(hdr);
}
void print_picopass_header(const picopass_hdr_t *hdr) {
PrintAndLogEx(INFO, "--------------------------- " _CYAN_("Card") " ---------------------------");
PrintAndLogEx(INFO, "-------------------------- " _CYAN_("Card") " -------------------------");
PrintAndLogEx(SUCCESS, " CSN... " _GREEN_("%s") " uid", sprint_hex(hdr->csn, sizeof(hdr->csn)));
PrintAndLogEx(SUCCESS, " Config... %s card configuration", sprint_hex((uint8_t *)&hdr->conf, sizeof(hdr->conf)));
PrintAndLogEx(SUCCESS, "E-purse... %s card challenge, CC", sprint_hex(hdr->epurse, sizeof(hdr->epurse)));
@ -768,13 +768,13 @@ void print_picopass_header(const picopass_hdr_t *hdr) {
if (memcmp(hdr->key_d, zeros, sizeof(zeros)) && memcmp(hdr->key_d, empty, sizeof(empty))) {
PrintAndLogEx(SUCCESS, " Kd... " _YELLOW_("%s") " debit key", sprint_hex(hdr->key_d, sizeof(hdr->key_d)));
} else {
PrintAndLogEx(SUCCESS, " Kd... %s debit key ( hidden )", sprint_hex(hdr->key_d, sizeof(hdr->key_d)));
PrintAndLogEx(SUCCESS, " Kd... -- -- -- -- -- -- -- -- debit key ( hidden )");
}
if (memcmp(hdr->key_c, zeros, sizeof(zeros)) && memcmp(hdr->key_c, empty, sizeof(empty))) {
PrintAndLogEx(SUCCESS, " Kc... " _YELLOW_("%s") " credit key", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
} else {
PrintAndLogEx(SUCCESS, " Kc... %s credit key ( hidden )", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
PrintAndLogEx(SUCCESS, " Kc... -- -- -- -- -- -- -- -- credit key ( hidden )");
}
PrintAndLogEx(SUCCESS, " AIA... %s application issuer area", sprint_hex(hdr->app_issuer_area, sizeof(hdr->app_issuer_area)));
@ -3163,12 +3163,12 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
bool reread = false;
bool erase_phase = false;
if (blockno < 3){
if (blockno < 3) {
read_auth = false;
}
int res_orig = iclass_read_block_ex(key, blockno, keyType, elite, rawkey, use_replay, verbose, read_auth, shallow_mod, data_read_orig, false);
while (reread){
while (reread) {
if (res_orig == PM3_SUCCESS && !reread) {
if (memcmp(data_read_orig, zeros, 8) == 0) {
reread = true;
@ -3177,25 +3177,25 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
}
} else if (res_orig == PM3_SUCCESS && reread) {
reread = false;
if (blockno == 2 && memcmp(data_read_orig, zeros, 8) == 0){
if (blockno == 2 && memcmp(data_read_orig, zeros, 8) == 0) {
reread = true;
}
}
}
if (blockno == 2 && data_len == 0){
if (blockno == 2 && data_len == 0) {
int value_index = 0; //assuming FFFFFFFF is on the right
if(memcmp(data_read_orig + 4, "\xFF\xFF\xFF\xFF", 4) != 0){ //FFFFFFFF is on the left
if (memcmp(data_read_orig + 4, "\xFF\xFF\xFF\xFF", 4) != 0) { //FFFFFFFF is on the left
value_index = 4;
}
memcpy(key, iClass_Key_Table[1], PICOPASS_BLOCK_SIZE);
use_credit_key = true;
auth = true;
memcpy(data,data_read_orig,PICOPASS_BLOCK_SIZE);
memcpy(data, data_read_orig, PICOPASS_BLOCK_SIZE);
//decrease the debit epurse value by 1
if(data_read_orig[value_index] != 0x00){
if (data_read_orig[value_index] != 0x00) {
data[value_index]--;
}else{
} else {
data[value_index + 2]--;
data[value_index] = 0xFF;
}
@ -3369,7 +3369,7 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
if (memcmp(data_read, ff_data, 8) == 0 &&
memcmp(data_read_orig, ff_data, 8) != 0) {
if (erase_phase == false){
if (erase_phase == false) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, _CYAN_("Erase phase hit... ALL ONES"));
iclass_cmp_print(data_read_orig, data_read, "Original: ", "Read: ");
@ -6018,7 +6018,7 @@ int info_iclass(bool shallow_mod) {
picopass_ns_hdr_t *ns_hdr = &r->header.ns_hdr;
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " ----------------------------------------");
PrintAndLogEx(INFO, "--- " _CYAN_("Tag Information") " -------------------------------------");
if ((r->status & FLAG_ICLASS_CSN) == FLAG_ICLASS_CSN) {
PrintAndLogEx(SUCCESS, " CSN: " _GREEN_("%s") " uid", sprint_hex(hdr->csn, sizeof(hdr->csn)));
@ -6042,13 +6042,13 @@ int info_iclass(bool shallow_mod) {
if (memcmp(hdr->key_d, zeros, sizeof(zeros))) {
PrintAndLogEx(SUCCESS, " Kd: " _YELLOW_("%s") " debit key", sprint_hex(hdr->key_d, sizeof(hdr->key_d)));
} else {
PrintAndLogEx(SUCCESS, " Kd: %s debit key ( hidden )", sprint_hex(hdr->key_d, sizeof(hdr->key_d)));
PrintAndLogEx(SUCCESS, " Kd: -- -- -- -- -- -- -- -- debit key ( hidden )");
}
if (memcmp(hdr->key_c, zeros, sizeof(zeros))) {
PrintAndLogEx(SUCCESS, " Kc: " _YELLOW_("%s") " credit key", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
} else {
PrintAndLogEx(SUCCESS, " Kc: %s credit key ( hidden )", sprint_hex(hdr->key_c, sizeof(hdr->key_c)));
PrintAndLogEx(SUCCESS, " Kc: -- -- -- -- -- -- -- -- credit key ( hidden )");
}
@ -6061,7 +6061,7 @@ int info_iclass(bool shallow_mod) {
print_picopass_info(hdr);
}
PrintAndLogEx(INFO, "------------------------ " _CYAN_("Fingerprint") " -----------------------");
PrintAndLogEx(INFO, "----------------------- " _CYAN_("Fingerprint") " ---------------------");
uint8_t aia[8];
if (pagemap == PICOPASS_NON_SECURE_PAGEMODE) {

View file

@ -3745,7 +3745,7 @@
"--sleep <ms> Sleep between each tear",
"--arm Runs the commands on device side and tries to stabilize tears"
],
"usage": "hf iclass tear [-hv] [-k <hex>] [--ki <dec>] --blk <dec> -d <hex> [-m <hex>] [--credit] [--elite] [--raw] [--nr] [--shallow] -s <dec> [-i <dec>] [-e <dec>] [--loop <dec>] [--sleep <ms>] [--arm]"
"usage": "hf iclass tear [-hv] [-k <hex>] [--ki <dec>] --blk <dec> [-d <hex>] [-m <hex>] [--credit] [--elite] [--raw] [--nr] [--shallow] -s <dec> [-i <dec>] [-e <dec>] [--loop <dec>] [--sleep <ms>] [--arm]"
},
"hf iclass unhash": {
"command": "hf iclass unhash",
@ -13372,6 +13372,6 @@
"metadata": {
"commands_extracted": 768,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2025-05-29T23:30:20"
"extracted_on": "2025-06-04T16:02:17"
}
}