Securecrt Login Script Example



Sample scripts SecureCrt. Download securecrt.tlb type library. 'Dim crt As SecureCrt.crt ' A VBScript login script that waits for a login prompt then sends ' a 'setenv DISPLAY:0.0' command to direct X-clients to a ' locally run Xserver. Sub Main crt.Screen.WaitForString ('myhost$ '). Set-AutoLogon, Windows automatically login after reboot. RUNONCE AUTOLOGON Here is the PowerShell CmdLet that would enable AutoLogon next time when the server reboots.We could trigger a specific Script to execute after the server is back online after Auto Logon as optional.

The following custom modules include the majority of the functionality that is used in the single and multi-device scripts. The classes described below are designed to handle the common actions that scripts would need into a single method to avoid the need to copy and paste chunks of code into multiple scripts, and to make writing scripts faster and easier than when you have to use the low-level SecureCRT API to interact with devices.

It is important to understand the relationship between the classes listed below.

Securecrt

The classes in the “scripts” module and used to represent the execution of the script itself and that script’s interactions with the calling application (primarily SecureCRT). Since a SecureCRT script has the ability to open multiple tabs to different devices and interact with all of them, any attribute or method that is common to the script and not specific to each open session is defined in the script class. This class tracks a reference to the main session object, which represents the SecureCRT tab that the script was launched from.

The “sessions” classes represent a session to a remote device, which will usually be the SecureCRT tab that the script was initially launched from. The Script class has the ability to open a new connection in a new tab, and it will return a reference to a separate Session object so that the script can interact with each session independently. NOTE: SecureCRT does NOT support multi-threading so the use of multiple sessions are best used in cases where you do not want to close an existing session before performing actions on another device. One example can be validating login to a remote device after making AAA changes without disconnecting the original session and potentially locking ourselves out. A rollback of the changes could be performed if the second session is unable to log into the device.

Securecrt login script example template

The “settings” classes are simply used to manage importing, exporting and updating entries in the settings.ini file. The script object keeps a reference to the settings class so that settings can be retrieved or changed. This class will also attempt to update/re-write the local settings.ini file (while preserving existing settings) should the default_settings.ini contains settings that do not exist in the local settings file. This may happen when a new script is created and needs settings available in the settings.ini file.

The “utilities” class contains a bunch of helper functions that can be used to simplify certain common tasks. These funtions are pure Python which means they do not require interactions with scripts, sessions or settings in any way. For example, some of these functions will convert a string containing an interface name to the short version (Gi0/0) or the long version (GigabitEthernet0/0), while others perform action like sorting in “human” order (device1, device2, device10) instead of alphanumeric (device1, device10, device2). Functions of this sort should all be saved in this file when they need to be used by multiple scripts.

  • securecrt_tools.scripts
  • securecrt_tools.sessions
  • securecrt_tools.settings

I love SecureCRT by Van Dyke Software. I used it when I was running Windows as my main desktop, then used it when I was running Linux as my main desktop (for 8 years), and now for the past 4 years on my Mac. I love it to death.

Here are some of the features I am using and the tweaks I have done for my specific workflow.

When I am working with Cisco ASA, I want to be able to identify interface as it is something I refer to immediately. in a complex config, it is easy to lose it in the crowded output. You can, and I do, run the sh ip which gives you a brief information about the IP addresses assigned to the interfaces. But it does not give you description, security level etc.

The way I like to view it is in a different color. In this case, I am using red.

Also, when I view the the IPSec Phase II, I like to look at encrypted and decrtypted packets. I change this color to two different shades of blue.

Here are the steps:

Securecrt Script Examples Cisco

Go to your Secure CRT. Select Options then Edit Default Session

Go to ‘Apperance’ and under Highligted Keywords, Choose Edit, now select a name and add a keyword you want to highlight and click add. Now you can use set color and edit to set your colors for each words.

Securecrt

Button Bars

SecureCRT has a great button bar that allows you to choose application shortcuts, menu items, scripts etc by clicking a button.

Here is an example.

To enable this feature, go to view then choose button bar

Now you should see the button bar on the bottom which is the defualt location for the button bar. You can now right click on the button bar and choose ‘new button’

On the left, you will see ‘Function’. In this section you can choose from Menu Function, Scripts and other fucntionality although what I mostly use it Menu Function and Run Script.

Securecrt Login Script Example

Under Menu Function I have the following buttons created:

1. MENU_LOG_SESSION – With this button, I am able to click it and it will prompt me for the name and location for the log file. Once I select it, it starts to log ALL output from the screen. If I click it again, it toggles to off, meaning it will stop logging the session.

2. MENU_COPY_PASTE – With this button, I am able to copy and paste whatever I have highlighted on the screen. Easier than right clicking and choosing Copy/Paste.

3. MENU_CLEAR_SCREEN_AND_SCROLL – This will clear the screen and clear the line buffer.

Additionally, I have scripts that run. These scripts will:

Login

Securecrt Login Script Examples

1. Add or remove a ‘no’ at the beginning of a highlighted command. Therefore anything you select that has a ‘no’ infront of it will be copied and pasted without the ‘no’ and if you choose a command on the device without a ‘no’ (e.g. ip route 0.0.0.0 0.0.0.0 1.1.1.1) the script will add a ‘no’ to it.

Securecrt Python Script

In addition to these features, I have added a space to allow me to select IP addresses and other text by using the space character as the delimiter. This allows me to double click and IP address and have it automatically add it to my clip board. You CAN enable the ‘Right Click Paste’ such as PuTTY, but I have that and it has bit me in the ass a few times already.