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.

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

<br />

<br />

<br />

<br />

<br />

Another possibility is to display different pages depending on the HTTP error code<br />

generated when rendering the page:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

In the preceding example, the application by default will redirect the user to Error.aspx.<br />

However, in three cases (HTTP codes 403, 404, <strong>and</strong> 500) the user will be redirected to<br />

another page.<br />

My<strong>SQL</strong> Errors<br />

In this section, you will see some of the typical My<strong>SQL</strong> errors. All of the main server-side<br />

scripting languages can access My<strong>SQL</strong> databases. My<strong>SQL</strong> can be executed in many architectures<br />

<strong>and</strong> operating systems. A common configuration is formed by an Apache Web server running<br />

PHP on a Linux operating system, but you can find it in many other scenarios as well.<br />

The following error is usually an indication of a My<strong>SQL</strong> injection vulnerability:<br />

Warning: mysql_fetch_array(): supplied argument is not a valid My<strong>SQL</strong> result<br />

resource in /var/www/victim.com/showproduct.php on line 8<br />

In this example, the attacker injected a single quote in a GET parameter <strong>and</strong> the PHP<br />

page sent the <strong>SQL</strong> statement to the database. The following fragment of PHP code shows<br />

the vulnerability:<br />

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

Saved successfully!

Ooh no, something went wrong!