pressing the pm3 button now stops 4x50_chk function

This commit is contained in:
tharexde 2020-11-11 01:37:54 +01:00
commit 3d14dbfbd0
2 changed files with 15 additions and 11 deletions

View file

@ -1490,7 +1490,7 @@ void em4x50_chk(uint32_t *offset) {
// check passwords from dictionary content in flash memory
bool bsuccess = false;
int status = 0;
uint8_t counter[2] = {0x00, 0x00};
uint16_t isok = 0;
uint16_t pwd_count = 0;
@ -1530,14 +1530,16 @@ void em4x50_chk(uint32_t *offset) {
for (int i = 0; i < pwd_count; i++) {
// manual interruption
if (BUTTON_PRESS())
goto OUT;
if (BUTTON_PRESS()) {
status = BUTTON_SINGLE_CLICK;
break;
}
// get next password from flash memory
pwd = get_pwd(pwds, i);
bsuccess = login(pwd);
if (bsuccess)
status = login(pwd);
if (status == 1)
break;
}
}
@ -1545,5 +1547,5 @@ void em4x50_chk(uint32_t *offset) {
OUT:
lf_finalize();
reply_ng(CMD_LF_EM4X50_CHK, bsuccess, (uint8_t *)&pwd, 32);
reply_ng(CMD_LF_EM4X50_CHK, status, (uint8_t *)&pwd, 32);
}

View file

@ -1228,7 +1228,7 @@ int CmdEM4x50Chk(const char *Cmd) {
// upload passwords from dictionary to flash memory and start password check
bool key_found = false;
int status = 0;
int res = 0, slen = 0;
int keys_remain = 0;
int block_count = 1;
@ -1277,7 +1277,9 @@ int CmdEM4x50Chk(const char *Cmd) {
PrintAndLogEx(FAILED, "error, filesize is larger than available memory");
return PM3_EOVFLOW;
}
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
if (datalen > CARD_MEMORY_SIZE) {
// we have to use more than one block of passwords
@ -1324,13 +1326,13 @@ int CmdEM4x50Chk(const char *Cmd) {
SendCommandNG(CMD_LF_EM4X50_CHK, (uint8_t *)&offset, sizeof(offset));
WaitForResponseTimeoutW(CMD_LF_EM4X50_CHK, &resp, -1, false);
key_found = (bool)resp.status;
if (key_found)
status = resp.status;
if (status != false)
break;
}
// print response
if (key_found)
if (status == 1)
PrintAndLogEx(SUCCESS, "Password " _GREEN_("found: %02x %02x %02x %02x"),
resp.data.asBytes[3],
resp.data.asBytes[2],