added option validation to check path

git-svn-id: file:///home/svn/framework3/trunk@4536 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2007-03-17 19:39:30 +00:00
parent 207b1aec83
commit d8dc31be15
3 changed files with 40 additions and 8 deletions

View File

@ -127,6 +127,38 @@ module Exploit
Msf::Simple::Exploit.exploit_simple(self, opts)
end
#
# Initiates a check, setting up the exploit to be used. The following
# options can be specified:
#
# LocalInput
#
# The local input handle that data can be read in from.
#
# LocalOutput
#
# The local output through which data can be displayed.
#
def self.check_simple(mod, opts)
if opts['LocalInput']
mod.init_ui(opts['LocalInput'], opts['LocalOutput'])
end
# Validate the option container state so that options will
# be normalized
mod.validate
# Run check
mod.check
end
#
# Calls the class method.
#
def check_simple(opts)
Msf::Simple::Exploit.check_simple(self, opts)
end
end
end

View File

@ -49,11 +49,9 @@ class Exploit
begin
mod.init_ui(
driver.input,
driver.output)
code = mod.check
code = mod.check_simple(
'LocalInput' => driver.input,
'LocalOutput' => driver.output)
if (code)
stat = '[*]'
@ -68,7 +66,7 @@ class Exploit
"Check failed: The state could not be determined.")
end
rescue
log_error("Check failed: #{$!}.")
log_error("Check failed: #{$!}")
ensure
mod.reset_ui
end

6
msfcli
View File

@ -86,7 +86,7 @@ end
# Get the module name we'll be using
exploit_name = ARGV.shift
exploit = nil
module_class = nil
module_class = "exploit"
# Process special var/val pairs...
Msf::Ui::Common.process_cli_arguments($framework, ARGV)
@ -153,7 +153,9 @@ case mode.downcase
when "c"
if (module_class == 'exploit')
begin
if (code = exploit.check)
if (code = exploit.check_simple(
'LocalInput' => Rex::Ui::Text::Input::Stdio.new,
'LocalOutput' => Rex::Ui::Text::Output::Stdio.new))
stat = (code == Msf::Exploit::CheckCode::Vulnerable) ? '[+]' : '[*]'
$stdout.puts("#{stat} #{code[1]}")