Skip to content

Commit e8c3a61

Browse files
committed
Land rapid7#7405, nil fix for ntp_protocol_fuzzer
2 parents 60ea0bd + b95cc7b commit e8c3a61

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/auxiliary/fuzzers/ntp/ntp_protocol_fuzzer.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ def initialize
5353
register_advanced_options(
5454
[
5555
OptString.new('VERSIONS', [false, 'Specific versions to fuzz (csv)', '2,3,4']),
56-
OptString.new('MODES', [false, 'Modes to fuzz (csv)', nil]),
57-
OptString.new('MODE_6_OPERATIONS', [false, 'Mode 6 operations to fuzz (csv)', nil]),
58-
OptString.new('MODE_7_IMPLEMENTATIONS', [false, 'Mode 7 implementations to fuzz (csv)', nil]),
59-
OptString.new('MODE_7_REQUEST_CODES', [false, 'Mode 7 request codes to fuzz (csv)', nil])
56+
OptString.new('MODES', [false, 'Modes to fuzz (csv)']),
57+
OptString.new('MODE_6_OPERATIONS', [false, 'Mode 6 operations to fuzz (csv)']),
58+
OptString.new('MODE_7_IMPLEMENTATIONS', [false, 'Mode 7 implementations to fuzz (csv)']),
59+
OptString.new('MODE_7_REQUEST_CODES', [false, 'Mode 7 request codes to fuzz (csv)'])
6060
], self.class)
6161
end
6262

@@ -68,7 +68,7 @@ def check_and_set(setting)
6868
thing = setting.upcase
6969
const_name = thing.to_sym
7070
var_name = thing.downcase
71-
if datastore.key?(thing)
71+
if datastore[thing]
7272
instance_variable_set("@#{var_name}", datastore[thing].split(/[^\d]/).select { |v| !v.empty? }.map { |v| v.to_i })
7373
unsupported_things = instance_variable_get("@#{var_name}") - Rex::Proto::NTP.const_get(const_name)
7474
fail "Unsupported #{thing}: #{unsupported_things}" unless unsupported_things.empty?
@@ -178,7 +178,11 @@ def fuzz_version_mode(host, short)
178178
# Sends +message+ to +host+ on UDP port +port+, returning all replies
179179
def probe(host, port, message)
180180
replies = []
181-
udp_sock.sendto(message, host, port, 0)
181+
begin
182+
udp_sock.sendto(message, host, port, 0)
183+
rescue ::Errno::EISCONN
184+
udp_sock.write(message)
185+
end
182186
reply = udp_sock.recvfrom(65535, datastore['WAIT'] / 1000.0)
183187
while reply && reply[1]
184188
replies << reply

0 commit comments

Comments
 (0)