Obtains and prints an NTP server's monitor data.
Monitor data is a list of the most recently used (MRU) having NTP associations with the target. Each record contains information about the most recent NTP packet sent by a host to the target including the source and destination addresses and the NTP version and mode of the packet. With this information it is possible to classify associated hosts as Servers, Peers, and Clients.
A Peers command is also sent to the target and the peers list in the response allows differentiation between configured Mode 1 Peers and clients which act like Peers (such as the Windows W32Time service).
Associated hosts are further classified as either public or private. Private hosts are those having IP addresses which are not routable on the public Internet and thus can help to form a picture about the topology of the private network on which the target resides.
Other information revealed by the monlist and peers commands are the host with which the target clock is synchronized and hosts which send Control Mode (6) and Private Mode (7) commands to the target and which may be used by admins for the NTP service.
It should be noted that the very nature of the NTP monitor data means that the
Mode 7 commands sent by this script are recorded by the target (and will often
appear in these results). Since the monitor data is a MRU list, it is probable
that you can overwrite the record of the Mode 7 command by sending an innocuous
looking Client Mode request. This can be achieved easily using Nmap:
nmap -sU -pU:123 -Pn -n --max-retries=0 <target>
- The monitor list in response to the monlist command is limited to 600 associations.
- The monitor capability may not be enabled on the target in which case you may receive an error number 4 (No Data Available).
- There may be a restriction on who can perform Mode 7 commands (e.g. "restrict noquery" in
ntp.conf) in which case you may not receive a reply.
- This script does not handle authenticating and targets expecting auth info may respond with error number 3 (Format Error).
nmap -sU -pU:123 -Pn -n --script=ntp-monlist <target>
PORT STATE SERVICE REASON 123/udp open ntp udp-response | ntp-monlist: | Target is synchronised with 127.127.38.0 (reference clock) | Alternative Target Interfaces: | 10.17.4.20 | Private Servers (0) | Public Servers (0) | Private Peers (0) | Public Peers (0) | Private Clients (2) | 10.20.8.69 169.254.138.63 | Public Clients (597) | 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 | ... | 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 | 188.8.131.52 | 2001:1400:0:0:0:0:0:1 2001:16d8:dd00:38:0:0:0:2 | 2002:db5a:bccd:1:21d:e0ff:feb7:b96f 2002:b6ef:81c4:0:0:1145:59c5:3682 | Other Associations (1) |_ 127.0.0.1 seen 1949869 times. last tx was unicast v2 mode 7
License: Same as Nmap--See http://nmap.org/book/man-legal.html
- action (host, port)
Send an NTPv2 Mode 7 'monlist' command to the target, receive any responses and parse records from those responses. If the target responds favourably then send a 'peers' command and parse the responses. Finally, categorise the discovered NTP associations (hosts) and output the interpreted results.