Noosrep has asked for the wisdom of the Perl Monks concerning the following question:
I have an XML file that is generated as follows:
<port protocol="tcp" portid="139"><state state="open" reason="syn-ack" + reason_ttl="64"/><service name="netbios-ssn" method="table" conf="3" +/></port> <port protocol="tcp" portid="445"><state state="open" reason="syn-ack" + reason_ttl="64"/><service name="microsoft-ds" method="table" conf="3 +"/></port> <port protocol="tcp" portid="1984"><state state="open" reason="syn-ack +" reason_ttl="64"/><service name="bigbrother" method="table" conf="3" +/></port>
With following code, I parse it:
my $fct_openPort = (join ',',$fct_host_obj->tcp_ports('open'))."\n" ; my @fct_ports = split ',', $fct_openPort; for my $fct_port (@fct_ports) { my $fct_svc = $fct_host_obj->tcp_service($fct_port); my $fct_service = $fct_svc->name() ; print "\nservice : $fct_service \n" ; print "port : $fct_port \n" ; print "service and port = $fct_port:$fct_service \n" ; }
However, the last open port has no service!
service : netbios-ssn port : 139 service and port = 139:netbios-ssn service : microsoft-ds port : 445 service and port = 445:microsoft-ds service : port : 1984 service and port = 1984 :
Does anybody have any why the last service isn't resolved? When I change
my $fct_svc = $fct_host_obj->tcp_service($fct_port);to
my $fct_svc = $fct_host_obj->tcp_service("1984");it does work
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Last service name comes up empty in NMAP Parser
by huck (Prior) on Jan 18, 2017 at 11:11 UTC | |
by Noosrep (Novice) on Jan 18, 2017 at 11:23 UTC | |
|
Re: Last service name comes up empty in NMAP Parser
by haukex (Archbishop) on Jan 18, 2017 at 11:16 UTC | |
by Noosrep (Novice) on Jan 18, 2017 at 11:25 UTC |