diff --git a/lib/core/gui.py b/lib/core/gui.py index e85044454..1d8046a36 100644 --- a/lib/core/gui.py +++ b/lib/core/gui.py @@ -64,19 +64,42 @@ def runGui(parser): style.theme_create("custom", parent="alt", settings=settings) style.theme_use("custom") - def dummy(): - pass + def run(): + options = {} + + for key in window._widgets: + dest, type = key + widget = window._widgets[key] + + if hasattr(widget, "get") and not widget.get(): + value = None + elif type == "string": + value = widget.get() + elif type == "float": + value = float(widget.get()) + elif type == "int": + value = int(widget.get()) + else: + value = bool(widget.getint()) + + options[dest] = value + + for option in parser.option_list: + options[option.dest] = defaults.get(option.dest, None) + + parser._args = options + window.destroy() menubar = tkinter.Menu(window) filemenu = tkinter.Menu(menubar, tearoff=0) - filemenu.add_command(label="Open", command=dummy, state=tkinter.DISABLED) - filemenu.add_command(label="Save", command=dummy, state=tkinter.DISABLED) + filemenu.add_command(label="Open", state=tkinter.DISABLED) + filemenu.add_command(label="Save", state=tkinter.DISABLED) filemenu.add_separator() filemenu.add_command(label="Exit", command=window.quit) menubar.add_cascade(label="File", menu=filemenu) - menubar.add_command(label="Run", command=window.quit) + menubar.add_command(label="Run", command=run) helpmenu = tkinter.Menu(menubar, tearoff=0) helpmenu.add_command(label="Official site", command=lambda: webbrowser.open(SITE)) @@ -88,11 +111,13 @@ def runGui(parser): menubar.add_cascade(label="Help", menu=helpmenu) window.config(menu=menubar) + window._widgets = {} notebook = AutoresizableNotebook(window) first = None frames = {} + for group in parser.option_groups: frame = frames[group.title] = tkinter.Frame(notebook, width=200, height=200) notebook.add(frames[group.title], text=group.title) @@ -122,6 +147,8 @@ def runGui(parser): first = first or widget widget.grid(column=1, row=row, sticky=tkinter.W) + window._widgets[(option.dest, option.type)] = widget + default = defaults.get(option.dest) if default: if hasattr(widget, "insert"): diff --git a/lib/core/settings.py b/lib/core/settings.py index 133301557..bbf44f433 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.3.11.91" +VERSION = "1.3.11.92" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 6fa1334df..c1a6cac4e 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -863,9 +863,11 @@ def cmdLineParser(argv=None): if "--gui" in argv: from lib.core.gui import runGui - runGui(parser) + if hasattr(parser, "_args"): + return parser._args + elif "--sqlmap-shell" in argv: _createHomeDirectories() diff --git a/sqlmap.py b/sqlmap.py index cd94040fb..e50f57456 100755 --- a/sqlmap.py +++ b/sqlmap.py @@ -141,7 +141,8 @@ def main(): banner() # Store original command line options for possible later restoration - cmdLineOptions.update(cmdLineParser().__dict__) + args = cmdLineParser() + cmdLineOptions.update(args.__dict__ if hasattr(args, "__dict__") else args) initOptions(cmdLineOptions) if checkPipedInput():