Re: [Nmap-scanner-general] Need a little help with example from perldoc
Brought to you by:
perldork
From: Max S. <max...@gm...> - 2006-11-02 18:43:30
|
Hi Clayton, > my $hostname = $host->name(); ->name() should be ->hostname() :) Did you get your example code from one of the Nmap::Scanner examples? If so, which version of the module are you using? I do see one example that has incorrect code that I did not notice before, ftpscan.pl has a reference to a name() accessor. Please let me know if you found your example code in one of the example scripts, and if so, which one. Code fixed in CVS, credit for bringing up the problem given to you in the Changes file. Regards, Max On 11/2/06, Dukes Clayton <Cla...@hc...> wrote: > > > > > Trying to create a multi host scanner but I'm getting errors, can anyone > help out here? > > #!/usr/bin/perl > use strict; > > $| = 1; > use Nmap::Scanner; > > open (FILE, $ARGV[0]); > my $count = 1; > my(@host_array) = <FILE>; # read file into list > my $total = (@host_array); > print "Checking $total hosts\n"; > @host_array = sort(@host_array); # sort the list > chomp (@host_array); > > if (@ARGV < 1){ > usage(); > } > sub usage { > print "Usage: synping.pl <hosts>\n"; > print "Example:\n"; > print "perl synping.pl hosts.txt\n"; > exit(-1); > } > > foreach my $hostname (@host_array) { > my $scanner = new Nmap::Scanner; > > $scanner->register_scan_started_event(\&scan_started); > $scanner->register_port_found_event(\&port_found); > $scanner->scan("-sS -p 22,23 -O $hostname"); # Scan for telnet or ssh > > } > 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"; > > } > > > This returns: > Checking 2520 hosts > 2693<nmap-error> > <pid="2142"/> > <cmdline="'/usr/bin/nmap' -v -v -v -sS -p 22,23 -O 2811-x-f-h.vac.co.y.net > -oX -"/> > <perl-msg>Can't locate object method "name" via package > "Nmap::Scanner::Host" at ./synping.pl line 55. > </perl-msg> > <nmap-msg></nmap-msg> > </nmap-error> > > > > ---clueless :-) > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > Nmap-scanner-general mailing list > Nma...@li... > https://lists.sourceforge.net/lists/listinfo/nmap-scanner-general > > > |