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)

  1. '============================================== 'NAME: ScriptDEcoder.vbs ' 'AUTHOR:  Scott Greenberg 'COMPANY: SG Technology 'WEBSITE: http://gogogadgetscott.info 'Date :    4/23/2004 'VERSION: 1.0 ' 'COMMENT: 'Recognized file extensions: 'vbs vbe js jse htm html asa asp cdx 'Decode procces derived from VBE decoder 'by: Jean-Luc Antoine 'http://www.interclasse.com/scripts/decovbe.php ' 'Copyright© 2004. SG Technology. All rights reserved. '============================================== Const TagInit = "#@~^" Const TagFin = "==^#~@" 'Get And check command arguments Set oArgs = WScript.Arguments If oArgs.Count = 0 Then   DisplayHelp ""   WScript.Quit End If 'Check If user requests help For Each Arg In oArgs   If InStr (Arg, "?") > 0 Then     DisplayHelp ""     WScript.Quit   End If Next Set oFSO = CreateObject ("Scripting.FileSystemObject") 'Create encoder object Set oEncoder = CreateObject ("Scripting.Encoder") For Each Arg In oArgs   'Check If argument contains path To a valid file   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" 'Clean up Set oEncoder = Nothing Set oFSO = Nothing Set oArgs = Nothing 'Process file Function Process(sFileIn) 'Get In file extension sSourceExt = "." & oFSO.GetExtensionName(sFileIn) sSourceFile = oFSO.GetBaseName(sFileIn)   'Read file into buffer   Set fIn = oFSO.OpenTextFile(sFileIn)   sSource = fIn.ReadAll   fIn.Close : Set fIn = Nothing   'Run process   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   'Write New file   sFileOut = oFSO.GetParentFolderName(sFileIn) & "\" & _     sSourceFile & sOutExt   '* Fix To overwrite file   Set fOut = oFSO.OpenTextFile(sFileOut, 2, True )   fOut.Write sOut   fOut.close : Set fOut = Nothing End Function 'Encode buffer Function Encode(sSource, sSourceExt)   'Encode source   Encode = oEncoder.EncodeScriptFile(sSourceExt, sSource, 0, 0)   Set oEncoder = Nothing End Function 'Decode helper Function Decode(sSource, sSourceExt)   Do     FinCode = 0     'Find the start positon of encoded data     StartCode = InStr (sSource, TagInit)     If StartCode > 0 Then       'If "==" the marker follows       If (InStr (StartCode, sSource, "==") - StartCode) = 10 Then         'Find the End positon of encoded data         FinCode = InStr (StartCode, sSource, TagFin)         If FinCode > 0 Then           'Decode encoded data           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 'Decode buffer 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 To display help message And any exceptions 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)