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.

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

On modern versions of <strong>SQL</strong> Server, however, xp_cmdshell is disabled by default. This<br />

(along with many other settings) can be configured through the Surface Area Configuration<br />

tool that ships with <strong>SQL</strong> Server. The Surface Area Configuration tool is shown in Figure 6.20.<br />

Figure 6.20 The Surface Area Configuration Tool<br />

This, however, poses little problem if the attacker has the necessary privileges, since it can<br />

once more be turned on through in-b<strong>and</strong> signaling using the sp_configure statement.<br />

Figure 6.21 demonstrates how to reenable xp_cmdshell within Query Manager. A quick<br />

search on the Internet for “xp_cmdshell alternative” will also quickly point you to the<br />

hordes of posts where people have rediscovered the possibility of instantiating a Wscript.Shell<br />

instance through T-<strong>SQL</strong> in much the same manner as we used in this chapter for file reading<br />

<strong>and</strong> writing. The neatest of these, demonstrated in the code that follows, creates a new stored<br />

procedure called xp_cmdshell3. 3

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

Saved successfully!

Ooh no, something went wrong!