savon-noir / python-libnmap

libnmap is a python library to run nmap scans, parse and diff scan results. It supports python 2.7 up to 3.8. It's wonderful.
https://libnmap.readthedocs.org
Other
489 stars 182 forks source link

Wrong XML structure error when using arg: -sV -T4 -O -F #86

Closed adnanmig closed 3 years ago

adnanmig commented 6 years ago

Hi,

I have this function in my code:

def do_scan(targets, options):
    parsed = None
    nmproc = NmapProcess(targets, options, safe_mode=True)
    rc = nmproc.sudo_run()
    if rc != 0:
        print("nmap scan failed: {0}".format(nmproc.stderr))
    #print(type(nmproc.stdout))
    try:
        parsed = NmapParser.parse(nmproc.stdout)
    except NmapParserException as e:
        print("Exception raised while parsing scan: {0}".format(e.msg))
        pass
    return parsed

when I call the function with these arguments: -sV -T4 -O -F

I get this exception:

Exception raised while parsing scan: Wrong XML structure: cannot parse data

I see the following warning while scanning:

nmap scan failed: adjust_timeouts2: packet supposedly had rtt of -69799 microseconds. Ignoring time. adjust_timeouts2: packet supposedly had rtt of -66058 microseconds. Ignoring time.

The scan works using normal nmap command with the same arguments. Any suggestions to fix this?

adnanmig commented 6 years ago

After more research into this issue, I found that Ubuntu's default package is old. I installed the latest version from https://nmap.org/download.html, ran the same scans and it seems to have resolved the issue.