mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-01 00:17:25 +03:00 
			
		
		
		
	Adding basic functionality to a hidden feature
This commit is contained in:
		
							parent
							
								
									948903f232
								
							
						
					
					
						commit
						f7a237fdee
					
				|  | @ -5,17 +5,23 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) | ||||||
| See the file 'LICENSE' for copying permission | See the file 'LICENSE' for copying permission | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
|  | import os | ||||||
| import re | import re | ||||||
| import socket | import socket | ||||||
| import subprocess | import subprocess | ||||||
| import sys | import sys | ||||||
|  | import tempfile | ||||||
| import threading | import threading | ||||||
| import webbrowser | import webbrowser | ||||||
| 
 | 
 | ||||||
| from lib.core.common import getSafeExString | from lib.core.common import getSafeExString | ||||||
|  | from lib.core.common import saveConfig | ||||||
|  | from lib.core.data import paths | ||||||
| from lib.core.defaults import defaults | from lib.core.defaults import defaults | ||||||
|  | from lib.core.enums import MKSTEMP_PREFIX | ||||||
| from lib.core.exception import SqlmapMissingDependence | from lib.core.exception import SqlmapMissingDependence | ||||||
| from lib.core.settings import DEV_EMAIL_ADDRESS | from lib.core.settings import DEV_EMAIL_ADDRESS | ||||||
|  | from lib.core.settings import IS_WIN | ||||||
| from lib.core.settings import ISSUES_PAGE | from lib.core.settings import ISSUES_PAGE | ||||||
| from lib.core.settings import GIT_PAGE | from lib.core.settings import GIT_PAGE | ||||||
| from lib.core.settings import SITE | from lib.core.settings import SITE | ||||||
|  | @ -110,48 +116,19 @@ def runGui(parser): | ||||||
|                 line = "" |                 line = "" | ||||||
|                 event.widget.master.master.destroy() |                 event.widget.master.master.destroy() | ||||||
|                 return "break" |                 return "break" | ||||||
|  |             except: | ||||||
|  |                 return | ||||||
| 
 | 
 | ||||||
|             event.widget.insert(tkinter.END, "\n") |             event.widget.insert(tkinter.END, "\n") | ||||||
| 
 | 
 | ||||||
|             counter = 0 |  | ||||||
|             while True: |  | ||||||
|                 line = "" |  | ||||||
|                 try: |  | ||||||
|                     #line = queue.get_nowait() |  | ||||||
|                     line = queue.get(timeout=.1) |  | ||||||
|                     event.widget.insert(tkinter.END, line) |  | ||||||
|                     counter = 0 |  | ||||||
|                 except _queue.Empty: |  | ||||||
|                     event.widget.see(tkinter.END) |  | ||||||
|                     event.widget.update_idletasks() |  | ||||||
|                     if counter > 3: |  | ||||||
|                         break |  | ||||||
|                     else: |  | ||||||
|                         counter += 1 |  | ||||||
| 
 |  | ||||||
|             return "break" |             return "break" | ||||||
| 
 | 
 | ||||||
|     def run(): |     def run(): | ||||||
|  |         global alive | ||||||
|         global process |         global process | ||||||
|         global queue |         global queue | ||||||
| 
 | 
 | ||||||
|         ON_POSIX = "posix" in sys.builtin_module_names |         config = {} | ||||||
| 
 |  | ||||||
|         def enqueue(stream, queue): |  | ||||||
|             for line in iter(stream.readline, b''): |  | ||||||
|                 queue.put(line) |  | ||||||
|             stream.close() |  | ||||||
| 
 |  | ||||||
|         process = subprocess.Popen("/bin/bash", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, bufsize=1, close_fds=ON_POSIX) |  | ||||||
| 
 |  | ||||||
|         # Reference: https://stackoverflow.com/a/4896288 |  | ||||||
|         queue = _queue.Queue() |  | ||||||
|         thread = threading.Thread(target=enqueue, args=(process.stdout, queue)) |  | ||||||
|         thread.daemon = True |  | ||||||
|         thread.start() |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         options = {} |  | ||||||
| 
 | 
 | ||||||
