import subprocess
command = ["wine"]
arguments = ['/root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.exe', ' --inconfig /root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.0.xml', '--targetip 0.0.0.0']
command.extend(arguments)
proc = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
print(proc)
print("\n Done")
所以我使用 subprocess.Popen 来获取命令的输出。从技术上讲,该命令运行 2 个程序:wine 和eternalblue.exe。我需要将参数传递给eternalblue.exe,但出现错误。它似乎接受我传递的任何参数并尝试将它们用于 wine 而不是 exe。
根据Python文档,
import shlex, subprocess
command_line = raw_input()
## /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"
args = shlex.split(command_line)
print args
##['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd',"echo '$MONEY'"]
p = subprocess.Popen(args) # Success!
您只需将参数分成两个元素。例如,' --inconfig/root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.0.xml' --> '--inconfig', '/root/Desktop/COLDHEART/exploits/eternalblue/Eternalblue-2.2.0.0. xml'
我是一名优秀的程序员,十分优秀!