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 <strong>SQL</strong> <strong>Injection</strong> • Chapter 4 175<br />

As you can see, we now know the names of the columns of the customers table. We can<br />

guess that both login <strong>and</strong> passwords are of type string, <strong>and</strong> we can therefore return them with<br />

yet another UNION SELECT, this time using both the Type <strong>and</strong> Description fields of the<br />

original query. This is performed by the following URL:<br />

http://www.victim.com/products.aspid=12+union+select+null,login,password,<br />

null+from+e–shop..customers--<br />

As you can see, this time we use two column names in our injected query. The result,<br />

which finally contains the data we were looking for, is in the screenshot shown in Figure 4.14.<br />

Figure 4.14 Finally Getting the Data: Username <strong>and</strong> Passwords, in This Case!<br />

Bingo!! However, the result is not just a very long list of users. It seems that this application<br />

likes to store user passwords in clear text instead of using a hashing algorithm. The same<br />

attack sequence could be used to enumerate <strong>and</strong> retrieve any other table that the user has<br />

access to, but having arrived at this point, you might just call the client, tell them they have a<br />

huge problem (actually, more than just one), <strong>and</strong> call it a day.

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

Saved successfully!

Ooh no, something went wrong!