Files
metasploit-gs/lib/msf/core/exploit/auto_check.rb
T
2020-07-01 14:20:04 -05:00

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