mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-29 14:52:19 +08:00
Add client option -i
to stay in interactive mode after a script or command
From 5a3f474331
with some fix in the logical flow
This commit is contained in:
parent
88d2a61c0b
commit
1cb039255e
6 changed files with 28 additions and 15 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Add client option `-i` to stay in interactive mode after a script or command (@DidierStevens/@doegox)
|
||||
- Add VSCode tasks (@ViRb3)
|
||||
- Better warn user of hardcoded hitag info (@ViRb3)
|
||||
- Format and docs hitag (@ViRb3)
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
static ProxGuiQT *gui = NULL;
|
||||
static WorkerThread *main_loop_thread = NULL;
|
||||
|
||||
WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd) : script_cmds_file(script_cmds_file), script_cmd(script_cmd) {
|
||||
WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) : script_cmds_file(script_cmds_file), script_cmd(script_cmd), stayInCommandLoop(stayInCommandLoop) {
|
||||
}
|
||||
|
||||
WorkerThread::~WorkerThread() {
|
||||
}
|
||||
|
||||
void WorkerThread::run() {
|
||||
main_loop(script_cmds_file, script_cmd);
|
||||
main_loop(script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
}
|
||||
|
||||
extern "C" void ShowGraphWindow(void) {
|
||||
|
@ -53,12 +53,12 @@ extern "C" void MainGraphics(void) {
|
|||
gui->MainLoop();
|
||||
}
|
||||
|
||||
extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd) {
|
||||
extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||
#ifdef Q_WS_X11
|
||||
if (getenv("DISPLAY") == NULL)
|
||||
return;
|
||||
#endif
|
||||
main_loop_thread = new WorkerThread(script_cmds_file, script_cmd);
|
||||
main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
gui = new ProxGuiQT(argc, argv, main_loop_thread);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ void ShowGraphWindow(void);
|
|||
void HideGraphWindow(void);
|
||||
void RepaintGraphWindow(void);
|
||||
void MainGraphics(void);
|
||||
void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd);
|
||||
void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
|
||||
void ExitGraphics(void);
|
||||
#ifndef MAX_GRAPH_TRACE_LEN
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8)
|
||||
|
|
|
@ -93,12 +93,13 @@ class ProxWidget : public QWidget {
|
|||
class WorkerThread : public QThread {
|
||||
Q_OBJECT;
|
||||
public:
|
||||
WorkerThread(char *, char *);
|
||||
WorkerThread(char *, char *, bool);
|
||||
~WorkerThread();
|
||||
void run();
|
||||
private:
|
||||
char *script_cmds_file;
|
||||
char *script_cmd;
|
||||
bool stayInCommandLoop;
|
||||
};
|
||||
|
||||
class ProxGuiQT : public QObject {
|
||||
|
|
|
@ -70,7 +70,7 @@ void
|
|||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
#endif
|
||||
main_loop(char *script_cmds_file, char *script_cmd) {
|
||||
main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||
|
||||
char *cmd = NULL;
|
||||
bool execCommand = (script_cmd != NULL);
|
||||
|
@ -138,7 +138,7 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
|||
script_cmd_len -= len;
|
||||
} else {
|
||||
// exit after exec command
|
||||
if (script_cmd)
|
||||
if (script_cmd && !stayInCommandLoop)
|
||||
break;
|
||||
|
||||
// if there is a pipe from stdin
|
||||
|
@ -206,7 +206,10 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
|||
cmd = NULL;
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
break;
|
||||
if (script_cmds_file && stayInCommandLoop)
|
||||
stayInCommandLoop = false;
|
||||
else
|
||||
break;
|
||||
}
|
||||
} // end while
|
||||
|
||||
|
@ -266,7 +269,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "syntax: %s [-h|-t|-m]\n", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-s <cmd_script_file>]\n", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s [[-p] <port>] [-b] [-w] [-f] [-c <command>]|[-l <lua_script_file>]|[-s <cmd_script_file>] [-i]\n", exec_name);
|
||||
|
||||
if (showFullHelp) {
|
||||
PrintAndLogEx(NORMAL, "options:");
|
||||
|
@ -280,6 +283,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
|||
PrintAndLogEx(NORMAL, " -c/--command <command> execute one Proxmark3 command (or several separated by ';').");
|
||||
PrintAndLogEx(NORMAL, " -l/--lua <lua script file> execute lua script.");
|
||||
PrintAndLogEx(NORMAL, " -s/--script-file <cmd_script_file> script file with one Proxmark3 command per line");
|
||||
PrintAndLogEx(NORMAL, " -i/--interactive enter interactive mode after executing the script or the command");
|
||||
PrintAndLogEx(NORMAL, "\nsamples:");
|
||||
PrintAndLogEx(NORMAL, " %s -h\n", exec_name);
|
||||
PrintAndLogEx(NORMAL, " %s -m\n", exec_name);
|
||||
|
@ -302,6 +306,7 @@ int main(int argc, char *argv[]) {
|
|||
session.help_dump_mode = false;
|
||||
bool waitCOMPort = false;
|
||||
bool addLuaExec = false;
|
||||
bool stayInCommandLoop = false;
|
||||
char *script_cmds_file = NULL;
|
||||
char *script_cmd = NULL;
|
||||
char *port = NULL;
|
||||
|
@ -438,6 +443,12 @@ int main(int argc, char *argv[]) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// go to interactive instead of quitting after a script/command
|
||||
if(strcmp(argv[i], "-i") == 0 || strcmp(argv[i], "--interactive") == 0){
|
||||
stayInCommandLoop = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// We got an unknown parameter
|
||||
PrintAndLogEx(ERR, _RED_("ERROR:") "invalid parameter: " _YELLOW_("%s") "\n", argv[i]);
|
||||
show_help(false, exec_name);
|
||||
|
@ -512,21 +523,21 @@ int main(int argc, char *argv[]) {
|
|||
#ifdef HAVE_GUI
|
||||
|
||||
# ifdef _WIN32
|
||||
InitGraphics(argc, argv, script_cmds_file, script_cmd);
|
||||
InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
MainGraphics();
|
||||
# else
|
||||
// for *nix distro's, check enviroment variable to verify a display
|
||||
char *display = getenv("DISPLAY");
|
||||
if (display && strlen(display) > 1) {
|
||||
InitGraphics(argc, argv, script_cmds_file, script_cmd);
|
||||
InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
MainGraphics();
|
||||
} else {
|
||||
main_loop(script_cmds_file, script_cmd);
|
||||
main_loop(script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
}
|
||||
# endif
|
||||
|
||||
#else
|
||||
main_loop(script_cmds_file, script_cmd);
|
||||
main_loop(script_cmds_file, script_cmd, stayInCommandLoop);
|
||||
#endif
|
||||
|
||||
// Clean up the port
|
||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
|
||||
const char *get_my_executable_path(void);
|
||||
const char *get_my_executable_directory(void);
|
||||
void main_loop(char *script_cmds_file, char *script_cmd);
|
||||
void main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue