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 // check passwords from dictionary content in flash memory
bool bsuccess = false; int status = 0;
uint8_t counter[2] = {0x00, 0x00}; uint8_t counter[2] = {0x00, 0x00};
uint16_t isok = 0; uint16_t isok = 0;
uint16_t pwd_count = 0; uint16_t pwd_count = 0;
@ -1530,14 +1530,16 @@ void em4x50_chk(uint32_t *offset) {
for (int i = 0; i < pwd_count; i++) { for (int i = 0; i < pwd_count; i++) {
// manual interruption // manual interruption
if (BUTTON_PRESS()) if (BUTTON_PRESS()) {
goto OUT; status = BUTTON_SINGLE_CLICK;
break;
}
// get next password from flash memory // get next password from flash memory
pwd = get_pwd(pwds, i); pwd = get_pwd(pwds, i);
bsuccess = login(pwd); status = login(pwd);
if (bsuccess) if (status == 1)
break; break;
} }
} }
@ -1545,5 +1547,5 @@ void em4x50_chk(uint32_t *offset) {
OUT: OUT:
lf_finalize(); 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 // upload passwords from dictionary to flash memory and start password check
bool key_found = false; int status = 0;
int res = 0, slen = 0; int res = 0, slen = 0;
int keys_remain = 0; int keys_remain = 0;
int block_count = 1; int block_count = 1;
@ -1278,6 +1278,8 @@ int CmdEM4x50Chk(const char *Cmd) {
return PM3_EOVFLOW; return PM3_EOVFLOW;
} }
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
if (datalen > CARD_MEMORY_SIZE) { if (datalen > CARD_MEMORY_SIZE) {
// we have to use more than one block of passwords // 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)); SendCommandNG(CMD_LF_EM4X50_CHK, (uint8_t *)&offset, sizeof(offset));
WaitForResponseTimeoutW(CMD_LF_EM4X50_CHK, &resp, -1, false); WaitForResponseTimeoutW(CMD_LF_EM4X50_CHK, &resp, -1, false);
key_found = (bool)resp.status; status = resp.status;
if (key_found) if (status != false)
break; break;
} }
// print response // print response
if (key_found) if (status == 1)
PrintAndLogEx(SUCCESS, "Password " _GREEN_("found: %02x %02x %02x %02x"), PrintAndLogEx(SUCCESS, "Password " _GREEN_("found: %02x %02x %02x %02x"),
resp.data.asBytes[3], resp.data.asBytes[3],
resp.data.asBytes[2], resp.data.asBytes[2],