To the Top

Online VBScript Obfuscator/Defuscator (Encrypt/Protect VBS)

Using this handy VBS tool, you can convert your VBScript into an obfuscated VBS source code, without compromising/altering the scripting functionalities and the VBScript keywords. This Free VBScript Obfuscator works by converting each character in your VBS source code into a much obfuscated format. Then these obfuscated letters are combined at runtime and be executed via the Execute function.

msgbox "Is VBScript Dead?"

will be encrypted and protected by the following:


However, sophicated software engineer knows how to reverse engineer the obfuscated VBScript source code within a few minutes. This should not be trusted in hiding any sensitive information inside your VBScript source code. However, you can use this tool if you do not want people read the VBS source at an easy glance and modify it.

You could again copy the obfuscated VBS source to the input box and re-apply the obfuscation process to achieve a much higher level of obfuscation.

Online VBScript Obfuscator/Encryptor

How do you Deobfuscate the Obfuscated VBScript?

In case you want to deobfuscate the obfuscated VBScript source code (produced by above VBS Obfuscator Freeware), you can simply Replace the Execute keyword in the obfuscated VBScript source with either MsgBox or WScript.Echo and then all you need to do is to run the source code which should print out the original un-obfuscated VBS source.

How do you Deobfuscate the Obfuscated VBScript?

The VBScript Obfuscator in VBScript

The following is the VBScript Obfuscator written in VBScript. You can obfuscate your VBS source file easily with this command line utility.

Github Repro:

The obfuscator will parse each character of your VBS file, and obfuscate it via a random character. The source code is thus obfuscated with concatenation of these characters. The obfuscated source can be run with the VBScript function Execute but the source code looks pretty obfuscated.

The VBScript Obfuscator in VBScript

You can pass multiple VBScript file names at command line, and the obfuscator will obfuscate each source and print the obfuscated string one by one to the console. You can also redirect the console to save to new vbs via the following example:

cscript.exe vbs_obfuscator.vbs sample.vbs > sample_obfuscated.vbs

VBScript Obfuscator Source Code

Option Explicit

Function vbs_obfuscator(n)
	Dim r, k
	r = Round(Rnd() * 10000) + 1
	k = Round(Rnd() * 2) + 1
	Select Case k
		Case 0
			vbs_obfuscator = "CLng(&H" & Hex(r + n) & ")-" & r
		Case 1
			vbs_obfuscator = (n - r) & "+CLng(&H" & Hex(r) & ")"
		Case Else
			vbs_obfuscator = (n * r) & "/CLng(&H" & Hex(r) & ")"
	End Select
End Function

Function Obfuscator(vbs)
	Dim length, s, i
	length = Len(vbs)
	s = ""
	For i = 1 To length
		s = s & "chr(" & vbs_obfuscator(Asc(Mid(vbs, i))) + ")&"
	s = s & "vbCrlf"
	Obfuscator = "Execute " & s
End Function

If WScript.Arguments.Count = 0 Then
	WScript.Echo "Missing parameter(s): VBScript source file(s)"
End If 

Dim fso, i
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 0 To WScript.Arguments.Count - 1
	Dim FileName
	FileName = WScript.Arguments(i)
	Dim MyFile
	Set MyFile = fso.OpenTextFile(FileName, ForReading)
	Dim vbs
	vbs = MyFile.ReadAll
	WScript.Echo Obfuscator(vbs)

Set fso = Nothing

The VBScript Defuscator in VBScript

The obfuscator allows you to obfuscate the VBScript source code and still the VBScript can run as expected. If you don't have the original source code, the process can still be reverted.

The VBScript Defuscator reverts the process. The defuscator tries to look for the function keyword Execute and evaluate the expression, writes the original clean source code back to the console.

The source code of the VBScript defuscator is as follows, which only works for the specific version of VBScript obfuscator:

Option Explicit

Function Defuscator(vbs)
    Dim t
    t = InStr(1, vbs, "Execute", 1)
    t = Mid(vbs, t + Len("Execute")) 
    t = Eval(t)
    Defuscator = t
End Function

Dim fso, i
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 0 To WScript.Arguments.Count - 1
    Dim FileName
    FileName = WScript.Arguments(i)
    Dim MyFile
    Set MyFile = fso.OpenTextFile(FileName, ForReading)
    Dim vbs
    vbs = MyFile.ReadAll    
    WScript.Echo Defuscator(vbs)
Set fso = Nothing

You can revert the process via the following vbs_defuscator.vbs

cscript.exe vbs_defuscator.vbs sample_defuscated.vbs > sample.vbs
VBScript Defuscator

Adanced ROT47 VBScript Obfuscator in VBScript

Combined with ROT47, the VBScript obfuscator can be quite powerful. The source code of ROT47 VBScript Obfuscator. For example, the original VBS is:

