分享
 
 
 

(原创)解密JScript.Encode加密过的脚本

王朝html/css/js·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Public Class JSDecoder

'=============JS脚本的解密类===========

'说明: 此类用来解密JScript.Encode加密过的脚本代码!

'作者: 哇哇鱼

'版本: VB.NET版

'日期: 2005年3月21日

'注释: 此类是参考"李辉煌"的JavaScript(ASP)解密脚本代码而编写.

'======================================

Private Const STATE_COPY_INPUT = 100

Private Const STATE_READLEN = 101

Private Const STATE_DECODE = 102

Private Const STATE_UNESCAPE = 103

Private Pick_Encoding, rawData As Integer()

Private Transformed(2, 287), Digits(122) As Integer

Public Sub New()

InitArrayData()

End Sub

Private Sub InitArrayData()

Dim i, j As Integer

Pick_Encoding = New Integer() { _

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 _

}

rawData = New Integer() { _

&H64, &H37, &H69, &H50, &H7E, &H2C, &H22, &H5A, &H65, &H4A, &H45, &H72, _

&H61, &H3A, &H5B, &H5E, &H79, &H66, &H5D, &H59, &H75, &H5B, &H27, &H4C, _

&H42, &H76, &H45, &H60, &H63, &H76, &H23, &H62, &H2A, &H65, &H4D, &H43, _

&H5F, &H51, &H33, &H7E, &H53, &H42, &H4F, &H52, &H20, &H52, &H20, &H63, _

&H7A, &H26, &H4A, &H21, &H54, &H5A, &H46, &H71, &H38, &H20, &H2B, &H79, _

&H26, &H66, &H32, &H63, &H2A, &H57, &H2A, &H58, &H6C, &H76, &H7F, &H2B, _

&H47, &H7B, &H46, &H25, &H30, &H52, &H2C, &H31, &H4F, &H29, &H6C, &H3D, _

&H69, &H49, &H70, &H3F, &H3F, &H3F, &H27, &H78, &H7B, &H3F, &H3F, &H3F, _

&H67, &H5F, &H51, &H3F, &H3F, &H3F, &H62, &H29, &H7A, &H41, &H24, &H7E, _

&H5A, &H2F, &H3B, &H66, &H39, &H47, &H32, &H33, &H41, &H73, &H6F, &H77, _

&H4D, &H21, &H56, &H43, &H75, &H5F, &H71, &H28, &H26, &H39, &H42, &H78, _

&H7C, &H46, &H6E, &H53, &H4A, &H64, &H48, &H5C, &H74, &H31, &H48, &H67, _

&H72, &H36, &H7D, &H6E, &H4B, &H68, &H70, &H7D, &H35, &H49, &H5D, &H22, _

&H3F, &H6A, &H55, &H4B, &H50, &H3A, &H6A, &H69, &H60, &H2E, &H23, &H6A, _

&H7F, &H9, &H71, &H28, &H70, &H6F, &H35, &H65, &H49, &H7D, &H74, &H5C, _

&H24, &H2C, &H5D, &H2D, &H77, &H27, &H54, &H44, &H59, &H37, &H3F, &H25, _

&H7B, &H6D, &H7C, &H3D, &H7C, &H23, &H6C, &H43, &H6D, &H34, &H38, &H28, _

&H6D, &H5E, &H31, &H4E, &H5B, &H39, &H2B, &H6E, &H7F, &H30, &H57, &H36, _

&H6F, &H4C, &H54, &H74, &H34, &H34, &H6B, &H72, &H62, &H4C, &H25, &H4E, _

&H33, &H56, &H30, &H56, &H73, &H5E, &H3A, &H68, &H73, &H78, &H55, &H9, _

&H57, &H47, &H4B, &H77, &H32, &H61, &H3B, &H35, &H24, &H44, &H2E, &H4D, _

&H2F, &H64, &H6B, &H59, &H4F, &H44, &H45, &H3B, &H21, &H5C, &H2D, &H37, _

&H68, &H41, &H53, &H36, &H61, &H58, &H58, &H7A, &H48, &H79, &H22, &H2E, _

&H9, &H60, &H50, &H75, &H6B, &H2D, &H38, &H4E, &H29, &H55, &H3D, &H3F _

}

