Closed trashgordon-zz closed 10 years ago
I see the XML did not get included. I can send that to you if you need.
yes you can send it over to mini.pelle@gmail.com. thanks for bug post
Quick fix, i need to get further with this (parsing
In [1]: from libnmap.parser import NmapParser In [2]: p = NmapParser.parse_fromfile("/vagrant/smb-os-test.xml") In [3]: h[0].scripts_results Out[3]: [{'id': 'smb-os-discovery', 'output': '\n OS: Windows 2000 (Windows 2000 LAN Manager)\n OS CPE: cpe:/o:microsoft:windows_2000::-\n Computer name: oracle\n NetBIOS computer name: ORACLE\n Domain name: acme.local\n FQDN: oracle.acme.local\n NetBIOS domain name: ACME\n System time: 2014-03-03T16:41:35+02:00\n'}]
ok... way better now...
Check change log: you now have
NmapHost.scripts_results (it's a property) and will produce the below output for your specific XML. you also have NmapService.scripts_results (again a property, it was formerly a method) and will produce similar output but for service specific nse scripts output.
See example with your xml:
In [1]: from libnmap.parser import NmapParser In [2]: p = NmapParser.parse_fromfile("/vagrant/smb-os-test.xml") In [3]: h = p.hosts.pop() In [4]: h.scripts_results Out[4]: [{'elements': {'cpe': 'cpe:/o:microsoft:windows_2000::-', 'date': '2014-03-03T16:41:35+02:00', 'domain': 'ACME', 'domain_dns': 'acme.local', 'fqdn': 'oracle.acme.local', 'lanmanager': 'Windows 2000 LAN Manager', 'os': 'Windows 5.0', 'server': 'ORACLE' } ,
Any feedback and more tests cases are most welcome.
@trashgordon did you tested this?
Yes, and it works great now. Thank you! And thank you for your great library!
I've downloaded straight from github as opposed to PIP install, and still have issue of dict showing {} when printing it out. I print out nmap_report = NmapParser.parse(nmap_proc.stdout), and see values in the XML.
What am I doing wrong :\?
[edit] got it figured out.
here is a gist of: nmap_report = NmapParser.parse(nmap_proc.stdout) that shows how to cycle through everything.
I ran an Nmap scan (outside of python-libnmap) as follows: nmap -p139,445 --script=smb-os-discovery -oX smb-os-test.xml 192.168.31.205
In the smb-os-test.xml file, I can see that the NSE script results are included:
<?xml version="1.0"?> <?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
However, anytime I use the following code to get the NSE script results, the dictionary returned is empty:
nmap_report = NmapParser.parse_fromfile('smb-os-test.xml') host = nmap_report.get_host_byid('192.168.31.205') svc = host.get_service(139) nse_results = svc.scripts_results() print nse_results
{}
This is what svc.get_dict() shows me: {'banner': '', 'id': 'tcp.139', 'port': '139', 'protocol': 'tcp', 'service': 'netbios-ssn', 'state': 'open'}
I also tried this for port 445, but get the same results. Am I doing something wrong? Let me know if you need any additional info.