Land #9848, handle 'check' command on modules that do not implement it

GSoC/Meterpreter_Web_Console
Brent Cook 2018-04-09 22:27:21 -05:00
commit c525bc3c0a
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
1 changed files with 13 additions and 3 deletions

View File

@ -217,9 +217,16 @@ module ModuleCommandDispatcher
end end
begin begin
code = instance.check_simple( if instance.respond_to?(:check_simple)
'LocalInput' => driver.input, code = instance.check_simple(
'LocalOutput' => driver.output) 'LocalInput' => driver.input,
'LocalOutput' => driver.output
)
else
msg = "Check failed: #{instance.type.capitalize} modules do not support check."
raise NotImplementedError, msg
end
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("#{peer} #{code[1]}") print_good("#{peer} #{code[1]}")
@ -240,6 +247,9 @@ module ModuleCommandDispatcher
rescue ::RuntimeError => e rescue ::RuntimeError => e
# Some modules raise RuntimeError but we don't necessarily care about those when we run check() # Some modules raise RuntimeError but we don't necessarily care about those when we run check()
elog("#{e.message}\n#{e.backtrace.join("\n")}") elog("#{e.message}\n#{e.backtrace.join("\n")}")
rescue ::NotImplementedError => e
print_error(e.message)
elog("#{e.message}\n#{e.backtrace.join("\n")}")
rescue ::Exception => e rescue ::Exception => e
print_error("Check failed: #{e.class} #{e}") print_error("Check failed: #{e.class} #{e}")
elog("#{e.message}\n#{e.backtrace.join("\n")}") elog("#{e.message}\n#{e.backtrace.join("\n")}")