vbs腳本 加密 幾個小細(xì)節(jié)小結(jié)下
更新時間:2008年01月27日 11:10:47 作者:
加密的vbs腳本拖到這個腳本上就行了。網(wǎng)上有位朋友問我這個問題,我由于今天才上email看了下文件,發(fā)現(xiàn)下面的問題,說實話對于他要問的我和你清楚,我不太會寫呢,不是出于技術(shù)問題,是出于已經(jīng)沒了這份愛好。出于對朋友學(xué)習(xí)的理解,我給解決了幾個問題,下面總結(jié)下。并給出正確的代碼。
復(fù)制代碼 代碼如下:
dxy:
你好!
我學(xué)vbs也有一小段時間了,最近看到一本書上講vbs腳本的加密,就自己試了試,可是有一點問題,低級的語法錯誤我都自己修正了,可腳本運行后不起作用.所以想請教你一下.腳本的原理是這樣的:它把代碼轉(zhuǎn)換成16進(jìn)制,然后再寫個解密代碼,通過這個解密來執(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
解密代碼好象有點問題,請幫忙指正,我實在找不出
整個成品就是:
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ā)生錯誤,則退出
with fso.opentextfile(arg(0)&"*.vbs",2,true) '將轉(zhuǎn)換好的寫到一個新的vbs中
if err.number<>0 then wscript.quit '如果發(fā)生錯誤,則退出
.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腳本拖到這個腳本上就行了,不過我沒有成功,不知道那里有問題,請幫幫我,謝謝~
上面的代碼注意的幾個情況:
1、set arg=wscript.arguements
后門有個s
2、set fso=creatobject("Scripting.Filesystem Object") '聲明fso組件
應(yīng)該是filesystemboject
3、.writeline "N= )"
對于需要輸出N=")"用vbs輸入"(雙引號)的方法就是用兩個""
.writeline "N="")"""
4、.writeline "data = (data,3)"這里少個mid
基本上就這些了
do.vbs保存為do.vbs ,將要加密的js文件拖到這個文件上就可以
復(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ā)生錯誤,則退出
with fso.opentextfile(filename&"_out.vbs",2,true) '將轉(zhuǎn)換好的寫到一個新的vbs中
if err.number<>0 then wscript.quit '如果發(fā)生錯誤,則退出
.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
相關(guān)文章
使用 Iisext.vbs 刪除應(yīng)用程序依存關(guān)系的實現(xiàn)方法
這篇文章主要介紹了使用 Iisext.vbs 刪除應(yīng)用程序依存關(guān)系的實現(xiàn)方法,需要的朋友可以參考下2014-07-07利用VBS腳本修改聯(lián)想筆記本BIOS密碼的代碼分享
這篇文章主要介紹了利用VBS腳本修改聯(lián)想筆記本BIOS密碼的實現(xiàn)代碼,感覺這不科學(xué)!無意中找到的一些資料,喜歡的朋友可以試試2013-07-07按鍵精靈 腳本-學(xué)習(xí)VBS的一個不錯的教程
現(xiàn)在看到很多朋友都不明白VBS,但我也沒有時間全部寫完,所以一天寫一些,邊寫邊和大家交流,也希望有朋友能接著寫或指出我的錯誤。2007-02-02VBS教程:VBScript 基礎(chǔ)-VBScript 變量
VBScript只有一種數(shù)據(jù)類型 —— Variant,它是根據(jù)上下文來判斷是數(shù)字還是字符串。因為Variant是VBScript中唯一的數(shù)據(jù)類型,所以它也是VBScript中所有函數(shù)的返回值的數(shù)據(jù)類型2006-11-11