byt3bl33d3r / WitnessMe

Web Inventory tool, takes screenshots of webpages using Pyppeteer (headless Chrome/Chromium) and provides some extra bells & whistles to make life easier.
GNU General Public License v3.0
734 stars 109 forks source link

TypeError when parsing nmap file #14

Closed pwnfoo closed 4 years ago

pwnfoo commented 4 years ago

The following error is thrown when an nmap XML is given as input :

  File "/home/neo/.local/pipx/venvs/witnessme/lib/python3.8/site-packages/witnessme/parsers.py", line 109, in parser_callback
    if port["@protocol"] == "tcp" and port["state"]["@state"] == "open":
TypeError: string indices must be integers
byt3bl33d3r commented 4 years ago

@sachinkamath Can you give me the NMap command you ran to generate the XML?

pwnfoo commented 4 years ago

@byt3bl33d3r I ran : nmap -iL infile --top-ports 1000 -oX outfile

byt3bl33d3r commented 4 years ago

Can you try adding the -sV or the -A flag to the NMap command? Also is there at least 1 open port in the nmap results?

pwnfoo commented 4 years ago

@byt3bl33d3r I tried running nmap with both -sV and -A and the issue still seems to be there. I tested this locally with a single port open.

Attaching nmap xml file for your reference

nmap_test.log

pwnfoo commented 4 years ago

I think I have narrowed down on the issue. When there is only a single port available, item["ports"]["port"] is an OrderedDict object, so for port in ports doesn't work as intended.

The hack in #15 seems to work for me.

byt3bl33d3r commented 4 years ago

Latest push should have fixed it. Thanks for giving me the Nmap XML, helped a ton. Cheers