Discuz!NT 后台任意文件上传的源代码修补方法
时间:2014-03-11 14:09:49
收藏:0
阅读:221
相关的漏洞介绍:
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)函数
1
2
3
4
5
6 |
<span style= "color: rgb(255, 0, 0);" > if
(fileName!= null &&(fileName.ToLower().Contains( ".asp" )||fileName.ToLower().Contains( ".php" )||fileName.ToLower().Contains( ".jsp" ))) { attachmentInfo[saveFileCount].Sys_noupload = "文件格式无效" ; } // 判断 文件扩展名/文件大小/文件类型 是否符合要求 else </span> 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
Discuz!NT 后台任意文件上传的源代码修补方法,布布扣,bubuko.com
原文:http://www.cnblogs.com/miao31/p/3585924.html
评论(0)