mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
restore function now stops if password is wrong
This commit is contained in:
parent
414b892b65
commit
e41e8555a3
1 changed files with 23 additions and 20 deletions
|
@ -1331,7 +1331,7 @@ void em4x50_restore(em4x50_data_t *etd) {
|
||||||
// restore em4x50 dump file to tag
|
// restore em4x50 dump file to tag
|
||||||
|
|
||||||
bool bsuccess = false;
|
bool bsuccess = false;
|
||||||
int status = PM3_EFAILED;
|
int status = PM3_SUCCESS;
|
||||||
int start_word = 3; // first block/address with user data
|
int start_word = 3; // first block/address with user data
|
||||||
uint8_t em4x50_mem[DUMP_FILESIZE] = {0x0};
|
uint8_t em4x50_mem[DUMP_FILESIZE] = {0x0};
|
||||||
uint32_t addresses = 0x00001F01; // from fwr = 1 to lwr = 31 (0x1F)
|
uint32_t addresses = 0x00001F01; // from fwr = 1 to lwr = 31 (0x1F)
|
||||||
|
@ -1357,35 +1357,38 @@ void em4x50_restore(em4x50_data_t *etd) {
|
||||||
|
|
||||||
// login first if password is available
|
// login first if password is available
|
||||||
if (etd->pwd_given) {
|
if (etd->pwd_given) {
|
||||||
if (login(etd->password1) == PM3_SUCCESS) {
|
if ((status = login(etd->password1)) == PM3_SUCCESS) {
|
||||||
|
|
||||||
// successful login allows words 1 and 2 to be written
|
// successful login allows words 1 and 2 to be written
|
||||||
start_word = 1;
|
start_word = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write data to each address but ignore addresses
|
if (status == PM3_SUCCESS) {
|
||||||
// 0 -> password, 32 -> serial, 33 -> uid
|
|
||||||
for (int i = start_word; i < EM4X50_NO_WORDS - 2; i++) {
|
// write data to each address but ignore addresses
|
||||||
status = write(words_client[i], i);
|
// 0 -> password, 32 -> serial, 33 -> uid
|
||||||
if (status == PM3_ETEAROFF) {
|
for (int i = start_word; i < EM4X50_NO_WORDS - 2; i++) {
|
||||||
lf_finalize();
|
status = write(words_client[i], i);
|
||||||
return;
|
if (status == PM3_ETEAROFF) {
|
||||||
|
lf_finalize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// to verify result -> reset EM4x50
|
// to verify result -> reset EM4x50
|
||||||
if (reset() == PM3_SUCCESS) {
|
if (reset() == PM3_SUCCESS) {
|
||||||
|
|
||||||
// login not necessary because protected word has been set to 0
|
// login not necessary because protected word has been set to 0
|
||||||
// -> no read protected words
|
// -> no read protected words
|
||||||
// -> selective read can be called immediately
|
// -> selective read can be called immediately
|
||||||
if (selective_read(addresses, words_read) == PM3_SUCCESS) {
|
if (selective_read(addresses, words_read) == PM3_SUCCESS) {
|
||||||
|
|
||||||
// check if everything is zero
|
// check if everything is zero
|
||||||
bsuccess = true;
|
bsuccess = true;
|
||||||
for (int i = start_word; i < EM4X50_NO_WORDS - 2; i++)
|
for (int i = start_word; i < EM4X50_NO_WORDS - 2; i++)
|
||||||
bsuccess &= (reflect32(words_read[i]) == words_client[i]);
|
bsuccess &= (reflect32(words_read[i]) == words_client[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue