mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
exits
This commit is contained in:
parent
c454b1f3e6
commit
275986e743
1 changed files with 40 additions and 35 deletions
|
@ -1680,8 +1680,10 @@ static int unlock_write_protect(bool use_pwd, uint32_t pwd, uint32_t data, bool
|
|||
|
||||
return status;
|
||||
}
|
||||
static int unlock_reset(bool use_pwd, uint32_t pwd, uint32_t data) {
|
||||
static int unlock_reset(bool use_pwd, uint32_t pwd, uint32_t data, bool verbose) {
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "resetting the " _RED_("active") " lock block");
|
||||
|
||||
return unlock_write_protect(use_pwd, pwd, data, false);
|
||||
}
|
||||
|
||||
|
@ -1791,7 +1793,10 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, " write value [ " _GREEN_("%08X") " ]", write_value);
|
||||
|
||||
PrintAndLogEx(INFO, "----------------------------------------------------------------------------\n");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "press " _YELLOW_("'enter'") " to cancel the command");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "--------------- " _CYAN_("start") " -----------------------\n");
|
||||
|
||||
int exit_code = PM3_SUCCESS;
|
||||
uint32_t word14 = 0, word15 = 0;
|
||||
|
@ -1833,20 +1838,11 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
late = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (is_cancelled()) {
|
||||
exit_code = PM3_EOPABORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( start != prev_delay) {
|
||||
PrintAndLogEx(INFO, "Tear-off delay hook configured => " _GREEN_("%.0lf us"), start);
|
||||
prev_delay = start;
|
||||
}
|
||||
*/
|
||||
|
||||
// set tear off trigger
|
||||
clearCommandBuffer();
|
||||
tearoff_params_t params = {
|
||||
|
@ -1857,7 +1853,7 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
res = handle_tearoff(¶ms, verbose);
|
||||
if ( res != PM3_SUCCESS ) {
|
||||
PrintAndLogEx(WARNING, "failed to configure tear off");
|
||||
return PM3_EOPABORTED;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// write
|
||||
|
@ -1865,18 +1861,16 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
|
||||
// read after trigger
|
||||
res = EM4x05ReadWord_ext(14, pwd, use_pwd, &word14);
|
||||
if (res == PM3_SUCCESS) {
|
||||
//PrintAndLogEx(INFO, "14 after [ " _GREEN_("%08X") " ]", word14);
|
||||
} else {
|
||||
break;
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "failed to read 14");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// read after trigger
|
||||
res = EM4x05ReadWord_ext(15, pwd, use_pwd, &word15);
|
||||
if (res == PM3_SUCCESS) {
|
||||
//PrintAndLogEx(INFO, "15 after [ " _GREEN_("%08X") " ]", word15);
|
||||
} else {
|
||||
break;
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "failed to read 15");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
|
@ -1905,31 +1899,40 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Status: 15 ok, 14 partially erased => " _GREEN_("tearing too late"));
|
||||
}
|
||||
}
|
||||
unlock_reset(use_pwd, pwd, write_value);
|
||||
|
||||
unlock_reset(use_pwd, pwd, write_value, verbose);
|
||||
|
||||
uint32_t word14b = 0, word15b = 0;
|
||||
|
||||
// read after reset
|
||||
res = EM4x05ReadWord_ext(14, pwd, use_pwd, &word14b);
|
||||
if (res != PM3_SUCCESS) {
|
||||
break;
|
||||
PrintAndLogEx(WARNING, "failed to read 14");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (word14b == 0) {
|
||||
unlock_reset(use_pwd, pwd, write_value);
|
||||
|
||||
unlock_reset(use_pwd, pwd, write_value, verbose);
|
||||
|
||||
res = EM4x05ReadWord_ext(14, pwd, use_pwd, &word14b);
|
||||
if (res != PM3_SUCCESS) {
|
||||
break;
|
||||
PrintAndLogEx(WARNING, "failed to read 14");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
|
||||
if (word14b != search_value) {
|
||||
|
||||
// read after reset
|
||||
res = EM4x05ReadWord_ext(15, pwd, use_pwd, &word15b);
|
||||
if (res == PM3_SUCCESS) {
|
||||
PrintAndLogEx(INFO, "Status: new definitive value! => " _RED_("SUCCESS:") " 14: " _CYAN_("%08X") " 15: %08X", word14b, word15b);
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "failed to read 15");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
if (my_auto) {
|
||||
end = start;
|
||||
|
@ -1947,18 +1950,20 @@ static int CmdEM4x05Unlock(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Status: 15 bitflipped and active => " _RED_("SUCCESS?: ") "14: %08X 15: " _CYAN_("%08X"), word14, word15);
|
||||
PrintAndLogEx(INFO, "Committing results...");
|
||||
|
||||
unlock_reset(use_pwd, pwd, write_value);
|
||||
unlock_reset(use_pwd, pwd, write_value, verbose);
|
||||
uint32_t word14b = 0, word15b = 0;
|
||||
|
||||
// read after reset
|
||||
res = EM4x05ReadWord_ext(14, pwd, use_pwd, &word14b);
|
||||
if ( res != PM3_SUCCESS ) {
|
||||
PrintAndLogEx(WARNING, "failed to read 14");
|
||||
return PM3_EOPABORTED;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
res = EM4x05ReadWord_ext(15, pwd, use_pwd, &word15b);
|
||||
if ( res != PM3_SUCCESS ) {
|
||||
PrintAndLogEx(WARNING, "failed to read 15");
|
||||
return PM3_EOPABORTED;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue