zoukankan      html  css  js  c++  java
  • Discuz!NT 后台任意文件上传的源代码修补方法

    相关的漏洞介绍:

    http://www.wooyun.org/bugs/wooyun-2013-035199

    Discuz!NT 管理后台可以自定义文件类型,从而造成任意文件上传,测试过程中 aspx文件,目录并不会解析。所以需要能解析 asp 或者php等。
    
    过程演示【程序版本:Discuz!NT 3.6】:
    1. 登陆 Discuz!NT 后台,【全局】-->【附件设置】-->【附件尺寸】-->【添加附件类型】
    添加需要上传的文件类型。如图,我添加了ASP
    2. 给用户组加上上传ASP的权限。【用户】-->【分组与级别】-->【编辑用户组】-->【编辑系统组】-->【管理员】,勾选上添加的ASP 类型。
    3.去前台上传上传asp文件。【附件】-->【批量上传】,选择ASP文件。
    4.进入后台找shell。【内容】-->【附件管理】-->【搜索附件】。

    特此记录一下:

    -------------------------------------------

    1.先加强后台中的判断准则:Discuz.Web.Admin.attachtypesgrid.cs文件中的

            private void AddNewRec_Click(object sender, EventArgs e)
            {
                #region 添加新的附件信息
    
                if (extension.Text == "")
                {
                    base.RegisterStartupScript( "", "<script>alert('要添加的附件扩展名不能为空');window.location.href='forum_attachtypesgrid.aspx';</script>");
                    return;
                }
    
                if (extension.Text.ToLower().Contains("asp") || extension.Text.ToLower().Contains("php")||extension.Text.ToLower().Contains("jsp"))
                {
                    base.RegisterStartupScript("", "<script>alert('要添加的附件扩展名不能为asp,php,jsp');window.location.href='forum_attachtypesgrid.aspx';</script>");
                    return;
                }

    2.再加强前台中的代码判断准则:Discuz.Forum.ForumUtils.cs文件中的

            public static AttachmentInfo[] SaveRequestFiles(int forumid, int MaxAllowFileCount, int MaxSizePerDay, int MaxFileSize, int TodayUploadedSize, string AllowFileType, int watermarkstatus, GeneralConfigInfo config, string filekey, bool isImage)函数

                        if (fileName!=null&&(fileName.ToLower().Contains(".asp")||fileName.ToLower().Contains(".php")||fileName.ToLower().Contains(".jsp")))
                        {
                            attachmentInfo[saveFileCount].Sys_noupload = "文件格式无效";
                        }
                        // 判断 文件扩展名/文件大小/文件类型 是否符合要求
                        else if (!(Utils.IsImgFilename(fileName) && !fileType.StartsWith("image")) && ValidateImage(fileType, HttpContext.Current.Request.Files[i].InputStream))
    

     

    现提供编辑好的DLL:Discuz.Web.Admin.dll+Discuz.Forum.dll,此编译DLL仅供测试,请自己备份好之前的DLL。

    http://files.cnblogs.com/miao31/Discuz.Web.Admin.dll.rar

  • 相关阅读:
    Thinkphp中自己组合的数据怎样使用框架的分页
    CI框架不能有Index控制器
    购物车,修改数量错误
    TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement.
    OAuth2.0
    通过控制面板查看时间日志
    js再学习笔记
    Thinkphp验证码异步验证第二次及以后验证,验证错误----待解决
    cookie&&session再理解笔记
    markdown语法学习笔记
  • 原文地址:https://www.cnblogs.com/miao31/p/3585924.html
Copyright © 2011-2022 走看看