mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-13 09:33:16 +03:00
prep for subprocess..
This commit is contained in:
parent
7fa75792dd
commit
1e1892c962
|
@ -10,21 +10,11 @@ import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import StringIO
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
_multiprocessing = None
|
from subprocess import PIPE
|
||||||
try:
|
from subprocess import Popen
|
||||||
import multiprocessing
|
|
||||||
|
|
||||||
# problems on FreeBSD (Reference: http://www.eggheadcafe.com/microsoft/Python/35880259/multiprocessing-on-freebsd.aspx)
|
|
||||||
_ = multiprocessing.Queue()
|
|
||||||
except (ImportError, OSError):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
_multiprocessing = multiprocessing
|
|
||||||
|
|
||||||
from lib.controller.controller import start
|
from lib.controller.controller import start
|
||||||
from lib.core.common import unArrayizeValue
|
from lib.core.common import unArrayizeValue
|
||||||
|
@ -86,22 +76,6 @@ def init_options():
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
def start_scan():
|
|
||||||
# Wrap logger stdout onto a custom file descriptor (LOGGER_OUTPUT)
|
|
||||||
def emit(self, record):
|
|
||||||
message = stdoutencode(FORMATTER.format(record))
|
|
||||||
print >>LOGGER_OUTPUT, message.strip('\r')
|
|
||||||
|
|
||||||
LOGGER_HANDLER.emit = types.MethodType(emit, LOGGER_HANDLER, type(LOGGER_HANDLER))
|
|
||||||
|
|
||||||
# Wrap standard output onto a custom file descriptor
|
|
||||||
sys.stdout = open(str(os.getpid()) + ".out", "wb")
|
|
||||||
#sys.stderr = StringIO.StringIO()
|
|
||||||
|
|
||||||
taskid = multiprocessing.current_process().name
|
|
||||||
init(tasks[taskid], True)
|
|
||||||
start()
|
|
||||||
|
|
||||||
@hook("after_request")
|
@hook("after_request")
|
||||||
def security_headers():
|
def security_headers():
|
||||||
"""
|
"""
|
||||||
|
@ -204,9 +178,8 @@ def status(taskid):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if is_admin(taskid):
|
if is_admin(taskid):
|
||||||
busy = kb.get("busyFlag")
|
|
||||||
tasks_num = len(tasks)
|
tasks_num = len(tasks)
|
||||||
return jsonize({"busy": busy, "tasks": tasks_num})
|
return jsonize({"tasks": tasks_num})
|
||||||
else:
|
else:
|
||||||
abort(401)
|
abort(401)
|
||||||
|
|
||||||
|
@ -293,12 +266,8 @@ def scan_start(taskid):
|
||||||
# Launch sqlmap engine in a separate thread
|
# Launch sqlmap engine in a separate thread
|
||||||
logger.debug("starting a scan for task ID %s" % taskid)
|
logger.debug("starting a scan for task ID %s" % taskid)
|
||||||
|
|
||||||
if _multiprocessing:
|
proc = Popen("python sqlmap.py -c %s" % config_file, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||||
#_multiprocessing.log_to_stderr(logging.DEBUG)
|
stdout, stderr = proc.communicate()
|
||||||
p = _multiprocessing.Process(name=taskid, target=start_scan)
|
|
||||||
p.daemon = True
|
|
||||||
p.start()
|
|
||||||
p.join()
|
|
||||||
|
|
||||||
return jsonize({"success": True})
|
return jsonize({"success": True})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user