Hi,

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


In reply to Last service name comes up empty in NMAP Parser by Noosrep

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.