中华考试网·阅读新闻
编程开发 > ASP > 文章内容

ASP编码教程:asp解密、还原chrw、chr编码文件的方法

2015-4-15编辑:ljnbset

将asp函数的参数通过chrw编码加密后,如何解码chrw内容。下面的解码函数,原来很简单,用正则提取内容中的chrw串,然后eval动态执行获取的chrw串得到内容,再执行替换即可。注意事项参考源代码里面的注释,注意将源代码保存为vbs格式的文件后执行,如果是asp文件,需要将createobject修改为server.createobject。

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

function readfile(fn)'读取编码文件的内容

 set fso=createobject("scripting.filesystemobject")

 set ts=fso.OpenTextFile(fn,1,false,-2)'注意这里的最后一个参数,如果你的是unicode编码,将-2(系统默认编码)修改为-1(unicode编码)。0为ascii

 readfile=ts.ReadAll

 ts.close

 set ts=nothing

 set fso=nothing

end function

function decodechrw(s)'解码chrw编码的内容

 set rx=new RegExp

 rx.Global=true

 rx.IgnoreCase=true

 rx.Pattern="ChrW\s*\(\s*\d+\s*\)(\s*&\s*ChrW\s*\(\s*\d+\s*\))*"'解码chrw串

 set mc=rx.Execute(s)

 for each m in mc

  s=replace(s, m.value,""""&eval(m.value)&"""")

 next

 rx.Pattern="Chr\s*\(\s*\d+\s*\)(\s*&\s*Chr\s*\(\s*\d+\s*\))*"‘急吗chr串

 set mc=rx.Execute(s)

 for each m in mc

  s=replace(s, m.value,""""&eval(m.value)&"""")

 next

 decodechrw=s

   

end function

function decodechrwfile(fn)'解码内容包含chrw编码的文件

 s=readfile(fn)

 s=decodechrw(s)

 '将解码内容写回文件

 set fso=createobject("scripting.filesystemobject")

 set ts=fso.OpenTextFile(replace(fn,".","_decode."),2,true,-2)'写入解码后的内容到原来文件名替换为 _decode的文件里面,如fn为encode.txt,则解码后的文件为encode_decode.txt

 ts.write s

 ts.close

 set ts=nothing

 set fso=nothing

end function

CSS基础教程:CSS类选择器
咨询热线:4000-525-585(免长途费)