From 0c253ab0858cd2e07d38ca21ef1f12ba77d567b6 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 28 Feb 2019 05:50:27 -0600 Subject: [PATCH] add file: support for RHOSTS option on exploit modules --- lib/msf/ui/console/command_dispatcher/exploit.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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)