lib/msf/core/exploit/check_module.rb
# When this mixin is included, this method becomes the exploit's check method
#
# @return [Msf::Exploit::CheckCode] Whether or not the target is vulnerable
When this mixin is included, this method becomes the exploit's check method
When this mixin is included this method becomes the exploit ' s check method
def check
    mod = framework.modules.create(check_module)
    unless mod
      return CheckCode::Unsupported("Could not instantiate #{check_module}")
    end
    if mod.respond_to?(:run_host)
      meth = :run_host
    elsif mod.respond_to?(:run)
      meth = :run
    else
      return CheckCode::Unsupported("#{check_module} does not define a run_host/run method")
    end
    %w[RHOSTS RHOST RPORT].each do |opt|
      next unless datastore[opt]
      mod.datastore[opt] = datastore[opt].dup
    end
    mod.options.validate(mod.datastore)
    mod.user_input, mod.user_output = user_input, user_output
    checkcode =
      case meth
      when :run_host
        mod.run_host(rhost)
      when :run
        mod.run
      end
    unless checkcode.kind_of?(Exploit::CheckCode)
      print_warning("#{check_module} does not return a CheckCode")
      return Exploit::CheckCode::Unsupported
    end
    checkcode
  end
def check mod = framework . modules . create ( check_module ) unless mod return CheckCode :: Unsupported ( "Could not instantiate #{check_module}" ) end if mod . respond_to? ( :run_host ) meth = :run_host elsif mod . respond_to? ( :run ) meth = :run else return CheckCode :: Unsupported ( "#{check_module} does not define a run_host/run method" ) end %w[ RHOSTS RHOST RPORT ] . each do | opt | next unless datastore [ opt ] mod . datastore [ opt ] = datastore [ opt ] . dup end mod . options . validate ( mod . datastore ) mod . user_input , mod . user_output = user_input , user_output checkcode = case meth when :run_host mod . run_host ( rhost ) when :run mod . run end unless checkcode . kind_of? ( Exploit :: CheckCode ) print_warning ( "#{check_module} does not return a CheckCode" ) return Exploit :: CheckCode :: Unsupported end checkcode end
When this mixin is included, this method becomes the exploit's check method
When this mixin is included this method becomes the exploit ' s check method
# Instantiate the module # Bail if we couldn't # Bail if run_host/run isn't defined # Add the exploit's targeting options to the module's datastore # Bail if module options don't validate # Use the exploit's input and output as the module's # Use the module's CheckCode # Bail if module doesn't return a CheckCode # Return the CheckCode
Whether or not the target is vulnerable
Whether or not the target is vulnerable
Msf::Exploit::CheckCode