Search This Blog

Wednesday, December 27, 2006

Cisco ASA view active VPN sessions

Below you can find a web script that shows active VPN sessions on Cisco ASA. It logs with predefined user vpn-view. This user has priviledge 0, but is able to use show vpn- command.
The script runs on PerlEx (ActivePerl) and obviously IIS 6.0. Save it as "vpn-view.aspl"
------------------------------script starts here -------------------------

<%
use CGI;
use Net::Telnet::Cisco;
my $cgi = new CGI;

my $session = Net::Telnet::Cisco->new(Host => '192.168.1.5', Prompt => '/[\$%#>] $/');


$session->login("vpn-view", "Password");
$session->print("login");
$session->print("vpn-view");
$session->print("Password");
$session->cmd('terminal pager 0');
my @output;
@output = $session->cmd('sh vpn- full remote');

#print "Content-type: text/html\n\n";

print "<html><head>\n";
print "<title>VPN - current sessions</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
$now_string = localtime;
print "Timestamp: ";
print $now_string;

foreach (@output) {
print $_;
print "<br>\n";
}

print "</body></html>";
$session->close;

%>
------------------------------script stops here -------------------------

No comments: