From 7d40ea754fdb76ffe9ceebc568c5bd3989baa3ca Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 9 Sep 2015 11:39:44 +0200 Subject: [PATCH] Completely removed nmap network scans. --- .../util/recon_scripts/snmp-recon.pl | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pandora_server/util/recon_scripts/snmp-recon.pl b/pandora_server/util/recon_scripts/snmp-recon.pl index 64a2e29db9..74c3c69d61 100755 --- a/pandora_server/util/recon_scripts/snmp-recon.pl +++ b/pandora_server/util/recon_scripts/snmp-recon.pl @@ -1102,14 +1102,6 @@ $DBH = db_connect ('mysql', $CONF{'dbname'}, $CONF{'dbhost'}, $CONF{'dbport'}, $ # 0% update_recon_task($DBH, $TASK_ID, 1); -# Populate ARP caches. -message("Populating ARP caches..."); -my $nmap_args = '-nsP --send-ip --max-retries '.$CONF{'icmp_checks'}.' --host-timeout '.$CONF{'networktimeout'}.'s -T'.$CONF{'recon_timing_template'}; -my $np = new PandoraFMS::NmapParser; -if ($#SUBNETS >= 0) { - $np->parsescan($CONF{'nmap'}, $nmap_args, @SUBNETS); -} - # Find routers. message("[1/6] Searching for routers..."); if (defined($ROUTER) && $ROUTER ne '') { @@ -1125,14 +1117,21 @@ if (defined($ROUTER) && $ROUTER ne '') { } } else { - my @scanned_hosts = $np->all_hosts(); - foreach my $host (@scanned_hosts) { - next unless defined($host->addr()) and defined($host->status()) and ($host->status() eq 'up'); + my $np = new PandoraFMS::NmapParser; + if ($#SUBNETS >= 0) { + $np->parsescan($CONF{'nmap'}, '-nsL', @SUBNETS); - # Make sure the host is up (nmap gives false positives!). - next if (pandora_ping(\%CONF, $host->addr(), 1, 1) == 0); + my @scanned_hosts = $np->get_ips(); + foreach my $host (@scanned_hosts) { - arp_cache_discovery($host->addr()); + # Skip network and broadcast addresses. + next if ($host =~ m/(\.0$)|(\.255$)/); + + # Check if the host is up. + next if (pandora_ping(\%CONF, $host, 1, 1) == 0); + + arp_cache_discovery($host); + } } } update_recon_task($DBH, $TASK_ID, 30);