Land #2906, check a given range
commit
856feb82e8
|
@ -41,29 +41,57 @@ module ModuleCommandDispatcher
|
||||||
#
|
#
|
||||||
def cmd_check(*args)
|
def cmd_check(*args)
|
||||||
defanged?
|
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
|
begin
|
||||||
code = mod.check_simple(
|
code = mod.check_simple(
|
||||||
'LocalInput' => driver.input,
|
'LocalInput' => driver.input,
|
||||||
'LocalOutput' => driver.output)
|
'LocalOutput' => driver.output)
|
||||||
if (code and code.kind_of?(Array) and code.length > 1)
|
if (code and code.kind_of?(Array) and code.length > 1)
|
||||||
if (code == Msf::Exploit::CheckCode::Vulnerable)
|
if (code == Msf::Exploit::CheckCode::Vulnerable)
|
||||||
print_good(code[1])
|
print_good("#{rhost}:#{rport} - #{code[1]}")
|
||||||
else
|
else
|
||||||
print_status(code[1])
|
print_status("#{rhost}:#{rport} - #{code[1]}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print_error("Check failed: The state could not be determined.")
|
print_error("#{rhost}:#{rport} - Check failed: The state could not be determined.")
|
||||||
end
|
end
|
||||||
rescue ::Interrupt
|
rescue ::Interrupt
|
||||||
raise $!
|
raise $!
|
||||||
rescue ::Exception => e
|
rescue ::Exception => e
|
||||||
print_error("Exploit check failed: #{e.class} #{e}")
|
|
||||||
if(e.class.to_s != 'Msf::OptionValidateError')
|
if(e.class.to_s != 'Msf::OptionValidateError')
|
||||||
|
print_error("Exploit check failed: #{e.class} #{e}")
|
||||||
print_error("Call stack:")
|
print_error("Call stack:")
|
||||||
e.backtrace.each do |line|
|
e.backtrace.each do |line|
|
||||||
break if line =~ /lib.msf.base.simple/
|
break if line =~ /lib.msf.base.simple/
|
||||||
print_error(" #{line}")
|
print_error(" #{line}")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
print_error("#{rhost}:#{rport} - Exploit check failed: #{e.class} #{e}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue