Closed sebrink closed 4 years ago
The problem is that it raises an error when parsing the xml if no port is open but e.g. a filtered port is shown in
For me the issue was fixed when changing the following code of parsers.py
class NmapParser(XmlParser):
def __init__(self, file_path):
super().__init__(file_path)
self.item_depth = 2
def parser_callback(self, path, item):
if isinstance(item, OrderedDict):
if "address" in item.keys() and "ports" in item.keys():
address = item["address"]["@addr"]
ports = item["ports"]["port"]
# If there's only a single port discovered, ports will be an OrderedDict
if isinstance(ports, OrderedDict):
ports = [ports]
for port in ports:
if port["@protocol"] == "tcp" and port["state"]["@state"] == "open":
service = port["service"].get("@name")
port_number = port["@portid"]
if "ssl" in service or service == "https":
self.urls.add(f"https://{address}:{port_number}")
elif service == "http-alt" or service == "http":
self.urls.add(f"http://{address}:{port_number}")
return True
to
class NmapParser(XmlParser):
def __init__(self, file_path):
super().__init__(file_path)
self.item_depth = 2
def parser_callback(self, path, item):
if isinstance(item, OrderedDict):
if "address" in item.keys() and "ports" in item.keys():
if "port" in item["ports"].keys() and "@addr" in item["address"].keys():
address = item["address"]["@addr"]
ports = item["ports"]["port"]
# If there's only a single port discovered, ports will be an OrderedDict
if isinstance(ports, OrderedDict):
ports = [ports]
for port in ports:
if port["@protocol"] == "tcp" and port["state"]["@state"] == "open":
service = port["service"].get("@name")
tunnel = port["service"].get("@tunnel")
port_number = port["@portid"]
if "ssl" in service or service == "https" or (service == "http" and tunnel == "ssl") or \
(service == "http-proxy" and tunnel == "ssl"):
self.urls.add(f"https://{address}:{port_number}")
elif service == "http-alt" or service == "http" or service == "http-proxy":
self.urls.add(f"http://{address}:{port_number}")
return True
The following check on line number 107 was added to the previous code which fixed the issue for me:
if "port" in item["ports"].keys() and "@addr" in item["address"].keys():
Does this fix the issue for you as well?
Note that in the port section I've additionally added triggers for ports which were not detected correctly in my nmap file. Since a "http" service which is using ssl on port 443 was not detected with the preconfigured triggers. Some ports were detected as "http-proxy" service, so I've added that as well.
Hi,
Just wanted to subscribe to this thread as I'm having very similar output issues to @sebrink's scan. @CT-H00K I'd be interested in trying your fix. I've got Witnessme running in Docker and I'm a Docker novice so if you wouldn't mind spelling out the instructions a bit for tweaking this .py file I can give it a swing.
Thanks, Brian
Hi,
if you have pulled the image with:
docker pull byt3bl33d3r/witnessme
You can check the $IMAGEID with the following command:
docker image ls
Use the IMAGE ID to drop into a root shell with the following command:
docker run --user=root -it --entrypoint=/bin/bash $IMAGEID
To edit files you would need an editor within the docker, which might not be installed. Therefore just install your editor within the docker using apt install vim
Within the container you need to edit the parsers.py file as mentioned above, might be somewhere at:
/home/appuser/src/witnessme/witnessme/parsers.py
Note that you need to move all lines below the change with 4 spaces except the return True
in the last line.
After you made the changes to the file, drop into an appuser shell with su appuser
and run witnessme
. I've not tested it with docker, so could be that I missed something here.
The change will not be persistent but will be enough for testing the fix. For persistence you would need to e.g. map the file into the container from your host.
@CT-H00K @braimee this was fixed in https://github.com/byt3bl33d3r/WitnessMe/commit/2fbd06c8c39e10d09322597eb8a5e89fb9ac3cbd
Thanks
Thanks @byt3bl33d3r and @CT-H00K, got my first scan done today and she's a beaut!
I was attempting to run WitnessMe with a large nmap XML file for the top 1000 ports in a certain range. When passing this to WitnessMe (using both pipx and docker) I received the following error:
I was able to use gowitness and it parsed the file normally, so I believe this has something to do with how WitnessMe handles nmap XML parsing.