• php封装协议的两道题


         这几天终于刷完了自己说是要刷完的那几道题,赶紧写几篇博客记录。。

         

            1.  先看看这个网站:https://blog.csdn.net/qq_41289254/article/details/81388343

               接下来直接上题:

               1.http://123.206.87.240:8005/post/index.php?file=show.php

                

                  看源码和抓包都无果,根据题目提示,flag在index里,应该想到这里是要我们找到index.php的源码。

                   再看url里面file参数=show.php这里联想到可能是有文件包含漏洞。

                 所以这里进行php://filter协议去看index的源码  

               关于 php://filter   这里有个大佬的博客:https://www.leavesongs.com/PENETRATION/php-filter-magic.html  

                   这里有一句常常用到,所以我觉得最好可以背下来,不然每次都难得百度,需要想将php转base64读取,这样include才不会把php文件执行。

                  这里令file=php://filter/read=convert.base64-encode/resource=index.php

                 然后直接拿到index的base64的源码,然后直接拿去解码,然后再源码里可以找到flag。

                  2.bugku    "welcome to bugkuctf"

                      连接:http://123.206.87.240:8006/test1/

                    点进去看源码

                     

                        这里可以看到       include($file);       有这个一般都存在文件包含漏洞。

                        和上题一样,这里可以利用php封装协议查看index.php 的源码和 hint.php的源码,但是,这里要先满足if里的条件才会包含file

                        file_get_contents()  这个函数是把文件读为字符串,这里要用到php://input 协议,

                       这里有关于 php://input 协议的一片博客附上:https://blog.csdn.net/qq_27682041/article/details/73326435

                        官方的说法是

                       我自己的理解是,php://input 它是一个文件,它读取post数据,并且写入文件里,而include()会把文件当作php文件来解释,所以可以post  php代码执行的。

                      回到这道题,这里就直接user=php://input  然后再post数据过去,然后再读取index和hint两个的源码

                      http://123.206.87.240:8006/test1/?txt=php://input&file=php://filter/read=convert.base64-encode/resource=index.php

                      

                        拿去base64解码 得到源码 

                        

    <?php
    $txt = $_GET["txt"];
    $file = $_GET["file"];
    $password = $_GET["password"];

    if(isset($txt)&&(file_get_contents($txt,'r')==="welcome to the bugkuctf")){
    echo "hello friend!<br>";
    if(preg_match("/flag/",$file)){
    echo "ä¸èƒ½çŽ°åœ¨å°±ç»™ä½ flag哦";
    exit();
    }else{
    include($file);
    $password = unserialize($password);
    echo $password;
    }
    }else{
    echo "you are not the number of bugku ! ";
    }

    ?>

    <!--
    $user = $_GET["txt"];
    $file = $_GET["file"];
    $pass = $_GET["password"];

    if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){
    echo "hello admin!<br>";
    include($file); //hint.php
    }else{
    echo "you are not admin ! ";
    }

    同样的方法拿到 hint.php的源码

    <?php

    class Flag{//flag.php
    public $file;


    public function __tostring(){
    if(isset($this->file)){
    echo file_get_contents($this->file);
    echo "<br>";
    return ("good");
    }
    }
    }
    ?>

              这里看到flag.php 本来是想直接读出flag的源码,但是没法读,因为他把flag给我过滤了,但是 ,这里else里面又有include(),而且最后会echo password,所以这里想到会用echo输出flag。

               unserialize()函数参见此网站,https://www.cnblogs.com/perl6/p/7124345.html

               看了过后你就应该明白,这里构造 password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

              

             

              

                          

                                      

  • 相关阅读:
    LR12解决不能打开webTours服务问题
    python中join()方法介绍
    python中的sort方法和sorted方法
    如何发送最新的测试报告到目标邮箱?
    python2.7发送邮件失败之——邮箱安全问题
    python2.7发送邮件失败之——代码问题
    python2.7发送邮件失败之——SMTPAuthenticationError问题
    使用HTMLTestRunner在目标目录下并未生成HTML文件解决办法
    python标准日志模块logging及日志系统设计
    性能测试需求分析
  • 原文地址:https://www.cnblogs.com/tlbjiayou/p/10890314.html
Copyright © 2020-2023  润新知