求解开jscript.encode代码的asp函数
程序员文章站
2023-11-22 11:13:28
javascript函数已经有了,有没有asp的函数??? 或者有没有高手可以把下面的写成asp的 &...
javascript函数已经有了,有没有asp的函数???
或者有没有高手可以把下面的写成asp的 ,万分感谢~!!
<script language="javascript">
<!--
function toencode(s,l)
{enc=new activexobject("scripting.encoder");
return enc.encodescriptfile("."+l,s,0,l+"cript");
}
var state_copy_input = 100
var state_readlen = 101
var state_decode = 102
var state_unescape = 103
var pick_encoding = new array(
1, 2, 0, 1, 2, 0, 2, 0, 0, 2, 0, 2, 1, 0, 2, 0,
1, 0, 2, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2,
1, 1, 0, 2, 0, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 2,
1, 0, 2, 0, 1, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 2
)
var rawdata = new array(
0x64,0x37,0x69, 0x50,0x7e,0x2c, 0x22,0x5a,0x65, 0x4a,0x45,0x72,
0x61,0x3a,0x5b, 0x5e,0x79,0x66, 0x5d,0x59,0x75, 0x5b,0x27,0x4c,
0x42,0x76,0x45, 0x60,0x63,0x76, 0x23,0x62,0x2a, 0x65,0x4d,0x43,
0x5f,0x51,0x33, 0x7e,0x53,0x42, 0x4f,0x52,0x20, 0x52,0x20,0x63,
0x7a,0x26,0x4a, 0x21,0x54,0x5a, 0x46,0x71,0x38, 0x20,0x2b,0x79,
0x26,0x66,0x32, 0x63,0x2a,0x57, 0x2a,0x58,0x6c, 0x76,0x7f,0x2b,
0x47,0x7b,0x46, 0x25,0x30,0x52, 0x2c,0x31,0x4f, 0x29,0x6c,0x3d,
0x69,0x49,0x70, 0x3f,0x3f,0x3f, 0x27,0x78,0x7b, 0x3f,0x3f,0x3f,
0x67,0x5f,0x51, 0x3f,0x3f,0x3f, 0x62,0x29,0x7a, 0x41,0x24,0x7e,
0x5a,0x2f,0x3b, 0x66,0x39,0x47, 0x32,0x33,0x41, 0x73,0x6f,0x77,
0x4d,0x21,0x56, 0x43,0x75,0x5f, 0x71,0x28,0x26, 0x39,0x42,0x78,
0x7c,0x46,0x6e, 0x53,0x4a,0x64, 0x48,0x5c,0x74, 0x31,0x48,0x67,
0x72,0x36,0x7d, 0x6e,0x4b,0x68, 0x70,0x7d,0x35, 0x49,0x5d,0x22,
0x3f,0x6a,0x55, 0x4b,0x50,0x3a, 0x6a,0x69,0x60, 0x2e,0x23,0x6a,
0x7f,0x09,0x71, 0x28,0x70,0x6f, 0x35,0x65,0x49, 0x7d,0x74,0x5c,
0x24,0x2c,0x5d, 0x2d,0x77,0x27, 0x54,0x44,0x59, 0x37,0x3f,0x25,
0x7b,0x6d,0x7c, 0x3d,0x7c,0x23, 0x6c,0x43,0x6d, 0x34,0x38,0x28,
0x6d,0x5e,0x31, 0x4e,0x5b,0x39, 0x2b,0x6e,0x7f, 0x30,0x57,0x36,
0x6f,0x4c,0x54, 0x74,0x34,0x34, 0x6b,0x72,0x62, 0x4c,0x25,0x4e,
0x33,0x56,0x30, 0x56,0x73,0x5e, 0x3a,0x68,0x73, 0x78,0x55,0x09,
0x57,0x47,0x4b, 0x77,0x32,0x61, 0x3b,0x35,0x24, 0x44,0x2e,0x4d,
0x2f,0x64,0x6b, 0x59,0x4f,0x44, 0x45,0x3b,0x21, 0x5c,0x2d,0x37,
0x68,0x41,0x53, 0x36,0x61,0x58, 0x58,0x7a,0x48, 0x79,0x22,0x2e,
0x09,0x60,0x50, 0x75,0x6b,0x2d, 0x38,0x4e,0x29, 0x55,0x3d,0x3f
)
var transformed = new array()
for (var i=0; i<3; i++) transformed[i] = new array()
for (var i=31; i<=126; i++) for (var j=0; j<3; j++) transformed[j][rawdata[(i-31) * 3 + j]] = (i==31) ? 9 : i
var digits = new array()
for (var i=0; i<26; i++)
{
digits["a".charcodeat(0)+i] = i
digits["a".charcodeat(0)+i] = i+26
}
for (var i=0; i<10; i++) digits["0".charcodeat(0)+i] = i+52
digits[0x2b] = 62
digits[0x2f] = 63
function unescape(char)
{
var escapes = "#&!*$"
var escaped = "\r\n<>@"
if (char.charcodeat(0) > 126) return char
if (escapes.indexof(char) != -1) return escaped.substr(escapes.indexof(char), 1)
return "?"
}
function decodebase64(string)
{
var val = 0
val += (digits[string.substr(0,1).charcodeat(0)] << 2)
val += (digits[string.substr(1,1).charcodeat(0)] >> 4)
val += (digits[string.substr(1,1).charcodeat(0)] & 0xf) << 12
val += ((digits[string.substr(2,1).charcodeat(0)] >> 2) << 8)
val += ((digits[string.substr(2,1).charcodeat(0)] & 0x3) << 22)
val += (digits[string.substr(3,1).charcodeat(0)] << 16)
return val
}
function tranencode(encodingstring)
{
var marker = "#@~^"
var stringindex = 0
var scriptindex = -1
var unencodingindex = 0
var char = null
var encodinglength = unencodinglength = 0
var state = state_copy_input
var unencodingstring = ""
var re, arr
while(state)
{
switch (state)
{
case (state_copy_input) :
scriptindex = encodingstring.indexof(marker, stringindex)
if (scriptindex != -1)
{
unencodingstring += encodingstring.substring(stringindex, scriptindex)
scriptindex += marker.length
state = state_readlen
}
else
{
stringindex = stringindex==0 ? 0 : stringindex
unencodingstring += encodingstring.substr(stringindex, encodingstring.length)
state = 0
}
break
case (state_readlen) :
encodinglength = encodingstring.substr(scriptindex, 6)
unencodinglength = decodebase64(encodinglength)
scriptindex += (6 + "==".length)
state = state_decode
break
case (state_decode) :
if (!unencodinglength)
{
stringindex = scriptindex + "dqgaaa==^#~@".length
unencodingindex = 0
state = state_copy_input
break
}
char = encodingstring.substr(scriptindex, 1)
if (char == "@") state = state_unescape
else
{
if (char.charcodeat(0) < 0xff)
{
unencodingstring += string.fromcharcode(transformed[pick_encoding[unencodingindex%64]][char.charcodeat(0)])
unencodingindex++
}
else
{
unencodingstring += char
}
scriptindex++
unencodinglength--
break
}
case state_unescape:
unencodingstring += unescape(encodingstring.substr(++scriptindex, 1))
scriptindex++; unencodinglength -=2
unencodingindex++
state = state_decode
break
}
}
re = new regexp("(jscript|vbscript).encode", "gmi")
while(arr = re.exec(unencodingstring)) unencodingstring = regexp.leftcontext + regexp.$1 + regexp.rightcontext
return unencodingstring
}
//-->
</script>
asp 不等于 vbs, 只是个框架而已
这段代码你在 script 里加个 runat="server" 然后直接调用这个函数就可以了
<script language="javascript" runat="server">...
<%
toencode(xxx)
%>
或者有没有高手可以把下面的写成asp的 ,万分感谢~!!
复制代码 代码如下:
<script language="javascript">
<!--
function toencode(s,l)
{enc=new activexobject("scripting.encoder");
return enc.encodescriptfile("."+l,s,0,l+"cript");
}
var state_copy_input = 100
var state_readlen = 101
var state_decode = 102
var state_unescape = 103
var pick_encoding = new array(
1, 2, 0, 1, 2, 0, 2, 0, 0, 2, 0, 2, 1, 0, 2, 0,
1, 0, 2, 0, 1, 1, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2,
1, 1, 0, 2, 0, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 2,
1, 0, 2, 0, 1, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 2
)
var rawdata = new array(
0x64,0x37,0x69, 0x50,0x7e,0x2c, 0x22,0x5a,0x65, 0x4a,0x45,0x72,
0x61,0x3a,0x5b, 0x5e,0x79,0x66, 0x5d,0x59,0x75, 0x5b,0x27,0x4c,
0x42,0x76,0x45, 0x60,0x63,0x76, 0x23,0x62,0x2a, 0x65,0x4d,0x43,
0x5f,0x51,0x33, 0x7e,0x53,0x42, 0x4f,0x52,0x20, 0x52,0x20,0x63,
0x7a,0x26,0x4a, 0x21,0x54,0x5a, 0x46,0x71,0x38, 0x20,0x2b,0x79,
0x26,0x66,0x32, 0x63,0x2a,0x57, 0x2a,0x58,0x6c, 0x76,0x7f,0x2b,
0x47,0x7b,0x46, 0x25,0x30,0x52, 0x2c,0x31,0x4f, 0x29,0x6c,0x3d,
0x69,0x49,0x70, 0x3f,0x3f,0x3f, 0x27,0x78,0x7b, 0x3f,0x3f,0x3f,
0x67,0x5f,0x51, 0x3f,0x3f,0x3f, 0x62,0x29,0x7a, 0x41,0x24,0x7e,
0x5a,0x2f,0x3b, 0x66,0x39,0x47, 0x32,0x33,0x41, 0x73,0x6f,0x77,
0x4d,0x21,0x56, 0x43,0x75,0x5f, 0x71,0x28,0x26, 0x39,0x42,0x78,
0x7c,0x46,0x6e, 0x53,0x4a,0x64, 0x48,0x5c,0x74, 0x31,0x48,0x67,
0x72,0x36,0x7d, 0x6e,0x4b,0x68, 0x70,0x7d,0x35, 0x49,0x5d,0x22,
0x3f,0x6a,0x55, 0x4b,0x50,0x3a, 0x6a,0x69,0x60, 0x2e,0x23,0x6a,
0x7f,0x09,0x71, 0x28,0x70,0x6f, 0x35,0x65,0x49, 0x7d,0x74,0x5c,
0x24,0x2c,0x5d, 0x2d,0x77,0x27, 0x54,0x44,0x59, 0x37,0x3f,0x25,
0x7b,0x6d,0x7c, 0x3d,0x7c,0x23, 0x6c,0x43,0x6d, 0x34,0x38,0x28,
0x6d,0x5e,0x31, 0x4e,0x5b,0x39, 0x2b,0x6e,0x7f, 0x30,0x57,0x36,
0x6f,0x4c,0x54, 0x74,0x34,0x34, 0x6b,0x72,0x62, 0x4c,0x25,0x4e,
0x33,0x56,0x30, 0x56,0x73,0x5e, 0x3a,0x68,0x73, 0x78,0x55,0x09,
0x57,0x47,0x4b, 0x77,0x32,0x61, 0x3b,0x35,0x24, 0x44,0x2e,0x4d,
0x2f,0x64,0x6b, 0x59,0x4f,0x44, 0x45,0x3b,0x21, 0x5c,0x2d,0x37,
0x68,0x41,0x53, 0x36,0x61,0x58, 0x58,0x7a,0x48, 0x79,0x22,0x2e,
0x09,0x60,0x50, 0x75,0x6b,0x2d, 0x38,0x4e,0x29, 0x55,0x3d,0x3f
)
var transformed = new array()
for (var i=0; i<3; i++) transformed[i] = new array()
for (var i=31; i<=126; i++) for (var j=0; j<3; j++) transformed[j][rawdata[(i-31) * 3 + j]] = (i==31) ? 9 : i
var digits = new array()
for (var i=0; i<26; i++)
{
digits["a".charcodeat(0)+i] = i
digits["a".charcodeat(0)+i] = i+26
}
for (var i=0; i<10; i++) digits["0".charcodeat(0)+i] = i+52
digits[0x2b] = 62
digits[0x2f] = 63
function unescape(char)
{
var escapes = "#&!*$"
var escaped = "\r\n<>@"
if (char.charcodeat(0) > 126) return char
if (escapes.indexof(char) != -1) return escaped.substr(escapes.indexof(char), 1)
return "?"
}
function decodebase64(string)
{
var val = 0
val += (digits[string.substr(0,1).charcodeat(0)] << 2)
val += (digits[string.substr(1,1).charcodeat(0)] >> 4)
val += (digits[string.substr(1,1).charcodeat(0)] & 0xf) << 12
val += ((digits[string.substr(2,1).charcodeat(0)] >> 2) << 8)
val += ((digits[string.substr(2,1).charcodeat(0)] & 0x3) << 22)
val += (digits[string.substr(3,1).charcodeat(0)] << 16)
return val
}
function tranencode(encodingstring)
{
var marker = "#@~^"
var stringindex = 0
var scriptindex = -1
var unencodingindex = 0
var char = null
var encodinglength = unencodinglength = 0
var state = state_copy_input
var unencodingstring = ""
var re, arr
while(state)
{
switch (state)
{
case (state_copy_input) :
scriptindex = encodingstring.indexof(marker, stringindex)
if (scriptindex != -1)
{
unencodingstring += encodingstring.substring(stringindex, scriptindex)
scriptindex += marker.length
state = state_readlen
}
else
{
stringindex = stringindex==0 ? 0 : stringindex
unencodingstring += encodingstring.substr(stringindex, encodingstring.length)
state = 0
}
break
case (state_readlen) :
encodinglength = encodingstring.substr(scriptindex, 6)
unencodinglength = decodebase64(encodinglength)
scriptindex += (6 + "==".length)
state = state_decode
break
case (state_decode) :
if (!unencodinglength)
{
stringindex = scriptindex + "dqgaaa==^#~@".length
unencodingindex = 0
state = state_copy_input
break
}
char = encodingstring.substr(scriptindex, 1)
if (char == "@") state = state_unescape
else
{
if (char.charcodeat(0) < 0xff)
{
unencodingstring += string.fromcharcode(transformed[pick_encoding[unencodingindex%64]][char.charcodeat(0)])
unencodingindex++
}
else
{
unencodingstring += char
}
scriptindex++
unencodinglength--
break
}
case state_unescape:
unencodingstring += unescape(encodingstring.substr(++scriptindex, 1))
scriptindex++; unencodinglength -=2
unencodingindex++
state = state_decode
break
}
}
re = new regexp("(jscript|vbscript).encode", "gmi")
while(arr = re.exec(unencodingstring)) unencodingstring = regexp.leftcontext + regexp.$1 + regexp.rightcontext
return unencodingstring
}
//-->
</script>
asp 不等于 vbs, 只是个框架而已
这段代码你在 script 里加个 runat="server" 然后直接调用这个函数就可以了
<script language="javascript" runat="server">...
<%
toencode(xxx)
%>
上一篇: 适合做公告板的代码收集