From 702e50519619b10f2ba3faf5d3519c8f60fdf410 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 2 Nov 2021 10:53:50 +0100 Subject: [PATCH] enh(disco) nmap discovery (#3224) * + enhance nmap discovery * + manage cases when both os and vendor are unknown --- apps/nmap/cli/mode/discovery.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/nmap/cli/mode/discovery.pm b/apps/nmap/cli/mode/discovery.pm index 5e9b2badf..7d11a228f 100644 --- a/apps/nmap/cli/mode/discovery.pm +++ b/apps/nmap/cli/mode/discovery.pm @@ -53,7 +53,7 @@ sub check_options { } my $lookup_type = [ - { type => 'cisco standard', re => qr/Cisco IOS Software/i }, + { type => 'cisco standard', re => qr/Cisco/i }, { type => 'emc data domain', re => qr/Data Domain/i }, { type => 'sonicwall', re => qr/SonicWALL/i }, { type => 'silverpeak', re => qr/Silver Peak/i }, @@ -70,6 +70,7 @@ my $lookup_type = [ { type => 'macos', re => qr/Darwin/i }, { type => 'hp-ux', re => qr/HP-UX/i }, { type => 'freebsd', re => qr/FreeBSD/i }, + { type => 'synology', re => qr/Synology/i } ]; sub define_type { @@ -77,7 +78,10 @@ sub define_type { return "unknown" unless (defined($options{desc}) && $options{desc} ne ''); foreach (@$lookup_type) { - if ($options{desc} =~ /$_->{re}/) { + if (defined($options{vendor}) && $options{vendor} =~ /$_->{re}/) { + return $_->{type}; + } + if (defined($options{desc}) && $options{desc} =~ /$_->{re}/) { return $_->{type}; } } @@ -125,7 +129,6 @@ sub run { $host{status} = $entry->{status}->{state}; $host{os} = $entry->{os}->{osmatch}[0]->{name}; $host{os_accuracy} = $entry->{os}->{osmatch}[0]->{accuracy}; - $host{type} = $self->define_type(desc => $host{os}); $host{ip} = undef; $host{addresses} = undef; $host{hostname} = undef; @@ -149,6 +152,9 @@ sub run { name => $port->{service}->{name} }; } + + $host{type} = $self->define_type(vendor => $host{vendor}, desc => $host{os}); + push @disco_data, \%host; }