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.

Summary<br />

Testing for <strong>SQL</strong> <strong>Injection</strong> • Chapter 2 91<br />

The first step for successful <strong>SQL</strong> injection exploitation is to find the vulnerable piece of code<br />

which will allow you to perform the injection. In this chapter, I covered the process of finding<br />

<strong>SQL</strong> injection vulnerabilities from a black-box perspective, explaining the steps that you need<br />

to take.<br />

Web applications are an example of client/server architecture where the browser is the<br />

client <strong>and</strong> the Web application is the server. You learned how you can manipulate the data<br />

sent from the browser to the server in order to trigger <strong>SQL</strong> errors <strong>and</strong> identify vulnerabilities.<br />

Depending on the Web application <strong>and</strong> the amount of information leaked, the process of<br />

identifying a vulnerability varies in complexity. In some scenarios, the application responds to<br />

the Web request with the error returned from the database. However, there are scenarios<br />

where you will need to pay attention to details to identify the vulnerability.<br />

Once you trigger a vulnerability <strong>and</strong> you have evidence that you can inject <strong>SQL</strong> code<br />

using the Web application input, you need to craft an <strong>SQL</strong> snippet that will become a syntactically<br />

correct statement. There are several techniques for doing this, including injecting the<br />

code inline where all of the code of the original statement is executed, <strong>and</strong> commenting parts<br />

of the query to avoid execution of the full statement. The success of this phase will prepare<br />

you for further exploitation.<br />

A number of commercial <strong>and</strong> free tools automate the process of finding <strong>SQL</strong> injection<br />

vulnerabilities. Although they are all able to detect simple vulnerabilities where the application<br />

returns a st<strong>and</strong>ard <strong>SQL</strong> error, they provide varying degrees of accuracy when it comes to<br />

other scenarios such as custom errors. Additionally, the free tools generally focus on testing<br />

only GET requests, leaving the remaining POST requests untested.<br />

Solutions Fast Track<br />

Finding <strong>SQL</strong> <strong>Injection</strong><br />

˛˛ There are three key aspects for finding <strong>SQL</strong> injection vulnerabilities: 1) identifying<br />

the data entry accepted by the application, 2) modifying the value of the entry<br />

including hazardous strings, <strong>and</strong> 3) detecting the anomalies returned by the server.<br />

˛˛ Manipulation tools acting as a Web proxy help to bypass client-side restrictions,<br />

providing full control of the requests sent to servers. Additionally, they offer greater<br />

visibility of the response from the server, providing greater chances of detecting<br />

subtle vulnerabilities that could remain undetected if visualized in the Web browser.<br />

˛˛ A response of the server which includes a database error or that is an HTTP error<br />

code usually eases the identification of the existence of an <strong>SQL</strong> injection

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

Saved successfully!

Ooh no, something went wrong!