SQLi
Mostly SQL injection vulnerabilities can be found using modern scanners. However, for more complex scenarios such as second-order SQLi, manual testing can also be used.
Detection
The goal with many of these tests is to invoke some behaviour change in the application. Be sure to closely monitor for:
Test cases:
Test with out-of-band (OOB) or out-of-band application security testing (OAST) techniques
Test for stacked queries
Test for
UNIONkeywordSELECT username,password FROM users UNION SELECT null,nullTest for the number of columns using
null,nullorORDER BY 1,ORDER BY 2Test the data types with
'a',1etc
Test with different encoding techniques
Test evasion techniques
Test with encoded payloads
Test with builting functions
E.g.
CHAR()
Test ways to bypass commonly filtered characters
E.g. replacing space with
/**/
Detection syntax
General
MySQL
PostgeSQL
Oracle
MSSQL
Other Payloads
Tools:
SQLmap
The easiest way to get started with SQLmap is to either save a request to a file or copy a request as curl and change the curl command to sqlmap.

SQLi
Common
Polyglot
Resources by type
R/W files
Blind SQLi
Blind SQL Injection
Blind SQL injection (Blind SQLi) is a type of SQL injection attack where the attacker can exploit the database, but the application does not display the output. Instead, the attacker must "infer" data by sending payloads and observing the application's behavior or responses.
A simple example:
A vulnearble webapp uses an API for its search to return the number of results found.
A user searches for a product, and the application returns with "X products found" without displaying product details.
The application uses the SQL query
SELECT COUNT(*) FROM products WHERE product_name LIKE '%{searchTerm}%'.An attacker could exploit this by injecting SQL conditions into the
{searchTerm}.For exmaple, searching for
laptop' AND 1=1-- -returns "1 product found" and searching forlaptop' AND 1=2-- -returns "0 products found", this behavior can be an indicator of a potential Blind SQLi vulnerability.
Blind SQLi is more time-consuming than regular SQLi but is just as dangerous. It can lead to:
Sensitive data exposure
Data manipulation
Authentication bypass
Potential discovery of hidden data
Other learning resources:
SQLmap's guide on Blind SQLi: http://sqlmap.org/
PenTestMonkey's Cheat Sheet: http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
Writeups:
Checklist:
Identify potential vulnerable points:
URL parameters
Form fields
HTTP headers (e.g. cookies, user-agent)
Hidden fields
Test for true/false conditions:
Can you get a "true" condition? E.g.,
' AND 1=1-- -Can you get a "false" condition? E.g.,
' AND 1=2-- -
Time-based Blind SQLi:
Introduce artificial delays using functions like
SLEEP()orBENCHMARK()Measure response times
Error-based Blind SQLi:
Test a divide by zero payload
Can we trigger an error message?
Can we use
CAST()to trigger an error and view the data?
Content-based Blind SQLi:
Check for changes in page content based on payloads
Out-of-band (OAST):
Can we trigger a DNS query?
Can we append some data to the subdomain of the URL to exfiltrate information?
Binary search based extraction:
Exploit faster by dividing data and querying
Backend specifics:
Are you dealing with MySQL, MSSQL, Oracle, PostgreSQL, SQLite?
Adjust your payloads accordingly
Test with automated tools:
SQLmap with
--technique=Bflag
Encoding and obfuscation:
Test with URL encoding, hex encoding, or other methods to bypass filters
Bypassing filters:
Use comments, spaces, or alternative syntax
Exploitation:
Extract database version, e.g.,
AND (SELECT SUBSTRING(version(),1,1))='5'Fetch data character by character
Extract data from information_schema
Second-order SQLi
Second-order SQL Injection
Second order SQL injection (also known as Stored SQL Injection) occurs when user input is first stored in the database, and later used without being validated or encoded. The injection opportunity occurs in the second operation, hence the name "second order".
A simple example:
A vulnerable webapp allows users to save their usernames.
An attacker can provide a malicious payload as their username, e.g.
jeremy'); DROP TABLE users;-- -Later, when the application tries to fetch the username for an operation (e.g., greeting a returning user), it executes the malicious payload.
This type of attack can lead to:
Data loss or corruption.
Compromise of the database.
Sensitive data exposure.
Remote code execution.
Checklist:
sqlmap
Last updated