Files
metasploit-gs/lib/msf/core/exploit/auto_check.rb
T

54 lines
1.6 KiB
Ruby

# -*- coding: binary -*-
require 'msf/core/exploit'
require 'msf/core/module/failure'
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)')
# This isn't even my final form!
case (checkcode = check)
when Exploit::CheckCode::Vulnerable, Exploit::CheckCode::Appears
print_good(checkcode.message)
return super
when Exploit::CheckCode::Detected
print_warning(checkcode.message)
return super
when Exploit::CheckCode::Safe
print_warning(checkcode.message)
return super if datastore['ForceExploit']
fail_with(Module::Failure::NotVulnerable,
"#{checkcode.message} Disable ForceExploit to override.")
when Exploit::CheckCode::Unsupported
print_warning(checkcode.message)
return super if datastore['ForceExploit']
fail_with(Module::Failure::BadConfig,
"#{checkcode.message} Disable ForceExploit to override.")
else
print_warning(checkcode.message)
return super if datastore['ForceExploit']
fail_with(Module::Failure::Unknown,
"#{checkcode.message} Disable ForceExploit to override.")
end
end
end
end