Skip to main content

Ethical Hacking - SQL Injection

SQL injection is a set of SQL commands that are placed in a URL string or in data structures in order to retrieve a response that we want from the databases that are connected with the web applications. This type of attacks generally takes place on webpages developed using PHP or ASP.NET.
An SQL injection attack can be done with the following intentions −
  • To dump the whole database of a system,
  • To modify the content of the databases, or
  • To perform different queries that are not allowed by the application.
This type of attack works when the applications don’t validate the inputs properly, before passing them to an SQL statement. Injections are normally placed put in address bars, search fields, or data fields.
The easiest way to detect if a web application is vulnerable to an SQL injection attack is to use the " ‘ " character in a string and see if you get any error.

Example 1

Let’s try to understand this concept using a few examples. As shown in the following screenshot, we have used a " ‘ " character in the Name field.
Name Field
Now, click the Login button. It should produce the following response −
Login
It means that the “Name” field is vulnerable to SQL injection.

Example 2

We have this URL − http://10.10.10.101/mutillidae/index.php?page=site-footer-xssdiscussion.php
And we want to test the variable “page” but observe how we have injected a " ‘ " character in the string URL.
Variable Page
When we press Enter, it will produce the following result which is with errors.
Result With Errors

SQLMAP

SQLMAP is one of the best tools available to detect SQL injections. It can be downloaded from http://sqlmap.org/
It comes pre-compiled in the Kali distribution. You can locate it at − Applications → Database Assessment → Sqlmap.
After opening SQLMAP, we go to the page that we have the SQL injection and then get the header request. From the header, we run the following command in SQL −
./sqlmap.py --headers="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:25.0) 
Gecko/20100101 Firefox/25.0" --cookie="security=low;
PHPSESSID=oikbs8qcic2omf5gnd09kihsm7" -u '
http://localhost/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#' -
level=5 risk=3 -p id --suffix="-BR" -v3
The SQLMAP will test all the variables and the result will show that the parameter “id” is vulnerable, as shown in the following screenshot.
SQL Map

SQLNinja

SQLNinja is another SQL injection tool that is available in Kali distribution.
SQLninja

JSQL Injection

JSQL Injection is in Java and it makes automated SQL injections.
JSQL Injection

Quick Tips

To prevent your web application from SQL injection attacks, you should keep the following points in mind −
  • Unchecked user-input to database should not be allowed to pass through the application GUI.
  • Every variable that passes into the application should be sanitized and validated.
  • The user input which is passed into the database should be quoted.

Comments

Popular posts from this blog

IMPORTANCE AND ADVANTAGES OF SIWES

STUDENTS INDUSTRIAL WORK EXPERIENCE SCHEME (SIWES) The Industrial Training/Students Industrial Work Experience Scheme, IT/SIWES is a new Directorate under the Vice-Chancellor’s Office.  It was established on 20th April, 2012 The Students Industrial Work Experience Scheme (SIWES) is a skills training programme designed to expose and prepare students of universities and other tertiary institutions for the Industrial Work situation they are likely to meet after graduation.  It is also a planned and structured programme based on stated and specific career objectives which are geared towards developing the occupational competencies of participants (Mafe, 2009).  Consequently, the SIWES programme is a compulsory graduation requirement for all Nigerian university students offering certain courses. The Students Industrial Work Experience Scheme (SIWES), is the accepted training pro...

Hack Instagram Account with ighack

Ighack is a secure Instagram account hacking application that allows you to hack Instagram password free. The best part of the application is that it does not require any survey or download. It is available free on the internet. I addition to being free to use, this app is compatible with every device. The application has a reputation of being authentic and untraceable. Let us look into the procedure needed to follow for hacking Instagram passwords. Step 1: Visit the website ighack.net and click on ‘Start Hack’ option. Step 2: Enter the user name of the target’s Instagram account when the system asks you to do so and click the ‘Hack’ button. Step 3: Allow the application to do the rest. The ighack server establishes contact with Instagram server and searches for the password in the Instagram database by matching the username ID. Step 4: On extraction of the data, the installed software program automatically decrypts the data. Step 5: The system delivers the password to...

How to Crack a Password

What is Password Cracking? Password cracking is the process of attempting to gain Unauthorized access to restricted systems using common passwords or algorithms that guess passwords. In other words, it’s an art of obtaining the correct password that gives access to a system protected by an authentication method. Password cracking employs a number of techniques to achieve its goals. The cracking process can involve either comparing stored passwords against word list or use algorithms to generate passwords that match In this Tutorial, we will introduce you to the common password cracking techniques and the countermeasures you can implement to protect systems against such attacks. Topics covered in this tutorial What is password strength? Password cracking techniques Password Cracking Tools Password Cracking Counter Measures Hacking Assignment: Hack Now! What is password strength? Password strength is the measure of a password’s efficiency to resist password crackin...