mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-23 19:34:13 +03:00
Testing something out
This commit is contained in:
parent
35073ce43b
commit
e808496ed3
121
lib/core/gui.py
Normal file
121
lib/core/gui.py
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||||
|
See the file 'LICENSE' for copying permission
|
||||||
|
"""
|
||||||
|
|
||||||
|
def runGui(parser):
|
||||||
|
import re
|
||||||
|
import tkinter as tk
|
||||||
|
from tkinter import ttk
|
||||||
|
|
||||||
|
from lib.core.defaults import defaults
|
||||||
|
|
||||||
|
# Reference: https://www.reddit.com/r/learnpython/comments/985umy/limit_user_input_to_only_int_with_tkinter/e4dj9k9?utm_source=share&utm_medium=web2x
|
||||||
|
class ConstrainedEntry(tk.Entry):
|
||||||
|
def __init__(self, master=None, **kwargs):
|
||||||
|
self.var = tk.StringVar()
|
||||||
|
self.regex = kwargs["regex"]
|
||||||
|
del kwargs["regex"]
|
||||||
|
tk.Entry.__init__(self, master, textvariable=self.var, **kwargs)
|
||||||
|
self.old_value = ''
|
||||||
|
self.var.trace('w', self.check)
|
||||||
|
self.get, self.set = self.var.get, self.var.set
|
||||||
|
|
||||||
|
def check(self, *args):
|
||||||
|
if re.search(self.regex, self.get()):
|
||||||
|
self.old_value = self.get()
|
||||||
|
else:
|
||||||
|
self.set(self.old_value)
|
||||||
|
|
||||||
|
# Reference: https://code.activestate.com/recipes/580726-tkinter-notebook-that-fits-to-the-height-of-every-/
|
||||||
|
class AutoresizableNotebook(ttk.Notebook):
|
||||||
|
def __init__(self, master=None, **kw):
|
||||||
|
ttk.Notebook.__init__(self, master, **kw)
|
||||||
|
self.bind("<<NotebookTabChanged>>", self._on_tab_changed)
|
||||||
|
|
||||||
|
def _on_tab_changed(self,event):
|
||||||
|
event.widget.update_idletasks()
|
||||||
|
|
||||||
|
tab = event.widget.nametowidget(event.widget.select())
|
||||||
|
event.widget.configure(height=tab.winfo_reqheight())
|
||||||
|
|
||||||
|
window = tk.Tk()
|
||||||
|
window.title("sqlmap")
|
||||||
|
|
||||||
|
# Reference: https://www.holadevs.com/pregunta/64750/change-selected-tab-color-in-ttknotebook
|
||||||
|
style = ttk.Style()
|
||||||
|
settings = {"TNotebook.Tab": {"configure": {"padding": [5, 1], "background": "#fdd57e" }, "map": {"background": [("selected", "#C70039"), ("active", "#fc9292")], "foreground": [("selected", "#ffffff"), ("active", "#000000")]}}}
|
||||||
|
style.theme_create("custom", parent="alt", settings=settings)
|
||||||
|
style.theme_use("custom")
|
||||||
|
|
||||||
|
def dummy():
|
||||||
|
pass
|
||||||
|
|
||||||
|
menubar = tk.Menu(window)
|
||||||
|
|
||||||
|
filemenu = tk.Menu(menubar, tearoff=0)
|
||||||
|
filemenu.add_command(label="Open", command=dummy)
|
||||||
|
filemenu.add_command(label="Save", command=dummy)
|
||||||
|
filemenu.add_separator()
|
||||||
|
filemenu.add_command(label="Exit", command=window.quit)
|
||||||
|
menubar.add_cascade(label="File", menu=filemenu)
|
||||||
|
|
||||||
|
runmenu = tk.Menu(menubar, tearoff=0)
|
||||||
|
runmenu.add_command(label="Start", command=dummy)
|
||||||
|
runmenu.add_command(label="Stop", command=dummy)
|
||||||
|
menubar.add_cascade(label="Run", menu=runmenu)
|
||||||
|
|
||||||
|
helpmenu = tk.Menu(menubar, tearoff=0)
|
||||||
|
helpmenu.add_command(label="Wiki pages", command=dummy)
|
||||||
|
helpmenu.add_command(label="Official site", command=dummy)
|
||||||
|
helpmenu.add_separator()
|
||||||
|
helpmenu.add_command(label="About", command=dummy)
|
||||||
|
menubar.add_cascade(label="Help", menu=helpmenu)
|
||||||
|
|
||||||
|
window.config(menu=menubar)
|
||||||
|
|
||||||
|
notebook = AutoresizableNotebook(window)
|
||||||
|
|
||||||
|
frames = {}
|
||||||
|
for group in parser.option_groups:
|
||||||
|
frame = frames[group.title] = tk.Frame(notebook, width=200, height=200)
|
||||||
|
notebook.add(frames[group.title], text=group.title)
|
||||||
|
|
||||||
|
tk.Label(frame).grid(column=0, row=0, sticky=tk.W)
|
||||||
|
|
||||||
|
row = 1
|
||||||
|
for option in group.option_list:
|
||||||
|
tk.Label(frame, text=parser.formatter._format_option_strings(option)).grid(column=0, row=row, sticky=tk.W)
|
||||||
|
|
||||||
|
if option.type == "string":
|
||||||
|
widget = tk.Entry(frame)
|
||||||
|
elif option.type == "float":
|
||||||
|
widget = ConstrainedEntry(frame, regex=r"\A\d*\.?\d*\Z")
|
||||||
|
elif option.type == "int":
|
||||||
|
widget = ConstrainedEntry(frame, regex=r"\A\d*\Z")
|
||||||
|
else:
|
||||||
|
var = tk.IntVar()
|
||||||
|
widget = tk.Checkbutton(frame, variable=var)
|
||||||
|
widget.var = var
|
||||||
|
|
||||||
|
widget.grid(column=1, row=row, sticky=tk.W)
|
||||||
|
|
||||||
|
default = defaults.get(option.dest)
|
||||||
|
if default:
|
||||||
|
if hasattr(widget, "insert"):
|
||||||
|
widget.insert(0, default)
|
||||||
|
|
||||||
|
tk.Label(frame, text=" ").grid(column=3, row=row, sticky=tk.W)
|
||||||
|
tk.Label(frame, text=option.help).grid(column=4, row=row, sticky=tk.W)
|
||||||
|
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
tk.Label(frame).grid(column=0, row=row, sticky=tk.W)
|
||||||
|
|
||||||
|
notebook.pack(expand=1, fill="both")
|
||||||
|
|
||||||
|
notebook.enable_traversal()
|
||||||
|
|
||||||
|
window.mainloop()
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
||||||
from thirdparty.six import unichr as _unichr
|
from thirdparty.six import unichr as _unichr
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.3.11.84"
|
VERSION = "1.3.11.85"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
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)
|
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||||
|
|
|
@ -79,6 +79,7 @@ from lib.core.dicts import DEPRECATED_OPTIONS
|
||||||
from lib.core.enums import AUTOCOMPLETE_TYPE
|
from lib.core.enums import AUTOCOMPLETE_TYPE
|
||||||
from lib.core.exception import SqlmapShellQuitException
|
from lib.core.exception import SqlmapShellQuitException
|
||||||
from lib.core.exception import SqlmapSyntaxException
|
from lib.core.exception import SqlmapSyntaxException
|
||||||
|
from lib.core.gui import runGui
|
||||||
from lib.core.option import _createHomeDirectories
|
from lib.core.option import _createHomeDirectories
|
||||||
from lib.core.settings import BASIC_HELP_ITEMS
|
from lib.core.settings import BASIC_HELP_ITEMS
|
||||||
from lib.core.settings import DUMMY_URL
|
from lib.core.settings import DUMMY_URL
|
||||||
|
@ -780,6 +781,9 @@ def cmdLineParser(argv=None):
|
||||||
parser.add_argument("--force-pivoting", dest="forcePivoting", action="store_true",
|
parser.add_argument("--force-pivoting", dest="forcePivoting", action="store_true",
|
||||||
help=SUPPRESS)
|
help=SUPPRESS)
|
||||||
|
|
||||||
|
parser.add_argument("--gui", dest="gui", action="store_true",
|
||||||
|
help=SUPPRESS)
|
||||||
|
|
||||||
parser.add_argument("--smoke-test", dest="smokeTest", action="store_true",
|
parser.add_argument("--smoke-test", dest="smokeTest", action="store_true",
|
||||||
help=SUPPRESS)
|
help=SUPPRESS)
|
||||||
|
|
||||||
|
@ -847,7 +851,6 @@ def cmdLineParser(argv=None):
|
||||||
break
|
break
|
||||||
|
|
||||||
_ = []
|
_ = []
|
||||||
prompt = False
|
|
||||||
advancedHelp = True
|
advancedHelp = True
|
||||||
extraHeaders = []
|
extraHeaders = []
|
||||||
tamperIndex = None
|
tamperIndex = None
|
||||||
|
@ -859,9 +862,10 @@ def cmdLineParser(argv=None):
|
||||||
argv = _
|
argv = _
|
||||||
checkOldOptions(argv)
|
checkOldOptions(argv)
|
||||||
|
|
||||||
prompt = "--sqlmap-shell" in argv
|
if "--gui" in argv:
|
||||||
|
runGui(parser)
|
||||||
|
|
||||||
if prompt:
|
elif "--sqlmap-shell" in argv:
|
||||||
_createHomeDirectories()
|
_createHomeDirectories()
|
||||||
|
|
||||||
parser.usage = ""
|
parser.usage = ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user