60 lines
1.6 KiB
Ruby
60 lines
1.6 KiB
Ruby
# -*- coding: binary -*-
|
|
|
|
module Msf
|
|
module Exploit::Remote::AutoCheck
|
|
|
|
def initialize(info = {})
|
|
super
|
|
|
|
register_advanced_options([
|
|
OptBool.new('AutoCheck', [false, 'Run check before exploitation', true]),
|
|
OptBool.new('ForceExploit', [false, 'Override check result', false])
|
|
])
|
|
end
|
|
|
|
def exploit
|
|
unless datastore['AutoCheck']
|
|
print_warning('AutoCheck is disabled, proceeding with exploitation')
|
|
return super
|
|
end
|
|
|
|
print_status('Executing automatic check (disable AutoCheck to override)')
|
|
|
|
warning_msg = 'ForceExploit is enabled, proceeding with exploitation.'
|
|
error_msg = 'Enable ForceExploit to override check result.'
|
|
|
|
case (checkcode = check)
|
|
when Exploit::CheckCode::Vulnerable, Exploit::CheckCode::Appears
|
|
print_good(checkcode.message)
|
|
super
|
|
when Exploit::CheckCode::Detected
|
|
print_warning(checkcode.message)
|
|
super
|
|
when Exploit::CheckCode::Safe
|
|
if datastore['ForceExploit']
|
|
print_warning("#{checkcode.message} #{warning_msg}")
|
|
return super
|
|
end
|
|
|
|
fail_with(Module::Failure::NotVulnerable,
|
|
"#{checkcode.message} #{error_msg}")
|
|
when Exploit::CheckCode::Unsupported
|
|
if datastore['ForceExploit']
|
|
print_warning("#{checkcode.message} #{warning_msg}")
|
|
return super
|
|
end
|
|
|
|
fail_with(Module::Failure::BadConfig, "#{checkcode.message} #{error_msg}")
|
|
else
|
|
if datastore['ForceExploit']
|
|
print_warning("#{checkcode.message} #{warning_msg}")
|
|
return super
|
|
end
|
|
|
|
fail_with(Module::Failure::Unknown, "#{checkcode.message} #{error_msg}")
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|