Jack Coates [jack AT monkeynoodle.org] wrote:
> I'm trying to get Nmap::Scanner working, and I'm trying to use one
> of the examples from its perldoc.
> 
> Script:
> use Nmap::Scanner;
> my $scanner = new Nmap::Scanner; 
> $scanner->tcp_syn_scan;
> $scanner->add_scan_port('1-100
> ');
> $scanner->guess_os();
> $scanner->add_target(' 172.16.252.1');
> my $results = $scanner->scan();
> my $xml = $results->as_xml(); 
> print $xml;
> exit 0;
> 
> Result:
> Unable to recognise encoding of this document at
C:/Perl/site/lib/XML/SAX/PurePerl/EncodingDetect.pm line 96.
> <nmap-error>
>   <pid="1168"/>
>   <cmdline="'C:\Program Files\Nmap\nmap.exe' -v -v -v -sS -p 1-100 -O
-oX - 172.16.252.1"/>
>   <perl-msg>Document requires an element [Ln: 1, Col: 0]
> </perl-msg>
>   <nmap-msg></nmap-msg>
> </nmap-error>
> 
> I get the feeling that this is probably something simple, but STFW
> and RTFM aren't turning anything up yet... everything I've read
> implies that PurePerl is the right parser to use. However, since
> installing this parser PPM throws the same encoding error, so it
> looks like something's horked in Perl itself. Uninstalling
> XML-Sax-PurePerl puts PPM back to rights, but breaks Nmap::Scanner.
> Advice, please? 

The problem is invalid XML. This is illegal:

  <pid="1168"/>

You probably meant something like:

  <pid val="1168"/>

or maybe you'd like:

  <process pid="1168"/>

or:

  <pid>1168</pid>


Note the distinction between these valid forms. The first two are an
element with an attribute.
The second is an element with its text content.

Also this is illegal for the same reason:

  <cmdline="'C:\Program Files\Nmap\nmap.exe' -v -v -v -sS -p 1-100 -O
-oX - 172.16.252.1"/>

Hope this helps. Always make sure that your XML is well-formed (and
hopefully validated).

--
Mike Arms


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to