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.

322 Chapter 7 • Advanced Topics<br />

Table 7.1 Continued. St<strong>and</strong>ard <strong>and</strong><br />

Non-St<strong>and</strong>ard Unicode Encodings of Some Useful Characters<br />

Literal Character<br />

Encoded Equivalent<br />

( %u0028<br />

%uff08<br />

%c0%28<br />

%c0%a8<br />

%e0%80%a8<br />

) %u0029<br />

%uff09<br />

%c0%29<br />

%c0%a9<br />

%e0%80%a9<br />

* %u002a<br />

%uff0a<br />

%c0%2a<br />

%c0%aa<br />

%e0%80%aa<br />

[space] %u0020<br />

%uff00<br />

%c0%20<br />

%c0%a0<br />

%e0%80%a0<br />

Using Dynamic Query Execution<br />

Many databases allow <strong>SQL</strong> queries to be executed dynamically, by passing a string containing<br />

an <strong>SQL</strong> query into a database function which executes the query. If you have discovered<br />

a valid <strong>SQL</strong> injection point, but find that the application’s input filters are blocking queries<br />

you want to inject, you may be able to use dynamic execution to circumvent the filters.<br />

Dynamic query execution works differently on different databases. On Microsoft <strong>SQL</strong><br />

Server, you can use the EXEC function to execute a query in string form. For example:<br />

EXEC('SELECT password FROM tblUsers')<br />

In Oracle, you can use the EXECUTE IMMEDIATE comm<strong>and</strong> to execute a query in<br />

string form. For example:<br />

DECLARE pw VARCHAR2(1000);<br />

BEGIN<br />

EXECUTE IMMEDIATE 'SELECT password FROM tblUsers' INTO pw;<br />

DBMS_OUTPUT.PUT_LINE(pw);<br />

END;

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

Saved successfully!

Ooh no, something went wrong!