PDA

View Full Version : Is there any way to encode the script ?


liufirst
09-09-2005, 04:18 AM
When I finished the script, I am trying to encode it. But when I uses screnc.exe file from microsoft to encode the script, the script would not run. Is there any way to encode the script and protect it ?

jdev
09-09-2005, 10:12 AM
It looks like you have already encoded your script, but as a reference for those who would like more information about encoding their SecureCRT scripts, here is how it is done.

There are two other ActiveX script engines besides "VBScript" and "JScript" that are known as "VBscript.Encode" and "JScript.Encode". These script engines appear to be identical except for the fact that they decode input that has been encoded before executing it.

In order to encode scripts, you'll need to download the "Windows Script Encoder" from Microsoft. Here's a link to an overview of the script encoder technology:
http://msdn2.microsoft.com/en-us/library/d14c8zsc.aspx
The way the script encoder works with (Windows Script Host) WSH scripts is you simply take your *.vbs or *.js scripts and run them through the encoder and create new output files named *.vbe or *.jse, respectively.

SecureCRT requires that its own headers being present as the first lines of the script file. As with all SecureCRT scripts, you need to include these headers in plain text.

With an encoded script, these headers must still be in plain text so that SecureCRT can read them. There is a special comment which tells the script encoder where to begin encoding:
'**Start Encode**

Including this comment after the required SecureCRT script headers will ensure that SecureCRT will be able to load the correct script engine.

With respect to the "correct" script engine to use, this is where the SecureCRT script headers come in to play again. Normally, the script header for a SecureCRT script that uses the VBScript engine would look like:
# $language = "VBScript"
# $interface = "1.0"

An encoded script is actually interpreted by a different script engine, so the SecureCRT script headers must reflect this as well:
# $language = "VBScript.Encode"
# $interface = "1.0"

If you are using JScript as your language, the header would follow the same pattern:
# $language = "JScript.Encode"
# $interface = "1.0"


The following steps provide an example of using the
Microsoft script encoder with a SecureCRT script:

Take the following example VBScript for (called "plain.vbs"). Note that the "$language" header tag is now specified as "VBScript.Encode". Also, note the existence of the '**Start Encode** comment:
# $language = "VBScript.Encode"
# $interface = "1.0"
'**Start Encode**

Sub Main()
MsgBox "This is an encoded script!"
End Sub
At a shell prompt, run the Microsoft script encoder to encode "plain.vbs" to the output file named "encoded.vbe":
screnc plain.vbs encoded.vbe


If you open "encoded.vbe" in Notepad (or your favorite text/code editor) it should look now look something like this:
# $language = "VBScript.Encode"
# $interface = "1.0"
'**Start Encode**#@~^WgAAAA=as;dlka;23=-sdfl93jfje8*()#*%^sl,>/w.3dke.......
Now you should be able to run "encoded.vbe" from within SecureCRT.

liufirst
09-10-2005, 07:07 AM
Thanks for your answer. It works. But who'll answer
http://forums.vandyke.com/showthread.php?t=1006