Nmap Development mailing list archives

RE: output question/suggestion


From: "Max Schubert" <musitechman () earthlink net>
Date: Thu, 25 Jul 2002 09:11:07 -7012

Hi,

    Yet another way to handle this .. use Nmap::Scanner with perl ... example script
    for creating tab delimited output ... latest version is at

    http://webwizarddesign.com/nmap/

    I used a TCP connect scan as an example as I created this on a Win9x box.

Max

#!/usr/bin/perl

use Nmap::Scanner;
my $scanner = new Nmap::Scanner;

$scanner->tcp_connect_scan();
$scanner->add_scan_port('1-1024');
$scanner->max_rtt_timeout(200);
$scanner->add_target($ARGV[0] || '127.0.0.1');
$scanner->register_scan_started_event(\&scan_started);
$scanner->register_port_found_event(\&port_found);
$scanner->scan();

sub scan_started {

    my $self     = shift;
    my $hostname = shift;
    my $ip       = shift;
    my $status   = shift;
 
    #  Show on STDERR to avoid mix-in with output
    warn "$hostname ($ip) is $status\n";

}

sub port_found {

    my $self     = shift;
    my $hostname = shift;
    my $ip       = shift;
    my $port     = shift;
 
    my $port_num = $port->number();
    my $port_svc = $port->service();
    my $port_st  = $port->state();
    my $port_pr  = $port->protocol();

    print "$hostname\t$ip\t$port_svc\t$port_num\t$port_pr\t$port_st\n";

}

---------------------------------------------------------------------
For help using this (nmap-dev) mailing list, send a blank email to 
nmap-dev-help () insecure org . List run by ezmlm-idx (www.ezmlm.org).



Current thread: