Add SKIPREADLINE support to make and cmake
It's mostly for headless support. At the moment, for interactive uage without readline, some commands will exit the client prematurely if they use kbd_enter_pressed().
This commit is contained in:
@@ -73,12 +73,13 @@ static int usage_legic_sim(void) {
|
||||
}
|
||||
static int usage_legic_wrbl(void) {
|
||||
PrintAndLogEx(NORMAL, "Write data to a LEGIC Prime tag. It autodetects tagsize to make sure size\n");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf legic wrbl [h] [o <offset>] [d <data (hex symbols)>]\n");
|
||||
PrintAndLogEx(NORMAL, "Usage: hf legic wrbl [h] [o <offset>] [d <data (hex symbols)>] [y]\n");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h : this help");
|
||||
PrintAndLogEx(NORMAL, " o <offset> : (hex) offset in data array to start writing");
|
||||
//PrintAndLogEx(NORMAL, " <IV> : (optional) Initialization vector to use (ODD and 7bits)");
|
||||
PrintAndLogEx(NORMAL, " d <data> : (hex symbols) bytes to write ");
|
||||
PrintAndLogEx(NORMAL, " y : Auto-confirm dangerous operations ");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, _YELLOW_(" hf legic wrbl o 10 d 11223344 - Write 0x11223344 starting from offset 0x10"));
|
||||
@@ -596,6 +597,7 @@ static int CmdLegicWrbl(const char *Cmd) {
|
||||
uint8_t *data = NULL;
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
bool autoconfirm = false;
|
||||
int len = 0, bg, en;
|
||||
uint32_t offset = 0, IV = 0x55;
|
||||
|
||||
@@ -655,6 +657,10 @@ static int CmdLegicWrbl(const char *Cmd) {
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
case 'y': {
|
||||
autoconfirm = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
@@ -693,23 +699,28 @@ static int CmdLegicWrbl(const char *Cmd) {
|
||||
return PM3_EOUTOFBOUND;
|
||||
}
|
||||
|
||||
if (offset == 5 || offset == 6) {
|
||||
if ((offset == 5 || offset == 6) && (! autoconfirm)) {
|
||||
PrintAndLogEx(NORMAL, "############# DANGER ################");
|
||||
PrintAndLogEx(NORMAL, "# changing the DCF is irreversible #");
|
||||
PrintAndLogEx(NORMAL, "#####################################");
|
||||
|
||||
#ifndef ANDROID
|
||||
char *answer = readline("do you really want to continue? y(es) n(o) : ");
|
||||
bool overwrite = (answer[0] == 'y' || answer[0] == 'Y');
|
||||
const char *confirm = "Do you really want to continue? y(es)/n(o) : ";
|
||||
bool overwrite = false;
|
||||
#ifdef HAVE_READLINE
|
||||
char *answer = readline(confirm);
|
||||
overwrite = (answer[0] == 'y' || answer[0] == 'Y');
|
||||
#else
|
||||
printf("%s", confirm);
|
||||
char *answer = NULL;
|
||||
size_t anslen = 0;
|
||||
if (getline(&answer, &anslen, stdin) > 0) {
|
||||
overwrite = (answer[0] == 'y' || answer[0] == 'Y');
|
||||
}
|
||||
#endif
|
||||
free(answer);
|
||||
if (!overwrite) {
|
||||
PrintAndLogEx(NORMAL, "command cancelled");
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
#else
|
||||
PrintAndLogEx(NORMAL, "\n No interactive support on Android. ");
|
||||
PrintAndLogEx(NORMAL, " So no confirmation asked, beware! ");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
legic_chk_iv(&IV);
|
||||
|
||||
Reference in New Issue
Block a user