Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Agent can throw exception if it tries to read malformed nmap xml file #169

@0xdade

Description

@0xdade
[+] Thread-1: Fetching Target from https://natlas.io
[+] Thread-1: [Server] Target: 191.222.148.70
[+] Thread-1: Scan fdrvra799fodfg4e Complete
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/opt/natlas/natlas-agent/venv/lib/python3.6/site-packages/libnmap/parser.py", line 90, in _parse_xml
    root = ET.fromstring(nmap_data)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 1315, in XML
    return parser.close()
  File "<string>", line None
xml.etree.ElementTree.ParseError: no element found: line 7, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "./natlas-agent.py", line 367, in run
    result = scan(target_data)
  File "./natlas-agent.py", line 267, in scan
    nmap_report = NmapParser.parse(result['xml_data'])
  File "/opt/natlas/natlas-agent/venv/lib/python3.6/site-packages/libnmap/parser.py", line 41, in parse
    nmapobj = cls._parse_xml(nmap_data, incomplete)
  File "/opt/natlas/natlas-agent/venv/lib/python3.6/site-packages/libnmap/parser.py", line 92, in _parse_xml
    raise NmapParserException("Wrong XML structure: cannot parse data")
libnmap.parser.NmapParserException: Wrong XML structure: cannot parse data

Relevant xml file is posted here: https://pastebin.com/raw/0mAWysk3

I'm not 100% sure what caused this XML data to be malformed/unfinished, but the corresponding nmap and gnmap files are empty so I suspect that the nmap process got killed or something similar. We need to be able to handle NmapParserExceptions and probably just throw away the data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentaffecting natlas-agentbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions