fix #1234 - cliparse allow empty line, loop now user interuptable

This commit is contained in:
iceman1001 2021-04-06 23:37:45 +02:00
parent 372a6958fa
commit 30a10b266b
2 changed files with 31 additions and 17 deletions

View file

@ -1853,7 +1853,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
Dbprintf("NoAFI UID = %s", iso15693_sprintUID(NULL, recv + 2)); Dbprintf("NoAFI UID = %s", iso15693_sprintUID(NULL, recv + 2));
} else { } else {
DbpString("Failed to select card"); DbpString("Failed to select card");
reply_ng(CMD_ACK, PM3_ESOFT, NULL, 0); reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_ESOFT, NULL, 0);
switch_off(); switch_off();
return; return;
} }
@ -1881,10 +1881,8 @@ void BruteforceIso15693Afi(uint32_t speed) {
Dbprintf("AFI = %i UID = %s", i, iso15693_sprintUID(NULL, recv + 2)); Dbprintf("AFI = %i UID = %s", i, iso15693_sprintUID(NULL, recv + 2));
} }
aborted = BUTTON_PRESS(); aborted = BUTTON_PRESS() && data_available();
if (aborted) { if (aborted) {
DbpString("button pressed, aborting..");
break; break;
} }
} }
@ -1893,9 +1891,9 @@ void BruteforceIso15693Afi(uint32_t speed) {
switch_off(); switch_off();
if (aborted) { if (aborted) {
reply_ng(CMD_ACK, PM3_EOPABORTED, NULL, 0); reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_EOPABORTED, NULL, 0);
} else { } else {
reply_ng(CMD_ACK, PM3_SUCCESS, NULL, 0); reply_ng(CMD_HF_ISO15693_FINDAFI, PM3_SUCCESS, NULL, 0);
} }
} }

View file

@ -35,6 +35,7 @@
#include "cmddata.h" // getsamples #include "cmddata.h" // getsamples
#include "fileutils.h" // savefileEML #include "fileutils.h" // savefileEML
#include "cliparser.h" #include "cliparser.h"
#include "util_posix.h" // msleep
#define FrameSOF Iso15693FrameSOF #define FrameSOF Iso15693FrameSOF
#define Logic0 Iso15693Logic0 #define Logic0 Iso15693Logic0
@ -1151,28 +1152,43 @@ static int CmdHF15FindAfi(const char *Cmd) {
arg_param_begin, arg_param_begin,
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx); CLIParserFree(ctx);
PrintAndLogEx(SUCCESS, "press pm3-button to cancel"); PrintAndLogEx(INFO, "click " _GREEN_("pm3 button") " or press " _GREEN_("Enter") " to exit");
clearCommandBuffer(); clearCommandBuffer();
PacketResponseNG resp; PacketResponseNG resp;
SendCommandMIX(CMD_HF_ISO15693_FINDAFI, strtol(Cmd, NULL, 0), 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO15693_FINDAFI, strtol(Cmd, NULL, 0), 0, 0, NULL, 0);
uint32_t timeout = 0; for (;;) {
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
timeout++; if (kbd_enter_pressed()) {
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
PrintAndLogEx(DEBUG, "User aborted");
msleep(300);
break;
}
uint32_t timeout = 0;
if (WaitForResponseTimeout(CMD_HF_ISO15693_FINDAFI, &resp, 2000)){
if (resp.status == PM3_EOPABORTED) {
PrintAndLogEx(DEBUG, "Button pressed, user aborted");
break;
}
} else {
timeout++;
// should be done in about 2 minutes
if (timeout > 180) {
PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
break;
}
// should be done in about 2 minutes
if (timeout > 180) {
PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting...");
DropField();
return PM3_ETIMEOUT;
} }
} }
DropField(); DropField();
PrintAndLogEx(INFO, "Done");
return resp.status; // PM3_EOPABORTED or PM3_SUCCESS return resp.status; // PM3_EOPABORTED or PM3_SUCCESS
} }