|         for key in window._widgets: |         for key in window._widgets: | ||||||
|             dest, type = key |             dest, type = key | ||||||
|  | @ -168,12 +145,34 @@ def runGui(parser): | ||||||
|             else: |             else: | ||||||
|                 value = bool(widget.var.get()) |                 value = bool(widget.var.get()) | ||||||
| 
 | 
 | ||||||
|             options[dest] = value |             config[dest] = value | ||||||
| 
 | 
 | ||||||
|         for option in parser.option_list: |         for option in parser.option_list: | ||||||
|             options[option.dest] = defaults.get(option.dest, None) |             config[option.dest] = defaults.get(option.dest, None) | ||||||
| 
 | 
 | ||||||
|         parser._args = options |         handle, configFile = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.CONFIG, text=True) | ||||||
|  |         os.close(handle) | ||||||
|  | 
 | ||||||
|  |         saveConfig(config, configFile) | ||||||
|  | 
 | ||||||
|  |         def enqueue(stream, queue): | ||||||
|  |             global alive | ||||||
|  | 
 | ||||||
|  |             for line in iter(stream.readline, b''): | ||||||
|  |                 queue.put(line) | ||||||
|  | 
 | ||||||
|  |             alive = False | ||||||
|  |             stream.close() | ||||||
|  | 
 | ||||||
|  |         alive = True | ||||||
|  | 
 | ||||||
|  |         process = subprocess.Popen([sys.executable or "python", os.path.join(paths.SQLMAP_ROOT_PATH, "sqlmap.py"), "-c", configFile], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, bufsize=1, close_fds=not IS_WIN) | ||||||
|  | 
 | ||||||
|  |         # Reference: https://stackoverflow.com/a/4896288 | ||||||
|  |         queue = _queue.Queue() | ||||||
|  |         thread = threading.Thread(target=enqueue, args=(process.stdout, queue)) | ||||||
|  |         thread.daemon = True | ||||||
|  |         thread.start() | ||||||
| 
 | 
 | ||||||
|         top = tkinter.Toplevel() |         top = tkinter.Toplevel() | ||||||
|         top.title("Console") |         top.title("Console") | ||||||
|  | @ -187,6 +186,16 @@ def runGui(parser): | ||||||
| 
 | 
 | ||||||
|         center(top) |         center(top) | ||||||
| 
 | 
 | ||||||
|  |         while alive: | ||||||
|  |             line = "" | ||||||
|  |             try: | ||||||
|  |                 #line = queue.get_nowait() | ||||||
|  |                 line = queue.get(timeout=.1) | ||||||
|  |                 text.insert(tkinter.END, line) | ||||||
|  |             except _queue.Empty: | ||||||
|  |                 text.see(tkinter.END) | ||||||
|  |                 text.update_idletasks() | ||||||
|  | 
 | ||||||
|     menubar = tkinter.Menu(window) |     menubar = tkinter.Menu(window) | ||||||
| 
 | 
 | ||||||
|     filemenu = tkinter.Menu(menubar, tearoff=0) |     filemenu = tkinter.Menu(menubar, tearoff=0) | ||||||
|  |  | ||||||
|  | @ -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.12.0" | VERSION = "1.3.12.1" | ||||||
| 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) | ||||||
|  |  | ||||||
|  | @ -78,6 +78,7 @@ from lib.core.defaults import defaults | ||||||
| from lib.core.dicts import DEPRECATED_OPTIONS | 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 SqlmapSilentQuitException | ||||||
| from lib.core.exception import SqlmapSyntaxException | from lib.core.exception import SqlmapSyntaxException | ||||||
| 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 | ||||||
|  | @ -863,10 +864,10 @@ def cmdLineParser(argv=None): | ||||||
| 
 | 
 | ||||||
|         if "--gui" in argv: |         if "--gui" in argv: | ||||||
|             from lib.core.gui import runGui |             from lib.core.gui import runGui | ||||||
|  | 
 | ||||||
|             runGui(parser) |             runGui(parser) | ||||||
| 
 | 
 | ||||||
|             if hasattr(parser, "_args"): |             raise SqlmapSilentQuitException | ||||||
|                 return parser._args |  | ||||||
| 
 | 
 | ||||||
|         elif "--sqlmap-shell" in argv: |         elif "--sqlmap-shell" in argv: | ||||||
|             _createHomeDirectories() |             _createHomeDirectories() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user