动态线条
动态线条end

文件上传:phtml绕过+代码审计

等价后缀名

asp:asa、cdx、cer
php:php3、php4、php5、phtml
aspx:ashx、ascx、asmx
jsp:jspx、jspf
exe:exee

上传文件并抓包,将图片中php改为phtml

image-20211111190759861

发送repeater进行多次测试

连接成功

image-20211111191132301

总结:

能够解析不同后缀名文件的根本原因是配置文件,如果配置文件中写入可解析文件的后缀名,哪怕是txt文件都能够解析成php代码

过滤代码

if (file_exists(UPLOAD_PATH)) {
        $deny_ext = array('.asp','.aspx','.php','.jsp');
        $file_name = trim($_FILES['upload_file']['name']);
        $file_name = deldot($file_name);//删除文件名末尾的点
    	//trrchr — 查找指定字符在字符串中的最后一次出现
        $file_ext = strrchr($file_name, '.');
        $file_ext = strtolower($file_ext); //转换为小写
        $file_ext = str_ireplace('::$DATA', '', $file_ext);//去除字符串::$DATA
        $file_ext = trim($file_ext); //收尾去空

        if(!in_array($file_ext, $deny_ext)) {
            $temp_file = $_FILES['upload_file']['tmp_name'];
            $img_path = UPLOAD_PATH.'/'.date("YmdHis").rand(1000,9999).$file_ext;            
            if (move_uploaded_file($temp_file,$img_path)) {
                 $is_upload = true;
            } else {
                $msg = '上传出错!';
            }
        } else {
            $msg = '不允许上传.asp,.aspx,.php,.jsp后缀文件!';
        }
    } else {
        $msg = UPLOAD_PATH . '文件夹不存在,请手工创建!';
    }
posted @ 2022-01-26 19:07  v1v1v1  阅读(456)  评论(0)    收藏  举报