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.

References • Chapter 10 423<br />

you are attacking. However, if your injected <strong>SQL</strong> doesn’t quite work out to plan, it may<br />

be necessary to identify the database platform using a more scientific approach.<br />

Identifying the Database<br />

Platform via Time Delay Inference<br />

Generating a time delay based on server-specific functionality is a long-st<strong>and</strong>ing method<br />

of identifying the database platform. Table 10.4 lists the functions or procedures for generating<br />

measurable time delays across the most popular database platforms.<br />

Table 10.4 Generating a Time Delay<br />

Platform<br />

Microsoft <strong>SQL</strong> Server<br />

Oracle<br />

Time Delay<br />

WAITFOR DELAY '0:0:10'<br />

BEGIN DBMS_LOCK.SLEEP(5);END;--(PL/<strong>SQL</strong><br />

<strong>Injection</strong> only)<br />

SELECT UTL_INADDR.get_host_name('192.168.0.1')<br />

FROM dual<br />

SELECT UTL_INADDR.get_host_address<br />

('foo.nowhere999.zom') FROM dual<br />

My<strong>SQL</strong><br />

Postgres 8.2 <strong>and</strong> later<br />

SELECT UTL_HTTP.REQUEST('http://www.oracle.com')<br />

FROM dual<br />

BENCHMARK(1000000,MD5("HACK"))<br />

SLEEP(10)<br />

SELECT pg_sleep(10)<br />

Another similar approach involves submitting “heavy queries” designed to consume the<br />

processor for a measureable length of time. Since there are deviations within each vendor’s<br />

implementation of <strong>SQL</strong>, it is possible to construct a heavy query that will execute successfully<br />

on only one specific platform. Microsoft published an article on the subject in September<br />

2007 which you can find at http://technet.microsoft.com/en-us/library/cc512676.aspx<br />

Identifying the Database<br />

Platform via <strong>SQL</strong> Dialect Inference<br />

There are several deviations between each vendor’s <strong>SQL</strong> implementation that you could<br />

use to help identify the database server. A common method for narrowing down the list of<br />

potential database platforms is to assess how the target server deals with platform-specific

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

Saved successfully!

Ooh no, something went wrong!