fellow monks,

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:

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;
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.

cheers, -semio


In reply to module review 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.