Module: Msf::Exploit::Remote::CheckModule

Defined in:
lib/msf/core/exploit/check_module.rb

Instance Method Summary collapse

Instance Method Details

#checkMsf::Exploit::CheckCode

When this mixin is included, this method becomes the exploit's check method

Returns:


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/msf/core/exploit/check_module.rb', line 21

def check
  # Instantiate the module
  mod = framework.modules.create(check_module)

  # Bail if we couldn't
  unless mod
    return Exploit::CheckCode::Unsupported(
      "Could not instantiate #{check_module}."
    )
  end

  # Bail if it isn't aux
  if mod.type != Msf::MODULE_AUX
    return Exploit::CheckCode::Unsupported(
      "#{check_module} is not an auxiliary module."
    )
  end

  # Bail if run isn't defined
  unless mod.respond_to?(:run)
    return Exploit::CheckCode::Unsupported(
      "#{check_module} does not define a run method."
    )
  end

  print_status("Using #{check_module} as check")

  # Retrieve the module's return value
  res = mod.run_simple(
    'LocalInput'  => user_input,
    'LocalOutput' => user_output,
    'Options'     => datastore # XXX: This clobbers the datastore!
  )

  # Ensure return value is a CheckCode
  case res
  when Exploit::CheckCode
    # Return the CheckCode
    res
  when Hash
    # XXX: Find CheckCode associated with RHOST, which is set automatically
    checkcode = res[datastore['RHOST']]

    # Bail if module doesn't return a CheckCode
    unless checkcode.kind_of?(Exploit::CheckCode)
      return Exploit::CheckCode::Unsupported(
        "#{check_module} does not return a CheckCode."
      )
    end

    # Return the CheckCode
    checkcode
  else
    # Bail if module doesn't return a CheckCode
    Exploit::CheckCode::Unsupported(
      "#{check_module} does not return a CheckCode."
    )
  end
end

#check_moduleObject


81
82
83
# File 'lib/msf/core/exploit/check_module.rb', line 81

def check_module
  datastore['CheckModule']
end

#initialize(info = {}) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/msf/core/exploit/check_module.rb', line 10

def initialize(info = {})
  super

  register_advanced_options([
    OptString.new('CheckModule', [true, 'Module to check with'])
  ])
end