我有一个程序必须调用sqlmap API并在后台运行它,如果你曾经使用过sqlmap,你会知道sqlmap API进程启动并继续运行直到退出。似乎程序正在等待sqlmap的API在继续该过程之前停止运行:
输出:
[11:02:10 INFO] creating arguments for sqlmap...
[11:02:10 INFO] attempting to find sqlmap on your system...
[11:02:10 INFO] attempting to call sqlmap API...
------------------------------
[11:02:12] [INFO] Running REST-JSON API server at '127.0.0.1:8775'..
[11:02:12] [INFO] Admin ID: 7e8f2de3647ff14d8cd777f3fddabca8
[11:02:12] [DEBUG] IPC database: '/tmp/sqlmapipc-mH6At_'
[11:02:12] [DEBUG] REST-JSON API server connected to IPC database
[11:02:13] [DEBUG] Using adapter 'wsgiref' to run bottle
# just hangs here
代码:
try:
path = find_sqlmap("sqlmap", verbose=verbose)
lib.core.settings.logger.info(lib.core.settings.set_color(
"attempting to call sqlmap API..."
))
called = subprocess.Popen(
"python {}/sqlmapapi.py -s".format("".join(path)),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
close_fds=True
)
print("-" * 30)
for line in iter(called.stdout.readline, ""):
print(line.strip())
print("-" * 30)
lib.core.settings.logger.info(lib.core.settings.set_color(
"API started with PID {}, continuing process...".format(
called.pid
)
))
except Exception as e:
lib.core.settings.logger.exception("test")
print e
lib.core.settings.logger.error(lib.core.settings.set_color(
"ran into an error while trying to start the sqlmap API, please do it manually...", level=50
))
正如您所看到的那样,它将启动API,但之后它将暂停,并且不会继续(我已经让它坐了大约五分钟)。所以我的问题是,有没有办法可以将系统调用分配到后台并继续前进?我认为subprocess.Popen
会创建一个后台流程,但这似乎不是真相。非常感谢任何帮助,谢谢。