Topic 6b - Web Application SQL Injection Testing - Using Sqmap
Topic 6b - Web Application SQL Injection Testing - Using Sqmap
Sqlmap
Sqlmap is one of the most popular and powerful sql injection automation tool out
there.
Given a vulnerable http request url, sqlmap can exploit the remote database and do
a lot of hacking like extracting database names, tables, columns, all the data
in the tables etc.
It can even read and write files on the remote file system under certain
conditions.
Written in python it is one of the most powerful hacking tools out there.
Sqlmap is the metasploit of sql injections.
Sqlmap is included in pen testing linux tools like kali linux, backtrack,
backbox etc.
On other operating systems, it can be simply downloaded from the following url
http://sqlmap.org/.
Since its written in python, first you have to install python on your system if using
Windows
1|Page
Step 1.a: Google Dorks strings to find Vulnerable SQLMAP SQL injectable
website
Examples
Google Dork string Column Google Dork string Google Dork string Column
1 Column 2 3
2|Page
inurl:trainers.php?id= inurl:curriculum.php?id= inurl:rub.php?idr=
3|Page
inurl:index.php?id= inurl:newscat.php?id= inurl:productinfo.php?id=
inurl:newsticker_info.php
inurl:news.php?id= inurl:collectionitem.php?id=
?idn=
inurl:declaration_more.php?de
inurl:news_view.php?id= inurl:pop.php?id=
cl_id=
inurl:select_biblio.php?id
inurl:pageid= inurl:shopping.php?id=
=
4|Page
inurl:ogl_inet.php?ogl_id
inurl:newsDetail.php?id= inurl:viewshowdetail.php?id=
=
inurl:fiche_spectacle.php?
inurl:gallery.php?id= inurl:clubpage.php?id=
id=
inurl:communique_detail.
inurl:article.php?id= inurl:memberInfo.php?id=
php?id=
inurl:shredder-
inurl:readnews.php?id= inurl:index.php?id=
categories.php?id=
inurl:product_ranges_view.php?
inurl:historialeer.php?num= inurl:show_an.php?id=
ID=
5|Page
inurl:Stray-Questions-
inurl:loadpsb.php?id= inurl:transcript.php?id=
View.php?num=
inurl:news.php?id= inurl:participant.php?id=
inurl:avd_start.php?avd= inurl:download.php?id=
inurl:event.php?id= inurl:main.php?id=
inurl:product-item.php?id= inurl:review.php?id=
inurl:sql.php?id= inurl:chappies.php?id=
6|Page
inurl:material.php?id= inurl:read.php?id=
inurl:clanek.php4?id= inurl:prod_detail.php?id=
inurl:announce.php?id= inurl:viewphoto.php?id=
inurl:chappies.php?id= inurl:article.php?id=
inurl:read.php?id= inurl:person.php?id=
inurl:viewapp.php?id= inurl:productinfo.php?id=
inurl:viewphoto.php?id= inurl:showimg.php?id=
inurl:rub.php?idr= inurl:view.php?id=
inurl:galeri_info.php?l= inurl:website.php?id=
Discover Databases
Once sqlmap confirms that a remote url is vulnerable to sql injection and is exploitable
the next step is to find out the names of the databases that exist on the remote
system.
Now its time to find out what tables exist in a particular database. Lets say the
database of interest over here is 'safecosmetics'
Command
Now that we have the list of tables with us, it would be a good idea to get the columns
of some important table.
Lets say the table is 'users' and it contains the username and password.
8|Page
$ python sqlmap.py -u "http://www.site.com/section.php?id=51" --columns -D safecosmetics -T users
Now comes the most interesting part, of extracting the data from the table.
9|Page
The above command will simply dump the data of the particular table, very much like
the mysqldump command.
The output might look similar to this
The hash column seems to have the password hash. Try cracking the hash and then you
would get the login details rightaway.
sqlmap will create a csv file containing the dump data for easy analysis.
So far we have been able to collect a lot of information from the remote database using
sqlmap
Its almost like having direct access to remote database through a client like
phpmyadmin.
In real scenarios hackers would try to gain a higher level to access to the system.
For this, they would try to crack the password hashes and try to login through the admin
panel. Or they would try to get an os shell using sqlmap.
10 | P a g e