metasploit-model 0.27.3 → 0.27.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- 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,20 +1,16 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
end
|
3
|
+
# Adds {#real_pathname} to class, which will convert `#real_path` `String` to a `Pathname`.
|
4
|
+
module Metasploit::Model::RealPathname
|
5
|
+
# `#real_path` as a `Pathname`.
|
6
|
+
#
|
7
|
+
# @return [Pathname] unless `#real_path` is `nil`.
|
8
|
+
# @return [nil] if `#real_path` is `nil`.
|
9
|
+
def real_pathname
|
10
|
+
if real_path
|
11
|
+
Pathname.new(real_path)
|
12
|
+
else
|
13
|
+
nil
|
18
14
|
end
|
19
15
|
end
|
20
|
-
end
|
16
|
+
end
|
@@ -1,110 +1,104 @@
|
|
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
|
-
derived = nil
|
101
|
-
|
102
|
-
if authority and designation.present?
|
103
|
-
derived = authority.designation_url(designation)
|
104
|
-
end
|
105
|
-
|
106
|
-
derived
|
107
|
-
end
|
1
|
+
# Code shared between `Mdm::Reference` and `Metasploit::Framework::Reference`.
|
2
|
+
module Metasploit::Model::Reference
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
include Metasploit::Model::Translation
|
7
|
+
|
8
|
+
included do
|
9
|
+
include ActiveModel::MassAssignmentSecurity
|
10
|
+
include ActiveModel::Validations
|
11
|
+
include Metasploit::Model::Derivation
|
12
|
+
include Metasploit::Model::Search
|
13
|
+
|
14
|
+
#
|
15
|
+
# Derivations
|
16
|
+
#
|
17
|
+
|
18
|
+
derives :url, :validate => false
|
19
|
+
|
20
|
+
#
|
21
|
+
# Mass Assignment Security
|
22
|
+
#
|
23
|
+
|
24
|
+
attr_accessible :designation
|
25
|
+
attr_accessible :url
|
26
|
+
|
27
|
+
#
|
28
|
+
# Search Attributes
|
29
|
+
#
|
30
|
+
|
31
|
+
search_attribute :designation, :type => :string
|
32
|
+
search_attribute :url, :type => :string
|
33
|
+
|
34
|
+
#
|
35
|
+
# Validations
|
36
|
+
#
|
37
|
+
|
38
|
+
validates :designation,
|
39
|
+
:presence => {
|
40
|
+
:if => :authority?
|
41
|
+
},
|
42
|
+
:nil => {
|
43
|
+
:unless => :authority?
|
44
|
+
}
|
45
|
+
validates :url,
|
46
|
+
:presence => {
|
47
|
+
:unless => :authority?
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Associations
|
53
|
+
#
|
54
|
+
|
55
|
+
# @!attribute [rw] authority
|
56
|
+
# The {Metasploit::Model::Authority authority} that assigned {#designation}.
|
57
|
+
#
|
58
|
+
# @return [Metasploit::Model::Authority, nil]
|
59
|
+
|
60
|
+
# @!attribute [r] module_instances
|
61
|
+
# {Metasploit::Model::Module::Instance Modules} that exploit this reference or describe a proof-of-concept (PoC)
|
62
|
+
# code that the module is based on.
|
63
|
+
#
|
64
|
+
# @return [Array<Metasploit::Model::Module::Instance>]
|
65
|
+
|
66
|
+
#
|
67
|
+
# Attributes
|
68
|
+
#
|
69
|
+
|
70
|
+
# @!attribute [rw] designation
|
71
|
+
# A designation (usually a string of numbers and dashes) assigned by {#authority}.
|
72
|
+
#
|
73
|
+
# @return [String, nil]
|
74
|
+
|
75
|
+
# @!attribute [rw] url
|
76
|
+
# URL to web page with information about referenced exploit.
|
77
|
+
#
|
78
|
+
# @return [String, nil]
|
79
|
+
|
80
|
+
#
|
81
|
+
# Instance Methods
|
82
|
+
#
|
83
|
+
|
84
|
+
# Returns whether {#authority} is not `nil`.
|
85
|
+
#
|
86
|
+
# @return [true] unless {#authority} is `nil`.
|
87
|
+
# @return [false] if {#authority} is `nil`.
|
88
|
+
def authority?
|
89
|
+
authority.present?
|
90
|
+
end
|
91
|
+
|
92
|
+
# Derives {#url} based how {#authority} routes {#designation designations} to a URL.
|
93
|
+
#
|
94
|
+
# @return [String, nil]
|
95
|
+
def derived_url
|
96
|
+
derived = nil
|
97
|
+
|
98
|
+
if authority and designation.present?
|
99
|
+
derived = authority.designation_url(designation)
|
108
100
|
end
|
101
|
+
|
102
|
+
derived
|
109
103
|
end
|
110
|
-
end
|
104
|
+
end
|
@@ -1,106 +1,103 @@
|
|
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
|
-
extend ActiveSupport::Concern
|
66
|
-
extend ActiveSupport::Autoload
|
67
|
-
|
68
|
-
require 'metasploit/model/search/association'
|
69
|
-
require 'metasploit/model/search/attribute'
|
70
|
-
require 'metasploit/model/search/with'
|
1
|
+
# DSL to define associations and attributes that can be searched. Making an association searchable, will expose
|
2
|
+
# the attributes that association's class defined as searchable.
|
3
|
+
#
|
4
|
+
# # Operators
|
5
|
+
#
|
6
|
+
# Search operators define how to search against a given `Class`.
|
7
|
+
#
|
8
|
+
# ## Attributes
|
9
|
+
#
|
10
|
+
# Boolean, `Date`, `Integer`, and `String` attributes can be searched with
|
11
|
+
# {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute}. `Integer` and `String`
|
12
|
+
# attributes can be further restricted to a defined `Set` of values.
|
13
|
+
#
|
14
|
+
# class Part
|
15
|
+
# include Metasploit::Model::Search
|
16
|
+
#
|
17
|
+
# search_attribute :part,
|
18
|
+
# :integer
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# The above defines the `:part` operator on `Part`.
|
22
|
+
#
|
23
|
+
# ## Custom search operators
|
24
|
+
#
|
25
|
+
# If a search operator does not directly correspond to an attribute or a the attribute needs custom validation, then
|
26
|
+
# a custom {Metasploit::Model::Search::Operator operator class} can be setup as the search operator
|
27
|
+
#
|
28
|
+
# class Search::Operator::UUID
|
29
|
+
# def name
|
30
|
+
# :uuid
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# class Part
|
35
|
+
# include Metasploit::Model::Search
|
36
|
+
#
|
37
|
+
# search_with Search::Operator::UUID
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# The above defines the `:uuid` operator on `Part`.
|
41
|
+
#
|
42
|
+
# ## Associations
|
43
|
+
#
|
44
|
+
# Search operators registered with
|
45
|
+
# {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute search_attribute} or
|
46
|
+
# {Metasploit::Model::Search::With::ClassMethods#search_with search_with} on an associated `Class` can be searched
|
47
|
+
# with {Metasploit::Model::Search::Association::ClassMethods#search_association}:
|
48
|
+
#
|
49
|
+
# class Widget
|
50
|
+
# include Metasploit::Model::Search
|
51
|
+
#
|
52
|
+
# # declare parts association
|
53
|
+
#
|
54
|
+
# search_association :parts
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# The above will define the `:'parts.number'` and `:'parts.uuid'` operator on `Widget`.
|
58
|
+
#
|
59
|
+
# # Queries
|
60
|
+
#
|
61
|
+
# {include:Metasploit::Model::Search::Query}
|
62
|
+
module Metasploit::Model::Search
|
63
|
+
extend ActiveSupport::Autoload
|
64
|
+
extend ActiveSupport::Concern
|
71
65
|
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
autoload :Association
|
67
|
+
autoload :Attribute
|
68
|
+
autoload :Group
|
69
|
+
autoload :Operation
|
70
|
+
autoload :Operator
|
71
|
+
autoload :Query
|
72
|
+
autoload :Search
|
73
|
+
autoload :With
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
include Metasploit::Model::Search::Association
|
76
|
+
include Metasploit::Model::Search::Attribute
|
77
|
+
include Metasploit::Model::Search::With
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
79
|
+
# Allows operators registered with {Metasploit::Model::Search::Association::ClassMethods#search_association} and
|
80
|
+
# {Metasploit::Model::Search::Attribute::ClassMethods#search_attribute} to be looked up by name.
|
81
|
+
module ClassMethods
|
82
|
+
# Collects all search attributes from search associations and all attributes from this class to show the valid
|
83
|
+
# search operators to search.
|
84
|
+
#
|
85
|
+
# @return [Hash{Symbol => Metasploit::Model::Search::Operator}] Maps
|
86
|
+
# {Metasploit::Model::Search::Operator::Base#name} to {Metasploit::Model::Search::Operator::Base#name}.
|
87
|
+
def search_operator_by_name
|
88
|
+
unless instance_variable_defined? :@search_operator_by_name
|
89
|
+
@search_operator_by_name = {}
|
91
90
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
search_association_operators.each do |operator|
|
97
|
-
@search_operator_by_name[operator.name] = operator
|
98
|
-
end
|
99
|
-
end
|
91
|
+
search_with_operator_by_name.each_value do |operator|
|
92
|
+
@search_operator_by_name[operator.name] = operator
|
93
|
+
end
|
100
94
|
|
101
|
-
|
95
|
+
search_association_operators.each do |operator|
|
96
|
+
@search_operator_by_name[operator.name] = operator
|
102
97
|
end
|
103
98
|
end
|
99
|
+
|
100
|
+
@search_operator_by_name
|
104
101
|
end
|
105
102
|
end
|
106
|
-
end
|
103
|
+
end
|