#!perlenv -w use strict; my ( $port, $uniqip, $longip ); my ( @nessusdata, @ports, @ips, @uniqip, @splitip, @rearranged ); my %longips; my $nessusdata = $ARGV[0]; my $portreport = "portreport"; my $num = 256; my $count = 0; if ( $#ARGV < 0 ) { print "usage: npr.pl <NessusWX Export File>"; exit; } open( NESSUSDATA, "< $nessusdata" ) || die "Could not open file: $! \n +"; @nessusdata = <NESSUSDATA>; close(NESSUSDATA); open( PORTREPORT, "> $portreport" ) || die "Could not open file: $! \n +"; if ( $nessusdata[0] !~ m/[NessusWX Export File]/ ) { print "File $ARGV[0] does not appear to be a valid NessusWX Export + File\n"; exit 0; } foreach $nessusdata (@nessusdata) { my @result = split ( /\|/, $nessusdata ); if ( $result[0] =~ /(NessusWX|DATA)/ ) { next; } elsif ( !$result[2] ) { push @ports, $nessusdata; push @ips, $result[0]; } } @uniqip = keys %{ { @ips, reverse @ips } }; foreach $uniqip (@uniqip) { @splitip = split ( /\./, $uniqip ); $longip = ( $splitip[0] * ( $num * $num * $num ) ) + ( $splitip[1] * ( $num * $num ) ) + ( $splitip[2] * $num ) + ( $splitip[3] ); $longips{$longip} = $uniqip; } @rearranged = sort { $a <=> $b } keys %longips; foreach (@rearranged) { if ( $count == 0 ) { print PORTREPORT $longips{$_}, "|"; } else { print PORTREPORT "\n", $longips{$_}, "|"; } foreach $port (@ports) { my @result = split ( /\|/, $port ); if ( $result[1] =~ m/general/ ) { next; } elsif ( $longips{$_} =~ m/$result[0]$/ ) { $result[1] =~ s/(\(|\))//g; chomp $result[1]; print PORTREPORT $result[1], "|"; } } $count = 1; } close(PORTREPORT);

In reply to nessus port reporter by semio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.