Path: blob/master/modules/auxiliary/scanner/ntp/ntp_readvar.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Report7include Msf::Exploit::Remote::Udp8include Msf::Auxiliary::UDPScanner9include Msf::Auxiliary::NTP10include Msf::Auxiliary::DRDoS1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'NTP Clock Variables Disclosure',17'Description' => %q{18This module reads the system internal NTP variables. These variables contain19potentially sensitive information, such as the NTP software version, operating20system version, peers, and more.21},22'Author' => [23'Ewerson Guimaraes(Crash) <crash[at]dclabs.com.br>', # original Metasploit module24'Jon Hart <jon_hart[at]rapid7.com>' # UDPScanner version for faster scans25],26'License' => MSF_LICENSE,27'References' => [28['CVE', '2013-5211'], # see also scanner/ntp/ntp_monlist.rb29[ 'URL', 'https://www.rapid7.com/db/vulnerabilities/ntp-clock-variables-disclosure/' ]30],31'Notes' => {32'Reliability' => UNKNOWN_RELIABILITY,33'Stability' => UNKNOWN_STABILITY,34'SideEffects' => UNKNOWN_SIDE_EFFECTS35}36)37)38end3940def scanner_process(data, shost, _sport)41@results[shost] ||= []42@results[shost] << Rex::Proto::NTP::NTPControl.new.read(data)43end4445def scan_host(ip)46if spoofed?47datastore['ScannerRecvWindow'] = 048scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])49else50scanner_send(@probe, ip, datastore['RPORT'])51end52end5354def scanner_prescan(batch)55@results = {}56print_status("Sending NTP v2 READVAR probes to #{batch[0]}->#{batch[-1]} (#{batch.length} hosts)")57@probe = Rex::Proto::NTP::NTPControl.new58@probe.version = datastore['VERSION']59@probe.operation = 260end6162def scanner_postscan(_batch)63@results.keys.each do |k|64# TODO: check to see if any of the responses are actually NTP before reporting65report_service(66host: k,67proto: 'udp',68port: rport,69name: 'ntp',70info: @results[k].map { |r| r.payload.slice(0, r.payload_size) }.join.inspect71)7273peer = "#{k}:#{rport}"74response_map = { @probe => @results[k] }75vulnerable, proof = prove_amplification(response_map)76what = 'NTP Mode 6 READVAR DRDoS'77if vulnerable78print_good("#{peer} - Vulnerable to #{what}: #{proof}")79report_vuln(80host: k,81port: rport,82proto: 'udp',83name: what,84refs: references85)86else87vprint_status("#{peer} - Not vulnerable to #{what}: #{proof}")88end89end90end91end929394