Startup ScriptingStartup scripts are small programs written in VBScript or Ruby which are executed automatically when Unsniff Network Analyzer is launched. You can use startup scripts to automate network captures or for customizing Unsniff startup behavior.
If you have a requirement like below - you need to use Startup Scripts
Using startup scripts1. Write the startup script in VBScript or Ruby (see examples below)
2. Save the script file
3. Specify the name of the script on the command line using script:<filename> notation
usnfctr script:<script-file-name> [script-arguments]
usnfctr : Fixed Name of the main unsniff executable (the main EXE file)
script-file : The script file (.vbs or .rb extension required)
script-arguments : Any arguments to the script, accessible via the Application.Arguments object
c:\UnsniffInstallDir\Bin> usnfctr script:autoimport.vbs mypcapfile.pcap
The Application objectThe key to using startup scripts is to understand the Application object. The application object exposes several methods and properties that you must access via VBScript or Ruby. The methods are summarized in the table below.
Example 1: Start a new capture on startup
We want to automatically create a new capture file and start capturing to that file upon startup.
c:\temp> usnfctr script:autostart.vbsFile autostart.vbs
Note: We first create a new capture document App.New followed by an App.Start
Example 2: Start a new capture on startup with a capture filter
A new capture with a specified capture filter. The capture filter was created previously in Unsniff via the capture filter wizard. The name of the filter is only "subnet 192.168.4"
c:\temp> usnfctr script:autostart2.vbsFile autostart2.vbs
Example 3: Import a libpcap file specified on the command line
We will now look at a script that will import a libpcap file. The filename is specified on the command line so we can see how the Arguments property is used. The name of the libpcap file is "ethereal-capture-3.cap"
c:\temp> usnfctr script:import.vbs c:\captures\ethereal-capture-3.capFile import.vbs
Example 4: Open two capture files
This script demonstrates how you can work with multiple files
c:\temp> usnfctr script:opentwo.vbsFile opentwo.vbs