Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Tue Jun 28, 2022 1:19 am

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
PostPosted: Wed Jun 18, 2008 3:43 am 
Offline
Newbie

Joined: Wed Jun 18, 2008 12:09 am
Posts: 4
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]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group