XorEncode的vbs实现代码
程序员文章站
2022-08-27 14:38:22
复制代码 代码如下:if not wscript.arguments.count=1 then wscript.echo "请将要转换的vbs文件托拽到我身上!":wscr...
复制代码 代码如下:
if not wscript.arguments.count=1 then wscript.echo "请将要转换的vbs文件托拽到我身上!":wscript.quit
set fso=createobject("scripting.filesystemobject")
set self=fso.opentextfile(wscript.scriptfullname)
set vbs=fso.createtextfile(left(wscript.arguments(0),len(wscript.arguments(0))-4)+"_xorencode.vbs")
do until self.atendofstream
aline=self.readline
if aline="function decode(s,n)" then w=true
if w then vbs.writeline aline
loop
set src=fso.opentextfile(wscript.arguments(0))
randomize:n=int(255*rnd+1)
vbs.writeline "execute("&"decode("""&encode(src.read(fso.getfile(wscript.arguments(0)).size),n)&""","&n&"))"
src.close:vbs.close:self.close
set src=nothing:set vbs=nothing:set self=nothing:set fso=nothing
wscript.echo "successful!"
function encode(s,n)
for i=1 to len(s)
encode=encode&" "&(asc(mid(s,i,1)) xor n)
next
end function
function decode(s,n)
ns=split(mid(s,2,len(s)-1))
for i=0 to ubound(ns)
decode=decode&chr(cint(ns(i)) xor n)
next
end function