CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/core/modules/external.rb
Views: 11655
1
# -*- coding: binary -*-
2
# Namespace for loading external Metasploit modules
3
4
class Msf::Modules::External
5
6
autoload :Bridge, 'msf/core/modules/external/bridge'
7
autoload :Message, 'msf/core/modules/external/message'
8
autoload :CLI, 'msf/core/modules/external/cli'
9
10
attr_reader :path
11
12
def meta
13
@meta ||= describe
14
end
15
16
def initialize(module_path, framework: nil)
17
self.path = module_path
18
self.framework = framework
19
end
20
21
def exec(method: :run, args: {}, &block)
22
req = Message.new(method)
23
req.params = args.dup
24
25
b = Bridge.open(self.path, framework: self.framework).exec(req)
26
27
if block
28
begin
29
while m = b.messages.pop
30
block.call m
31
end
32
ensure
33
b.close
34
end
35
return b.success?
36
else
37
return b
38
end
39
end
40
41
protected
42
43
attr_writer :path
44
attr_accessor :framework
45
46
def describe
47
exec method: :describe do |msg|
48
return msg.params if msg.method == :reply
49
end
50
return nil
51
end
52
end
53
54