mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
cppcheck duplicatecondition
This commit is contained in:
parent
85ed469340
commit
4fff85d6ed
1 changed files with 166 additions and 184 deletions
|
@ -1186,7 +1186,6 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
|
|
||||||
// 1. Verify passed parameters authenticate with the tag (safety check)
|
// 1. Verify passed parameters authenticate with the tag (safety check)
|
||||||
// lf em 4x70 auth --rnd <rnd_1> --frn <frn_1>
|
// lf em 4x70 auth --rnd <rnd_1> --frn <frn_1>
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(INFO, "Step 1. Verifying passed parameters authenticate with the tag (safety check)");
|
PrintAndLogEx(INFO, "Step 1. Verifying passed parameters authenticate with the tag (safety check)");
|
||||||
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 auth --rnd %s --frn %s"), rnd_string, frn_string);
|
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 auth --rnd %s --frn %s"), rnd_string, frn_string);
|
||||||
|
|
||||||
|
@ -1217,7 +1216,6 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
last_successful_step = 1;
|
last_successful_step = 1;
|
||||||
}
|
|
||||||
|
|
||||||
// 2/3/4. Brute force the key bits in block 7,8,9
|
// 2/3/4. Brute force the key bits in block 7,8,9
|
||||||
// lf em 4x70 write -b N -d 0000
|
// lf em 4x70 write -b N -d 0000
|
||||||
|
@ -1232,7 +1230,6 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
em4x70_cmd_output_brute_t brute = {0};
|
em4x70_cmd_output_brute_t brute = {0};
|
||||||
|
|
||||||
// lf em 4x70 write -b N -d 0000
|
// lf em 4x70 write -b N -d 0000
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(INFO, "Step %d. Brute force the key bits in block %d", step, block);
|
PrintAndLogEx(INFO, "Step %d. Brute force the key bits in block %d", step, block);
|
||||||
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 write -b %d -d 0000"), block);
|
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 write -b %d -d 0000"), block);
|
||||||
|
|
||||||
|
@ -1253,10 +1250,8 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
PrintAndLogEx(HINT, "Hint: Block %d data was overwritten. Manually restart at step %d", block, step);
|
PrintAndLogEx(HINT, "Hint: Block %d data was overwritten. Manually restart at step %d", block, step);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// lf em 4x70 brute -b N --rnd <rnd_1> --frn <frn_1>
|
// lf em 4x70 brute -b N --rnd <rnd_1> --frn <frn_1>
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 brute -b %d --rnd %s --frn %s"), block, rnd_string, frn_string);
|
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 brute -b %d --rnd %s --frn %s"), block, rnd_string, frn_string);
|
||||||
|
|
||||||
em4x70_cmd_input_brute_t opts_brute = {
|
em4x70_cmd_input_brute_t opts_brute = {
|
||||||
|
@ -1295,18 +1290,16 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
opts.key.k[5] = brute.partial_key[1];
|
opts.key.k[5] = brute.partial_key[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// lf em 4x70 write -b N -d <key_block_N>
|
// lf em 4x70 write -b N -d <key_block_N>
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 write -b %d -d %02X%02X"), block, brute.partial_key[0], brute.partial_key[1]);
|
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 write -b %d -d %02X%02X"), block, brute.partial_key[0], brute.partial_key[1]);
|
||||||
|
|
||||||
em4x70_cmd_input_writeblock_t opt_write_zeros = {
|
em4x70_cmd_input_writeblock_t opt_write_zeros2 = {
|
||||||
.use_parity = opts.parity,
|
.use_parity = opts.parity,
|
||||||
.block = block,
|
.block = block,
|
||||||
.value = {brute.partial_key[0], brute.partial_key[1]},
|
.value = {brute.partial_key[0], brute.partial_key[1]},
|
||||||
};
|
};
|
||||||
|
|
||||||
result = writeblock_em4x70(&opt_write_zeros, &tag_info);
|
result = writeblock_em4x70(&opt_write_zeros2, &tag_info);
|
||||||
|
|
||||||
if (PM3_ETIMEOUT == result) {
|
if (PM3_ETIMEOUT == result) {
|
||||||
PrintAndLogEx(FAILED, "timeout while waiting for reply");
|
PrintAndLogEx(FAILED, "timeout while waiting for reply");
|
||||||
|
@ -1317,13 +1310,8 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
PrintAndLogEx(HINT, "Hint: Block %d data (" _GREEN_("%02X%02X") ") may need to be rewritten", block, brute.partial_key[0], brute.partial_key[1]);
|
PrintAndLogEx(HINT, "Hint: Block %d data (" _GREEN_("%02X%02X") ") may need to be rewritten", block, brute.partial_key[0], brute.partial_key[1]);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
last_successful_step = step;
|
last_successful_step = step;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// The good news is that, if the above succeeded, then from this point forward, the tag remains in a known-good state.
|
// The good news is that, if the above succeeded, then from this point forward, the tag remains in a known-good state.
|
||||||
|
|
||||||
|
@ -1332,7 +1320,6 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
|
|
||||||
// 5. Recover potential values of the lower 48 bits of the key
|
// 5. Recover potential values of the lower 48 bits of the key
|
||||||
// lf em 4x70 recover --key <key_block_9><key_block_8><key_block_7> --rnd <rnd_1> --frn <frn_1>
|
// lf em 4x70 recover --key <key_block_9><key_block_8><key_block_7> --rnd <rnd_1> --frn <frn_1>
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(INFO, "Step 5. Recover potential values of the lower 48 bits of the key");
|
PrintAndLogEx(INFO, "Step 5. Recover potential values of the lower 48 bits of the key");
|
||||||
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 recover --key %s --rnd %s --frn %s --grn %s"), key_string, rnd_string, frn_string, grn_string);
|
PrintAndLogEx(HINT, "Hint: " _YELLOW_("lf em 4x70 recover --key %s --rnd %s --frn %s --grn %s"), key_string, rnd_string, frn_string, grn_string);
|
||||||
|
|
||||||
|
@ -1361,11 +1348,9 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
}
|
}
|
||||||
last_successful_step = 5;
|
last_successful_step = 5;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 6. Verify which potential key is actually on the tag (using a different rnd/frn combination)
|
// 6. Verify which potential key is actually on the tag (using a different rnd/frn combination)
|
||||||
// lf em 4x70 auth --rnd <rnd_2> --frn <frn_N>
|
// lf em 4x70 auth --rnd <rnd_2> --frn <frn_N>
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(INFO, "Step 6. Verify which potential key is actually on the tag");
|
PrintAndLogEx(INFO, "Step 6. Verify which potential key is actually on the tag");
|
||||||
|
|
||||||
em4x70_cmd_input_verify_auth_t opts_v = {
|
em4x70_cmd_input_verify_auth_t opts_v = {
|
||||||
|
@ -1428,12 +1413,9 @@ static int CmdEM4x70AutoRecover(const char *Cmd) {
|
||||||
q.k[ 6], q.k[ 7], q.k[ 8], q.k[ 9], q.k[10], q.k[11]
|
q.k[ 6], q.k[ 7], q.k[ 8], q.k[ 9], q.k[10], q.k[11]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// 7. Print the validated key
|
// 7. Print the validated key
|
||||||
if (PM3_SUCCESS == result) {
|
|
||||||
PrintAndLogEx(SUCCESS, "Recovered key... " _GREEN_("%s"), key_string);
|
PrintAndLogEx(SUCCESS, "Recovered key... " _GREEN_("%s"), key_string);
|
||||||
last_successful_step = 7;
|
last_successful_step = 7;
|
||||||
}
|
|
||||||
|
|
||||||
// For posterity, step 7 used to do the following:
|
// For posterity, step 7 used to do the following:
|
||||||
// 7. Print the validated key --OR-- Print that the tag is still OK --OR-- Print instructions on what to retry to recover tag to a good state
|
// 7. Print the validated key --OR-- Print that the tag is still OK --OR-- Print instructions on what to retry to recover tag to a good state
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue