VBScript reference
This page documents the built-in objects available exclusively in Remote Scripting (VBScript). These objects are not available in Python. In addition to regular automation objects created with CreateObject(), you can call Internal.CreateObject() to create the following objects.
Telnet
| Method |
Description |
| Connect |
Establishes a connection to the configured Host and Port. |
| Disconnect |
Terminates a connection established with the above call. |
| Send("string") |
Sends a string to the remote host. For sending a command you may need to add vbCrLf. |
| WaitFor("string") |
Waits for a string to be sent by the remote host. Useful for detecting prompts and sending data after that. |
| string Recv("terminator") |
Reads data up to the specified terminator. To read to the end of line use vbCrLf as the terminator. |
| Property |
Description |
| Host |
Host name or IP address to connect to. |
| Port |
Port number to connect to. The default port is 23. |
+ Show usage example
'Retrieve system info via Telnet
'This example code can be adapted to work
'with any device that supports the protocol
'Create internal Telnet object
set objTelnet = Internal.CreateObject("Telnet")
'Set host name and port
objTelnet.Host = Input.Current
objTelnet.Port = 23
'Make connection
objTelnet.Connect
'Wait for login prompt
objTelnet.WaitFor("login:")
'Then send username
objTelnet.Send("YourUserName" & vbCrLf)
'Wait for password prompt
objTelnet.WaitFor("password:")
'Then send password
objTelnet.Send("YourPassword" & vbCrLf)
'Wait for shell prompt
objTelnet.WaitFor("xsh>")
'Then send command
objTelnet.Send("show sys versions" & vbCrLf)
'Wait for shell prompt (when command finishes)
data = objTelnet.Recv("xsh>")
'Return data and disconnect
Output.Write data
objTelnet.Disconnect
Process
| Method |
Description |
| Execute("command-line-string") |
Launches the specified console program and waits for its completion. |
| Property |
Description |
| ExitCode |
A numeric exit code with which the program terminates. |
| Output |
A collection of strings containing captured console output. |
+ Show usage example
'This runs ping.exe, captures its output and extracts reported packet loss
'It can be adapted to execute any console programs and parse their output
'Create process object and execute ping
Set proc = Internal.CreateObject("process")
proc.execute("ping.exe " & Input.Current)
'Check ping exit code
If proc.ExitCode = 0 Then
'Setup a regex object
Set objRegex = New RegExp
objRegex.IgnoreCase = True
objRegex.Multiline = True
objRegex.Global = True
'Look for a string like (X% loss)
objRegex.Pattern = "\((\d+%\s\w+)\)"
'Traverse output lines
For Each line in proc.output
Set matches = objRegex.Execute(line)
'Print matching data
For Each match in matches
Output.Write match.SubMatches(0)
Next
Next
Else
Output.Write "Exit code " & proc.ExitCode
End If
DNS
| Method |
Description |
| GetName("target","type") |
Sends a DNS request to the DNS server specified in the Server property. The first parameter is a host name or IP address to be resolved. The second parameter is the record type, usually "a" or "aaaa" for a regular name lookup or "ptr" for a reverse lookup. |
| Property |
Description |
| Server |
One or more comma-separated DNS server addresses. If not specified, the default servers will be used. |
+ Show usage example
'Resolve a name or IP address via DNS
'This example performs a reverse lookup
'Create internal DNS object
set dnsObj = Internal.CreateObject("dns")
'Optionally set DNS server
'dnsObj.Server = "x.x.x.x"
'Get PTR record for the current IP address
name = dnsObj.GetName(Input.Current, "ptr")
'Print out resolved name
Output.Write name
SNMP
| Method |
Description |
| SendRequest |
Sends an SNMP request to the device specified in the Host property. Request parameters are set in the Query property. If this method succeeds, the response is available in the Reply property. |
| Property |
Description |
| Host |
Target host name or IP address. |
| Query |
The Query object defines request parameters. |
| Reply |
The Reply object contains response details. |
| Query Object |
Description |
| Query.AddOid("string") |
Adds an OID string to the request. Multiple OIDs can be added. |
| Query.SetOid("string") |
Sets an OID string for use in the request. Any previously added OIDs are deleted. Pass an empty string to clear all added OIDs. |
| Query.Version |
SNMP version number to use: 1, 2 or 3. |
| Query.PduType |
PDU type used in the request: &hA0 (GetRequest), &hA1 (GetNextRequest) or &hA5 (GetBulkRequest). |
| Query.Community |
Community string for use in SNMPv1 and SNMPv2. |
| Query.V3Security |
SNMPv3 security mode string: NoAuthNoPriv, AuthNoPriv or AuthPriv. |
| Query.V3AuthMode |
SNMPv3 authentication algorithm string: MD5 or SHA1. |
| Query.V3PrivMode |
SNMPv3 privacy algorithm string: DES, 3DES or AES. |
| Query.V3UserName |
SNMPv3 username string. |
| Query.V3AuthPass |
SNMPv3 authentication password string. |
| Query.V3PrivPass |
SNMPv3 privacy password string. |
| Query.MaxRepetitions |
Target max-repetitions value for a bulk request. |
| Query.NonRepeaters |
Target non-repeaters value for a bulk request. |
| Reply Object |
Description |
| Reply.ErrorStatus |
A numeric SNMP error code. |
| Reply.Items |
Collection of reply items. |
| Reply.Items.Count |
Number of items in the collection. |
| Reply.Items(index).Oid |
A string value containing response OID. |
| Reply.Items(index).Value |
A string value containing response data. |
| Reply.Items(index).Type |
A numeric value containing response data type. |
+ Show usage example
'Create SNMP object and set target host
set objSnmp = Internal.CreateObject("snmp")
objSnmp.Host = Input.Current
'Use version 2 and get sysDescr
objSnmp.Query.Version = 2
objSnmp.Query.SetOID("1.3.6.1.2.1.1.1.0")
If objSnmp.SendRequest then
'Success
Output.Write objSnmp.Reply.Items(0).Value
End If
'Now get interface table.
'In SNMP v2/3 we can use bulk requests
objSnmp.Query.SetOID("1.3.6.1.2.1.2.2.1.2")
objSnmp.Query.MaxRepetitions = 10
objSnmp.Query.PDUType = &hA5
Do While objSnmp.SendRequest
'Success
For Each Item in objSnmp.Reply.Items
'Break the loop if found a different OID
If InStr(Item.OID, "1.3.6.1.2.1.2.2.1.2") = 0 Then
Exit Do
End if
'Write interface name
Output.Write Item.Value
'Continue from the current OID
objSnmp.Query.SetOID(Item.OID)
Next
Loop
Remote namespace
You can invoke any named scan item from your script using the following functions:
| Method |
Description |
| Remote.Files("name") |
Retrieves file or folder properties from remote machines. |
| Remote.Groups("name") |
Retrieves user group membership from remote systems. |
| Remote.JSON("name") |
Extracts data from JSON responses obtained via HTTP. |
| Remote.Nmap("name") |
Runs an Nmap scan for OS detection, port scanning and more. |
| Remote.Performance("name") |
Gathers Windows performance counters from remote machines. |
| Remote.PowerShell("name") |
Executes PowerShell scripts on remote Windows systems. |
| Remote.Registry("name") |
Queries the Windows Registry on remote devices. |
| Remote.SNMP("name") |
Performs SNMP queries on network devices. |
| Remote.SSH("name") |
Executes commands on remote Unix/Linux systems via SSH. |
| Remote.Services("name") |
Checks the status of Windows services on remote machines. |
| Remote.WMI("name") |
Runs WMI queries on remote Windows devices. |
| Remote.XML("name") |
Parses XML data retrieved over HTTP. |
Calling an item by its name executes the corresponding scan. For example:
+ Show usage example
'This script prints the Windows version retrieved via WMI.
winName = Remote.WMI("Windows Name")
Output.Write "This comes from WMI: " & winName