17

I would like to use Nmap::Parser to convert the XML output of an nmap scan into a CSV file and I am already having problems at the very beginning.

Parsing small TCP/UDP scans work fine, but when I try to convert a larger file (e.g., 20 MB) , especially one with all 65535 UDP ports open|filtered, I get a segmentation fault.

The problem seems to be the "parsefile" method.

I tried different versions of Perl 5.10/5.14 on Linux and Mac OS X with the same results. Please see code snippet below.

#!/usr/bin/env perl
use strict; use warnings;
use Nmap::Parser;

my $np1 = new Nmap::Parser;
my $xmlin = $ARGV[0];

sub read_file {
    $np1->parsefile($xmlin);
    for my $host ($np1->all_hosts()) {
        for my $port ($host->udp_ports()) {
            print $host->ipv4_addr()." ".$port."\n";

        }   
    }
}

&read_file;
Marc
  • 16,170
  • 20
  • 76
  • 119
rhe24
  • 171
  • 2
  • 13
    could you try with perl 5.16? It looks like a bug in Perl, described here: http://www.perlmonks.org/?node_id=955478 – mirod Jul 23 '12 at 09:37
  • 4
    Hi mirod, thank you very much for your help. Upgrading Perl did the trick. I've just installed perl 5.16 and everything is working now. Successfully converted a 70MB XML file. :-) – rhe24 Jul 23 '12 at 11:47
  • Please provide this as an answer and accept it. – Thomas Berger Oct 15 '12 at 20:37

1 Answers1

3

The problem arises due to a known bug in perl versions <5.16 as mentioned at: http://www.perlmonks.org/?node_id=955478

Upgrading the perl to 5.16 or higher will solve this problem.

askmish
  • 6,464
  • 23
  • 42
  • 1
    This question has an answer, and is off of the unanswered list. I was about to do what you did. Thanks for doing it. – Tim Post Oct 18 '12 at 16:11