mrschyte / nmap-converter

Python script for converting nmap reports into XLS
BSD 2-Clause "Simplified" License
336 stars 87 forks source link

Error procesing xml with nmap -sn option #5

Closed fearx135 closed 4 years ago

fearx135 commented 4 years ago

Hello I've tried to pass to a xls a xml file but the nmap result is with a "-sn" option (no port scan)

I've excecuted the following command; nmap -sn script=whois-domain -iL targets.txt -oA nmap/nmap_targets

There is no issue in the resulting xml,

but when I try to pass the xml to xls this is the following error (I thing it has to do with the fact that can make a summary sheet, because there are no ports)

>python nmap-converter-master\nmap-converter.py "location\nmap_whoisdomain.xml" -o test.xls
Traceback (most recent call last):
  File "nmap-converter-master\nmap-converter.py", line 186, in <module>
    main(reports, workbook)
  File "nmap-converter-master\nmap-converter.py", line 161, in main
    sheet_func(workbook, sheet, report)
  File "nmap-converter-master\nmap-converter.py", line 55, in generate_summary
    sheet.write(sheet.lastrow + 1, idx, summary_body[item](report))
  File "nmap-converter-master\nmap-converter.py", line 45, in <lambda>
    "Scan Type": lambda report: report.scan_type,
  File "D:\Programas\Python\Python37\lib\site-packages\libnmap\objects\report.py", line 113, in scan_type
    return self._scaninfo['type']
KeyError: 'type'
mrschyte commented 4 years ago

Thanks for reporting this issue. I've made some changes to the script so that it now works without scan results. I've also patched it to include results form host scripts such as the "whois-domain" script you're trying to run.

Unfortunately I don't think this will help you much as the "whois-domain" script doesn't include its full output in the XML. For example this is the complete output saved by the script for a domain:

<hostscript>
  <script id="whois-domain"
    output="&#xa;&#xa;Domain name record found at whois.nic.hu&#xa;% Whois server 3.0 serving the hu ccTLD&#xd;&#xa;"/>
</hostscript>