SO i've kinda got though the first part now I need to ping from the first entered address through to the last entered address. here is the code i have so far
#A script to identify any device that is using factory settings within
+ the network ie default username and password.
#The script is designed so that the user (Network Admin) enters in bot
+h the start and end of the IP range of the network and a address list
+
#is then generated and logged.After logging the range of the network e
+ach address will be pinged to detect if a device is located on that a
+ddress
#A second log file is created and the active address are then listed.
+On a second round the script will grab any information the device is
#showing and log this as well. The known device locatations are then t
+o be cross referenced with a default list of device usernames and pas
+swords.
#If a device is able to be access with one of the defaults it will be
+listed as TRUE in the log and the device will be identified as well.
#Once complete an email will be sent to the admin containing the three
+ log files.
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
#Enter and Validate IP Address Range.
use Data::Validate::IP qw(is_ipv4 is_ipv6);
print "Enter IP Range Starting Address:";
my $answera = <STDIN>;
if(is_ipv4($answera)){
print "Looks like an ipv4 address\n";
} else {
print "Not an ipv4 address\n";
print "\nReEnter Address:";
my $answera = <STDIN>;
}
print "\nEnter IP Range Finishing Address:";
my $answerb = <STDIN>;
if(is_ipv4($answerb)){
print "Looks like an ipv4 address";
} else {
print "Not an ipv4 address\n";
print "\nReEnter Address:\n";
my $answerb = <STDIN>;
}
use Net::IP;
use NetAddr::IP;
my $ipa = new NetAddr::IP->new($answera);
my $ipb = new NetAddr::IP->new($answerb);
print "\nNetwork starts at $ipa and finshes at $ipb\n";
#Create a log file with the active IP address and corresponding device
+ names.
open (MYLOG, '>>addressrange.txt');
print MYLOG "Network starts at $ipa and finshes at $ipb";
print MYLOG "$ipa +(1)";
close (MYLOG);
#Create range between the two entered IP address'
#Ping address' within the range. Log these in the log file.
use Net::Ping;
my $p = Net::Ping->new();
$p->ping($ipa [,5]);
print "$ipa ia alive.\n" if $p->ping($ipa);
$p->close();
I've read the syntax and diagnostics but it's not making any sense sorry.
|