[SQLMap]SQL injection + Database takeover - pt. 1 03-23-2012, 10:48 PM
#1
Hello and welcome to part 1 of "SQL injection + database takeover" with SQL map.
In this part, I'll teach you how to use the basic functions of SQLMap.
SQLMap or Havij?
A hacker can't bother to do everything manually all the time. You can call me a skid, but even the top hackers use SQLMap or Havij time to time. The reason is, that some injections are just too boring and you must focus on other things that simply injecting the server.
HOWEVER do not rely on scripts and/or programs too much. They should only save you your time, not do your job.
When it comes to choosing a tool, I prefer using SQLMap, here are couple of reasons why:
=> Its free
=> Tells you exactly what it is doing
=> Gives you more information about the injection
=> Can use Metasploit framework in your attacks
=> Has a lot of covering methods (You can use Tor with it, simulate a smartphone etc.)
=> Saves all information to session file, so you can continue in your attack without having to re-discover all info over and over
=> Has a lot of options so you always get what you need
Getting ready
BackTrack has SQLMap already pre-installed. For other systems you can get it HERE
For this tutorial, we will use --tor option, this will use tor to cover all of our attacks. If you don't have it installed, SQLMap will provide you with a link to a guide how to install it.
Exploiting
I'm using BackTrack 5 R1 in this tutorial, there might be small differences on your system.
Starting SQLMap:
![[Image: StartSQL.png]](http://dl.dropbox.com/u/46190297/StartSQL.png)
To start an attack, you will have to start SQL map with arguments.
Follow them this way:
![[Image: ArgumentsSQL.png]](http://dl.dropbox.com/u/46190297/ArgumentsSQL.png)
SQLMap will scan the link and choose attacks according to the information found. Once the injection is completed, it will give you all information it found INCLUDING the payload (THANKS DEVELOPERS!)
![[Image: infoSQL.png]](http://dl.dropbox.com/u/46190297/infoSQL.png)
All of the information will be saved to session file. Next time you exploit the same URL, SQLMap won't have to search for the payload, instead, it will use one of the payloads found previously.
Now lets find out the databases. This can take a lot of time, so let me introduce you to the --threads option, it works like this:
To enumerate databases, we will use the --dbs command. Our final command should look like this:
![[Image: DBMSSQL.png]](http://dl.dropbox.com/u/46190297/DBMSSQL.png)
SQLMap will start finding the databases, in my case, it was a blind injection so it takes a bit longer (however, its faster than havij for sure!)
![[Image: DBSQL.png]](http://dl.dropbox.com/u/46190297/DBSQL.png)
Congratulations! You have injected your first website with SQLMap!
In the next part you will learn about dumping databases, looking for certain columns across databases and more!
Have a great day!
In this part, I'll teach you how to use the basic functions of SQLMap.
SQLMap or Havij?
A hacker can't bother to do everything manually all the time. You can call me a skid, but even the top hackers use SQLMap or Havij time to time. The reason is, that some injections are just too boring and you must focus on other things that simply injecting the server.
HOWEVER do not rely on scripts and/or programs too much. They should only save you your time, not do your job.
When it comes to choosing a tool, I prefer using SQLMap, here are couple of reasons why:
=> Its free
=> Tells you exactly what it is doing
=> Gives you more information about the injection
=> Can use Metasploit framework in your attacks
=> Has a lot of covering methods (You can use Tor with it, simulate a smartphone etc.)
=> Saves all information to session file, so you can continue in your attack without having to re-discover all info over and over
=> Has a lot of options so you always get what you need
Getting ready
BackTrack has SQLMap already pre-installed. For other systems you can get it HERE
For this tutorial, we will use --tor option, this will use tor to cover all of our attacks. If you don't have it installed, SQLMap will provide you with a link to a guide how to install it.
Exploiting
I'm using BackTrack 5 R1 in this tutorial, there might be small differences on your system.
Starting SQLMap:
![[Image: StartSQL.png]](http://dl.dropbox.com/u/46190297/StartSQL.png)
To start an attack, you will have to start SQL map with arguments.
Follow them this way:
Code:
./sqlmap.py --tor -u [vulnerable link]
--tor = Uses tor to cover your attacks
-u = Tells the system you will provide URL (type --help for more information)![[Image: ArgumentsSQL.png]](http://dl.dropbox.com/u/46190297/ArgumentsSQL.png)
SQLMap will scan the link and choose attacks according to the information found. Once the injection is completed, it will give you all information it found INCLUDING the payload (THANKS DEVELOPERS!)
![[Image: infoSQL.png]](http://dl.dropbox.com/u/46190297/infoSQL.png)
All of the information will be saved to session file. Next time you exploit the same URL, SQLMap won't have to search for the payload, instead, it will use one of the payloads found previously.
Now lets find out the databases. This can take a lot of time, so let me introduce you to the --threads option, it works like this:
Code:
--threads [number of threads]
USAGE:
./sqlmap.py --tor --threads [number of threads] -u [vulnerable link]To enumerate databases, we will use the --dbs command. Our final command should look like this:
Code:
./sqlmap.py --tor --threads [number of threads] -u [vulnerable link] --dbs![[Image: DBMSSQL.png]](http://dl.dropbox.com/u/46190297/DBMSSQL.png)
SQLMap will start finding the databases, in my case, it was a blind injection so it takes a bit longer (however, its faster than havij for sure!)
![[Image: DBSQL.png]](http://dl.dropbox.com/u/46190297/DBSQL.png)
Congratulations! You have injected your first website with SQLMap!
In the next part you will learn about dumping databases, looking for certain columns across databases and more!
Have a great day!
Staff will never ever ask you for your personal information.
We know everything about you anyway.
We know everything about you anyway.



![[+]](https://sinister.li/images/modern/collapse_collapsed.png)