Class: Msf::Modules::External

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/modules/external.rb,
lib/msf/core/modules/external/bridge.rb

Overview

Namespace for loading external Metasploit modules

Defined Under Namespace

Modules: CLI Classes: Bridge, GoBridge, Message, PyBridge, RbBridge, Shim

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(module_path, framework: nil) ⇒ External

Returns a new instance of External.



16
17
18
19
# File 'lib/msf/core/modules/external.rb', line 16

def initialize(module_path, framework: nil)
  self.path = module_path
  self.framework = framework
end

Instance Attribute Details

#frameworkObject (protected)

Returns the value of attribute framework.



44
45
46
# File 'lib/msf/core/modules/external.rb', line 44

def framework
  @framework
end

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/msf/core/modules/external.rb', line 10

def path
  @path
end

Instance Method Details

#describeObject (protected)



46
47
48
49
50
51
# File 'lib/msf/core/modules/external.rb', line 46

def describe
  exec method: :describe do |msg|
    return msg.params if msg.method == :reply
  end
  return nil
end

#exec(method: :run, args: {}, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/msf/core/modules/external.rb', line 21

def exec(method: :run, args: {}, &block)
  req = Message.new(method)
  req.params = args.dup

  b = Bridge.open(self.path, framework: self.framework).exec(req)

  if block
    begin
      while m = b.messages.pop
        block.call m
      end
    ensure
      b.close
    end
    return b.success?
  else
    return b
  end
end

#metaObject



12
13
14
# File 'lib/msf/core/modules/external.rb', line 12

def meta
  @meta ||= describe
end