Resend as the formatting was terrible - this is better but still not great :-(
I am trying to scan for and retrieve the NTP-MONLIST Results.
I end with with a KEYERROR when trying to reference the NTP-MONLIST results.
Please see below my scripts and testing.
Any guidance will be much appreciated!
-John
When I run the nmap command manually I get the results as part of the XML results:
++++++++++++
/usr/bin/nmap -oX - -vvv --stats-every 2s -sU -pU:123 -n -Pn --script=ntp-monlist 127.0.0.1
<?xml version="1.0"?>
<?xml-stylesheet href="file:///usr/share/nmap/nmap.xsl" type="text/xsl"?>
++++++++++++
This is my script:
++++++++++++
!/usr/bin/python
from libnmap.process import NmapProcess
from libnmap.parser import NmapParser, NmapParserException
from libnmap.objects import NmapReport, NmapHost, NmapService
Hi
Resend as the formatting was terrible - this is better but still not great :-(
I am trying to scan for and retrieve the NTP-MONLIST Results.
I end with with a KEYERROR when trying to reference the NTP-MONLIST results.
Please see below my scripts and testing.
Any guidance will be much appreciated!
-John
When I run the nmap command manually I get the results as part of the XML results: ++++++++++++ /usr/bin/nmap -oX - -vvv --stats-every 2s -sU -pU:123 -n -Pn --script=ntp-monlist 127.0.0.1 <?xml version="1.0"?> <?xml-stylesheet href="file:///usr/share/nmap/nmap.xsl" type="text/xsl"?>
++++++++++++
This is my script:
++++++++++++
!/usr/bin/python
from libnmap.process import NmapProcess from libnmap.parser import NmapParser, NmapParserException from libnmap.objects import NmapReport, NmapHost, NmapService
def do_scan(targets, options): nm = NmapProcess(targets, options, safe_mode=False) rc = nm.run() if rc != 0: print "nmap scan failed: %s" % (nm.stderr)
def print_scan(nmap_report): print "Starting Nmap {0} ( http://nmap.org ) at {1}".format( nmap_report._nmaprun['version'], nmap_report._nmaprun['startstr'])
if name == "main": global DEBUG DEBUG = 0
TGTHOST = "127.0.0.1" TGTPROTO = "udp" NMAP_PROTO = " -sU -pU:" TGTPORT = 123
report = do_scan(TGTHOST, NMAP_PROTO + str(TGTPORT) + " -n -Pn --script=ntp-monlist ")
print_scan(report) ++++++++++++++++++++++
This is the output I get when I run this script from the command_line:
[root@localhost python]# ./libnmap_testing.py Starting Nmap 5.51 ( http://nmap.org ) at Fri May 16 13:10:26 2014 Nmap scan report for 127.0.0.1 (127.0.0.1) Host is up. PORT STATE SERVICE 123/udp open ntp Nmap done at Fri May 16 13:10:26 2014; 1 IP address (1 host up) scanned in 0.08 seconds ++++++++++++++++++++++ nmap_report.commandline: /usr/bin/nmap -oX - -vvv --stats-every 2s -sU -pU:123 -n -Pn --script=ntp-monlist 127.0.0.1 ++++++++++++++++++++++ HOST.address: 127.0.0.1 HOST.mac:
print_scan(report)
File "./libnmap_testing.py", line 57, in print_scan
print "HOST.scripts_results: ", (host.scripts_results['ntp-monlist'])
KeyError: 'ntp-monlist'
++++++++++++++++++++++
HOST.scripts_results: Traceback (most recent call last): File "./libnmap_testing.py", line 76, in