Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: nessus port reporter

by Aristotle (Chancellor)
on Jan 25, 2003 at 23:33 UTC ( [id://229894]=note: print w/replies, xml ) Need Help??


in reply to nessus port reporter

m/[NessusWX Export File]/

Are you sure you want to test whether the file contains any of the characters N, e, s, u, W, X, E, x, p, o, r, t, F, i, or l? If not, you have to backslash the square brackets.

Also, this is a matter of style, but I suggest you declare your variables when you first use them. That makes it much easier to keep track of what gets used where - esp if the code is longer than this example.

Untested:

#!/usr/bin/perl -w use strict; use Socket qw(inet_aton); use constant USAGE => "usage: npr.pl <NessusWX Export File>"; my $infilename = shift || die USAGE; my $outfilename = shift || "portreport"; die USAGE if @ARGV; my @data = do { open my $fh, "<", $infilename or die "Could not open $infilename: $!\n"; <$fh> }; die "$infilename does not appear to be a valid NessusWX Export File\n" unless $nessusdata[0] =~ m/\[NessusWX Export File\]/; my (@port, @ip); for (@data) { my @field = split /\|/; next if $field[2] or $field[0] =~ /(NessusWX|DATA)/; push @port, $_; push @ip, $result[0]; } my @uniqip = do { my %seen; grep !$seen{$_}++, @ip; }; my %longip = map { unpack("N", inet_aton $_), $_ } @uniqip; open my $fh, ">", $outfilename or die "Could not open $outfilename: $!\n"; foreach (sort { $a <=> $b } @uniqip) { my @report; for (@port) { my @field = split /\|/; next if $field[1] =~ m/general/; or not $longips{$_} =~ m/\Q$field[0]\E$/ chomp, tr/()//d for $field[1]; push @report, $field[1]; } print $fh join "|", $longips{$_}, @report; print $fh "\n"; }

Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://229894]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-12-06 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (44 votes). Check out past polls.