| 149 | return "break" |
| 150 | |
| 151 | def run(): |
| 152 | global alive |
| 153 | global process |
| 154 | global queue |
| 155 | |
| 156 | config = {} |
| 157 | |
| 158 | for key in window._widgets: |
| 159 | dest, widget_type = key |
| 160 | widget = window._widgets[key] |
| 161 | |
| 162 | if hasattr(widget, "get") and not widget.get(): |
| 163 | value = None |
| 164 | elif widget_type == "string": |
| 165 | value = widget.get() |
| 166 | elif widget_type == "float": |
| 167 | value = float(widget.get()) |
| 168 | elif widget_type == "int": |
| 169 | value = int(widget.get()) |
| 170 | else: |
| 171 | value = bool(widget.var.get()) |
| 172 | |
| 173 | config[dest] = value |
| 174 | |
| 175 | for option in parser.option_list: |
| 176 | # Only set default if not already set by the user |
| 177 | if option.dest not in config or config[option.dest] is None: |
| 178 | config[option.dest] = defaults.get(option.dest, None) |
| 179 | |
| 180 | handle, configFile = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.CONFIG, text=True) |
| 181 | os.close(handle) |
| 182 | |
| 183 | saveConfig(config, configFile) |
| 184 | |
| 185 | def enqueue(stream, queue): |
| 186 | global alive |
| 187 | |
| 188 | for line in iter(stream.readline, b''): |
| 189 | queue.put(line) |
| 190 | |
| 191 | alive = False |
| 192 | stream.close() |
| 193 | |
| 194 | alive = True |
| 195 | |
| 196 | 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) |
| 197 | |
| 198 | # Reference: https://stackoverflow.com/a/4896288 |
| 199 | queue = _queue.Queue() |
| 200 | thread = threading.Thread(target=enqueue, args=(process.stdout, queue)) |
| 201 | thread.daemon = True |
| 202 | thread.start() |
| 203 | |
| 204 | top = _tkinter.Toplevel() |
| 205 | top.title("Console") |
| 206 | top.configure(background=bg_color) |
| 207 | |
| 208 | # Create a frame for the console |