How to run commands on PIX, ASA, FWSM using HTTPS and Perl

Many times we need a way to fetch system configuration, or to get some of the interface statistics, or maybe we want to get pre-shared key retrieved...

We also want to make this request using secure network connection, such as HTTPS.

This Perl script will show you how to retrieve "running-configuration" from the device. We are doing this using "more system:running-config" command, which will output our preshared keys.

use strict;
use warnings;
use LWP;
my $url = 'https://firewall01/admin/exec/more%20system:running-config';
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $url);
$req->authorization_basic('MyUsername', 'MyPassword');
my $content = $ua->request($req)->as_string;
print "Configuration file:\n";
print $content;

This will work on FWSM, PIX, ASA, or ever any other IOS devices...

Sometimes you will need to execute several commands in a row, such as:

FWSM# changeto system
FWSM# show resource acl-partition

In order to accomplish that we will separate each command by the "/" (slash).

#!/usr/local/bin/perl
use strict;
use warnings;
use LWP;
my $url = 'https://firewall01/admin/exec/changeto%20context%20system/show%20resource%20acl-partition';
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $url);
$req->authorization_basic('user', 'password');
my $content = $ua->request($req)->as_string;
print "Command Output:\n";
print $content;

Moving your apps to Amazon or Miscrosoft Clouds?

We can help you analyze your existing infrastructure, identify the cost savings we can achieve by migrating to a cloud provider. We can then execute end-to-end migration plan of your infrastructure and bringing down your TCO.

Cloud Computing

Ready for IPv6 Migration?

The Internet is running out of the equivalent of phone numbers - familiar problem, non-trivial solution.

The world has to move to IPv6, with its 128-bit addresses. But that's easier said than done.

IPv6 Migration

Are you fluent in "Linux"?

Learn Linux from a leading expert and quickly master you Linux skills.

Learn how to simplify your workflow and increase your productivity using tips and techniques of the pros.

Ideal training for Corporate IT Beginners and Advanced IT Admins alike.

Corporate Linux Training

Who's Online

We have 3 guests and no members online