復制代碼 代碼如下: dxy: 你好! 我學vbs也有一小段時間了,最近看到一本書上講vbs腳本的加密,就自己試了試,可是有一點問題,低級的語法錯誤我都自己修正了,可腳本運行后不起作用.所以想請教你一下.腳本的原理是這樣的:它把代碼轉換成16進制,然后再寫個解密代碼,通過這個解密來執行加密的代碼,將字符串成16進制的代碼如下: 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
解密代碼好象有點問題,請幫忙指正,我實在找不出
整個成品就是:
on error resume next set arg=wscript.arguement '聲明外部參數 if arg.count=0 Then wscript.quit '若無參數則退出腳本 set fso=creatobject("Scripting.Filesystem Object") '聲明fso組件 when fso.opentextfile(arg(0),1,flase) data = readall:.close'讀取文本內容 if err.number 0 then wscript.quit '如果發生錯誤,則退出 with fso.opentextfile(arg(0)&"*.vbs",2,true) '將轉換好的寫到一個新的vbs中 if err.number 0 then wscript.quit '如果發生錯誤,則退出 .writeline "Execute(Hextostr("""&str2hex(data)&"""))" '執行解密并執行解密后的代碼 .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" '把解密函數寫進去 .close '關閉文本 set fso=Nothing'注銷fso組件 end with msgbox "OK" '以下是加密函數 Function str2hex (Byval strHex) For i=1 to Len(strHex) sHex = sHex & Hex(Asc(mid(strHex,i,1))) next str2Hex = sHex end function '全部代碼就到這了,好長~