下面是加密程序,原理很低級(jí),讀取源文件的所有代碼并計(jì)算Asc值后寫入,Execute用Chr還原后的代碼。
代碼如下:
On Error Resume Next
Set argv = WScript.Arguments
If argv.Count = 0 Then WScript.Quit
Set fso = CreateObject("scripting.filesystemobject")
With fso.OpenTextFile(argv(0),1)
data = .ReadAll : .Close
End With
With fso.OpenTextFile(argv(0)&".txt",2,True)
.WriteLine "data="&Chr(34)&ASCdata(data)&Chr(34)
.WriteLine "Function ChrData(Data)"
.WriteLine "MyArray = Split(Data, "","", -1, 1)"
.WriteLine "For each OldData in MyArray"
.WriteLine "Newdata=NewData"&Chr(38)&"chr(OldData)"
.WriteLine "Next"
.WriteLine "ChrData=NewData"
.WriteLine "End Function"
.WriteLine "execute Chrdata(data)"
.Close
End With
MsgBox "OK!",,"Encrypt"
Function ASCdata(Data)
num=len(data)
newdata=""
For j=1 to num
If j=num then
newdata=newdata&asc(mid(data,j,1))
Else
newdata=newdata&asc(mid(data,j,1))&","
End If
Next
ASCdata=newdata
End function
使用方法:直接將需要加密的VBS腳本拖動(dòng)到這個(gè)加密程序文件上,會(huì)自動(dòng)生成加密后腳本的txt文件。