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/base/simple/module.rb
Views: 11784
1
# -*- coding: binary -*-
2
3
module Msf
4
module Simple
5
6
###
7
#
8
# Simple module wrapper that provides some common methods for dealing with
9
# modules, such as importing options and other such things.
10
#
11
###
12
module Module
13
14
#
15
# Imports extra options from the supplied hash either as a string or as a
16
# hash.
17
#
18
def _import_extra_options(opts)
19
# If options were supplied, import them into the payload's
20
# datastore
21
if (value = opts['Options'])
22
if value.is_a?(String)
23
self.datastore.import_options_from_s(value)
24
else
25
self.datastore.import_options_from_hash(value)
26
end
27
elsif (value = opts['OptionStr'])
28
self.datastore.import_options_from_s(value)
29
end
30
end
31
32
def inspect
33
"#<Module:#{self.fullname} datastore=[#{self.datastore.inspect}]>"
34
end
35
36
#
37
# Initializes the simplified interface.
38
#
39
def init_simplified(load_saved_config=true)
40
load_config if load_saved_config
41
end
42
43
#
44
# Populates the datastore from the config file.
45
#
46
def load_config
47
self.datastore.from_file(Msf::Config.config_file, self.refname)
48
end
49
50
#
51
# Saves the module's datastore to the file.
52
#
53
def save_config
54
self.datastore.to_file(Msf::Config.config_file, self.refname)
55
end
56
57
end
58
59
end
60
end
61
62