http://www.perlmonks.org?node_id=1030656

petermilanese has asked for the wisdom of the Perl Monks concerning the following question:

Greetings-

I have some code that does OS fingerprint/port scans. It uses Nmap::Scanner. For a few particular hosts it will hang on the scan within the module. However, if I execute the nmap line used by the module from the command line it's fine. It seems to only hang when using the Nmap::Scanner module.

For instance - This routine is called:
sub portScan { print "Port Scan - "; $key = shift; my $hostname = $hash{$key}{"Address - FQDN"}; my $scanner = new Nmap::Scanner; $scanner->register_scan_started_event(\&scan_started); $scanner->debug(1); $scanner->register_scan_complete_event(\&scan_ended); $scanner->register_port_found_event(\&port_found); $scanner->scan('-sS -p 1-1024,5555,8000-8200 -O --max-rtt-time +out 100ms --max-retries 2 -T aggressive '. $hostname); $scanner->guess_os(); print "\n"; #print "$hostname - ".$hash{$key}{'Ports Open'} . "\n"; }

On one host it will return immediately and successfully. On another, it will not. It's literally frozen on that execution all night. However. If I pull the command line executed by the module-

#!/usr/bin/perl @OU=`/usr/bin/nmap -v -v -v -sS -p 1-1024,5555,8000-8200 -O --max-rtt- +timeout 100ms --max-retries 2 -T aggressive host.mydomamin.com -oX -` +; print @OU;
It returns immediate output :/ Has anyone run into this? Thanks- Pete