vbs腳本 加密 幾個小細(xì)節(jié)小結(jié)下
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文件拖到這個文件上就可以
'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
欄 目:vb
下一篇:管理網(wǎng)卡vbs腳本
本文標(biāo)題:vbs腳本 加密 幾個小細(xì)節(jié)小結(jié)下
本文地址:http://mengdiqiu.com.cn/a1/vb/7776.html
您可能感興趣的文章
- 01-10下載文件到本地運行的vbs
- 01-10VBS中的正則表達(dá)式的用法大全 <font color=red>原創(chuàng)&
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10VBScript教程 第十一課深入VBScript
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript語法速查及實例說明
- 01-10VBS中Select CASE的其它用法
- 01-10VBScript教程 第七課使用條件語句
- 01-10vbscript 可以按引用傳遞參數(shù)嗎?
- 01-10VBScript教程 第二課在HTML頁面中添加VBscript代碼


閱讀排行
本欄相關(guān)
- 01-10下載文件到本地運行的vbs
- 01-10飄葉千夫指源代碼,又稱qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語法速查及實例說明
隨機(jī)閱讀
- 04-02jquery與jsp,用jquery
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10C#中split用法實例總結(jié)
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10delphi制作wav文件的方法