復(fù)制代碼 代碼如下:
dxy:  
    你好!  
    我學(xué)vbs也有一小段時(shí)間了,最近看到一本書上講vbs腳本的加密,就自己試了試,可是有一點(diǎn)問題,低級(jí)的語法錯(cuò)誤我都自己修正了,可腳本運(yùn)行后不起作用.所以想請(qǐng)教你一下.腳本的原理是這樣的:它把代碼轉(zhuǎn)換成16進(jìn)制,然后再寫個(gè)解密代碼,通過這個(gè)解密來執(zhí)行加密的代碼,將字符串成16進(jìn)制的代碼如下:  
Function str2hex (Byval strHex)  
For i=1 to Len(strHex)  
sHex = sHex & Hex(Asc(mid(strHex,i,1)))  
 next  
 str2Hex = sHex  
end Function  
解密的代碼如下:  
Function hextostr(data)  
Hextostr = "Execute"""""  
C= "&Chr(&H"  
N= ")"  
Do while Len(data)>1  
if IsNumeric (Left(data,1)) then  
Hextostr=Hextostr&c&Left(data,2)&N  
data=mid(data,3)  
else  
Hextostr=HextoStr&C&Left(data,4)&N  
data=mid(data,5)  
end if  
loop  
end Function  
解密代碼好象有點(diǎn)問題,請(qǐng)幫忙指正,我實(shí)在找不出  
整個(gè)成品就是:  
on error resume next  
set arg=wscript.arguement '聲明外部參數(shù)  
if arg.count=0 Then wscript.quit '若無參數(shù)則退出腳本  
set fso=creatobject("Scripting.Filesystem Object") '聲明fso組件  
when fso.opentextfile(arg(0),1,flase)  
data = readall:.close'讀取文本內(nèi)容  
if err.number<>0 then wscript.quit '如果發(fā)生錯(cuò)誤,則退出  
with fso.opentextfile(arg(0)&"*.vbs",2,true) '將轉(zhuǎn)換好的寫到一個(gè)新的vbs中  
if err.number<>0 then wscript.quit '如果發(fā)生錯(cuò)誤,則退出  
.writeline "Execute(Hextostr("""&str2hex(data)&"""))"  '執(zhí)行解密并執(zhí)行解密后的代碼  
.writeline "Function hextostr(data)"  
.writeline "Hextostr=""Execute"""""""""""  
.writeline "C=""&CHR(&H"""  
.writeline "N= )"  
.writeline "Do while Len(data)>1"  
.writeline "if IsNumeric (Left(data,1)) then"  
.writeline "Hextostr=Hextostr&c&Left(data,2)&N"  
.writeline "data = (data,3)"  
.writeline "else"  
.writeline "Hextostr=Hex to str&c&Left(data,4)&N"  
.writeline "data=mid(data,5)"  
.writeline "end if"  
.writeline "loop"  
.writeline "end function"  
'把解密函數(shù)寫進(jìn)去  
.close '關(guān)閉文本  
set fso=Nothing'注銷fso組件  
end with  
msgbox "OK"  
'以下是加密函數(shù)  
Function str2hex (Byval strHex)  
For i=1 to Len(strHex)  
sHex = sHex & Hex(Asc(mid(strHex,i,1)))  
 next  
 str2Hex = sHex  
end function  
'全部代碼就到這了,好長~  
書上說,把要加密的vbs腳本拖到這個(gè)腳本上就行了,不過我沒有成功,不知道那里有問題,請(qǐng)幫幫我,謝謝~ 
上面的代碼注意的幾個(gè)情況:
1、set arg=wscript.arguements
后門有個(gè)s
2、set fso=creatobject("Scripting.Filesystem Object") '聲明fso組件
應(yīng)該是filesystemboject
3、.writeline "N= )"
對(duì)于需要輸出N=")"用vbs輸入"(雙引號(hào))的方法就是用兩個(gè)""
.writeline "N="")"""
4、.writeline "data = (data,3)"這里少個(gè)mid
基本上就這些了
do.vbs保存為do.vbs ,將要加密的js文件拖到這個(gè)文件上就可以
復(fù)制代碼 代碼如下:
'on error resume next 
set arg=wscript.arguments '聲明外部參數(shù) 
if arg.count=0 Then wscript.quit '若無參數(shù)則退出腳本 
set fso=createobject("Scripting.FilesystemObject") '聲明fso組件 
filename=wscript.arguments(0) 
set readline=fso.opentextfile(filename,1,flase) 
data=readline.readall: 
readline.close '讀取文本內(nèi)容 
if err.number<>0 then wscript.quit '如果發(fā)生錯(cuò)誤,則退出 
with fso.opentextfile(filename&"_out.vbs",2,true) '將轉(zhuǎn)換好的寫到一個(gè)新的vbs中 
if err.number<>0 then wscript.quit '如果發(fā)生錯(cuò)誤,則退出 
.writeline "Execute(Hextostr("""&str2hex(data)&"""))"  '執(zhí)行解密并執(zhí)行解密后的代碼 
.writeline "Function hextostr(data)" 
.writeline "Hextostr=""Execute""""""""""" 
.writeline "C=""&CHR(&H""" 
.writeline "N= "")""" 
.writeline "Do while Len(data)>1" 
.writeline "if IsNumeric (Left(data,1)) then" 
.writeline "Hextostr=Hextostr&c&Left(data,2)&N" 
.writeline "data = mid(data,3)" 
.writeline "else" 
.writeline "Hextostr=Hextostr&c&Left(data,4)&N" 
.writeline "data=mid(data,5)" 
.writeline "end if" 
.writeline "loop" 
.writeline "end function" 
'把解密函數(shù)寫進(jìn)去 
.close '關(guān)閉文本 
end with 
set fso=Nothing'注銷fso組件 
msgbox "OK" 
'以下是加密函數(shù) 
Function str2hex (Byval strHex) 
For i=1 to Len(strHex) 
sHex = sHex & Hex(Asc(mid(strHex,i,1))) 
 next 
 str2Hex = sHex 
end function