如何在 vbScript 中打乱函数名称
How can I scramble the name of function in vbScript
我想在定义函数时在源代码中隐藏一个函数名。我测试了下面的逻辑将名称分成两部分但不起作用:
function convertName(x)
convertName= x & "tion"
end function
function convertName("myFunc")(text)
convertName("myFunc")= text
end function
response.write myFunction("test")
还有其他方法来打乱函数名吗?
阅读 OP 问题评论我确定这不是 OP 所需要的(Ansgar Wiechers 是完全正确的,这只会混淆代码但根本不提供任何安全性),但它是一种方法的示例处理请求的内容。
以防万一有人觉得有用,基本思路是
Sub scrambledName( data )
WScript.Echo data
End Sub
Set originalName = GetRef("scrambledName")
originalName "this is a test"
也就是我们用一个原名的变量来保存对炒名背后代码的引用。
示例:
Option Explicit
' Scrambled named code
'------------------------------------------------------------------------------
Sub Sbesttu29348( inputText )
WScript.Echo "data=" & inputText
End Sub
Function Fceinnostttu6953( a, b, c)
Fceinnostttu6953 = a + b + c
End Function
'------------------------------------------------------------------------------
' Map original names to scrambled ones
prepareFunctions Array( "testSub", "testFunction" )
' Call functions using original names
testSub "this is a test"
WScript.Echo testFunction(1, 2, 3)
'Scramble handling code
'------------------------------------------------------------------------------
' Function used to find a scrambled name for the original function
' This simply concatenates input text sorted characters with a simple hash
Function scramble( inputText )
Dim a(256), i, s, h
For i = 1 To LenB( inputText )
s = AscB(MidB(inputText, i, 1))
If s > 0 Then a(s) = a(s) & Chr(s)
h = ((h)Xor(((h And 1)*65535)And&hffff))+s
Next
scramble = Trim(Join(a,"")) & h
End Function
' Map original names to scrambled names
' It just defines new variables for the original names pointing to the scrambled names
Sub prepareFunctions( aFunctions )
Dim f, s
For Each f in aFunctions
s = s & "Set " & f & "=GetRef(""" & scramble(f) & """)" & vbCrLf
Next
ExecuteGlobal s
End Sub
'------------------------------------------------------------------------------
我想在定义函数时在源代码中隐藏一个函数名。我测试了下面的逻辑将名称分成两部分但不起作用:
function convertName(x)
convertName= x & "tion"
end function
function convertName("myFunc")(text)
convertName("myFunc")= text
end function
response.write myFunction("test")
还有其他方法来打乱函数名吗?
阅读 OP 问题评论我确定这不是 OP 所需要的(Ansgar Wiechers 是完全正确的,这只会混淆代码但根本不提供任何安全性),但它是一种方法的示例处理请求的内容。
以防万一有人觉得有用,基本思路是
Sub scrambledName( data )
WScript.Echo data
End Sub
Set originalName = GetRef("scrambledName")
originalName "this is a test"
也就是我们用一个原名的变量来保存对炒名背后代码的引用。
示例:
Option Explicit
' Scrambled named code
'------------------------------------------------------------------------------
Sub Sbesttu29348( inputText )
WScript.Echo "data=" & inputText
End Sub
Function Fceinnostttu6953( a, b, c)
Fceinnostttu6953 = a + b + c
End Function
'------------------------------------------------------------------------------
' Map original names to scrambled ones
prepareFunctions Array( "testSub", "testFunction" )
' Call functions using original names
testSub "this is a test"
WScript.Echo testFunction(1, 2, 3)
'Scramble handling code
'------------------------------------------------------------------------------
' Function used to find a scrambled name for the original function
' This simply concatenates input text sorted characters with a simple hash
Function scramble( inputText )
Dim a(256), i, s, h
For i = 1 To LenB( inputText )
s = AscB(MidB(inputText, i, 1))
If s > 0 Then a(s) = a(s) & Chr(s)
h = ((h)Xor(((h And 1)*65535)And&hffff))+s
Next
scramble = Trim(Join(a,"")) & h
End Function
' Map original names to scrambled names
' It just defines new variables for the original names pointing to the scrambled names
Sub prepareFunctions( aFunctions )
Dim f, s
For Each f in aFunctions
s = s & "Set " & f & "=GetRef(""" & scramble(f) & """)" & vbCrLf
Next
ExecuteGlobal s
End Sub
'------------------------------------------------------------------------------