Nmap::Scanner & XML::SAx problems

K

kearins.alan

I am new to perl and quite rusty in programming, but I am trying to
create pwerl scrip to scan the ports on a machine in a local
network.However whehn I go to run the script I get the following error
"Can't call a method "as_XML" on an undefined value at
c:/perl/site/lib/nmap/Scanner/backend/results.pm.

Basically I want to get the user to
enter a computer name
take that nme as STDIN
Print port information for that nachine

Any help apreciated


use Nmap::Scanner;
use XML::SAX;

# Batch scan method

my $scanner = new Nmap::Scanner;
$scanner->tcp_syn_scan();
$scanner->add_scan_port('1-1024');
$scanner->add_scan_port(8080);
$scanner->guess_os();
$scanner->max_rtt_timeout(200);
$scanner->add_target('some.host.out.there.com.org');

# $results is an instance of Nmap::Scanner::Backend::Results
my $results = $scanner->scan();

# Print the results out as an well-formatted XML document
print $results->as_xml();

# Event scan method using *new* easier way to set scan options.

my $scanner = new Nmap::Scanner;
$scanner->register_scan_started_event(\&scan_started);
$scanner->register_port_found_event(\&port_found);
$scanner->scan('-sS -p 1-1024 -O --max-rtt-timeout 200
somehost.org.net.it');

sub scan_started {
my $self = shift;
my $host = shift;

my $hostname = $host->name();
my $addresses = join(',', map {$_->address()}
$host->addresses());
my $status = $host->status();

print "$hostname ($addresses) is $status\n";
}

sub port_found {
my $self = shift;
my $host = shift;
my $port = shift;

my $name = $host->name();
my $addresses = join(',', map {$_->addr()}

$host->addresses());

print "On host $name ($addresses), found ",
$port->state()," port ",
join('/',$port->protocol(),$port->portid()),"\n";}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top