下面是加密程序,原理很低级,读取源文件的所有代码并计算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脚本拖动到这个加密程序文件上,会自动生成加密后脚本的txt文件。