3

大規模なネットワークの機器を可能な限り迅速に監査したいと考えています。またはを使用する必要がありますNmap::ParserNmap::Scanner

関連する OS のフットプリントと ID だけでなく、ping を返す IP アドレスのリストを作成したいと考えています。

ping 192.168.*.*

次に、ping が成功したら、OS の推測とともに IP アドレスをハッシュに保存します。

4

2 に答える 2

8

Whether you use Nmap::Parser or Nmap::Scanner, you have to run the same scan with Nmap, so there is no speed difference between the two.

Here's an example using Nmap::Scanner which does approximately what you want, reporting the status of the hosts and attempting to OS fingerprint them if they are up, storing the results in a hash. You should be able to extend it as needed.

#!/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;
}
于 2009-10-05T02:51:51.113 に答える
1

そのうちの 1 つは既に持っているデータのパーサーであり、そのうちの 1 つはデータを作成するスキャナーです。必要な仕事をするものを使用してください。タスクのどの部分が問題を引き起こしていますか?

于 2009-10-04T21:57:09.813 に答える