Skip to content

nmap 7.94 produces invalid XML output #2657

@firefart

Description

@firefart

Describe the bug
nmap 7.94 seems to produce invalid xml output. This happens when a service name has some special characters for example. In my case it only happened on port 445 so it might be related to the samba modules only. When loading such a XML with the perl nmap parser for example, you get an error about reference to invalid character number at ....

To Reproduce
Example XML parts:

<port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="62"/><service name="0M&#xec;&#x1;" product="Samba smbd" version="3.6.23-53.el6_10" extrainfo="workgroup: REDACTED" method="probed" conf="10"><cpe>cpe:/a:samba:samba</cpe></service></port>
<port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="122"/><service name="ife-biteP&#x1b;" product="Windows Server 2008 R2 Standard 7601 Service Pack 1 microsoft-ds" ostype="Windows Server 2008 R2 - 2012" method="probed" conf="10"><cpe>cpe:/o:microsoft:windows</cpe></service></port>

&#x1b; and so on is not allowed in XML and results in errors when trying to parse those files with xml libraries (perl for example)

Expected behavior
The service name should be in a CDATA section I believe

Version info (please complete the following information):

Nmap version 7.94 ( https://nmap.org )
Platform: x86_64-redhat-linux-gnu
Compiled with: nmap-liblua-5.4.4 openssl-3.0.8 nmap-libssh2-1.10.0 nmap-libz-1.2.13 nmap-libpcre-7.6 nmap-libpcap-1.10.4 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions