0

如何在 Perl 中使用 cpan 安装模块 Nmap::Scanner 的所有依赖项?我做到了,cpan Nmap::Scanner。但是,需要模块的其他依赖项。

  #!/bash/perl

  use Nmap::Scanner;
  my $scan = Nmap::Scanner->new();
  
  $scan->add_target('localhost');
  $scan->add_target('host.i.administer');
  $scan->add_scan_port('1-1024');
  $scan->add_scan_port('31337');
  $scan->tcp_syn_scan();
  $scan->noping();
  
  my $results = $scan->scan();
  
  my $hosts = $results->gethostlist();
  
  while (my $host = $hosts->get_next()) {
  
      print "On " . $host->hostname() . ": \n";
  
      my $ports = $host->get_port_list();
  
      while (my $port = $ports->get_next()) {
          print join(' ',
              'Port',
              $port->service() . '/' . $port->portid(),
              'is in state',
              $port->state(),
              "\n"
          );
      }
  
  }

我做到了,但是在 perl 中运行脚本时,在控制台中显示了这一点。

Can't locate XML/SAX/Exception.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl` /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/XML/SAX/ParserFactory.pm line 12.
BEGIN failed--compilation aborted at /usr/local/share/perl5/XML/SAX/ParserFactory.pm line 12.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner/Backend/XML.pm line 8.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner/Backend/XML.pm line 8.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner/Scanner.pm line 4.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner/Scanner.pm line 4.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner.pm line 10.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner.pm line 10.
Compilation failed in require at e1-insecure.pl line 3.
BEGIN failed--compilation aborted at e1-insecure.pl line 3.
4

1 回答 1

4

cpan自动解决依赖关系。要安装执行以下命令:

cpan Nmap::Scanner

CPAN 模块的替代安装程序是cpanminus. 使用cpanm

cpanm Nmap::Scanner
于 2012-08-15T04:05:26.317 回答