Hi,
I have the following perl code:
use Nmap::Scanner;
my $scan = Nmap::Scanner->new();
$scan->add_target('localhost');
$scan->add_scan_port('16310-16316');
$scan->tcp_syn_scan();
my $results = $scan->scan();
But it is throwing error:
[root@station19 ~]# perl nmap.pl
<nmap-error>
<pid="8711"/>
<cmdline="'/usr/bin/nmap' -v -v -v -sS -p 16310-16316 -oX - localhos
+t"/>
<nmap-err>mass_dns: warning: Unable to determine any DNS servers. Re
+verse DNS is disabled. Try using --system-dns or specify valid server
+s with --dns_servers
</nmap-msg>
</nmap-error>
and the output when I run the nmap command from command line is:
[root@station19 ~]# '/usr/bin/nmap' -v -v -v -sS -p 16310-16316 -oX -
+localhost
<?xml version="1.0" ?>
<?xml-stylesheet href="/usr/share/nmap/nmap.xsl" type="text/xsl"?>
<!-- Nmap 4.11 scan initiated Tue Jan 3 16:17:13 2012 as: /usr/bin/nm
+ap -v -v -v -sS -p 16310-16316 -oX - localhost -->
<nmaprun scanner="nmap" args="/usr/bin/nmap -v -v -v -sS -p 16310-1631
+6 -oX - localhost" start="1325587633" startstr="Tue Jan 3 16:17:13 2
+012" version="4.11" xmloutputversion="1.01">
<scaninfo type="syn" protocol="tcp" numservices="7" services="16310-16
+316" />
<verbose level="3" />
<debugging level="0" />
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is
+ disabled. Try using --system-dns or specify valid servers with --dns
+_servers
<host><status state="up" />
<address addr="127.0.0.1" addrtype="ipv4" />
<hostnames><hostname name="localhost.localdomain" type="PTR" /></hostn
+ames>
<ports><port protocol="tcp" portid="16310"><state state="open" /></por
+t>
<port protocol="tcp" portid="16311"><state state="open" /></port>
<port protocol="tcp" portid="16312"><state state="open" /></port>
<port protocol="tcp" portid="16313"><state state="open" /></port>
<port protocol="tcp" portid="16314"><state state="open" /></port>
<port protocol="tcp" portid="16315"><state state="open" /></port>
<port protocol="tcp" portid="16316"><state state="open" /></port>
</ports>
</host>
<runstats><finished time="1325587633" timestr="Tue Jan 3 16:17:13 201
+2"/><hosts up="1" down="0" total="1" />
<!-- Nmap run completed at Tue Jan 3 16:17:13 2012; 1 IP address (1 h
+ost up) scanned in 0.010 seconds -->
</runstats></nmaprun>
So, running from command line is giving some warning but still continuing and giving me the output which I want. But not the perl code. Is there anyway that I can get this perl code to be working?
Thanks,
Ashok