SQL Injection Attack - How to use and find Vulnerabilities
What is SQL Injection
A cyberattack known as SQL injection occurs when an attacker inserts malicious code into a SQL statement. If it is successful, the attacker will be able to access private information stored in a database.
The data can be stolen, altered, or even deleted if the attacker has control of the database.
What is SQLMap
SQL injection vulnerabilities are automatically found and exploited by a free programme called SQLmap. It enables us to gain access to a fragile database and examine web applications for SQL injection vulnerabilities.
Pen-testers adore SQLMap as a tool because of its versatility and simplicity. It was created in Python and is compatible with Windows, Linux, and MacOS.
Using SQLMap, we can execute a range of attacks. This includes data extraction, database fingerprinting, and even a complete database takeover. Additionally, it enables us to bypass login windows and execute arbitrary code on the underlying operating system.
How to Install SQLMap
In both Parrot OS and Kali Linux, SQLMap is pre-installed. Use the apt package manager to install SQLMap on Ubuntu and Debian-based computers.
Also Use In Windows and Linux
Here is Command For Linux
1. apt install sqlmap
if you are using other platforms,you can find installation instruction here
2.sqlmap -h
The -h command can be used to check the help menu after installation is complete. This will be useful as a reference when using SQLMap.
How to use Sqlmap
An instrument called SQLMap is used to automatically attack SQL injection flaws. Using SQLMap, we can scan websites and databases for flaws and then exploit those flaws to gain control of the target database.
We must first locate a website or database that is susceptible to SQL injection before we can use SQLMap. To scan the webpage, we have two options: manually or with SQLMap. We can use SQLMap to exploit a weak website or database once we have found it.
The basic SQLMap command is as follows
$ sqlmap -u [URL] -p [parameter] --dbs
This command instructs SQLMap to check the URL and argument for security flaws. Data exposure, data updating, and even database dumps are all included in this.
Using query parameters is the quickest approach to determining whether a website is susceptible to SQL injection. Assume a website uses an id parameter to list user information, such as testsite.com/page.php?id=1.
If this is given to Sqlmap as input, it will automatically scan the website to check whether the database is susceptible. The order is as follows:
$ sqlmap -u http://testsite.com/page.php?id=1 --dbs
The --dbs command instructs Sqlmap to attempt to enumerate the database, and the -u parameter is used to give a URL.
If the assault is successful, Sqlmap will display a list of the tables and the database that ware used.