Skip to content

Commit 0715c67

Browse files
committed
Update NTP readvar module to detect DRDoS, UDPScanner to be faster
1 parent 6f50ef5 commit 0715c67

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

modules/auxiliary/scanner/ntp/ntp_readvar.rb

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
class Metasploit3 < Msf::Auxiliary
99

10-
11-
include Msf::Exploit::Remote::Udp
1210
include Msf::Auxiliary::Report
13-
include Msf::Auxiliary::Scanner
14-
11+
include Msf::Exploit::Remote::Udp
12+
include Msf::Auxiliary::UDPScanner
13+
include Msf::Auxiliary::NTP
14+
include Msf::Auxiliary::DRDoS
1515

1616
def initialize(info = {})
1717
super(update_info(info,
@@ -29,39 +29,51 @@ def initialize(info = {})
2929
]
3030
)
3131
)
32-
register_options(
33-
[
34-
Opt::RPORT(123)
35-
], self.class)
3632
end
3733

38-
def run_host(ip)
34+
# Called for each response packet
35+
def scanner_process(data, shost, sport)
36+
@results[shost] ||= []
37+
@results[shost] << Rex::Proto::NTP::NTPControl.new(data)
38+
end
3939

40-
connect_udp
40+
# Called before the scan block
41+
def scanner_prescan(batch)
42+
@results = {}
43+
@probe = Rex::Proto::NTP::NTPControl.new
44+
@probe.version = datastore['VERSION']
45+
@probe.operation = 2
46+
end
4147

42-
readvar = "\x16\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" #readvar command
43-
print_status("Connecting target #{rhost}:#{rport}...")
48+
# Called after the scan block
49+
def scanner_postscan(batch)
50+
@results.keys.each do |k|
51+
# TODO: check to see if any of the responses are actually NTP before reporting
52+
report_service(
53+
:host => k,
54+
:proto => 'udp',
55+
:port => rport,
56+
:name => 'ntp',
57+
:info => @results[k].map { |r| r.payload }.join.inspect
58+
)
4459

45-
print_status("Sending command")
46-
udp_sock.put(readvar)
47-
reply = udp_sock.recvfrom(65535, 0.1)
48-
if not reply or reply[0].empty?
49-
print_error("#{rhost}:#{rport} - Couldn't read NTP variables")
50-
return
51-
end
52-
p_reply = reply[0].split(",")
53-
arr_count = 0
54-
while ( arr_count < p_reply.size)
55-
if arr_count == 0
56-
print_good("#{rhost}:#{rport} - #{p_reply[arr_count].slice(12,p_reply[arr_count].size)}") #12 is the adjustment of packet garbage
57-
arr_count = arr_count + 1
60+
peer = "#{k}:#{rport}"
61+
response_map = { @probe => @results[k] }
62+
vulnerable, proof = prove_amplification(response_map)
63+
what = 'NTP Mode 6 READVAR DRDoS'
64+
if vulnerable
65+
print_good("#{peer} - Vulnerable to #{what}: #{proof}")
66+
report_vuln({
67+
:host => k,
68+
:port => rport,
69+
:proto => 'udp',
70+
:name => what,
71+
:refs => self.references
72+
})
5873
else
59-
print_good("#{rhost}:#{rport} - #{p_reply[arr_count].strip}")
60-
arr_count = arr_count + 1
74+
vprint_status("#{peer} - Not vulnerable to #{what}: #{proof}")
6175
end
6276
end
63-
disconnect_udp
64-
6577
end
6678

6779
end

0 commit comments

Comments
 (0)