πUnion Based MSSQL Injection
Some basic errors in MSSQLi
Error
----------------------------------------------------------------
Step : 1
Putting single quote and then putting double quote checking the Error:
http://aquaservices.co.in/Product.aspx?Id=13'
ERROR
http://aquaservices.co.in/Product.aspx?Id=13"
ERROR----------------------------------------------------------------
Step : 2
Now we need to know the comment type for MSSQL.
Comment
Name
Now lets try the basic -- comment with our target:
Now we continue with order by and in the end we come to know that 8 is the last working column.
----------------------------------------------------------------
Step : 3
Now we need using the union select query:
In case of Such Errors on Union select statement we have an option to use null in all columns, so lets try that:
Heres one more type of error you can find while MSSQL Injection and the solution for this is just use "Union All Select" in place of "Unoin Select", Lets try:
Now you can use Burp Suite intruder to Fuzz the payload on place of columns:
----------------------------------------------------------------
Step : 4
Now we can Put @@version on place of vulnerable column to get the current version from database:
----------------------------------------------------------------
Step : 5
Now and we got the version, now we can get the current database name using db_name()
---------------------------------------------------------------
There are some other ways also to collect some more information from MSSQL which are given here:
Query/Function
Output
----------------------------------------------------------------
Step : 5
Now we will extract the table names, here the syntax is a little bit different than MySQL of lack of limit clause in MSSQL.
----------------------------------------------------------------
Step : 6
In the same manner we can get all the tables one by one. Now lets get the columns.
I will extract the colums from AdminLogin table:
----------------------------------------------------------------
Step : 7
We got the table names the column names and now lets extrct the data from them.
For concatination we can use %2b which is +
----------------------------------------------------------------
MSSQL DIOS :
Now in the end i will like to show you how to make the whole process alot faster by using MSSQL DIOS:
It will give error but actually its making the DIOS table so now lets try checking the output under temp_dios_sample:

So Here we are finished with MSSQL Union Based Injection
Last updated