This commit is contained in:
2024-10-13 23:32:58 +02:00
parent 30627b25b3
commit dbfba56f66
38 changed files with 3897 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,145 @@
#!/bin/perl
use Net::Telnet();
use strict;
#my $IP="10.60.1.100";
my $IP="192.168.100.2";
# read config
#my @config=read_cisco_config($IP, "batman", "LTBTTTra25", "local", "prog");
my $version=read_devicetype($IP, "awisniewski", "peter", "local", "peter");
print "$version\n";
sub read_cisco_config {
my ($host, $user, $pass, $login, $enable) = @_;
my $t = new Net::Telnet (Timeout => 5, Prompt => '/#$/');
my $found_proper_method=0;
$t->errmode("return");
$t->open($host);
if ($t->waitfor('/>/i') == 1) {
# 1 wenn ok
# '' wenn n ok
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$pass");
$t->waitfor('/#/i');
$found_proper_method=1;
}
if ($found_proper_method==0) {
if ($t->waitfor('/#/i') == 1) {
$found_proper_method=1;
}
}
if ($found_proper_method==0) {
if ($t->waitfor('/username/i') == 1) {
$t->print("$user");
$t->waitfor('/password/i');
$t->print("$pass");
if ($t->waitfor('/>/i') == 1) {
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$enable");
}
if ($t->waitfor('/#/i') == '1') {
$found_proper_method=1;
}
}
}
if ($found_proper_method==0) {
if ($t->waitfor('/password/i') == 1 and $found_proper_method==0) {
$t->print("$login");
if ($t->waitfor('/>/i') == 1) {
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$enable");
}
if ($t->waitfor('/#/i') == '1') {
$found_proper_method=1;
}
}
}
if ($found_proper_method==1) {
#$t->put(Timeout=>20);
$t->cmd("terminal length 0");
$t->waitfor('/#/');
(@config) = $t->cmd("show running");
}
else {
@config=("Kein Login möglich.");
}
return @config;
}
sub read_devicetype {
my ($host, $user, $pass, $login, $enable) = @_;
my $t = new Net::Telnet (Timeout => 2, Prompt => '/#[\s]*$/');
my @version;
my $devicetype;
my $found_proper_method=0;
$t->errmode("return");
$t->open($host);
if ($t->waitfor('/>/i') == 1) {
# 1 wenn ok
# '' wenn n ok
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$pass");
$t->waitfor('/#/i');
$found_proper_method=1;
}
if ($found_proper_method==0) {
if ($t->waitfor('/#/i') == 1) {
$found_proper_method=1;
}
}
if ($found_proper_method==0) {
if ($t->waitfor('/username/i') == 1) {
$t->print("$user");
$t->waitfor('/password/i');
$t->print("$pass");
if ($t->waitfor('/>/i') == 1) {
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$enable");
}
if ($t->waitfor('/#/i') == '1') {
$found_proper_method=1;
}
}
}
if ($found_proper_method==0) {
if ($t->waitfor('/password/i') == 1 and $found_proper_method==0) {
$t->print("$login");
if ($t->waitfor('/>/i') == 1) {
$t->print("enable");
$t->waitfor('/password/i');
$t->print("$enable");
}
if ($t->waitfor('/#/i') == '1') {
$found_proper_method=1;
}
}
}
if ($found_proper_method==1) {
#$t->put(Timeout=>20);
$t->cmd("terminal length 0");
$t->waitfor('/#/');
$t->cmd("terminal pager 500");
$t->waitfor('/#/');
(@version) = $t->cmd("show version");
## Hier erfolgt die Auswertung des Gerätetyps
}
else {
$devicetype="Kein Login möglich";
}
return $devicetype;
}

View File

@@ -0,0 +1,16 @@
Cisco Adaptive Security Appliance Software Version 8.3(1)
Hardware: ASA
Cisco IOS Software
Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.0(7)T, RELEASE SOFTWARE (fc2)
Image stamp: /sw/code/build/alpmo(alp11)
Jan 7 2009 17:55:29
E.11.10
53
Boot Image: Primary