This script will encode or decode files containing VBScript or Jscript. Simply drag-and-drop file(s) on to script icon. It uses the Scripting.Encoder.
Download ScriptDEcoder (vbs file)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Const TagInit = "#@~^"
- Const TagFin = "==^#~@"
-
- Set oArgs = WScript.Arguments
- If oArgs.Count = 0 Then
- DisplayHelp ""
- WScript.Quit
- End If
-
- For Each Arg In oArgs
- If InStr (Arg, "?") > 0 Then
- DisplayHelp ""
- WScript.Quit
- End If
- Next
- Set oFSO = CreateObject ("Scripting.FileSystemObject")
-
- Set oEncoder = CreateObject ("Scripting.Encoder")
- For Each Arg In oArgs
-
- If oFSO.FileExists(Arg) Then
- sFileExt = oFSO.GetExtensionName(Arg)
- ValidExts = Array ("vbs", "js", "jse", "vbe", "htm", "html", "asa", "asp", "cdx")
- For Each Ext In ValidExts
- If Ext = sFileExt Then
- DisplayHelp Process(Arg)
- Exit For
- End If
- Next
- Else
- DisplayHelp "Argument Is Not a valid file."
- End If
- Next
- DisplayHelp "Process Is complete"
-
- Set oEncoder = Nothing
- Set oFSO = Nothing
- Set oArgs = Nothing
-
- Function Process(sFileIn)
-
- sSourceExt = "." & oFSO.GetExtensionName(sFileIn)
- sSourceFile = oFSO.GetBaseName(sFileIn)
-
- Set fIn = oFSO.OpenTextFile(sFileIn)
- sSource = fIn.ReadAll
- fIn.Close : Set fIn = Nothing
-
- If InStr (sSource, TagInit) = 0 Then
- Decoded = True
- End If
- If Decoded = True Then
- sOut = Encode(sSource, sSourceExt)
- Select Case sSourceExt
- Case ".vbs"
- sOutExt = ".vbe"
- Case ".js"
- sOutExt = ".jse"
- Case Else
- sOutExt = sSourceExt
- End Select
- Process = "File "&sSourceFile&sSourceExt&" encoded And saved As "&sSourceFile&sOutExt&"."
- Else
- sOut = Decode(sSource, sSourceExt)
- Select Case sSourceExt
- Case ".vbe"
- sOutExt = ".vbs"
- Case ".jse"
- sOutExt = ".js"
- Case Else
- sOutExt = sSourceExt
- End Select
- Process = "File "&sSourceFile&sSourceExt&" decoded And saved As "&sSourceFile&sOutExt&"."
- End If
-
- sFileOut = oFSO.GetParentFolderName(sFileIn) & "\" & _
- sSourceFile & sOutExt
-
- Set fOut = oFSO.OpenTextFile(sFileOut, 2, True )
- fOut.Write sOut
- fOut.close : Set fOut = Nothing
- End Function
-
- Function Encode(sSource, sSourceExt)
-
- Encode = oEncoder.EncodeScriptFile(sSourceExt, sSource, 0, 0)
- Set oEncoder = Nothing
- End Function
-
- Function Decode(sSource, sSourceExt)
- Do
- FinCode = 0
-
- StartCode = InStr (sSource, TagInit)
- If StartCode > 0 Then
-
- If (InStr (StartCode, sSource, "==") - StartCode) = 10 Then
-
- FinCode = InStr (StartCode, sSource, TagFin)
- If FinCode > 0 Then
-
- sSource = Left (sSource, StartCode - 1) & _
- DecodeH(Mid (sSource, StartCode + 12, FinCode - StartCode - 12 - 6)) & _
- Mid (sSource, FinCode + 6)
- End If
- End If
- End If
- Loop Until FinCode = 0
- If Asc (Right (sSource, 1)) = 0 Then sSource = Left (sSource, Len (sSource) - 1)
- sSource = Replace (sSource,".Encode","")
- Decode = sSource
- End Function
-
- Function DecodeH(Chain)
- Dim tDecode(127)
- Const Combination = "1231232332321323132311233213233211323231311231321323112331123132"
- For i = 9 To 127
- tDecode(i) = "JLA"
- Next
- For i = 9 To 127
- ChainsTemp = Mid (oEncoder.EncodeScriptFile(".vbs", String (3, i), 0, ""), 13, 3)
- For j = 1 To 3
- c = Asc (Mid (ChainsTemp, j, 1))
- If Not ((c = 42) And (i = 62)) Then
- tDecode(c) = Left (tDecode(c), j - 1) & Chr (i) & Mid (tDecode(c), j + 1)
- End If
- Next
- Next
- Chain = Replace (Replace (Chain, "@&", Chr (10)), "@#", Chr (13))
- Chain = Replace (Replace (Chain,"@*",">"), "@!", "<")
- Chain = Replace (Chain,"@$","@")
- index = -1
- For i = 1 To Len (Chain)
- c = Asc (Mid (Chain, i, 1))
- If c < 128 Then index = index + 1
- If (c = 9) Or ((c > 31) And (c < 128)) Then
- If (c <> 60) And (c <> 62) And (c <> 64) Then
- Chain = Left (Chain,i - 1) & _
- Mid (tDecode(c), Mid (Combination, (index Mod 64) + 1, 1), 1) & _
- Mid (Chain,i + 1)
- End If
- End If
- Next
- DecodeH = Chain
- End Function
-
- Sub DisplayHelp(msg)
- CRLF = Chr (13) + Chr (10)
- If msg = "" Then msg = msg & " --- About this script ---" & CRLF & _
- "Recognized file extensions: " & CRLF & _
- " vbs vbe js jse htm html asa asp cdx" & CRLF & CRLF & _
- "<file(s) To encode/decode>" & CRLF & _
- "? <help>"
- MsgBox msg, vbInformation , "ScriptDEcoder"
- End Sub
Download ScriptDEcoder (vbs file)