Skip to content

Instantly share code, notes, and snippets.

@sharpicx
Created October 25, 2019 06:39
Show Gist options
  • Save sharpicx/75121c0661efe19ccb46c9a975cdb7f5 to your computer and use it in GitHub Desktop.
Save sharpicx/75121c0661efe19ccb46c9a975cdb7f5 to your computer and use it in GitHub Desktop.
just an Obfuscator for VBScript :D
Option Explicit
Dim ws,Title,InPutFile,OutPutFile,Data
Title = "Obfuscator by Skofos"
If wscript.arguments.count > 0 Then
InPutFile = Wscript.Arguments(0)
If Not IsVBSFile(InPutFile) Then Call Display_Help_Usage()
OutPutFile = GetFilenameWithoutExtension(InPutFile) & "_lol.vbs"
Data = ReadFile(InPutFile)
Write2File Encrypt(Data),OutPutFile
Set ws = CreateObject("wscript.shell")
ws.Popup "The Vbscript file " & chr(34) & InPutFile & chr(34) & vbCrLF &_
"encrypted ==> " & chr(34) & OutPutFile & chr(34),8,Title,vbInformation
Explorer(OutPutFile)
ws.run "CMD /C Start /MAX Notepad " & chr(34) & OutPutFile & chr(34),0,True
Else
Call Display_Help_Usage()
End If
Function Encrypt(Data)
Dim MyArray,Data2,i
MyArray = "A = Array("
For i = Len(Data) To 1 step -1
MyArray = MyArray & Asc(Mid(Data,i,1))
If i <> 1 Then
MyArray = MyArray & ","
Else
MyArray = MyArray & ")"
End If
Next
Data2 = "C = Array (""W"",""r"",""h"",""C"")" & vbCrLF &_
"For i = UBound(a) To 0 Step -1" & vbCrLF &_
"O = O & eval(C(3) & C(2) & C(1) & C(0) & ""(A(i))"")" & vbCrLF &_
"Next" & vbCrLF &_
"ExecuteGlobal O"
Encrypt = MyArray & vbCrLF & Data2
End Function
Function ReadFile(InPutFile)
Dim objFSO,oTS,sText
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = objFSO.OpenTextFile(InPutFile)
sText = oTS.ReadAll
oTS.close
set oTS = nothing
Set objFSO = nothing
ReadFile = sText
End Function
Sub Write2File(strText,OutPutFile)
Dim fs,ts
Const ForWriting= 2
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(OutPutFile,ForWriting,True)
ts.WriteLine strText
ts.Close
End Sub
Function GetFilenameWithoutExtension(FileName)
Dim Result, i
Result = FileName
i = InStrRev(FileName, ".")
If ( i > 0 ) Then
Result = Mid(FileName, 1, i - 1)
End If
GetFilenameWithoutExtension = Result
End Function
Sub Display_Help_Usage()
Dim ws
Set ws = CreateObject("wscript.shell")
ws.Popup "You should drag and drop a Vbscript file over this script " & vbCrLF &_
chr(34) & WSH.ScriptName & chr(34) & vbCrLF &_
" to be encrypted !",8,Title,vbExclamation
Wscript.Quit(1)
End Sub
Function IsVBSFile(sFile)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "(.vbs|.vbe)"
regEx.IgnoreCase = True
If regEx.Test(sFile) Then
IsVBSFile = True
End If
End Function
Sub Explorer(File)
ws.run "Explorer /n,/select,"& File &"",1,True
End Sub
' Skofos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment