Skip to content

Commit 6f03f66

Browse files
committed
Support only fuzzing specific mode 6 operations
1 parent 8fa81de commit 6f03f66

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

modules/auxiliary/fuzzers/ntp/ntp_protocol_fuzzer.rb

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Metasploit3 < Msf::Auxiliary
1515

1616
NTP_SUPPORTED_VERSIONS = (0..7).to_a
1717
NTP_SUPPORTED_MODES = (0..7).to_a
18+
NTP_SUPPORTED_MODE_6_OPERATIONS = (0..31).to_a
1819
NTP_SUPPORTED_MODE_7_IMPLEMENTATIONS = (0..255).to_a
1920
NTP_SUPPORTED_MODE_7_REQUEST_CODES = (0..255).to_a
2021

@@ -53,6 +54,7 @@ def initialize
5354
Opt::RPORT(123),
5455
OptString.new('VERSIONS', [true, 'Versions to fuzz', [3,2,4]]),
5556
OptString.new('MODES', [true, 'Modes to fuzz', NTP_SUPPORTED_MODES]),
57+
OptString.new('MODE_6_OPERATIONS', [true, 'Mode 6 operations to fuzz', NTP_SUPPORTED_MODE_6_OPERATIONS]),
5658
OptString.new('MODE_7_IMPLEMENTATIONS', [true, 'Mode 7 implementations to fuzz', [3,2,0]]),
5759
OptString.new('MODE_7_REQUEST_CODES', [true, 'Mode 7 request codes to fuzz', (0..45).to_a]),
5860
OptInt.new('SLEEP', [true, 'Sleep for this many ms between requests', 0]),
@@ -174,13 +176,17 @@ def run_host(ip)
174176
@modes = datastore['MODES'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
175177
unsupported_modes = @modes - NTP_SUPPORTED_MODES
176178
fail "Unsupported NTP modes: #{unsupported_modes}" unless unsupported_modes.empty?
179+
# parse and sanity check mode 6 operations
180+
@mode_6_operations = datastore['MODE_6_OPERATIONS'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
181+
unsupported_ops = @mode_6_operations - NTP_SUPPORTED_MODE_6_OPERATIONS
182+
fail "Unsupported NTP mode 6 operations: #{unsupported_ops}" unless unsupported_ops.empty?
177183
# parse and sanity check mode 7 implementations
178-
@implementations = datastore['MODE_7_IMPLEMENTATIONS'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
179-
unsupported_implementations = @implementations - NTP_SUPPORTED_MODE_7_IMPLEMENTATIONS
180-
fail "Unsupported NTP mode 7implementations: #{unsupported_implementations}" unless unsupported_implementations.empty?
181-
# parse and sanity check mode 7 REQUEST_CODES
182-
@request_codes = datastore['MODE_7_REQUEST_CODES'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
183-
unsupported_request_codes = @request_codes - NTP_SUPPORTED_MODE_7_REQUEST_CODES
184+
@mode_7_implementations = datastore['MODE_7_IMPLEMENTATIONS'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
185+
unsupported_implementations = @mode_7_implementations - NTP_SUPPORTED_MODE_7_IMPLEMENTATIONS
186+
fail "Unsupported NTP mode 7 implementations: #{unsupported_implementations}" unless unsupported_implementations.empty?
187+
# parse and sanity check mode 7 request codes
188+
@mode_7_request_codes = datastore['MODE_7_REQUEST_CODES'].split(/[^\d]/).select { |m| !m.empty? }.map { |v| v.to_i }
189+
unsupported_request_codes = @mode_7_request_codes - NTP_SUPPORTED_MODE_7_REQUEST_CODES
184190
fail "Unsupported NTP mode 7 request codes: #{unsupported_request_codes}" unless unsupported_request_codes.empty?
185191

186192
connect_udp
@@ -197,7 +203,7 @@ def run_host(ip)
197203
def fuzz_control(host)
198204
@versions.each do |version|
199205
print_status("#{host}:#{rport} fuzzing version #{version} control messages (mode 6)")
200-
0.upto(31) do |op|
206+
@mode_6_operations.each do |op|
201207
request = build_ntp_control(version, op)
202208
what = "#{request.size}-byte version #{version} mode 6 op #{op} message"
203209
vprint_status("#{host}:#{rport} probing with #{request.size}-byte #{what}")
@@ -212,8 +218,8 @@ def fuzz_control(host)
212218
def fuzz_private(host)
213219
@versions.each do |version|
214220
print_status("#{host}:#{rport} fuzzing version #{version} private messages (mode 7)")
215-
@implementations.each do |implementation|
216-
@request_codes.each do |request_code|
221+
@mode_7_implementations.each do |implementation|
222+
@mode_7_request_codes.each do |request_code|
217223
request = build_ntp_private(version, implementation, request_code, "\x00"*188)
218224
what = "#{request.size}-byte version #{version} mode 7 imp #{implementation} req #{request_code} message"
219225
vprint_status("#{host}:#{rport} probing with #{request.size}-byte #{what}")

0 commit comments

Comments
 (0)