Skip to content

Commit

Permalink
Set correct default options; fix usage on OS X
Browse files Browse the repository at this point in the history
Fixes 7404
  • Loading branch information
jhart-r7 committed Oct 5, 2016
1 parent 035e688 commit b95cc7b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/auxiliary/fuzzers/ntp/ntp_protocol_fuzzer.rb
Expand Up @@ -53,10 +53,10 @@ def initialize
register_advanced_options(
[
OptString.new('VERSIONS', [false, 'Specific versions to fuzz (csv)', '2,3,4']),
OptString.new('MODES', [false, 'Modes to fuzz (csv)', nil]),
OptString.new('MODE_6_OPERATIONS', [false, 'Mode 6 operations to fuzz (csv)', nil]),
OptString.new('MODE_7_IMPLEMENTATIONS', [false, 'Mode 7 implementations to fuzz (csv)', nil]),
OptString.new('MODE_7_REQUEST_CODES', [false, 'Mode 7 request codes to fuzz (csv)', nil])
OptString.new('MODES', [false, 'Modes to fuzz (csv)']),
OptString.new('MODE_6_OPERATIONS', [false, 'Mode 6 operations to fuzz (csv)']),
OptString.new('MODE_7_IMPLEMENTATIONS', [false, 'Mode 7 implementations to fuzz (csv)']),
OptString.new('MODE_7_REQUEST_CODES', [false, 'Mode 7 request codes to fuzz (csv)'])
], self.class)
end

Expand All @@ -68,7 +68,7 @@ def check_and_set(setting)
thing = setting.upcase
const_name = thing.to_sym
var_name = thing.downcase
if datastore.key?(thing)
if datastore[thing]
instance_variable_set("@#{var_name}", datastore[thing].split(/[^\d]/).select { |v| !v.empty? }.map { |v| v.to_i })
unsupported_things = instance_variable_get("@#{var_name}") - Rex::Proto::NTP.const_get(const_name)
fail "Unsupported #{thing}: #{unsupported_things}" unless unsupported_things.empty?
Expand Down Expand Up @@ -178,7 +178,11 @@ def fuzz_version_mode(host, short)
# Sends +message+ to +host+ on UDP port +port+, returning all replies
def probe(host, port, message)
replies = []
udp_sock.sendto(message, host, port, 0)
begin
udp_sock.sendto(message, host, port, 0)
rescue ::Errno::EISCONN
udp_sock.write(message)
end
reply = udp_sock.recvfrom(65535, datastore['WAIT'] / 1000.0)
while reply && reply[1]
replies << reply
Expand Down

0 comments on commit b95cc7b

Please sign in to comment.