1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| import subprocess
def run_sqlmap(): url = input("请输入要测试的 URL: ") if not url: print("错误: URL 是必填项") return command = f'sqlmap -u {url} --batch --flush-session' print(f"完整的命令: {command}") split_command = command.split() print(f"分割后的命令: {split_command}") print("正在执行命令...") process = subprocess.Popen( split_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False ) while True: output = process.stdout.readline() if output == b'' and process.poll() is not None: break if output: print(output.decode('utf-8').strip())
if __name__ == "__main__": run_sqlmap()
|