metasploit-model 0.27.3-java → 0.27.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/app/models/metasploit/model/association/reflection.rb +0 -3
- data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -3
- data/app/models/metasploit/model/module/class/spec/template.rb +0 -4
- data/app/models/metasploit/model/module/instance/spec/template.rb +0 -4
- data/app/models/metasploit/model/search/group/base.rb +0 -3
- data/app/models/metasploit/model/search/group/intersection.rb +0 -3
- data/app/models/metasploit/model/search/group/union.rb +0 -3
- data/app/models/metasploit/model/search/operation/association.rb +0 -2
- data/app/models/metasploit/model/search/operation/base.rb +0 -3
- data/app/models/metasploit/model/search/operation/boolean.rb +0 -2
- data/app/models/metasploit/model/search/operation/date.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operation/integer.rb +1 -5
- data/app/models/metasploit/model/search/operation/null.rb +0 -2
- data/app/models/metasploit/model/search/operation/set.rb +5 -2
- data/app/models/metasploit/model/search/operation/set/integer.rb +1 -3
- data/app/models/metasploit/model/search/operation/set/string.rb +1 -3
- data/app/models/metasploit/model/search/operation/string.rb +1 -5
- data/app/models/metasploit/model/search/operator/association.rb +0 -2
- data/app/models/metasploit/model/search/operator/attribute.rb +0 -2
- data/app/models/metasploit/model/search/operator/base.rb +0 -4
- data/app/models/metasploit/model/search/operator/delegation.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/app.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/author.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/authority.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/platform.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/ref.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/text.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operator/null.rb +0 -2
- data/app/models/metasploit/model/search/operator/single.rb +0 -2
- data/app/models/metasploit/model/search/query.rb +0 -3
- data/app/models/metasploit/model/spec/template.rb +0 -3
- data/app/models/metasploit/model/visitation/visitor.rb +0 -3
- data/lib/metasploit/model.rb +14 -8
- data/lib/metasploit/model/architecture.rb +320 -326
- data/lib/metasploit/model/association.rb +43 -46
- data/lib/metasploit/model/association/error.rb +29 -33
- data/lib/metasploit/model/association/tree.rb +119 -125
- data/lib/metasploit/model/author.rb +45 -51
- data/lib/metasploit/model/authority.rb +139 -146
- data/lib/metasploit/model/authority/bid.rb +0 -2
- data/lib/metasploit/model/authority/cve.rb +0 -2
- data/lib/metasploit/model/authority/msb.rb +0 -2
- data/lib/metasploit/model/authority/osvdb.rb +0 -2
- data/lib/metasploit/model/authority/pmasa.rb +0 -2
- data/lib/metasploit/model/authority/secunia.rb +0 -2
- data/lib/metasploit/model/authority/us_cert_vu.rb +0 -2
- data/lib/metasploit/model/authority/waraxe.rb +0 -2
- data/lib/metasploit/model/authority/zdi.rb +0 -2
- data/lib/metasploit/model/base.rb +0 -2
- data/lib/metasploit/model/derivation.rb +95 -99
- data/lib/metasploit/model/derivation/full_name.rb +16 -22
- data/lib/metasploit/model/email_address.rb +122 -128
- data/lib/metasploit/model/engine.rb +26 -21
- data/lib/metasploit/model/error.rb +3 -7
- data/lib/metasploit/model/file.rb +0 -2
- data/lib/metasploit/model/invalid.rb +11 -17
- data/lib/metasploit/model/login.rb +0 -3
- data/lib/metasploit/model/login/status.rb +0 -2
- data/lib/metasploit/model/module.rb +19 -23
- data/lib/metasploit/model/module/action.rb +50 -58
- data/lib/metasploit/model/module/ancestor.rb +456 -465
- data/lib/metasploit/model/module/ancestor/spec.rb +3 -2
- data/lib/metasploit/model/module/architecture.rb +27 -35
- data/lib/metasploit/model/module/author.rb +38 -47
- data/lib/metasploit/model/module/class.rb +358 -366
- data/lib/metasploit/model/module/class/spec.rb +3 -2
- data/lib/metasploit/model/module/handler.rb +28 -34
- data/lib/metasploit/model/module/instance.rb +586 -596
- data/lib/metasploit/model/module/instance/spec.rb +3 -2
- data/lib/metasploit/model/module/path.rb +157 -166
- data/lib/metasploit/model/module/platform.rb +25 -33
- data/lib/metasploit/model/module/rank.rb +71 -79
- data/lib/metasploit/model/module/reference.rb +25 -33
- data/lib/metasploit/model/module/stance.rb +15 -21
- data/lib/metasploit/model/module/target.rb +76 -84
- data/lib/metasploit/model/module/target/architecture.rb +27 -37
- data/lib/metasploit/model/module/target/platform.rb +27 -37
- data/lib/metasploit/model/module/type.rb +35 -41
- data/lib/metasploit/model/nilify_blanks.rb +39 -43
- data/lib/metasploit/model/platform.rb +231 -237
- data/lib/metasploit/model/real_pathname.rb +12 -16
- data/lib/metasploit/model/realm.rb +0 -2
- data/lib/metasploit/model/realm/key.rb +0 -2
- data/lib/metasploit/model/reference.rb +102 -108
- data/lib/metasploit/model/search.rb +94 -97
- data/lib/metasploit/model/search/association.rb +163 -169
- data/lib/metasploit/model/search/attribute.rb +131 -139
- data/lib/metasploit/model/search/group.rb +5 -2
- data/lib/metasploit/model/search/operation.rb +32 -29
- data/lib/metasploit/model/search/operation/group.rb +5 -2
- data/lib/metasploit/model/search/operation/value.rb +7 -0
- data/lib/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +1 -1
- data/lib/metasploit/model/search/operation/{string/value.rb → value/string.rb} +1 -1
- data/lib/metasploit/model/search/operator.rb +65 -65
- data/lib/metasploit/model/search/operator/deprecated.rb +8 -2
- data/lib/metasploit/model/search/operator/group.rb +5 -2
- data/lib/metasploit/model/search/operator/help.rb +71 -79
- data/lib/metasploit/model/search/with.rb +72 -78
- data/lib/metasploit/model/spec.rb +133 -136
- data/lib/metasploit/model/spec/error.rb +3 -9
- data/lib/metasploit/model/spec/i18n_exception_handler.rb +0 -2
- data/lib/metasploit/model/spec/pathname_collision.rb +19 -27
- data/lib/metasploit/model/spec/template/write.rb +0 -2
- data/lib/metasploit/model/spec/temporary_pathname.rb +47 -56
- data/lib/metasploit/model/translation.rb +0 -2
- data/lib/metasploit/model/version.rb +1 -1
- data/lib/metasploit/model/visitation.rb +7 -10
- data/lib/metasploit/model/visitation/visit.rb +79 -85
- data/metasploit-model.gemspec +1 -1
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -0
- data/spec/lib/metasploit/model/search/operation/{integer/value_spec.rb → value/integer_spec.rb} +2 -2
- data/spec/lib/metasploit/model/search/operation/{string/value_spec.rb → value/string_spec.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{string/value.rb → value/string.rb} +2 -2
- metadata +16 -13
@@ -1,35 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
# CONSTANTS
|
8
|
-
#
|
1
|
+
# The handler Module for a {Metasploit::Model::Module::Ancestor#handled?} {Metasploit::Model::Module::Ancestor}.
|
2
|
+
module Metasploit::Model::Module::Handler
|
3
|
+
#
|
4
|
+
# CONSTANTS
|
5
|
+
#
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
7
|
+
# Maps {TYPES} to {GENERAL_TYPES} used as connection types for `Msf::Payload`.
|
8
|
+
GENERAL_TYPE_BY_TYPE = {
|
9
|
+
'bind_tcp' => 'bind',
|
10
|
+
'find_port' => 'find',
|
11
|
+
'find_shell' => 'find',
|
12
|
+
'find_tag' => 'find',
|
13
|
+
'none' => 'none',
|
14
|
+
'reverse_http' => 'tunnel',
|
15
|
+
'reverse_https' => 'tunnel',
|
16
|
+
'reverse_https_proxy' => 'tunnel',
|
17
|
+
'reverse_ipv6_http' => 'tunnel',
|
18
|
+
'reverse_ipv6_https' => 'tunnel',
|
19
|
+
'reverse_tcp' => 'reverse',
|
20
|
+
'reverse_tcp_allports' => 'reverse',
|
21
|
+
'reverse_tcp_double' => 'reverse',
|
22
|
+
'reverse_tcp_double_ssl' => 'reverse',
|
23
|
+
'reverse_tcp_ssl' => 'reverse'
|
24
|
+
}
|
25
|
+
# General handler types that are used as connection types for Msf::Payloads.
|
26
|
+
GENERAL_TYPES = GENERAL_TYPE_BY_TYPE.values.uniq.sort
|
27
|
+
# Types of handlers
|
28
|
+
TYPES = GENERAL_TYPE_BY_TYPE.keys.sort
|
29
|
+
end
|
@@ -1,632 +1,622 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
1
|
+
# Code shared between `Mdm::Module::Instance` and `Metasploit::Framework::Module::Instance`.
|
2
|
+
module Metasploit::Model::Module::Instance
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
extend ActiveSupport::Autoload
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
include Metasploit::Model::Translation
|
8
|
+
|
9
|
+
autoload :Spec
|
10
|
+
|
11
|
+
#
|
12
|
+
# CONSTANTS
|
13
|
+
#
|
14
|
+
|
15
|
+
# {#dynamic_length_validation_options} by {#module_type} by attribute.
|
16
|
+
DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE = {
|
17
|
+
actions: {
|
18
|
+
Metasploit::Model::Module::Type::AUX => {
|
19
|
+
minimum: 0
|
20
|
+
},
|
21
|
+
Metasploit::Model::Module::Type::ENCODER => {
|
22
|
+
is: 0
|
23
|
+
},
|
24
|
+
Metasploit::Model::Module::Type::EXPLOIT => {
|
25
|
+
is: 0
|
26
|
+
},
|
27
|
+
Metasploit::Model::Module::Type::NOP => {
|
28
|
+
is: 0
|
29
|
+
},
|
30
|
+
Metasploit::Model::Module::Type::PAYLOAD => {
|
31
|
+
is: 0
|
32
|
+
},
|
33
|
+
Metasploit::Model::Module::Type::POST => {
|
34
|
+
minimum: 0
|
35
|
+
}
|
36
|
+
},
|
37
|
+
module_architectures: {
|
38
|
+
Metasploit::Model::Module::Type::AUX => {
|
39
|
+
is: 0
|
40
|
+
},
|
41
|
+
Metasploit::Model::Module::Type::ENCODER => {
|
42
|
+
minimum: 1
|
43
|
+
},
|
44
|
+
Metasploit::Model::Module::Type::EXPLOIT => {
|
45
|
+
minimum: 1
|
46
|
+
},
|
47
|
+
Metasploit::Model::Module::Type::NOP => {
|
48
|
+
minimum: 1
|
49
|
+
},
|
50
|
+
Metasploit::Model::Module::Type::PAYLOAD => {
|
51
|
+
minimum: 1
|
52
|
+
},
|
53
|
+
Metasploit::Model::Module::Type::POST => {
|
54
|
+
minimum: 1
|
55
|
+
}
|
56
|
+
},
|
57
|
+
module_platforms: {
|
58
|
+
Metasploit::Model::Module::Type::AUX => {
|
59
|
+
is: 0
|
60
|
+
},
|
61
|
+
Metasploit::Model::Module::Type::ENCODER => {
|
62
|
+
is: 0
|
63
|
+
},
|
64
|
+
Metasploit::Model::Module::Type::EXPLOIT => {
|
65
|
+
minimum: 1
|
66
|
+
},
|
67
|
+
Metasploit::Model::Module::Type::NOP => {
|
68
|
+
is: 0
|
69
|
+
},
|
70
|
+
Metasploit::Model::Module::Type::PAYLOAD => {
|
71
|
+
minimum: 1
|
72
|
+
},
|
73
|
+
Metasploit::Model::Module::Type::POST => {
|
74
|
+
minimum: 1
|
75
|
+
}
|
76
|
+
},
|
77
|
+
module_references: {
|
78
|
+
Metasploit::Model::Module::Type::AUX => {
|
79
|
+
minimum: 0
|
80
|
+
},
|
81
|
+
Metasploit::Model::Module::Type::ENCODER => {
|
82
|
+
is: 0
|
83
|
+
},
|
84
|
+
Metasploit::Model::Module::Type::EXPLOIT => {
|
85
|
+
minimum: 1
|
86
|
+
},
|
87
|
+
Metasploit::Model::Module::Type::NOP => {
|
88
|
+
is: 0
|
89
|
+
},
|
90
|
+
Metasploit::Model::Module::Type::PAYLOAD => {
|
91
|
+
is: 0
|
92
|
+
},
|
93
|
+
Metasploit::Model::Module::Type::POST => {
|
94
|
+
minimum: 0
|
95
|
+
}
|
96
|
+
},
|
97
|
+
targets: {
|
98
|
+
Metasploit::Model::Module::Type::AUX => {
|
99
|
+
is: 0
|
100
|
+
},
|
101
|
+
Metasploit::Model::Module::Type::ENCODER => {
|
102
|
+
is: 0
|
103
|
+
},
|
104
|
+
Metasploit::Model::Module::Type::EXPLOIT => {
|
105
|
+
minimum: 1
|
106
|
+
},
|
107
|
+
Metasploit::Model::Module::Type::NOP => {
|
108
|
+
is: 0
|
109
|
+
},
|
110
|
+
Metasploit::Model::Module::Type::PAYLOAD => {
|
111
|
+
is: 0
|
112
|
+
},
|
113
|
+
Metasploit::Model::Module::Type::POST => {
|
114
|
+
is: 0
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
# Minimum length of {#module_authors}.
|
120
|
+
MINIMUM_MODULE_AUTHORS_LENGTH = 1
|
121
|
+
|
122
|
+
# {#privileged} is Boolean so, valid values are just `true` and `false`, but since both the validation and
|
123
|
+
# factory need an array of valid values, this constant exists.
|
124
|
+
PRIVILEGES = [
|
125
|
+
false,
|
126
|
+
true
|
127
|
+
]
|
128
|
+
|
129
|
+
# Member of {Metasploit::Model::Module::Type::ALL} that require {#stance} to be non-`nil`.
|
130
|
+
STANCED_MODULE_TYPES = [
|
131
|
+
Metasploit::Model::Module::Type::AUX,
|
132
|
+
Metasploit::Model::Module::Type::EXPLOIT
|
133
|
+
]
|
134
|
+
|
135
|
+
included do
|
136
|
+
include ActiveModel::Validations
|
137
|
+
include Metasploit::Model::Search
|
138
|
+
|
139
|
+
#
|
140
|
+
#
|
141
|
+
# Search
|
142
|
+
#
|
143
|
+
#
|
144
|
+
|
145
|
+
#
|
146
|
+
# Search Associations
|
147
|
+
#
|
148
|
+
|
149
|
+
search_association :actions
|
150
|
+
search_association :architectures
|
151
|
+
search_association :authorities
|
152
|
+
search_association :authors
|
153
|
+
search_association :email_addresses
|
154
|
+
search_association :module_class
|
155
|
+
search_association :platforms
|
156
|
+
search_association :rank
|
157
|
+
search_association :references
|
158
|
+
search_association :targets
|
159
|
+
|
160
|
+
#
|
161
|
+
# Search Attributes
|
162
|
+
#
|
163
|
+
|
164
|
+
search_attribute :description, :type => :string
|
165
|
+
search_attribute :disclosed_on, :type => :date
|
166
|
+
search_attribute :license, :type => :string
|
167
|
+
search_attribute :name, :type => :string
|
168
|
+
search_attribute :privileged, :type => :boolean
|
169
|
+
search_attribute :stance, :type => :string
|
170
|
+
|
171
|
+
#
|
172
|
+
# Search Withs
|
173
|
+
#
|
174
|
+
|
175
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::App
|
176
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Author
|
177
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Authority,
|
178
|
+
:abbreviation => :bid
|
179
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Authority,
|
180
|
+
:abbreviation => :cve
|
181
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Authority,
|
182
|
+
:abbreviation => :edb
|
183
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Authority,
|
184
|
+
:abbreviation => :osvdb
|
185
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Platform,
|
186
|
+
:name => :os
|
187
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Platform,
|
188
|
+
:name => :platform
|
189
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Ref
|
190
|
+
search_with Metasploit::Model::Search::Operator::Deprecated::Text
|
191
|
+
|
192
|
+
#
|
193
|
+
#
|
194
|
+
# Validations
|
195
|
+
#
|
196
|
+
#
|
197
|
+
|
198
|
+
#
|
199
|
+
# Method Validations
|
200
|
+
#
|
201
|
+
|
202
|
+
validate :architectures_from_targets,
|
203
|
+
if: 'allows?(:targets)'
|
204
|
+
validate :platforms_from_targets,
|
205
|
+
if: 'allows?(:targets)'
|
206
|
+
|
207
|
+
#
|
208
|
+
# Attribute Validations
|
209
|
+
#
|
210
|
+
|
211
|
+
validates :actions,
|
212
|
+
dynamic_length: true
|
213
|
+
validates :description,
|
214
|
+
:presence => true
|
215
|
+
validates :license,
|
216
|
+
:presence => true
|
217
|
+
validates :module_architectures,
|
218
|
+
dynamic_length: true
|
219
|
+
validates :module_authors,
|
220
|
+
:length => {
|
221
|
+
:minimum => MINIMUM_MODULE_AUTHORS_LENGTH
|
222
|
+
}
|
223
|
+
validates :module_class,
|
224
|
+
:presence => true
|
225
|
+
validates :module_platforms,
|
226
|
+
dynamic_length: true
|
227
|
+
validates :module_references,
|
228
|
+
dynamic_length: true
|
229
|
+
validates :name,
|
230
|
+
:presence => true
|
231
|
+
validates :privileged,
|
232
|
+
:inclusion => {
|
233
|
+
:in => PRIVILEGES
|
234
|
+
}
|
235
|
+
validates :stance,
|
236
|
+
inclusion: {
|
237
|
+
if: :stanced?,
|
238
|
+
in: Metasploit::Model::Module::Stance::ALL
|
239
|
+
},
|
240
|
+
nil: {
|
241
|
+
unless: :stanced?
|
242
|
+
}
|
243
|
+
validates :targets,
|
244
|
+
dynamic_length: true
|
245
|
+
end
|
246
|
+
|
247
|
+
#
|
248
|
+
#
|
249
|
+
# Associations
|
250
|
+
#
|
251
|
+
#
|
252
|
+
|
253
|
+
# @!attribute [rw] actions
|
254
|
+
# Auxiliary actions to perform when this running this module.
|
255
|
+
#
|
256
|
+
# @return [Array<Metasploit::Model::Module::Action>]
|
257
|
+
|
258
|
+
# @!attribute [rw] default_action
|
259
|
+
# The default action in {#actions}.
|
260
|
+
#
|
261
|
+
# @return [Metasploit::Model::Module::Action]
|
262
|
+
|
263
|
+
# @!attribute [rw] default_target
|
264
|
+
# The default target in {#targets}.
|
265
|
+
#
|
266
|
+
# @return [Metasploit::Model::Module::Target]
|
267
|
+
|
268
|
+
# @!attribute [rw] module_architectures
|
269
|
+
# Joins this with {#architectures}.
|
270
|
+
#
|
271
|
+
# @return [Array<Metasploit::Model::Module::Architecture>]
|
272
|
+
|
273
|
+
# @!attribute [rw] module_authors
|
274
|
+
# Joins this with {#authors} and {#email_addresses} to model the name and email address used for an author
|
275
|
+
# entry in the module metadata.
|
276
|
+
#
|
277
|
+
# @return [Array<Metasploit::Model::Module::Author>]
|
278
|
+
|
279
|
+
# @!attribute [rw] module_class
|
280
|
+
# Class-derived metadata to go along with the instance-derived metadata in this model.
|
281
|
+
#
|
282
|
+
# @return [Metasploit::Model::Module::Class]
|
283
|
+
|
284
|
+
# @!attribute [rw] module_platforms
|
285
|
+
# Joins this with {#platforms}.
|
286
|
+
#
|
287
|
+
# @return [Array<Metasploit::Model::Module::Platform>]
|
288
|
+
|
289
|
+
# @!attribute [rw] targets
|
290
|
+
# Names of targets with different configurations that can be exploited by this module.
|
291
|
+
#
|
292
|
+
# @return [Array<Metasploit::Model::Module::Target>]
|
293
|
+
|
294
|
+
# @!attribute [r] architectures
|
295
|
+
# The {Metasploit::Model::Architecture architectures} supported by this module.
|
296
|
+
#
|
297
|
+
# @return [Array<Metasploit::Model::Architecture>]
|
298
|
+
|
299
|
+
# @!attribute [r] authors
|
300
|
+
# The names of the authors of this module.
|
301
|
+
#
|
302
|
+
# @return [Array<Metasploit::Model::Author>]
|
303
|
+
|
304
|
+
# @!attribute [r] email_addresses
|
305
|
+
# The email addresses of the authors of this module.
|
306
|
+
#
|
307
|
+
# @return [Array<Metasploit::Model::EmailAddress>]
|
308
|
+
|
309
|
+
# @!attribute [r] platforms
|
310
|
+
# Platforms supported by this module.
|
311
|
+
#
|
312
|
+
# @return [Array<Metasploit::Model::Module::Platform>]
|
313
|
+
|
314
|
+
# @!attribute [r] references
|
315
|
+
# External references to the exploit or proof-of-concept (PoC) code in this module.
|
316
|
+
#
|
317
|
+
# @return [Array<Metasploit::Model::Reference>]
|
318
|
+
|
319
|
+
# @!attribute [r] vulns
|
320
|
+
# Vulnerabilities with same {Metasploit::Model::Reference reference} as this module.
|
321
|
+
#
|
322
|
+
# @return [Array<Metasploit::Model::Vuln>]
|
323
|
+
|
324
|
+
# @!attribute [r] vulnerable_hosts
|
325
|
+
# Hosts vulnerable to this module.
|
326
|
+
#
|
327
|
+
# @return [Array<Metasploit::Model::Host>]
|
328
|
+
|
329
|
+
# @!attribute [r] vulnerable_services
|
330
|
+
# Services vulnerable to this module.
|
331
|
+
#
|
332
|
+
# @return [Array<Metasploit::Model::Service>]
|
333
|
+
|
334
|
+
#
|
335
|
+
# Attributes
|
336
|
+
#
|
337
|
+
|
338
|
+
# @!attribute [rw] description
|
339
|
+
# A long, paragraph description of what the module does.
|
340
|
+
#
|
341
|
+
# @return [String]
|
342
|
+
|
343
|
+
# @!attribute [rw] disclosed_on
|
344
|
+
# The date the vulnerability exploited by this module was disclosed to the public.
|
345
|
+
#
|
346
|
+
# @return [Date, nil]
|
347
|
+
|
348
|
+
# @!attribute [rw] license
|
349
|
+
# The name of the software license for the module's code.
|
350
|
+
#
|
351
|
+
# @return [String]
|
352
|
+
|
353
|
+
# @!attribute [rw] name
|
354
|
+
# The human readable name of the module. It is unrelated to {Metasploit::Model::Module::Class#full_name} or
|
355
|
+
# {Metasploit::Model::Module::Class#reference_name} and is better thought of as a short summary of the
|
356
|
+
# {#description}.
|
357
|
+
#
|
358
|
+
# @return [String]
|
359
|
+
|
360
|
+
# @!attribute [rw] privileged
|
361
|
+
# Whether this module requires privileged access to run.
|
362
|
+
#
|
363
|
+
# @return [Boolean]
|
364
|
+
|
365
|
+
# @!attribute [rw] stance
|
366
|
+
# Whether the module is active or passive. `nil` if the {#module_type} is not {#stanced?}.
|
367
|
+
#
|
368
|
+
# @return ['active', 'passive', nil]
|
369
|
+
|
370
|
+
#
|
371
|
+
# Module Methods
|
372
|
+
#
|
373
|
+
|
374
|
+
module ClassMethods
|
375
|
+
# Whether the given `:attribute` is allowed to be present for the given `:module_type`. An attribute is
|
376
|
+
# considered allowed if it allows greatrr than 0 elements for a collection.
|
377
|
+
#
|
378
|
+
# @raise [KeyError] if `:attribute` is not given in `options`.
|
379
|
+
# @raise [KeyError] if `:module_type` is not given in `options`.
|
380
|
+
# @return [true] if maximum elements is greater than 0 or value can be non-nil
|
381
|
+
def allows?(options={})
|
382
|
+
allowed = false
|
383
|
+
length_validation_options = dynamic_length_validation_options(options)
|
384
|
+
|
385
|
+
is = length_validation_options[:is]
|
386
|
+
|
387
|
+
if is
|
388
|
+
if is > 0
|
389
|
+
allowed = true
|
251
390
|
end
|
391
|
+
else
|
392
|
+
maximum = length_validation_options[:maximum]
|
252
393
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
#
|
257
|
-
#
|
258
|
-
|
259
|
-
# @!attribute [rw] actions
|
260
|
-
# Auxiliary actions to perform when this running this module.
|
261
|
-
#
|
262
|
-
# @return [Array<Metasploit::Model::Module::Action>]
|
263
|
-
|
264
|
-
# @!attribute [rw] default_action
|
265
|
-
# The default action in {#actions}.
|
266
|
-
#
|
267
|
-
# @return [Metasploit::Model::Module::Action]
|
268
|
-
|
269
|
-
# @!attribute [rw] default_target
|
270
|
-
# The default target in {#targets}.
|
271
|
-
#
|
272
|
-
# @return [Metasploit::Model::Module::Target]
|
273
|
-
|
274
|
-
# @!attribute [rw] module_architectures
|
275
|
-
# Joins this with {#architectures}.
|
276
|
-
#
|
277
|
-
# @return [Array<Metasploit::Model::Module::Architecture>]
|
278
|
-
|
279
|
-
# @!attribute [rw] module_authors
|
280
|
-
# Joins this with {#authors} and {#email_addresses} to model the name and email address used for an author
|
281
|
-
# entry in the module metadata.
|
282
|
-
#
|
283
|
-
# @return [Array<Metasploit::Model::Module::Author>]
|
284
|
-
|
285
|
-
# @!attribute [rw] module_class
|
286
|
-
# Class-derived metadata to go along with the instance-derived metadata in this model.
|
287
|
-
#
|
288
|
-
# @return [Metasploit::Model::Module::Class]
|
289
|
-
|
290
|
-
# @!attribute [rw] module_platforms
|
291
|
-
# Joins this with {#platforms}.
|
292
|
-
#
|
293
|
-
# @return [Array<Metasploit::Model::Module::Platform>]
|
294
|
-
|
295
|
-
# @!attribute [rw] targets
|
296
|
-
# Names of targets with different configurations that can be exploited by this module.
|
297
|
-
#
|
298
|
-
# @return [Array<Metasploit::Model::Module::Target>]
|
299
|
-
|
300
|
-
# @!attribute [r] architectures
|
301
|
-
# The {Metasploit::Model::Architecture architectures} supported by this module.
|
302
|
-
#
|
303
|
-
# @return [Array<Metasploit::Model::Architecture>]
|
304
|
-
|
305
|
-
# @!attribute [r] authors
|
306
|
-
# The names of the authors of this module.
|
307
|
-
#
|
308
|
-
# @return [Array<Metasploit::Model::Author>]
|
309
|
-
|
310
|
-
# @!attribute [r] email_addresses
|
311
|
-
# The email addresses of the authors of this module.
|
312
|
-
#
|
313
|
-
# @return [Array<Metasploit::Model::EmailAddress>]
|
314
|
-
|
315
|
-
# @!attribute [r] platforms
|
316
|
-
# Platforms supported by this module.
|
317
|
-
#
|
318
|
-
# @return [Array<Metasploit::Model::Module::Platform>]
|
319
|
-
|
320
|
-
# @!attribute [r] references
|
321
|
-
# External references to the exploit or proof-of-concept (PoC) code in this module.
|
322
|
-
#
|
323
|
-
# @return [Array<Metasploit::Model::Reference>]
|
324
|
-
|
325
|
-
# @!attribute [r] vulns
|
326
|
-
# Vulnerabilities with same {Metasploit::Model::Reference reference} as this module.
|
327
|
-
#
|
328
|
-
# @return [Array<Metasploit::Model::Vuln>]
|
329
|
-
|
330
|
-
# @!attribute [r] vulnerable_hosts
|
331
|
-
# Hosts vulnerable to this module.
|
332
|
-
#
|
333
|
-
# @return [Array<Metasploit::Model::Host>]
|
334
|
-
|
335
|
-
# @!attribute [r] vulnerable_services
|
336
|
-
# Services vulnerable to this module.
|
337
|
-
#
|
338
|
-
# @return [Array<Metasploit::Model::Service>]
|
339
|
-
|
340
|
-
#
|
341
|
-
# Attributes
|
342
|
-
#
|
343
|
-
|
344
|
-
# @!attribute [rw] description
|
345
|
-
# A long, paragraph description of what the module does.
|
346
|
-
#
|
347
|
-
# @return [String]
|
348
|
-
|
349
|
-
# @!attribute [rw] disclosed_on
|
350
|
-
# The date the vulnerability exploited by this module was disclosed to the public.
|
351
|
-
#
|
352
|
-
# @return [Date, nil]
|
353
|
-
|
354
|
-
# @!attribute [rw] license
|
355
|
-
# The name of the software license for the module's code.
|
356
|
-
#
|
357
|
-
# @return [String]
|
358
|
-
|
359
|
-
# @!attribute [rw] name
|
360
|
-
# The human readable name of the module. It is unrelated to {Metasploit::Model::Module::Class#full_name} or
|
361
|
-
# {Metasploit::Model::Module::Class#reference_name} and is better thought of as a short summary of the
|
362
|
-
# {#description}.
|
363
|
-
#
|
364
|
-
# @return [String]
|
365
|
-
|
366
|
-
# @!attribute [rw] privileged
|
367
|
-
# Whether this module requires privileged access to run.
|
368
|
-
#
|
369
|
-
# @return [Boolean]
|
370
|
-
|
371
|
-
# @!attribute [rw] stance
|
372
|
-
# Whether the module is active or passive. `nil` if the {#module_type} is not {#stanced?}.
|
373
|
-
#
|
374
|
-
# @return ['active', 'passive', nil]
|
375
|
-
|
376
|
-
#
|
377
|
-
# Module Methods
|
378
|
-
#
|
379
|
-
|
380
|
-
module ClassMethods
|
381
|
-
# Whether the given `:attribute` is allowed to be present for the given `:module_type`. An attribute is
|
382
|
-
# considered allowed if it allows greatrr than 0 elements for a collection.
|
383
|
-
#
|
384
|
-
# @raise [KeyError] if `:attribute` is not given in `options`.
|
385
|
-
# @raise [KeyError] if `:module_type` is not given in `options`.
|
386
|
-
# @return [true] if maximum elements is greater than 0 or value can be non-nil
|
387
|
-
def allows?(options={})
|
388
|
-
allowed = false
|
389
|
-
length_validation_options = dynamic_length_validation_options(options)
|
390
|
-
|
391
|
-
is = length_validation_options[:is]
|
392
|
-
|
393
|
-
if is
|
394
|
-
if is > 0
|
395
|
-
allowed = true
|
396
|
-
end
|
397
|
-
else
|
398
|
-
maximum = length_validation_options[:maximum]
|
399
|
-
|
400
|
-
if maximum
|
401
|
-
if maximum > 0
|
402
|
-
allowed = true
|
403
|
-
end
|
404
|
-
else
|
405
|
-
# if there is no maximum, then it's treated as infinite
|
406
|
-
allowed = true
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
allowed
|
394
|
+
if maximum
|
395
|
+
if maximum > 0
|
396
|
+
allowed = true
|
411
397
|
end
|
398
|
+
else
|
399
|
+
# if there is no maximum, then it's treated as infinite
|
400
|
+
allowed = true
|
401
|
+
end
|
402
|
+
end
|
412
403
|
|
413
|
-
|
414
|
-
|
415
|
-
# `:minimum` (no attribute has an explicit :maximum currently).
|
416
|
-
# @raise [KeyError] if `:attribute` is not given in `options`.
|
417
|
-
# @raise [KeyError] if `:module_type` is not given in `options`.
|
418
|
-
# @raise [KeyError] if `:attribute` value is not a key in
|
419
|
-
# {DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE}.
|
420
|
-
# @raise [KeyError] if `:module_type` value is a not a {Metasploit::Model::Module::Type::ALL} member.
|
421
|
-
def dynamic_length_validation_options(options={})
|
422
|
-
options.assert_valid_keys(:attribute, :module_type)
|
423
|
-
attribute = options.fetch(:attribute)
|
424
|
-
module_type = options.fetch(:module_type)
|
425
|
-
|
426
|
-
dynamic_length_validation_options_by_module_type = DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE.fetch(attribute)
|
427
|
-
dynamic_length_validation_options_by_module_type.fetch(module_type)
|
428
|
-
end
|
404
|
+
allowed
|
405
|
+
end
|
429
406
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
407
|
+
# The length validation options for the given `:attribute` and `:module_type`.
|
408
|
+
# @return [Hash{Symbol => Integer}] Hash containing either `:is` (meaning :maximum and :minimum are the same) or
|
409
|
+
# `:minimum` (no attribute has an explicit :maximum currently).
|
410
|
+
# @raise [KeyError] if `:attribute` is not given in `options`.
|
411
|
+
# @raise [KeyError] if `:module_type` is not given in `options`.
|
412
|
+
# @raise [KeyError] if `:attribute` value is not a key in
|
413
|
+
# {DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE}.
|
414
|
+
# @raise [KeyError] if `:module_type` value is a not a {Metasploit::Model::Module::Type::ALL} member.
|
415
|
+
def dynamic_length_validation_options(options={})
|
416
|
+
options.assert_valid_keys(:attribute, :module_type)
|
417
|
+
attribute = options.fetch(:attribute)
|
418
|
+
module_type = options.fetch(:module_type)
|
419
|
+
|
420
|
+
dynamic_length_validation_options_by_module_type = DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE.fetch(attribute)
|
421
|
+
dynamic_length_validation_options_by_module_type.fetch(module_type)
|
422
|
+
end
|
440
423
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
# @return [Array<String>] Array with members of {Metasploit::Model::Module::Type::ALL}.
|
452
|
-
# @see DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE
|
453
|
-
def self.module_types_that_allow(attribute)
|
454
|
-
dynamic_length_validation_options_by_module_type = DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE.fetch(attribute)
|
455
|
-
|
456
|
-
dynamic_length_validation_options_by_module_type.each_with_object([]) { |(module_type, dynamic_length_validation_options), module_types|
|
457
|
-
is = dynamic_length_validation_options[:is]
|
458
|
-
|
459
|
-
if is
|
460
|
-
if is > 0
|
461
|
-
module_types << module_type
|
462
|
-
end
|
463
|
-
else
|
464
|
-
maximum = dynamic_length_validation_options[:maximum]
|
465
|
-
|
466
|
-
if maximum
|
467
|
-
if maximum > 0
|
468
|
-
module_types << module_type
|
469
|
-
end
|
470
|
-
else
|
471
|
-
module_types << module_type
|
472
|
-
end
|
473
|
-
end
|
424
|
+
# Whether the `:module_type` requires stance to be in {Metasploit::Model::Module::Stance::ALL} or if it must
|
425
|
+
# be `nil`.
|
426
|
+
#
|
427
|
+
# @param module_type [String] A member of `Metasploit::Model::Module::Type::ALL`.
|
428
|
+
# @return [true] if `module_type` is in {STANCED_MODULE_TYPES}.
|
429
|
+
# @return [false] otherwise.
|
430
|
+
def stanced?(module_type)
|
431
|
+
STANCED_MODULE_TYPES.include? module_type
|
432
|
+
end
|
433
|
+
end
|
474
434
|
|
475
|
-
|
476
|
-
|
435
|
+
# make ClassMethods directly callable on Metasploit::Model::Module::Instance for factories
|
436
|
+
extend ClassMethods
|
477
437
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
end
|
438
|
+
#
|
439
|
+
# Module Methods
|
440
|
+
#
|
441
|
+
|
442
|
+
# Values of {#module_type} (members of {Metasploit::Model::Module::Type::ALL}), which have an exact length
|
443
|
+
# (`:is`) or maximum length (`:maximum`) greater than 0 for the given `attribute`.
|
444
|
+
#
|
445
|
+
# @return [Array<String>] Array with members of {Metasploit::Model::Module::Type::ALL}.
|
446
|
+
# @see DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE
|
447
|
+
def self.module_types_that_allow(attribute)
|
448
|
+
dynamic_length_validation_options_by_module_type = DYNAMIC_LENGTH_VALIDATION_OPTIONS_BY_MODULE_TYPE_BY_ATTRIBUTE.fetch(attribute)
|
449
|
+
|
450
|
+
dynamic_length_validation_options_by_module_type.each_with_object([]) { |(module_type, dynamic_length_validation_options), module_types|
|
451
|
+
is = dynamic_length_validation_options[:is]
|
452
|
+
|
453
|
+
if is
|
454
|
+
if is > 0
|
455
|
+
module_types << module_type
|
497
456
|
end
|
457
|
+
else
|
458
|
+
maximum = dynamic_length_validation_options[:maximum]
|
498
459
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
# @param attribute [Symbol] name of attribute whose dynamic length validation options to be
|
503
|
-
# @return (see Metasploit::Model::Module::Instance::ClassMethods#dynamic_length_validation_options)
|
504
|
-
# @return [{}] an empty Hash if {#module_type} is not a member of {Metasploit::Model::Module::Type::ALL}
|
505
|
-
def dynamic_length_validation_options(attribute)
|
506
|
-
if Metasploit::Model::Module::Type::ALL.include? module_type
|
507
|
-
self.class.dynamic_length_validation_options(
|
508
|
-
module_type: module_type,
|
509
|
-
attribute: attribute
|
510
|
-
)
|
511
|
-
else
|
512
|
-
{}
|
460
|
+
if maximum
|
461
|
+
if maximum > 0
|
462
|
+
module_types << module_type
|
513
463
|
end
|
464
|
+
else
|
465
|
+
module_types << module_type
|
514
466
|
end
|
467
|
+
end
|
515
468
|
|
516
|
-
|
517
|
-
|
518
|
-
#
|
519
|
-
# @return (see Metasploit;:Model::Module::Class#module_type)
|
520
|
-
delegate :module_type,
|
521
|
-
allow_nil: true,
|
522
|
-
to: :module_class
|
523
|
-
|
524
|
-
# Whether {#module_type} requires {#stance} to be set or to be `nil`.
|
525
|
-
#
|
526
|
-
# @return (see Metasploit::Model::Module::Instance::ClassMethods#stanced?)
|
527
|
-
# @return [false] if {#module_type} is not valid
|
528
|
-
def stanced?
|
529
|
-
self.class.stanced?(module_type)
|
530
|
-
end
|
469
|
+
}
|
470
|
+
end
|
531
471
|
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
472
|
+
#
|
473
|
+
# Instance Methods
|
474
|
+
#
|
475
|
+
|
476
|
+
# Whether the given `attribute` is allowed to have elements.
|
477
|
+
#
|
478
|
+
# @param attribute [Symbol] name of attribute to check if {#module_type} allows it to have one or more
|
479
|
+
# elements.
|
480
|
+
# @return (see Metasploit::Model::Module::Instance::ClassMethods#allows?)
|
481
|
+
# @return [false] if {#module_type} is not valid
|
482
|
+
def allows?(attribute)
|
483
|
+
if Metasploit::Model::Module::Type::ALL.include? module_type
|
484
|
+
self.class.allows?(
|
485
|
+
attribute: attribute,
|
486
|
+
module_type: module_type
|
487
|
+
)
|
488
|
+
else
|
489
|
+
false
|
490
|
+
end
|
491
|
+
end
|
549
492
|
|
550
|
-
|
493
|
+
# The dynamic length valdiations, such as `:is` and `:minimum` for the given attribute for the current
|
494
|
+
# {#module_type}.
|
495
|
+
#
|
496
|
+
# @param attribute [Symbol] name of attribute whose dynamic length validation options to be
|
497
|
+
# @return (see Metasploit::Model::Module::Instance::ClassMethods#dynamic_length_validation_options)
|
498
|
+
# @return [{}] an empty Hash if {#module_type} is not a member of {Metasploit::Model::Module::Type::ALL}
|
499
|
+
def dynamic_length_validation_options(attribute)
|
500
|
+
if Metasploit::Model::Module::Type::ALL.include? module_type
|
501
|
+
self.class.dynamic_length_validation_options(
|
502
|
+
module_type: module_type,
|
503
|
+
attribute: attribute
|
504
|
+
)
|
505
|
+
else
|
506
|
+
{}
|
507
|
+
end
|
508
|
+
end
|
551
509
|
|
552
|
-
|
553
|
-
|
510
|
+
# @!method module_type
|
511
|
+
# The {Metasploit::Model::Module::Class#module_type} of the {#module_class}.
|
512
|
+
#
|
513
|
+
# @return (see Metasploit;:Model::Module::Class#module_type)
|
514
|
+
delegate :module_type,
|
515
|
+
allow_nil: true,
|
516
|
+
to: :module_class
|
517
|
+
|
518
|
+
# Whether {#module_type} requires {#stance} to be set or to be `nil`.
|
519
|
+
#
|
520
|
+
# @return (see Metasploit::Model::Module::Instance::ClassMethods#stanced?)
|
521
|
+
# @return [false] if {#module_type} is not valid
|
522
|
+
def stanced?
|
523
|
+
self.class.stanced?(module_type)
|
524
|
+
end
|
554
525
|
|
555
|
-
|
556
|
-
|
526
|
+
private
|
527
|
+
|
528
|
+
# Validates that the {#module_architectures}
|
529
|
+
# {Metasploit::Model::Module::Architecture#architecture architectures} match the {#targets}
|
530
|
+
# {Metasploit::Model::Module::Target#target_architectures target_architectures}
|
531
|
+
# {Metasploit::Model::Module::Target::Architecture#architecture architectures}.
|
532
|
+
#
|
533
|
+
# @return [void]
|
534
|
+
def architectures_from_targets
|
535
|
+
actual_architecture_set = Set.new module_architectures.map(&:architecture)
|
536
|
+
expected_architecture_set = Set.new
|
537
|
+
|
538
|
+
targets.each do |module_target|
|
539
|
+
module_target.target_architectures.each do |target_architecture|
|
540
|
+
expected_architecture_set.add target_architecture.architecture
|
541
|
+
end
|
542
|
+
end
|
557
543
|
|
558
|
-
|
544
|
+
extra_architecture_set = actual_architecture_set - expected_architecture_set
|
559
545
|
|
560
|
-
|
561
|
-
|
546
|
+
unless extra_architecture_set.empty?
|
547
|
+
human_extra_architectures = human_architecture_set(extra_architecture_set)
|
562
548
|
|
563
|
-
|
564
|
-
|
565
|
-
end
|
549
|
+
errors.add(:architectures, :extra, extra: human_extra_architectures)
|
550
|
+
end
|
566
551
|
|
567
|
-
|
568
|
-
# {Metasploit::Model::Architecture#abbreviation}.
|
569
|
-
#
|
570
|
-
# @return [String]
|
571
|
-
def human_architecture_set(architecture_set)
|
572
|
-
abbreviations = architecture_set.map(&:abbreviation)
|
552
|
+
missing_architecture_set = expected_architecture_set - actual_architecture_set
|
573
553
|
|
574
|
-
|
575
|
-
|
554
|
+
unless missing_architecture_set.empty?
|
555
|
+
human_missing_architectures = human_architecture_set(missing_architecture_set)
|
576
556
|
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
# @return [String]
|
581
|
-
def human_platform_set(platform_set)
|
582
|
-
fully_qualified_names = platform_set.map(&:fully_qualified_name)
|
557
|
+
errors.add(:architectures, :missing, missing: human_missing_architectures)
|
558
|
+
end
|
559
|
+
end
|
583
560
|
|
584
|
-
|
585
|
-
|
561
|
+
# Converts a Set<Metasploit::Model::Architecture> to a human readable representation including the
|
562
|
+
# {Metasploit::Model::Architecture#abbreviation}.
|
563
|
+
#
|
564
|
+
# @return [String]
|
565
|
+
def human_architecture_set(architecture_set)
|
566
|
+
abbreviations = architecture_set.map(&:abbreviation)
|
586
567
|
|
587
|
-
|
588
|
-
|
589
|
-
# @return [String]
|
590
|
-
def human_set(strings)
|
591
|
-
sorted = strings.sort
|
592
|
-
comma_separated = sorted.join(', ')
|
568
|
+
human_set(abbreviations)
|
569
|
+
end
|
593
570
|
|
594
|
-
|
595
|
-
|
571
|
+
# Converts a Set<Metasploit::Model::Platform> to a human-readable representation including the
|
572
|
+
# {Metasploit::Model::Platform#fully_qualified_name}.
|
573
|
+
#
|
574
|
+
# @return [String]
|
575
|
+
def human_platform_set(platform_set)
|
576
|
+
fully_qualified_names = platform_set.map(&:fully_qualified_name)
|
596
577
|
|
597
|
-
|
598
|
-
|
599
|
-
# {Metasploit::Model::Module::Target::Platform#platform platforms}.
|
600
|
-
#
|
601
|
-
# @return [void]
|
602
|
-
def platforms_from_targets
|
603
|
-
actual_platform_set = Set.new module_platforms.map(&:platform)
|
604
|
-
expected_platform_set = Set.new
|
605
|
-
|
606
|
-
targets.each do |module_target|
|
607
|
-
module_target.target_platforms.each do |target_platform|
|
608
|
-
expected_platform_set.add target_platform.platform
|
609
|
-
end
|
610
|
-
end
|
578
|
+
human_set(fully_qualified_names)
|
579
|
+
end
|
611
580
|
|
612
|
-
|
581
|
+
# Converts strings to a human-readable set notation.
|
582
|
+
#
|
583
|
+
# @return [String]
|
584
|
+
def human_set(strings)
|
585
|
+
sorted = strings.sort
|
586
|
+
comma_separated = sorted.join(', ')
|
613
587
|
|
614
|
-
|
615
|
-
|
588
|
+
"{#{comma_separated}}"
|
589
|
+
end
|
616
590
|
|
617
|
-
|
618
|
-
|
591
|
+
# Validates that {#module_platforms} {Metasploit::Model::Module::Platform#platform platforms} match the
|
592
|
+
# {#targets} {Metasploit::Model::Module::Target#target_platforms target_platforms}
|
593
|
+
# {Metasploit::Model::Module::Target::Platform#platform platforms}.
|
594
|
+
#
|
595
|
+
# @return [void]
|
596
|
+
def platforms_from_targets
|
597
|
+
actual_platform_set = Set.new module_platforms.map(&:platform)
|
598
|
+
expected_platform_set = Set.new
|
599
|
+
|
600
|
+
targets.each do |module_target|
|
601
|
+
module_target.target_platforms.each do |target_platform|
|
602
|
+
expected_platform_set.add target_platform.platform
|
603
|
+
end
|
604
|
+
end
|
619
605
|
|
620
|
-
|
606
|
+
extra_platform_set = actual_platform_set - expected_platform_set
|
621
607
|
|
622
|
-
|
623
|
-
|
608
|
+
unless extra_platform_set.empty?
|
609
|
+
human_extra_platforms = human_platform_set(extra_platform_set)
|
624
610
|
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
611
|
+
errors.add(:platforms, :extra, extra: human_extra_platforms)
|
612
|
+
end
|
613
|
+
|
614
|
+
missing_platform_set = expected_platform_set - actual_platform_set
|
615
|
+
|
616
|
+
unless missing_platform_set.empty?
|
617
|
+
human_missing_platforms = human_platform_set(missing_platform_set)
|
618
|
+
|
619
|
+
errors.add(:platforms, :missing, missing: human_missing_platforms)
|
629
620
|
end
|
630
621
|
end
|
631
622
|
end
|
632
|
-
|