首先,我们都知道,VBS代码可以直接被看到的,
不知道VBS的是什么,度娘会告诉你的。
下面这个程序可以对VBS代码进行简单的加密,原理灰常简单,
- 1.读取源文件的所有代码
- 1.读取源文件的所有代码
- 2.计算Asc值
- 3.写入,Execute用Chr还原后的代码。
废话不多说
上代码
代码:
加密:
代码语言:javascript复制<pre class="prism-highlight prism-language-bash">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[*.vbs],将欲加密文件拖入,生成加密后的txt
- 解密:
<pre class="prism-highlight prism-language-bash">on error resume next
set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "vbs File|*.vbs|All Files|*.*"
objDialog.InitialDir = ""
objDialog.ShowOpen
strLoadFile = objDialog.FileName
if not strLoadFile = "" then
set file=fso.opentextfile(strLoadFile,1)
all=file.readall
file.close
s=instr(1,all,"next")
alls=mid(all,1, s 3 )
set file=fso.createtextfile(strLoadFile,8,true)
file.write alls
file.writeline empty
file.writeline"set fso=createobject("&""""&"scripting.filesystemobject"&""""&")"
file.writeline"set file=fso.createtextfile(wscript.scriptfullname,8,true)"
file.writeline"file.write runner"
file.writeline"file.close"
file.close
ws.run""""&strLoadFile&"""",0,true
msgbox"解密成功!",4096 64
end if
- 保存上面代码为VBS[*.vbs],将欲解密文件拖入,生成解密后的txt