从蜜罐上线到1day发现
字数 1364 2025-08-20 18:18:24
PowerCreator CMS 任意文件上传漏洞分析与利用
漏洞概述
PowerCreator CMS 存在多处任意文件上传漏洞,攻击者可利用这些漏洞上传恶意文件(如ASPX webshell)获取服务器控制权。本文详细分析四个上传接口中的三个存在漏洞的接口,并提供完整的利用方法。
漏洞分析
1. UploadResourcePic.ashx 任意文件上传漏洞
漏洞文件: /upload/UploadResourcePic.ashx
漏洞代码分析:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string rid = context.Request["ResourceID"] ?? string.Empty;
if (!string.IsNullOrEmpty(rid))
{
if (context.Request.Files.Count > 0)
{
HttpPostedFile file = context.Request.Files[0];
string Url = PowerCreator.MediaServer.PublicClass.WebUtils.WebRoot + "/ResourcePic/";
string Path = context.Server.MapPath(Url);
if (System.IO.Directory.Exists(Path) == false)
{
System.IO.Directory.CreateDirectory(Path);
}
string ext = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToUpper();
if (file.ContentType != "image/jpeg")
{
context.Response.Write(-2);
}
else
{
string newFileName = PowerCreator.MediaServer.PublicClass.Base64.Encode(rid) + ext;
file.SaveAs(Path + newFileName);
context.Response.Write(newFileName);
}
}
else
{
context.Response.Write(-1);
}
}
else
{
context.Response.Write("参数错误");
}
context.Response.End();
}
漏洞点:
- 接口无任何权限验证,可直接访问
- 仅检查Content-Type是否为"image/jpeg",无其他安全措施
- 文件名由ResourceID参数base64编码后加上原始文件扩展名组成
利用方法:
- 构造上传表单,设置Content-Type为"image/jpeg"
- 通过GET或POST传递ResourceID参数
- 上传任意文件(如ASPX webshell)
示例表单:
<form action="http://target.com/upload/UploadResourcePic.ashx?ResourceID=1"
enctype="multipart/form-data" method="POST">
<input type="file" class="file1" name="file1" />
<button type="submit" class="but1">上传</button>
</form>
上传后路径: /ResourcePic/MQ==.ASPX (ResourceID=1的base64编码为"MQ==")
2. uploadCoursePic.ashx 任意文件上传漏洞
漏洞文件: /upload/uploadCoursePic.ashx
漏洞代码分析:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
// 文件删除逻辑(无关部分省略)
if (context.Request.Files.Count > 0)
{
HttpPostedFile file = context.Request.Files[0];
string Url = PowerCreator.MediaServer.PublicClass.WebUtils.WebRoot + "/fileManager/UploadFile/CoursePic/";
string Path = context.Server.MapPath(Url);
if (System.IO.Directory.Exists(Path) == false)
{
System.IO.Directory.CreateDirectory(Path);
}
string ext = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToUpper();
if (!".PNG.JPG".Contains(ext))
{
context.Response.Write(-2);
}
string newFileName = Guid.NewGuid().ToString() + ext;
file.SaveAs(Path + newFileName);
context.Response.Write(Url + newFileName);
}
else
{
context.Response.Write(-1);
}
}
漏洞点:
- 虽然检查文件扩展名是否为.PNG或.JPG,但即使检查失败(-2)仍会继续执行上传操作
- 无任何权限验证
- 文件名使用GUID生成,确保唯一性
利用方法:
直接发送multipart/form-data格式的POST请求到该接口,上传任意文件
上传后路径: /fileManager/UploadFile/CoursePic/{GUID}.ext (如示例中的485b1b71-8035-44c1-9ceb-637cd68eda19.ASPX)
3. UploadLogo.ashx 任意文件上传漏洞
漏洞文件: /upload/UploadLogo.ashx
漏洞代码分析:
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (context.Request.Files.Count > 0)
{
HttpPostedFile file = context.Request.Files[0];
string Url = PowerCreator.MediaServer.PublicClass.WebUtils.WebRoot + "/images/logo/";
string Path = context.Server.MapPath(Url);
if (System.IO.Directory.Exists(Path) == false)
{
System.IO.Directory.CreateDirectory(Path);
}
string ext = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToUpper();
string newFileName = context.Request["fileName"];
file.SaveAs(Path + newFileName);
context.Response.Write(Url + newFileName);
}
else
{
context.Response.Write(-1);
}
context.Response.End();
}
漏洞点:
- 无任何文件类型或扩展名检查
- 无权限验证
- 文件名完全由攻击者控制的fileName参数决定
利用方法:
- 发送multipart/form-data格式的POST请求
- 通过GET或POST传递fileName参数指定最终文件名
- 上传任意文件
上传后路径: /images/logo/{指定文件名}
4. uploadActPic.aspx (确认无漏洞)
该文件实际逻辑在LMS_MediaServer.dll中,经反编译分析使用白名单校验,不存在任意文件上传漏洞。
漏洞修复建议
- 对所有上传接口添加权限验证
- 实现严格的文件类型和扩展名检查(白名单方式)
- 对上传文件内容进行检测(如图片魔数检测)
- 限制上传目录的执行权限
- 使用随机化文件名(不包含用户可控部分)
- 修复逻辑错误(如uploadCoursePic.ashx中检查后仍执行上传的问题)
总结
PowerCreator CMS存在多处任意文件上传漏洞,主要由于缺乏权限验证和不足的文件安全检查导致。攻击者可利用这些漏洞上传webshell获取服务器完全控制权。建议使用该CMS的用户立即检查并修复这些安全问题。