diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index 25216a9d4e..e17a2b4706 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -165,9 +165,12 @@ class Exploit end rhosts = mod.datastore['RHOSTS'] - rhosts_range = Rex::Socket::RangeWalker.new(rhosts) + if rhosts + rhosts_opt = Msf::OptAddressRange.new('RHOSTS') + rhosts_range = Rex::Socket::RangeWalker.new(rhosts_opt.normalize(rhosts)) + end # For multiple targets exploit attempts. - if rhosts && rhosts_range.length.to_i > 1 + if rhosts_range && rhosts_range.length > 1 opts[:multi] = true rhosts_range.each do |rhost| nmod = mod.replicant @@ -196,7 +199,7 @@ class Exploit # For single target or no rhosts option. else # avoid bug when the cidr of rhosts is 32, like 8.8.8.8/32 - if rhosts_range.length == 1 + if rhosts_range && rhosts_range.length == 1 mod.datastore['RHOST'] = (Rex::Socket.addr_itoa(rhosts_range.ranges.first.start)) end session = exploit_single(mod, opts)