Nessus Parser
Found this very useful script for taking a NessusV2 file and turning into omething our system users might have a prayer of reading. However, I wanted to be able to filter results based on hostname regex, so this diff adds that.
--- parse_nessus_xml.v18.pl 2013-04-25 06:48:48.000000000 -0400
+++ parse_nessus_xml.v18.pl.new 2013-06-07 17:01:21.996481503 -0400
@@ -101,6 +101,8 @@
as the XML. Please note if the path to file has a "SPACE" use
double quotes around the file path and/or name.
+ -x Only include hosts matching the provided regex
+
-r The Recast option is a feature request from user KurtW. Kurt wanted
to be able to change the reported value of Nessus Plugin ID. While
this is not recommended in many cases, in some instanses the change
@@ -165,7 +167,7 @@
my $version = $ARGV[0];
my %opt;
-getopt('dfro', \%opt);
+getopt('dfrox=s', \%opt);
if($version =~ /-(v|V|h|H)/)
{
@@ -277,6 +279,10 @@
my @Host_uniq_cnt;
foreach my $item (@host_data)
{
+ if (defined $opt{'x'})
+ {
+ next unless $item->{name} =~ /$opt{'x'}/;
+ }
if ($search_item =~ /sev/){$host_seen_cnt{$item->{vuln_cnt}->{$search_item}}++}
else{$host_seen_cnt{$item->{$search_item}}++}
}
@@ -741,6 +747,10 @@
my %hash;
$hash{file} = $file;
$hash{name} = $hostproperties->{-name};
+ if (defined $opt{'x'})
+ {
+ next unless $hash{name} =~ /$opt{'x'}/;
+ }
my @host;
if (ref($hostproperties->{HostProperties}->{tag}) eq "HASH"){push @host, $hostproperties->{HostProperties}->{tag};}
elsif (ref($hostproperties->{HostProperties}->{tag}) eq "ARRAY"){@host = @{$hostproperties->{HostProperties}->{tag}};}
@@ -1071,6 +1081,10 @@
foreach my $host (@host_data)
{
my @report_data;
+ if (defined $opt{'x'})
+ {
+ next unless $host->{name} =~ /$opt{'x'}/;
+ }
if (ref $host->{host_report} eq "HASH"){push @report_data, $host->{host_report};}
else{@report_data = @{$host->{host_report}};}
my $name = $host->{name};
@@ -1767,6 +1781,10 @@
foreach my $host (@host_data)
{
+ if (defined $opt{'x'})
+ {
+ next unless $host->{"name"} =~ /$opt{'x'}/;
+ }
$HostConfigData_worksheet->write($HostConfigData_ctr, 0, $host->{"file"},$cell_format);
$HostConfigData_worksheet->write($HostConfigData_ctr, 1, $host->{"host-ip"},$cell_format);
$HostConfigData_worksheet->write($HostConfigData_ctr, 2, $host->{"host-fqdn"},$cell_format);
@@ -2772,13 +2790,15 @@
++$Home_cnt;++$Home_cnt;
$Home_worksheet->merge_range( $Home_cnt, 0, $Home_cnt, 1, "Overall Summary Data", $center_border6_format );
-++$Home_cnt;
-$Home_worksheet->write($Home_cnt, 0, "Number of IP's Scanned");
-$Home_worksheet->write($Home_cnt, 1, $target_cnt);
-++$Home_cnt;
-$Home_worksheet->write($Home_cnt, 0, "Number of Discovered Systems");
-$Home_worksheet->write($Home_cnt, 1, $total_discovered);
-++$Home_cnt;
+if (!defined $opt{'x'}) {
+ ++$Home_cnt;
+ $Home_worksheet->write($Home_cnt, 0, "Number of IP's Scanned");
+ $Home_worksheet->write($Home_cnt, 1, $target_cnt);
+ ++$Home_cnt;
+ $Home_worksheet->write($Home_cnt, 0, "Number of Discovered Systems");
+ $Home_worksheet->write($Home_cnt, 1, $total_discovered);
+ ++$Home_cnt;
+}
++$Home_cnt;
$Home_worksheet->write($Home_cnt, 0, "Total Unique Critical Severity Vulnerability");
$Home_worksheet->write($Home_cnt, 1, $total_critical);