mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Use NetAddr::IP and pandora_ping for network scans.
This commit is contained in:
parent
a52eb82d8d
commit
8b5e103d57
@ -10,6 +10,7 @@ use lib '/usr/lib/perl5';
|
|||||||
|
|
||||||
use POSIX qw/strftime/;
|
use POSIX qw/strftime/;
|
||||||
use Socket qw/inet_aton/;
|
use Socket qw/inet_aton/;
|
||||||
|
use NetAddr::IP;
|
||||||
|
|
||||||
use PandoraFMS::Tools;
|
use PandoraFMS::Tools;
|
||||||
use PandoraFMS::DB;
|
use PandoraFMS::DB;
|
||||||
@ -1117,15 +1118,18 @@ if (defined($ROUTER) && $ROUTER ne '') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $np = new PandoraFMS::NmapParser;
|
foreach my $subnet (@SUBNETS) {
|
||||||
if ($#SUBNETS >= 0) {
|
my $net_addr = new NetAddr::IP ($subnet);
|
||||||
$np->parsescan($CONF{'nmap'}, '-nsL', @SUBNETS);
|
if (!defined($net_addr)) {
|
||||||
|
message("Invalid network: $subnet");
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
my @scanned_hosts = $np->get_ips();
|
my @hosts = map { (split('/', $_))[0] } $net_addr->hostenum;
|
||||||
foreach my $host (@scanned_hosts) {
|
foreach my $host (@hosts) {
|
||||||
|
|
||||||
# Skip network and broadcast addresses.
|
# Check if the device has already been visited.
|
||||||
next if ($host =~ m/(\.0$)|(\.255$)/);
|
next if (defined($VISITED_DEVICES{$host}));
|
||||||
|
|
||||||
# Check if the host is up.
|
# Check if the host is up.
|
||||||
next if (pandora_ping(\%CONF, $host, 1, 1) == 0);
|
next if (pandora_ping(\%CONF, $host, 1, 1) == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user