防毒軟體掃描 ASP 原始碼時,若發現特定「敏感關鍵字」 (如 adodb.stream, CreateObject, Execute, Shell, WScript.Shell 等),常誤判為 Webshell / 木馬而隔離或刪除檔案。
將敏感字串拆解為多段,執行時用 & 串接,繞過靜態特徵碼掃描。
' 原始 (易被掃描)
Set stm = Server.CreateObject("adodb.stream")
' 拆分混淆
Set stm = Server.CreateObject("ado" & "db.stre" & "am")
' 或更進一步
Set stm = Server.CreateObject("ad" & "od" & "b." & "str" & "eam")
' 原始
stm1.CopyTo stm2, 200
' 使用 Execute 執行動態字串
Execute("stm1.Cop" & "yTo stm2, 200")
' 原始
Dim stm
Set stm = Server.CreateObject("adodb.stream")
' 全混淆版
Dim stm
Execute("Set stm = Ser" & "ver.Crea" & "teObject(""ad" & "od" & "b.stre" & "am"")")
<%
' 核心邏輯另存為 encoded_logic.txt (Base64 編碼)
' 執行時解碼並 Execute
Dim encoded, decoder, decoded
encoded = "RGltIHN0bQ0KU2V0IHN0bSA9IFNlcnZlci5DcmVhdGVPYmplY3QoImFkb2Iuc3RyZWFtIikNCg==" ' 範例
Set decoder = CreateObject("Microsoft.XMLDOM")
Set decoder = decoder.CreateElement("tmp")
decoder.DataType = "bin.base64"
decoder.Text = encoded
decoded = decoder.NodeTypedValue ' 取得二進位
' 需轉為字串再 Execute,略...
' 更簡單:使用自訂解碼函式
Function Base64Decode(b64)
Dim xml, node
Set xml = CreateObject("Microsoft.XMLDOM")
Set node = xml.CreateElement("tmp")
node.DataType = "bin.base64"
node.Text = b64
Base64Decode = BytesToString(node.NodeTypedValue)
End Function
Function BytesToString(bytes)
Dim stm
Set stm = CreateObject("ADODB.Stream")
stm.Type = 1: stm.Open
stm.Write bytes
stm.Position = 0
stm.Type = 2: stm.Charset = "utf-8"
BytesToString = stm.ReadText
stm.Close
End Function
Execute(Base64Decode(encoded))
%>
.asp 編碼為 .asa / .vbe / .jse,原始碼加密。screnc.exe input.asp output.aspClassic ASP (VBScript) 已停止主流支援,強烈建議遷移至 ASP.NET Core / Node.js / Python 等現代框架:
字串拆分 "ad" & "odb.stream"、Execute 動態執行、Base64 編碼載入、Script Encoder 加密,可有效繞過防毒靜態掃描。但這只是「治標」,根本之道在於架構現代化、最小權限部署、多層防禦體系。