0914_vbs加密解密

一开始的想着的是根据asc码进行加密解密操作。

不难,所以直接贴代码:

加密:

Filename =  CreateObject("WScript.Shell").Exec("mshta vbscript:""<input type=file id=f><script>f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value)[close()];</script>""").StdOut.ReadAll
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(Filename, 1) 
Set objWrit = objFSO.OpenTextFile("IP" & "-" & year(now) & month(now) & day(now) &".txt", 2, true)
strContents = objFile.ReadAll
'msgbox strContents
objFile.Close
for i = 1 to len(strContents) 
	ch = asc(mid(strContents,i,1))
	ch = ch - 3
	strNew = strNew & chr(ch)
next
objWrit.write(strNew)
objWrit.Close

解密:

Filename =  CreateObject("WScript.Shell").Exec("mshta vbscript:""<input type=file id=f><script>f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value)[close()];</script>""").StdOut.ReadAll
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(Filename, 1)
strNew = objFile.ReadAll
for i = 1 to len(strNew) 
	ch = asc(mid(strNew,i,1))
	ch = ch + 3
	strArr = strArr & chr(ch)
next
msgbox strArr

看完大神写的加密解密,顿时觉得自己被完爆了,贴一份代码:

参阅:http://www.52pojie.cn/thread-147071-1-1.html

'本工具用于加密vbs的脚本
'采用ASCII,hex+xor,Encoder 三重加密。
'第三重Encoder加密后,只能使用VBE后缀。
'VBS不支持Encoder编码。
' 1.0 比较合适新人加密解密练习用
' 1.1 修复了网友Yu2n测试中发现的BUG
'****************************************************
'Version: 1.1
'Date : 2012-05-02
'Author:乱码
'源码献上,欢迎翻版,写出更加强力的加密。
'****************************************************
'Set argv = WScript.Arguments
'If argv.Count = 0 Then
'    MsgBox "请把要加密的文件拖到我身上!", 64+4096, "乱码领域"
'    WScript.Quit
'End If

Filename =  CreateObject("WScript.Shell").Exec("mshta vbscript:""<input type=file id=f><script>f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value)[close()];</script>""").StdOut.ReadAll

Set fso = CreateObject("Scripting.FileSystemObject")
Randomize
pass = Int(Rnd*12)+20 '异或加密有效范围20-31,所以随机生成好了。
data = fso.OpenTextFile(Filename, 1).ReadAll
data = "d=" & Chr(34) & ASCdata(data) & Chr(34)
data = data & vbCrLf & ":M=Split(D):For each O in M:N=N&chr(O):Next:execute N"
data = Replace(data, " ", ",")
fso.OpenTextFile(Filename & "_加密.vbe", 2, True).Write Encoder(EncHexXorData(data))
MsgBox "加密完毕,文件生成到:" & vbCrLf & vbCrLf & Filename & "_加密.vbe", 64+4096, "乱码领域VBS加密"

Function EncHexXorData(data)
    EncHexXorData = "x=""" & EncHexXor(data) & """:For i=1 to Len(x) Step 2:s=s&Chr(CLng(""&H""&Mid(x,i,2)) Xor " & pass & "):Next:Execute Replace(s,"","","" "")"
End Function

Function Encoder(data) '加密3
    Encoder = CreateObject("Scripting.Encoder").EncodeScriptFile(".vbs", data, 0, "VBScript")
End Function

Function EncHexXor(x) '加密2
    For i = 1 To Len(x)
        EncHexXor = EncHexXor & Hex(Asc(Mid(x, i, 1)) Xor pass)
    Next
End Function

Function ASCdata(Data) '加密1
    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)