我应该使用 Nmap::Parser 还是 Nmap::Scanner 来审核网络?

发布于 2024-08-06 03:20:29 字数 413 浏览 6 评论 0原文

我想以最快的方式审核我的大型网络的设备。我应该使用 Nmap::ParserNmap::Scanner

我想创建一个返回 ping 以及相关操作系统占用空间和标识的 IP 地址列表。

示例

ping 192.168.*.*

然后,当我成功 ping 时,将 IP 地址存储在哈希值中,并猜测操作系统是什么

I'd like to audit the equipment of my large network in the fastest way possible. Should i use Nmap::Parser or Nmap::Scanner?

I want to create a list of IP addresses that return a ping as well as a related OS footprint and identification.

Example:

ping 192.168.*.*

Then when I get a successful ping, store the IP address in a hash along with a guess of what the OS is

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆躺在深渊里 2024-08-13 03:20:29

无论您使用Nmap::Parser还是Nmap::Scanner,您都必须与Nmap运行相同的扫描,因此两者之间没有速度差异。

下面是一个使用 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;
}

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;
}
剩余の解释 2024-08-13 03:20:29

嗯,其中之一是您已有数据的解析器,其中之一是创建数据的扫描器。使用能够完成您所需工作的产品。任务的哪一部分导致了问题?

Well, one of those is a parser for data you already have, and one of those is a scanner that creates data. Use the one that does the job that you need. Which part of the task is causing the problem?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文