我的问题是找到一种方法来从名为wordlist.txt的文本文件中馈送内容:
line1..
line2..
line3..
进入python程序的命令行参数,并遍历每个字符串以使用单词表的每个行/字符串运行命令。
python程序的工作原理如下:
python program.py -t wordlist.txt arg1 arg2 arg3
我正在尝试编写一个脚本,该脚本将运行程序管道或从wordlsit.txt文件的每一行提供第二个命令行参数。
例如,我希望这是结果:
python program.py -t line1 -p arg2 -U arg3 -P arg3
python program.py -t line2 -p arg2 -U arg3 -P arg3
python program.py -t line3 -p arg2 -U arg3 -P arg3
(忽略-t这只是代表目标的参数)
我尝试过:
import sys
import requests
import os
import exec_cmd
def run():
files = "wordlist.txt"
exc = "python program.py -t $files -p arg2 -U arg3 -P arg4"
while True:
exec(exc)
run()
我也尝试过:
import subprocess
t = "wordlist.txt"
t = open(t, "r")
for i in t:
subprocess.run(["python", "program.py", "-t", i, "-p", "args1", "-U", "args2", "-P", "args3"])