Hello,
I wrote a Perl script to import an nmap scan of the network into Open-AudIT.
It will usually be faster to do nmap scans for the entire network, instead of calling them one at a time since nmap can do parallel scanning.
Feel free to include it in Open-AudIT, if you like.
Thanks for creating a great open source tool.
Regards,
David
------------------------------------------------- [code] #!/usr/bin/env perl ##################################################### # # Split up nmap scan and submit to openaudit # v1.0 - David Bailey 6/17/2008 # # EXAMPLE: # nmap -v -O -oN filename.txt networks-or-hosts # split-and-submit-nmap-to-openaudit.pl filename.txt # #####################################################
# User modifiable settings my $nmap_ie_form_page = 'http://127.0.0.1/openaudit/admin_nmap_input.php';
# Probably don't need to modify these my $nmap_block_start='^Interesting ports on '; my $nmap_block_stop='^Network Distance: '; my $debug = 0;
# Don't modify these, initialize scalars my $nmap_block=''; my $inblock = 0; my $blockname = ''; my $line='';
# modules use strict; use LWP::UserAgent; use HTTP::Request::Common;
# Specify the information to post, the form field name on # the left of the => symbol and the value on the right. my %form_data = ( 'submit' => 'submit', 'add' => '' );
# Create the browser that will post the information. my $Browser = new LWP::UserAgent;
while ( $line = <> ) { # data is in $_ chomp $line; if ( $debug >= 2 ) { print "debug readline $inblock: $line\n"; } if ( $inblock ) { if ( $line =~ /$nmap_block_stop/ ) { # found end of block, check for required attribute(s), MAC address if ( $nmap_block =~ /MAC Address: / ) { # Found required attribute(s), submit it to Open-AudIT $form_data{'add'} = "$nmap_block\n$line\n";
# submit to web form if ( $debug ) { print "debug submit form: $form_data{'add'}\n"; } my $Page = $Browser->request(POST $nmap_ie_form_page,\%form_data);
# Give the results to the user if ($Page->is_success) { print "Successfully added node: $blockname\n"; if ( $debug ) { print $Page->content; } } else { print "Failed to add node: $blockname\n"; if ( $debug ) { print $Page->message; } } } else { print "Failed to add node: $blockname, missing required attributes\n"; }
# Reset block flag $inblock = 0; } else { # putting lines into block $nmap_block .= "$line\n"; } } elsif ( $line =~ /$nmap_block_start(\S+)/ ) { $inblock = 1; $nmap_block = "$line\n"; $blockname = $1; # strip trailing punctuation from blockname if ( $blockname =~ /(.*)[^A-Za-z0-9]$/ ) { $blockname = $1; } } }
# end of script[/code]
|