AttributeError: 'NoneType' object has no attribute 'findall'
jth0 opened this issue · 4 comments
Using Python 3.12.3 and Nmap version 7.95 on macOS. Received the following error when trying to follow along:
Traceback (most recent call last):
File "/Users/jth/Library/CloudStorage/Dropbox/Projects/nmap-did-what/data/nmap-to-sqlite.py", line 220, in <module>
main()
File "/Users/jth/Library/CloudStorage/Dropbox/Projects/nmap-did-what/data/nmap-to-sqlite.py", line 213, in main
scan, hosts = parse_nmap_xml(xml_file)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jth/Library/CloudStorage/Dropbox/Projects/nmap-did-what/data/nmap-to-sqlite.py", line 52, in parse_nmap_xml
for port in host.find('ports').findall('port'):
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'findall' ```
One or more hosts in your nmap output has no ports associated with it. Test with a single host, that you know has a port/s open. If that works, modify the script to skip hosts that do not have open ports.
That was it. Submitting a PR to try to add support for empty hosts.
I'm still having an issue though...with a scan of live-only hosts, I'm not seeing the details in my dashboard that you see. No services, open ports, etc.
Any ideas why this would be? Ran command nmap -sV -F -T4 -v --script=http-title,ssl-cert -oX home.xml -iL hosts.txt
Thanks, your fix looked good but have merged a fix with a bit cleaner code.
.