I've constructed a module that consists of several subs I've written while working with nessus nbe data. While writing network reports, these routines have become fairly useful to me in cleaning up and presenting specific data. Currently, the module has subs that will present os versions, service banners, ports and a few others. I plan to add more subs to it as I come across other data I may want to extract. So far, it looks as follows:
As this is my first attempt at putting together a module, I wanted to post it to see if I'm on the right track and to be made aware of any shortcomings that may be present (at my level, there are probably many ;) ). Would someone mind critiquing this, as a module or otherwise.package NessusNBE; #arbitrary at the moment use strict; use vars qw/ $VERSION @ISA @EXPORT /; require Exporter; @ISA = qw/ Exporter /; @EXPORT = qw/ nbanners nports nplugin nwebdirs nnfs nos /; $VERSION = '1.0'; sub nbanners { my (@ndata) = @_; my (@banners); foreach my $nbanner (@ndata) { if ( $nbanner =~ /emote(.*)server (banner|type)/ ) { my @result = split ( /\|/, $nbanner ); $result[6] =~ s/^(.*)\:\\n|Solution (.*)$|\\r|\\n//g; push @banners, join "|", $result[2], $result[6]; } } return @banners; } sub nports { my (@ndata) = @_; my (@ports); my $nport = pop (@ndata); foreach my $ndata (@ndata) { my @result = split ( /\|/, $ndata ); if ( $result[4] ) { next; } elsif ( $result[3] =~ /\($nport\// ) { push @ports, join "|", $result[2], $result[3]; } } return @ports; } sub nplugin { my (@ndata) = @_; my (@plugins); my $nplugin = pop (@ndata); foreach my $ndata (@ndata) { my @result = split ( /\|/, $ndata ); if ( !$result[4] ) { next; } elsif ( $result[4] =~ /$nplugin/ ) { push @plugins, join "|", $result[2], $result[3], $result[4 +]; } } return @plugins; } sub nwebdirs { my (@ndata) = @_; my (@webdirs); my $webdirplugin = 11032; foreach my $ndata (@ndata) { my @result = split ( /\|/, $ndata ); if ( !$result[4] ) { next; } elsif ( $result[4] =~ /$webdirplugin/ ) { $result[6] =~ s/^(.*)discovered\:|\\n//g; $result[6] =~ s/The following(.*)authentication/ --auth re +quired/; push @webdirs, join "|", $result[2], $result[3], $result[6 +]; } } return @webdirs; } sub nnfs { my (@ndata) = @_; my (@nfs); my $nfsplugin = 10437; foreach my $ndata (@ndata) { my @result = split ( /\|/, $ndata ); if ( !$result[4] ) { next; } elsif ( $result[4] =~ /$nfsplugin/ ) { $result[6] =~ s/^(.*) \: \\n|\\n\\n(.*)$//g; push @nfs, join "|", $result[2], $result[3], $result[6]; } } return @nfs; } sub nos { my (@nos) = @_; my (@os); foreach my $nos (@nos) { my @result = split ( /\|/, $nos ); if ( $nos =~ m/10336\|Security Note|11268\|Security Note/ ) { if ( $result[4] eq 10336 ) { $result[6] =~ s/(Nmap(.*)running |(\;|\\n))//g; push @os, join "|", $result[2], $result[6]; } elsif ( $result[4] eq 11268 ) { $result[6] =~ s/(Remote OS guess : |\\n\\n(.*)$)//g; push @os, join "|", $result[2], $result[6]; } } } return @os; } 1;
cheers, -semio
In reply to module review by semio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |