Land #2906, check a given range

bug/bundler_fix
Tod Beardsley 2014-01-24 16:01:57 -06:00
commit 856feb82e8
No known key found for this signature in database
GPG Key ID: 1EFFB682ADB9F193
1 changed files with 32 additions and 4 deletions

View File

@ -41,29 +41,57 @@ module ModuleCommandDispatcher
#
def cmd_check(*args)
defanged?
ip_range_arg = args.shift || ''
hosts = Rex::Socket::RangeWalker.new(ip_range_arg)
if hosts.ranges.blank?
# Check a single rhost
check_simple
else
# Check a range
last_rhost_opt = mod.rhost
begin
hosts.each do |ip|
mod.datastore['RHOST'] = ip
check_simple
end
ensure
# Restore the original rhost if set
mod.datastore['RHOST'] = last_rhost_opt
end
end
end
def check_simple
rhost = mod.rhost
rport = mod.rport
begin
code = mod.check_simple(
'LocalInput' => driver.input,
'LocalOutput' => driver.output)
if (code and code.kind_of?(Array) and code.length > 1)
if (code == Msf::Exploit::CheckCode::Vulnerable)
print_good(code[1])
print_good("#{rhost}:#{rport} - #{code[1]}")
else
print_status(code[1])
print_status("#{rhost}:#{rport} - #{code[1]}")
end
else
print_error("Check failed: The state could not be determined.")
print_error("#{rhost}:#{rport} - Check failed: The state could not be determined.")
end
rescue ::Interrupt
raise $!
rescue ::Exception => e
print_error("Exploit check failed: #{e.class} #{e}")
if(e.class.to_s != 'Msf::OptionValidateError')
print_error("Exploit check failed: #{e.class} #{e}")
print_error("Call stack:")
e.backtrace.each do |line|
break if line =~ /lib.msf.base.simple/
print_error(" #{line}")
end
else
print_error("#{rhost}:#{rport} - Exploit check failed: #{e.class} #{e}")
end
end
end