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

  • 相关阅读:
    数据结构 课程安排 (拓扑排序)
    数据结构 通畅工程 (最小生成树)
    01 C#基础
    计算机组成原理——第一章 系统概述
    数据结构——第八章 排序 第九章 文件
    数据结构——第七章 查找
    字符编码(转)
    数据结构——第六章 图
    NodeJS加密算法(转)
    入职总结
  • 原文地址:https://www.cnblogs.com/miao31/p/3585924.html
Copyright © 2011-2022 走看看