7
7
8
8
class Metasploit3 < Msf ::Auxiliary
9
9
10
-
11
- include Msf ::Exploit ::Remote ::Udp
12
10
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
15
15
16
16
def initialize ( info = { } )
17
17
super ( update_info ( info ,
@@ -29,39 +29,51 @@ def initialize(info = {})
29
29
]
30
30
)
31
31
)
32
- register_options (
33
- [
34
- Opt ::RPORT ( 123 )
35
- ] , self . class )
36
32
end
37
33
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
39
39
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
41
47
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
+ )
44
59
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
+ } )
58
73
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 } " )
61
75
end
62
76
end
63
- disconnect_udp
64
-
65
77
end
66
78
67
79
end
0 commit comments