mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
style
This commit is contained in:
parent
e23d4ac625
commit
b3285cce8a
12 changed files with 4333 additions and 4455 deletions
|
@ -2222,19 +2222,19 @@ void iClass_Recover(iclass_recover_req_t *msg) {
|
|||
picopass_hdr_t hdr = {0};
|
||||
bool res = false;
|
||||
|
||||
while(!card_select || !card_auth){
|
||||
while (!card_select || !card_auth) {
|
||||
Iso15693InitReader(); //has to be at the top as it starts tracing
|
||||
if(!msg->debug){
|
||||
if (!msg->debug) {
|
||||
set_tracing(false); //disable tracing to prevent crashes - set to true for debugging
|
||||
}else{
|
||||
if (loops == 1){
|
||||
} else {
|
||||
if (loops == 1) {
|
||||
clear_trace(); //if we're debugging better to clear the trace but do it only on the first loop
|
||||
}
|
||||
}
|
||||
if(msg->test){
|
||||
Dbprintf(_YELLOW_("*Cycled Reader*") " ----------------- TEST Index - Loops: "_YELLOW_("%3d / %3d") " --------------*",loops,msg->loop);
|
||||
}else{
|
||||
Dbprintf(_YELLOW_("*Cycled Reader*") " ----------------- Index: "_RED_("%3d")" Loops: "_YELLOW_("%3d / %3d") " --------------*",index,loops,msg->loop);
|
||||
if (msg->test) {
|
||||
Dbprintf(_YELLOW_("*Cycled Reader*") " ----------------- TEST Index - Loops: "_YELLOW_("%3d / %3d") " --------------*", loops, msg->loop);
|
||||
} else {
|
||||
Dbprintf(_YELLOW_("*Cycled Reader*") " ----------------- Index: "_RED_("%3d")" Loops: "_YELLOW_("%3d / %3d") " --------------*", index, loops, msg->loop);
|
||||
}
|
||||
//Step0 Card Select Routine
|
||||
eof_time = 0; //reset eof time
|
||||
|
@ -2247,22 +2247,22 @@ void iClass_Recover(iclass_recover_req_t *msg) {
|
|||
}
|
||||
|
||||
//Step1 Authenticate with AA1 using trace
|
||||
if(card_select){
|
||||
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 == false) {
|
||||
DbpString(_RED_("Unable to authenticate on AA1 using macs! Retrying..."));
|
||||
}else {
|
||||
} else {
|
||||
DbpString(_GREEN_("AA1 authentication with macs successful!"));
|
||||
card_auth = true;
|
||||
}
|
||||
}
|
||||
if(!card_auth || !card_select){
|
||||
if (!card_auth || !card_select) {
|
||||
reinit_tentatives++;
|
||||
switch_off();
|
||||
}
|
||||
if(reinit_tentatives == 5){
|
||||
if (reinit_tentatives == 5) {
|
||||
DbpString(_RED_("Unable to select or authenticate with card multiple times! Stopping."));
|
||||
goto out;
|
||||
}
|
||||
|
@ -2274,26 +2274,26 @@ void iClass_Recover(iclass_recover_req_t *msg) {
|
|||
AddCrc(cmd_read + 1, 1);
|
||||
int priv_esc_tries = 0;
|
||||
bool priv_esc = false;
|
||||
while(!priv_esc){
|
||||
while (!priv_esc) {
|
||||
//The privilege escalation is done with a readcheck and not just a normal read!
|
||||
iclass_send_as_reader(read_check_cc, sizeof(read_check_cc), &start_time, &eof_time, shallow_mod);
|
||||
// expect a 8-byte response here
|
||||
res2 = GetIso15693AnswerFromTag(resp, sizeof(resp), ICLASS_READER_TIMEOUT_OTHERS, &eof_time, false, true, &resp_len);
|
||||
if (res2 != PM3_SUCCESS || resp_len != 8){
|
||||
if (res2 != PM3_SUCCESS || resp_len != 8) {
|
||||
DbpString(_YELLOW_("Privilege Escalation -> ")_RED_("Read failed! Trying again..."));
|
||||
priv_esc_tries++;
|
||||
}else{
|
||||
} else {
|
||||
DbpString(_YELLOW_("Privilege Escalation -> ")_GREEN_("Response OK!"));
|
||||
priv_esc = true;
|
||||
}
|
||||
if(priv_esc_tries == 5){
|
||||
if (priv_esc_tries == 5) {
|
||||
DbpString(_RED_("Unable to complete privilege escalation! Stopping."));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
generate_single_key_block_inverted(zero_key, index, genkeyblock);
|
||||
if(msg->test){
|
||||
if (msg->test) {
|
||||
memcpy(genkeyblock, zero_key, PICOPASS_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
|
@ -2307,39 +2307,39 @@ void iClass_Recover(iclass_recover_req_t *msg) {
|
|||
bool use_mac = true;
|
||||
bool written = false;
|
||||
bool write_error = false;
|
||||
while(written == false && write_error == false){
|
||||
while (written == false && write_error == false) {
|
||||
//Step5 Perform Write
|
||||
if (iclass_writeblock_ext(blockno, genkeyblock, mac2, use_mac, shallow_mod)) {
|
||||
DbpString("Wrote key: ");
|
||||
Dbhexdump(8, genkeyblock, false);
|
||||
}
|
||||
//Reset cypher state
|
||||
//Reset cypher state
|
||||
iclass_send_as_reader(read_check_cc2, sizeof(read_check_cc2), &start_time, &eof_time, shallow_mod);
|
||||
res2 = GetIso15693AnswerFromTag(resp, sizeof(resp), ICLASS_READER_TIMEOUT_OTHERS, &eof_time, false, true, &resp_len);
|
||||
//try to authenticate with the original mac to verify the write happened
|
||||
memcpy(msg->req.key, original_mac, 8);
|
||||
res = authenticate_iclass_tag(&msg->req, &hdr, &start_time, &eof_time, mac1);
|
||||
if(msg->test){
|
||||
if (msg->test) {
|
||||
if (res != true) {
|
||||
DbpString(_RED_("*** CARD EPURSE IS SILENT! RISK OF BRICKING! DO NOT EXECUTE KEY UPDATES! SCAN IT ON READER FOR EPURSE UPDATE, COLLECT NEW TRACES AND TRY AGAIN! ***"));
|
||||
goto out;
|
||||
}else{
|
||||
} else {
|
||||
DbpString(_GREEN_("*** CARD EPURSE IS LOUD! OK TO ATTEMPT KEY RETRIEVAL! RUN AGAIN WITH -notest ***"));
|
||||
completed = true;
|
||||
goto out;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if (res != true) {
|
||||
DbpString("Write Operation : "_GREEN_("VERIFIED! Card Key Updated!"));
|
||||
written = true;
|
||||
}else{
|
||||
} else {
|
||||
DbpString("Write Operation : "_RED_("FAILED! Card Key is the Original. Retrying..."));
|
||||
write_error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!write_error){
|
||||
if (!write_error) {
|
||||
//Step6 Perform 8 authentication attempts + 1 to verify if we found the weak key
|
||||
for (int i = 0; i < 8 ; ++i) {
|
||||
iclass_send_as_reader(read_check_cc2, sizeof(read_check_cc2), &start_time, &eof_time, shallow_mod);
|
||||
|
@ -2359,7 +2359,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) {
|
||||
//Regain privilege escalation with a readcheck
|
||||
iclass_send_as_reader(read_check_cc, sizeof(read_check_cc), &start_time, &eof_time, shallow_mod);
|
||||
res2 = GetIso15693AnswerFromTag(resp, sizeof(resp), ICLASS_READER_TIMEOUT_OTHERS, &eof_time, false, true, &resp_len);
|
||||
|
@ -2381,27 +2381,27 @@ void iClass_Recover(iclass_recover_req_t *msg) {
|
|||
if (res == true) {
|
||||
DbpString("Restore of Original Key "_GREEN_("VERIFIED! Card is usable again."));
|
||||
reverted = true;
|
||||
if (recovered){
|
||||
if (recovered) {
|
||||
goto restore;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
DbpString("Restore of Original Key "_RED_("VERIFICATION FAILED! Trying again..."));
|
||||
}
|
||||
|
||||
revert_retries++;
|
||||
if(revert_retries >= 7){ //must always be an odd number!
|
||||
Dbprintf(_RED_("Attempted to restore original key for %3d times and failed. Stopping. Card is likely unusable."), revert_retries);
|
||||
goto out;
|
||||
if (revert_retries >= 7) { //must always be an odd number!
|
||||
Dbprintf(_RED_("Attempted to restore original key for %3d times and failed. Stopping. Card is likely unusable."), revert_retries);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(loops >= msg->loop){
|
||||
if (loops >= msg->loop) {
|
||||
completed = true;
|
||||
goto out;
|
||||
}
|
||||
if(!write_error){ //if there was a write error, re-run the loop for the same key index
|
||||
if (!write_error) { //if there was a write error, re-run the loop for the same key index
|
||||
loops++;
|
||||
index++;
|
||||
}
|
||||
|
@ -2413,7 +2413,7 @@ restore:
|
|||
;//empty statement for compilation
|
||||
uint8_t partialkey[PICOPASS_BLOCK_SIZE] = {0};
|
||||
|
||||
for(int i = 0; i < PICOPASS_BLOCK_SIZE; i++){
|
||||
for (int i = 0; i < PICOPASS_BLOCK_SIZE; i++) {
|
||||
partialkey[i] = genkeyblock[i] ^ bits_found;
|
||||
}
|
||||
|
||||
|
@ -2429,9 +2429,9 @@ restore:
|
|||
out:
|
||||
|
||||
switch_off();
|
||||
if(completed){
|
||||
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_EINVARG, NULL, 0);
|
||||
}else{
|
||||
if (completed) {
|
||||
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_EINVARG, NULL, 0);
|
||||
} else {
|
||||
reply_ng(CMD_HF_ICLASS_RECOVER, PM3_ESOFT, NULL, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -2440,7 +2440,7 @@ bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint16_t rec_
|
|||
|
||||
if (GetTickCountDelta(receive_timer) > timeout + 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*received_len = Demod.len;
|
||||
|
|
|
@ -3171,7 +3171,7 @@ static int CmdNumCon(const char *Cmd) {
|
|||
pn = (hlen * 4) - slen + 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "%s%.*s%s",radix[i].desc, pn, pad, s);
|
||||
PrintAndLogEx(SUCCESS, "%s%.*s%s", radix[i].desc, pn, pad, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1437,7 +1437,7 @@ bool HF14B_picopass_reader(bool verbose, bool info) {
|
|||
return false;
|
||||
}
|
||||
memcpy(card, resp.data.asBytes, sizeof(picopass_hdr_t));
|
||||
if(info){
|
||||
if (info) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, "iCLASS / Picopass CSN: " _GREEN_("%s"), sprint_hex(card->csn, sizeof(card->csn)));
|
||||
}
|
||||
|
|
|
@ -1311,7 +1311,7 @@ static int CmdGallagherDecode(const char *cmd) {
|
|||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int CmdGallagherEncode (const char *cmd) {
|
||||
static int CmdGallagherEncode(const char *cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hf gallagher encode",
|
||||
"Encode a Gallagher credential block\n"
|
||||
|
@ -1351,7 +1351,7 @@ static int CmdGallagherEncode (const char *cmd) {
|
|||
contents[i + 8] = contents[i] ^ 0xFF;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Raw: " _YELLOW_("%s"), sprint_hex_inrow(contents, ARRAYLEN(contents)/2));
|
||||
PrintAndLogEx(SUCCESS, "Raw: " _YELLOW_("%s"), sprint_hex_inrow(contents, ARRAYLEN(contents) / 2));
|
||||
PrintAndLogEx(SUCCESS, "Bitwise: " _YELLOW_("%s"), sprint_hex_inrow(contents, ARRAYLEN(contents)));
|
||||
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -2712,7 +2712,7 @@ static int CmdHFiClassRestore(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int iclass_read_block_ex(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool replay, bool verbose,
|
||||
bool auth, bool shallow_mod, uint8_t *out, bool print) {
|
||||
bool auth, bool shallow_mod, uint8_t *out, bool print) {
|
||||
|
||||
iclass_auth_req_t payload = {
|
||||
.use_raw = rawkey,
|
||||
|
@ -2762,7 +2762,7 @@ static int iclass_read_block_ex(uint8_t *KEY, uint8_t blockno, uint8_t keyType,
|
|||
}
|
||||
|
||||
static int iclass_read_block(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite, bool rawkey, bool replay, bool verbose,
|
||||
bool auth, bool shallow_mod, uint8_t *out) {
|
||||
bool auth, bool shallow_mod, uint8_t *out) {
|
||||
return iclass_read_block_ex(KEY, blockno, keyType, elite, rawkey, replay, verbose, auth, shallow_mod, out, true);
|
||||
}
|
||||
|
||||
|
@ -3714,10 +3714,10 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
if ((strlen(filename) == 0) && (use_vb6kdf == false)) {
|
||||
|
||||
if (use_elite) {
|
||||
PrintAndLogEx(INFO,"Using default elite dictionary");
|
||||
PrintAndLogEx(INFO, "Using default elite dictionary");
|
||||
snprintf(filename, sizeof(filename), ICLASS_DEFAULT_KEY_ELITE_DIC);
|
||||
} else {
|
||||
PrintAndLogEx(INFO,"Using default dictionary");
|
||||
PrintAndLogEx(INFO, "Using default dictionary");
|
||||
snprintf(filename, sizeof(filename), ICLASS_DEFAULT_KEY_DIC);
|
||||
}
|
||||
}
|
||||
|
@ -5297,7 +5297,7 @@ int info_iclass(bool shallow_mod) {
|
|||
|
||||
iclass_card_select_resp_t *r = (iclass_card_select_resp_t *)resp.data.asBytes;
|
||||
|
||||
uint8_t *p_response = (uint8_t*)&r->header.hdr;
|
||||
uint8_t *p_response = (uint8_t *)&r->header.hdr;
|
||||
// no tag found or button pressed
|
||||
if (r->status == FLAG_ICLASS_NULL || resp.status == PM3_ERFTRANS) {
|
||||
return PM3_EOPABORTED;
|
||||
|
@ -5382,9 +5382,9 @@ int info_iclass(bool shallow_mod) {
|
|||
uint8_t cardtype = get_mem_config(hdr);
|
||||
PrintAndLogEx(SUCCESS, " Card type.... " _GREEN_("%s"), card_types[cardtype]);
|
||||
|
||||
if(HF14B_picopass_reader(false, false)){
|
||||
if (HF14B_picopass_reader(false, false)) {
|
||||
PrintAndLogEx(SUCCESS, " Card chip.... "_YELLOW_("Old Silicon (14b support)"));
|
||||
}else{
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, " Card chip.... "_YELLOW_("NEW Silicon (No 14b support)"));
|
||||
}
|
||||
if (legacy) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -8526,7 +8526,7 @@
|
|||
"lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -> probing for Hitag 2/S",
|
||||
"lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11010 -> probing for Hitag S",
|
||||
"lf cmdread -d 50 -z 116 -o 166 -e W3000 -c W11000 -s 2000 -@ -> probing for Hitag 2/S, oscilloscope style",
|
||||
"lf cmdread -d 48 -z 112 -o 176 -e W3000 -e S240 -e E336 -c W0S00000010000E -> probing for Hitag \u00e6(micro)"
|
||||
"lf cmdread -d 48 -z 112 -o 176 -e W3000 -e S240 -e E336 -c W0S00000010000E -> probing for Hitag \u00b5(micro)"
|
||||
],
|
||||
"offline": false,
|
||||
"options": [
|
||||
|
@ -9762,7 +9762,7 @@
|
|||
"-1, --ht1 Card type Hitag 1",
|
||||
"-2, --ht2 Card type Hitag 2",
|
||||
"-s, --hts Card type Hitag S",
|
||||
"-m, --htm Card type Hitag \u00ce\u00bc"
|
||||
"-m, --htm Card type Hitag \u03bc"
|
||||
],
|
||||
"usage": "lf hitag eload [-h12sm] -f <fn>"
|
||||
},
|
||||
|
@ -13005,6 +13005,6 @@
|
|||
"metadata": {
|
||||
"commands_extracted": 749,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2024-11-02T12:57:51"
|
||||
"extracted_on": "2024-11-02T14:09:48"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue