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。我需要将args传递给eternalblue.exe,但出现错误。我似乎要通过任何参数,并尝试将其用于葡萄酒而不是exe。
答案 0 :(得分:0)
根据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'