For i = 31 To 126

For j = 0 To 2

Transformed(j, rawData((i - 31) * 3 + j)) = IIf(i = 31, 9, i)

Next

Next

For i = 0 To 25

Digits(65 + i) = i

Digits(97 + i) = i + 26

Next

For i = 0 To 9

Digits(48 + i) = i + 52

Next

Digits(43) = 62

Digits(47) = 63

End Sub

Private Function UnEscape(ByVal strChar As String) As String

Dim escapes As String

Dim escaped As String

Dim iIndex As Integer

escapes = "#&!*$"

escaped = Chr(13) & Chr(10) & "<>@"

If AscW(strChar.Substring(0, 1)) > 126 Then Return strChar

iIndex = escapes.IndexOf(strChar)

If iIndex <> -1 Then Return escaped.Substring(iIndex, 1)

Return "?"

End Function

Private Function DecodeBase64(ByVal strString As String) As Integer

Dim iVal As Integer = 0

iVal += (Digits(AscW(strString.Substring(0, 1))) << 2)

iVal += (Digits(AscW(strString.Substring(1, 1))) >> 4)

iVal += (Digits(AscW(strString.Substring(1, 1))) And &HF) << 12

iVal += ((Digits(AscW(strString.Substring(2, 1))) >> 2) << 8)

iVal += ((Digits(AscW(strString.Substring(2, 1))) And &H3) << 22)

iVal += (Digits(AscW(strString.Substring(3, 1))) << 16)

Return iVal

End Function

Public Function Decode(ByRef encodingString As String) As String

Dim marker As String = "#@~^"

Dim stringIndex As Integer = 0

Dim scriptIndex As Integer = -1

Dim unEncodingIndex As Integer = 0

Dim strChar As String = ""

Dim getCodeString As String = ""

Dim unEncodinglength As Integer = 0

Dim state As Integer = STATE_COPY_INPUT

Dim unEncodingString As String = ""

While state <> 0

Select Case state

Case STATE_COPY_INPUT

scriptIndex = encodingString.IndexOf(marker, stringIndex)

If scriptIndex <> -1 Then

unEncodingString &= Mid(encodingString, stringIndex + 1, scriptIndex - stringIndex)

scriptIndex += marker.Length

state = STATE_READLEN

Else

stringIndex = IIf(stringIndex = 0, 0, stringIndex)

unEncodingString &= Mid(encodingString, stringIndex + 1)

state = 0

End If

Case STATE_READLEN

getCodeString = Mid(encodingString, scriptIndex + 1, 6)

unEncodinglength = DecodeBase64(getCodeString)

scriptIndex += 8

state = STATE_DECODE

Case STATE_DECODE

If unEncodinglength = 0 Then

stringIndex = scriptIndex + "DQgAAA==^#~@".Length

unEncodingIndex = 0

state = STATE_COPY_INPUT

Else

strChar = Mid(encodingString, scriptIndex + 1, 1)

If strChar = "@" Then

state = STATE_UNESCAPE

unEncodingString &= UnEscape(Mid(encodingString, scriptIndex + 2, 1))

scriptIndex += 2

unEncodinglength -= 2

unEncodingIndex += 1

state = STATE_DECODE

Else

If AscW(strChar) < &HFF Then

unEncodingString &= Chr(Transformed(Pick_Encoding(unEncodingIndex Mod 64), AscW(strChar)))

unEncodingIndex += 1

Else

unEncodingString &= strChar

End If

scriptIndex += 1

unEncodinglength -= 1

End If

End If

Case STATE_UNESCAPE

unEncodingString &= UnEscape(Mid(encodingString, ++scriptIndex, 1))

scriptIndex += 1

unEncodinglength -= 2

unEncodingIndex += 1

state = STATE_DECODE

End Select

End While

Dim Pattern As String

Pattern = "(JScript|VBscript).encode"

unEncodingString = System.Text.RegularExpressions.Regex.Replace(unEncodingString, Pattern, "$1", System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Return unEncodingString

End Function

End Class

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有