Should I use Nmap :: Parser or Nmap :: Scanner to audit the network?

I would like to audit the equipment of my large network as quickly as possible. Should i use Nmap::ParserorNmap::Scanner

I want to create a list of IP addresses that return ping, as well as the corresponding trace and OS identification.

An example :

ping 192.168. *. *

Then, when I get a successful ping, store the IP address in a hash with the assumption that the OS

+3
source share
2 answers

Whether you use Nmap::Parseror Nmap::Scanner, you must perform the same scan with Nmap, so there is no difference in speed between them.

Nmap::Scanner, , , , , . .

#!/usr/bin/perl

use strict;
use warnings;

use Nmap::Scanner;

my %network_status;

my $scanner = new Nmap::Scanner;
$scanner->register_scan_complete_event(\&scan_completed);
$scanner->guess_os();

$scanner->scan('-O 192.168.*.*');

foreach my $host ( keys %network_status ) {
    print "$host => $network_status{$host}\n";
}


sub scan_completed {
    my $self     = shift;
    my $host     = shift;

    my $hostname = $host->hostname();
    my $addresses = join(',', map {$_->addr()} $host->addresses());
    my $status = $host->status();

    print "$hostname ($addresses) is $status ";

    my $os_name = 'unknown OS';
    if ( $status eq 'up' ) {
        if ( $host->os() && $host->os()->osmatches() ) {
            my ($os_type) = $host->os()->osmatches();
            $os_name = $os_type->name();
        }
        print "($os_name)";
    }
    print "\n";

    $network_status{$addresses} = $os_name;
}
+8

, - , , - , . , , . ?

+1

Source: https://habr.com/ru/post/1719200/


All Articles