這篇文章給大家分享的是有關(guān)vbs腳本中加密需要注意什么的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
代碼如下:
學(xué)vbs也有一小段時(shí)間了,最近看到一本書(shū)上講vbs腳本的加密,就自己試了試,可是有一點(diǎn)問(wèn)題,低級(jí)的語(yǔ)法錯(cuò)誤我都自己修正了,可腳本運(yùn)行后不起作用.所以想請(qǐng)教你一下.腳本的原理是這樣的:它把代碼轉(zhuǎn)換成16進(jìn)制,然后再寫(xiě)個(gè)解密代碼,通過(guò)這個(gè)解密來(lái)執(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)問(wèn)題,請(qǐng)幫忙指正,我實(shí)在找不出
整個(gè)成品就是:
on error resume next
set arg=wscript.arguement '聲明外部參數(shù)
if arg.count=0 Then wscript.quit '若無(wú)參數(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)換好的寫(xiě)到一個(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ù)寫(xiě)進(jìn)去
.close '關(guān)閉文本
set fso=Nothing'注銷(xiāo)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
'全部代碼就到這了,好長(zhǎng)~
書(shū)上說(shuō),把要加密的vbs腳本拖到這個(gè)腳本上就行了,不過(guò)我沒(méi)有成功,不知道那里有問(wèn)題,請(qǐng)幫幫我,謝謝~
上面的代碼注意的幾個(gè)情況:
1、set arg=wscript.arguements
后門(mén)有個(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 '若無(wú)參數(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)換好的寫(xiě)到一個(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ù)寫(xiě)進(jìn)去
.close '關(guān)閉文本
end with
set fso=Nothing'注銷(xiāo)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
感謝各位的閱讀!關(guān)于“vbs腳本中加密需要注意什么”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
文章標(biāo)題:vbs腳本中加密需要注意什么-創(chuàng)新互聯(lián)
網(wǎng)站網(wǎng)址:http://sd-ha.com/article48/pgdep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、搜索引擎優(yōu)化、微信小程序、企業(yè)建站、App設(shè)計(jì)、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容