MsgBox "Hello, @justyy"
and it can be obfuscated to:
Function l(str):Dim i,j,k,r:j=Len(str):r="":For i=1 to j:k=Asc(Mid(str,i,1)):If k>=33 And k<=126 Then:r=r&Chr(33+((k+14)Mod 94)):Else:r=r&Chr(k):End If:Next:l=r:End Function
Execute l("|[email protected] [email protected][ o;FDEJJQ")
Similar to previous obfuscator, you can obfuscate the VBS via the command line, for example:
cscript.exe vbs_rot47_obfuscator.vbs sample.vbs > sample-obfuscated.vbs
The ROT47 is a Caesar cipher by 47 chars. If you apply rot47 on the same string twice, you will get its original version. The VBScript source code for ROT47 VBScript obfuscator is maintained in github and the following is the core implementation:
Function Rot47(str)
    Dim i, j, k, r
    j = Len(str)
    r = ""
    For i = 1 to j
        k = Asc(Mid(str, i, 1))
        If k >= 33 And k <= 126 Then
            r = r & Chr(33 + ((k + 14) Mod 94))
            r = r & Chr(k)
        End If
    Rot47 = r
End Function

Function Obfuscator(vbs)
    Dim length, s, i, F
    F = "Function l(str):Dim i,j,k,r:j=Len(str):r=" & Chr(34) & Chr(34) & ":For i=1 to j:k=Asc(Mid(str,i,1)):If k>=33 And k<=126 Then:r=r&Chr(33+((k+14)Mod 94)):Else:r=r&Chr(k):End If:Next:l=r:End Function"
    length = Len(vbs)
    s = ""
    For i = 1 To length
        s = s & Rot47(Mid(vbs, i, 1))
    Obfuscator = F & vbCrlf & "Execute l(" & Chr(34) & (s)& Chr(34) &")" & vbCrLf 
End Function

The VBScript Obfuscator using Base64 Encoding/Decoding

With Base64 Encoding/Decoding, we can obfuscate the VBScript source easiy. For example, the following source unprotected VBScript:

msgbox "Hello, @justyy"
can be obfuscated into the base64-encoded version:
Function l(a): With CreateObject("Msxml2.DOMDocument").CreateElement("aux"): .DataType = "bin.base64": .Text = a: l = r(.NodeTypedValue): End With: End Function
Function r(b): With CreateObject("ADODB.Stream"): .Type = 1: .Open: .Write b: .Position = 0: .Type = 2: .CharSet = "utf-8": r = .ReadText: .Close:  End With: End function
Execute l("TXNnQm94ICJIZWxsbywgQGp1c3R5eSI=")
The full VBScript Base64 Obfuscator source code is maintained in github.


Adding more complex obfuscation/deobfuscation steps. e.g. add a character map and reference the characters in complicated ways.

API Source Code (PHP) for VBScript Obfuscator

We provide a free-to-use-on-fair-policy API to obfuscate any length of VBScript source code. The VBS Obfuscator API is implemented in PHP.

  $s = trim($_GET['s'] ?? '');
  function vbs_obfuscator($n) {
    $r = mt_rand(1, 99999);
    $k = mt_rand(0, 2);
    if ($k == 0) return 'CLng("&H'. dechex($r + $n) . '")-' . $r;
    if ($k == 1) return ($n - $r) . '+CLng("&H' . dechex($r) . '")';
    return ($n * $r) . '/CLng("&H' . dechex($r) . '")';
  function obfuscate($s) {
    $len = strlen($s);
    $t = '';
    for ($i = 0; $i < $len; ++ $i) {
      $t .= "chr(" . vbs_obfuscator(ord($s[$i])) . ")&";
    $t .= "vbcrlf";
    return "Execute(" . $t . ")";
  $data = obfuscate($s);
  header("Access-Control-Allow-Origin: *");
  header('Content-Type: application/json');

You can use the following APIs from 4 API servers:

For example: "Is VBScript Dead?"
returns (results may vary subject to VBS obfuscator/defuscator algorithm):
The following API will store the output obfuscated VBScript source code at the CloudFlare CDN, so you can expect the obfuscated cached and served quickly than the above API, which always returns randomly-obfuscated VBScript source code and that is served directly from the API server. "Is VBScript Dead?"
That should return the same output for a limited time period, e.g. 1 hour depending on the cache settings.

Please Note: It is recommended to pass the parameters via POST method instead of handy GET method. Passing the parameters via POST allows a lengthy input VBScript string and you don't need to explicity encode the return carriage and other characters that are required to be URL-encoded when it comes to GET.
For example:

curl -X POST -d "s=msgbox 1234" -d "cached"
Passing parameters via GET is also not secure, as the source code of the VBScript is glued to the API Calling URL (and limited by a maximum length). The content of VBS encoded via $_GET parameter may cause the API blocked by CloudFlare Web Firewall.

Disclamier of VBScript Obfuscator

Contact Me

via Web Email.

Donation helps

Donation helps the cost of the domain/server, and is very much appreciated.

Why Donate?

Check This page for a few reasons. :)

Page Edited on Irregular Basis: 09/Oct/2018 02:14:02
View in AMP (Accelerated Mobile Pages) Version