#!/usr/bin/perl # use Getopt::Std; getopts("t:f:k:", \%args); if(!defined $args{t} && !defined $args{f} && !defined $args{k}) { print << "EOT"; Nessus Session Data File Parser - g0ne usage: $0 -t -f -k "keyword" example: $0 -t txt -f 20010426-124153-data -k hole This would return a list of all holes found in the session. EOT exit; } @stuff = `egrep -i "$args{k}" $args{f}`; if ($args{t} eq "xml") { print "\n"; print "\n"; } if ($args{t} eq "html") { print "\n"; print "\n"; print "
\n"; } foreach(@stuff) { chomp $_; $mush = $_; $mush =~ s/\<\|\>/\|/g; ($x, $type, $address, $prot, $alert, $x) = split('\|', $mush); $alert =~ s/\;/\n/g; if ($args{t} eq "txt") { print "\n"; print "Host Type: $type\n"; print "Host Address: $address\n"; print "Protocol/Port: $prot\n"; print "Description:\n$alert\n"; print "%" . "-" x 40 . "\n"; } if ($args{t} eq "xml") { print "\n"; print "\t $address \n"; print "\t $type \n"; print "\t $prot \n"; print "\t $alert \n"; print "\n\n"; } if ($args{t} eq "html") { print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Host: $address
TypeProtocolDescription
$type $prot $alert
\n"; } } if ($args{t} eq "xml") { print "\n"; } if ($args{t} eq "html") { print "
\n"; print "\n"; print "\n"; }