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.

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

to <strong>SQL</strong> injection attacks. This is due in part to its popularity among first-time developers (a<br />

testimony to how Microsoft enables its developers) <strong>and</strong> in part to the fact that the Microsoft<br />

<strong>SQL</strong> Server allows for stacked queries. This exponentially increases the options available to a<br />

potential attacker, which can be evidenced by the repercussions of an injection against an<br />

<strong>SQL</strong> Server box. SensePost alone has built tool sets that will convert an injection point into<br />

full-blown domain name system (DNS) tunnels, remote file servers, <strong>and</strong> even Transmission<br />

Control Protocol (TCP) connect proxies.<br />

Let’s begin at the beginning, <strong>and</strong> try to use a vulnerable Web application to read a file<br />

from the remote <strong>SQL</strong> server. In this case, usually the first function an attacker who has<br />

managed to obtain system administrator privileges finesses is the BULK INSERT statement.<br />

A quick test through Microsoft’s <strong>SQL</strong> Query Analyzer (shown in Figure 6.5) demonstrates<br />

the use of BULK INSERT by way of example.<br />

Figure 6.5 A BULK INSERT inside <strong>SQL</strong> Query Analyzer<br />

The ability of the relational database management system (RDBMS) to h<strong>and</strong>le files such<br />

as this, along with the ability to h<strong>and</strong>le batched or stacked queries, should make it fairly<br />

obvious how an attacker can leverage this through his browser. Let’s take one more look at a<br />

simple search application written in ASP with a Microsoft <strong>SQL</strong> Server back end. Figure 6.6<br />

shows the results of a search on the application for “%”. As you should expect (by now), this<br />

returns all of the users on the system.

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

Saved successfully!

Ooh no, something went wrong!