SQL Injection
SQL injection is taking advantage of unsanitized input vulnerabilities to pass SQL commands to a web application.
Attack types
SQL injections can be used for various types of attacks:
Authentication Bypass
An intruder gains access to an application without a valid username and password, effectively obtaining administrative privileges.
Authorization Bypass
A hacker manipulates authorization data in a database by exploiting vulnerabilities, such as SQL injection.
Information Disclosure
An attacker acquires sensitive data from a database, potentially compromising the confidentiality of the information.
Compromised Data Integrity
Intruders vandalize web pages, insert malicious content, or alter a database's contents, compromising data integrity.
Compromised Data Availability
Aggressors delete database information, log records, or audit data stored in a database, leading to data unavailability.
Remote Code Execution
Intruders compromise the host operating system, potentially gaining control over the system's functionality.
SQL Injection example
Attackers can craft a query by inputting specific values in application fields, such as usernames and passwords. For example:
Username:
Bob' or 1=1 --
Password:
Whatever
During query execution, these values replace placeholders, resulting in a query like this:
Analyzing this query reveals that the condition in the WHERE clause will always evaluate to true, potentially leading to unauthorized access.
Cheat Sheets
Tools
sqlmap
Target URL and Cookies: First, specify the target URL where the injection will occur. You can also provide the necessary cookies for authentication.
-u
specifies the target URL.--cookie
is used to set the HTTP cookie header.--dbs
instructs sqlmap to enumerate the available databases in the DBMS.
Select a Database: After identifying the databases, you can select a specific one for further exploration. In this example, we'll use a database named "exampledb."
-D
specifies the database to enumerate.--tables
instructs sqlmap to list the tables in the chosen database.
Retrieve Table Content: Now, let's say we want to retrieve the content of a table called "user_data." You can use sqlmap to dump the table content.
-T
specifies the table to extract data from.--dump
is used to retrieve and display the table content.
Interactive OS Shell: sqlmap can also provide an interactive OS shell for advanced operations.
--os-shell
initiates an interactive OS shell.Optimize Delay Responses: If prompted with a message asking if you want sqlmap to optimize delay responses, you can respond with "Y" to improve the injection efficiency.
View Available Commands: To explore the available commands within the interactive OS shell, simply type "help."
Mole
Blisqy
For mobile devices
sqlmapchik
Last updated