metasploit_data_models 1.0.0.pre.rails.pre.4.0b → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/.travis.yml +6 -3
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +10 -52
  6. data/Gemfile +4 -6
  7. data/RELEASING.md +88 -0
  8. data/Rakefile +23 -0
  9. data/UPGRADING.md +1 -0
  10. data/app/models/mdm/api_key.rb +41 -1
  11. data/app/models/mdm/client.rb +41 -1
  12. data/app/models/mdm/cred.rb +116 -28
  13. data/app/models/mdm/event.rb +47 -0
  14. data/app/models/mdm/exploit_attempt.rb +65 -16
  15. data/app/models/mdm/exploited_host.rb +27 -0
  16. data/app/models/mdm/host_detail.rb +44 -0
  17. data/app/models/mdm/host_tag.rb +6 -8
  18. data/app/models/mdm/listener.rb +52 -0
  19. data/app/models/mdm/macro.rb +42 -0
  20. data/app/models/mdm/mod_ref.rb +21 -1
  21. data/app/models/mdm/module/action.rb +15 -0
  22. data/app/models/mdm/module/arch.rb +10 -0
  23. data/app/models/mdm/module/author.rb +17 -1
  24. data/app/models/mdm/module/mixin.rb +13 -0
  25. data/app/models/mdm/module/platform.rb +11 -0
  26. data/app/models/mdm/module/target.rb +18 -0
  27. data/app/models/mdm/nexpose_console.rb +82 -4
  28. data/app/models/mdm/profile.rb +36 -0
  29. data/app/models/mdm/route.rb +16 -4
  30. data/app/models/mdm/session_event.rb +32 -0
  31. data/app/models/mdm/tag.rb +48 -9
  32. data/app/models/mdm/task.rb +85 -46
  33. data/app/models/mdm/task_cred.rb +29 -0
  34. data/app/models/mdm/task_host.rb +25 -0
  35. data/app/models/mdm/task_service.rb +25 -0
  36. data/app/models/mdm/task_session.rb +25 -0
  37. data/app/models/mdm/user.rb +192 -6
  38. data/app/models/mdm/vuln_attempt.rb +37 -12
  39. data/app/models/mdm/vuln_detail.rb +138 -5
  40. data/app/models/mdm/vuln_ref.rb +3 -0
  41. data/app/models/mdm/web_form.rb +34 -0
  42. data/app/models/mdm/web_page.rb +69 -0
  43. data/app/models/mdm/web_site.rb +50 -0
  44. data/app/models/mdm/wmap_request.rb +85 -0
  45. data/app/models/mdm/wmap_target.rb +40 -0
  46. data/app/models/mdm/workspace.rb +160 -17
  47. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +13 -23
  48. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +25 -4
  49. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +15 -4
  50. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +7 -3
  51. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  52. data/app/models/metasploit_data_models/module_run.rb +1 -1
  53. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  54. data/app/validators/ip_format_validator.rb +4 -0
  55. data/app/validators/parameters_validator.rb +12 -0
  56. data/app/validators/password_is_strong_validator.rb +10 -1
  57. data/lib/mdm/host/operating_system_normalization.rb +7 -10
  58. data/lib/metasploit_data_models.rb +4 -0
  59. data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
  60. data/lib/metasploit_data_models/engine.rb +2 -0
  61. data/lib/metasploit_data_models/serialized_prefs.rb +6 -0
  62. data/lib/metasploit_data_models/version.rb +30 -7
  63. data/metasploit_data_models.gemspec +9 -2
  64. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  65. data/spec/app/models/mdm/client_spec.rb +9 -11
  66. data/spec/app/models/mdm/cred_spec.rb +42 -54
  67. data/spec/app/models/mdm/event_spec.rb +22 -24
  68. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  69. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  70. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  71. data/spec/app/models/mdm/host_spec.rb +262 -260
  72. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  73. data/spec/app/models/mdm/listener_spec.rb +30 -32
  74. data/spec/app/models/mdm/loot_spec.rb +21 -23
  75. data/spec/app/models/mdm/macro_spec.rb +1 -3
  76. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  77. data/spec/app/models/mdm/module/action_spec.rb +8 -10
  78. data/spec/app/models/mdm/module/arch_spec.rb +8 -10
  79. data/spec/app/models/mdm/module/author_spec.rb +19 -14
  80. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  81. data/spec/app/models/mdm/module/mixin_spec.rb +8 -10
  82. data/spec/app/models/mdm/module/platform_spec.rb +8 -10
  83. data/spec/app/models/mdm/module/ref_spec.rb +8 -10
  84. data/spec/app/models/mdm/module/target_spec.rb +10 -12
  85. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  86. data/spec/app/models/mdm/note_spec.rb +23 -25
  87. data/spec/app/models/mdm/profile_spec.rb +1 -3
  88. data/spec/app/models/mdm/ref_spec.rb +9 -12
  89. data/spec/app/models/mdm/route_spec.rb +6 -8
  90. data/spec/app/models/mdm/service_spec.rb +38 -40
  91. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  92. data/spec/app/models/mdm/session_spec.rb +13 -15
  93. data/spec/app/models/mdm/tag_spec.rb +29 -30
  94. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  95. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  96. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  97. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  98. data/spec/app/models/mdm/task_spec.rb +27 -29
  99. data/spec/app/models/mdm/user_spec.rb +17 -19
  100. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  101. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  102. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  103. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  104. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  105. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  106. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  107. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  108. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  109. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  110. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  111. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  112. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  113. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  114. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  115. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  116. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  117. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  118. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  119. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  120. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  121. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  122. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  123. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  124. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  125. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  126. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  127. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  128. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  129. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  130. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  131. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  132. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  133. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  134. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  135. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  136. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  137. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  138. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  139. data/spec/lib/base64_serializer_spec.rb +19 -21
  140. data/spec/lib/ipaddr_spec.rb +1 -3
  141. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  142. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  143. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  144. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  145. data/spec/lib/metasploit_data_models/version_spec.rb +3 -139
  146. data/spec/lib/metasploit_data_models_spec.rb +4 -0
  147. data/spec/spec_helper.rb +86 -12
  148. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  149. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  150. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  151. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  152. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  153. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  154. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  155. metadata +74 -14
  156. data/app/models/metasploit_data_models/automatic_exploitation.rb +0 -16
  157. data/lib/tasks/yard.rake +0 -33
@@ -1,4 +1,89 @@
1
+ # Request sent to a {Mdm::WmapTarget}. WMAP is a plugin to metasploit-framework.
1
2
  class Mdm::WmapRequest < ActiveRecord::Base
3
+ #
4
+ #
5
+ # Attributes
6
+ #
7
+ #
8
+
9
+ # @!attribute address
10
+ # IP address of {#host} to which this request was sent.
11
+ #
12
+ # @return [String]
13
+
14
+ # @!attribute body
15
+ # Body of this request.
16
+ #
17
+ # @return [String]
18
+
19
+ # @!attribute created_at
20
+ # When this request was created.
21
+ #
22
+ # @return [DateTime]
23
+
24
+ # @!attribute headers
25
+ # Headers sent as part of this request.
26
+ #
27
+ # @return [String]
28
+
29
+ # @!attribute host
30
+ # Name of host to which this request was sent.
31
+ #
32
+ # @return [String]
33
+
34
+ # @!attribute meth
35
+ # HTTP Method (or VERB) used for request.
36
+ #
37
+ # @return [String]
38
+
39
+ # @!attribute path
40
+ # Path portion of URL for this request.
41
+ #
42
+ # @return [String]
43
+
44
+ # @!attribute port
45
+ # Port at {#address} to which this request was sent.
46
+ #
47
+ # @return [Integer]
48
+
49
+ # @!attribute query
50
+ # Query portion of URL for this request.
51
+ #
52
+ # @return [String]
53
+
54
+ # @!attribute ssl
55
+ # Version of SSL to use.
56
+ #
57
+ # @return [Integer]
58
+
59
+ # @!attribute updated_at
60
+ # The last time this request was updated.
61
+ #
62
+ # @return [DateTime]
63
+
64
+ #
65
+ # @!group Response
66
+ #
67
+
68
+ # @!attribute respcode
69
+ # HTTP status code sent in response to this request from server.
70
+ #
71
+ # @return [String]
72
+
73
+ # @!attribute resphead
74
+ # Headers sent in response from server.
75
+ #
76
+ # @return [String]
77
+
78
+ # @!attribute response
79
+ # Response sent from server.
80
+ #
81
+ # @return [String]
82
+
83
+ #
84
+ # @!endgroup
85
+ #
86
+
2
87
  Metasploit::Concern.run(self)
3
88
 
4
89
  #
@@ -1,4 +1,44 @@
1
+ # WMAP target. WMAP is a plugin to metasploit-framework.
1
2
  class Mdm::WmapTarget < ActiveRecord::Base
3
+ #
4
+ # Attributes
5
+ #
6
+
7
+ # @!attribute address
8
+ # IP address of {#host}.
9
+ #
10
+ # @return [String]
11
+
12
+ # @!attribute created_at
13
+ # When this target was created.
14
+ #
15
+ # @return [DateTime]
16
+
17
+ # @!attribute host
18
+ # Name of this target.
19
+ #
20
+ # @return [String]
21
+
22
+ # @!attribute port
23
+ # Port on this target to send {Mdm::WmapRequest requests}.
24
+ #
25
+ # @return [Integer]
26
+
27
+ # @!attribute selected
28
+ # Whether this target should be sent requests.
29
+ #
30
+ # @return [Integer]
31
+
32
+ # @!attribute ssl
33
+ # Version of SSL to use when sending requests to this target.
34
+ #
35
+ # @return [Integer]
36
+
37
+ # @!attribute updated_at
38
+ # The last time this target was updated.
39
+ #
40
+ # @return [DateTime]
41
+
2
42
  Metasploit::Concern.run(self)
3
43
 
4
44
  #
@@ -1,11 +1,6 @@
1
+ # Workspace to separate different collections of {#hosts}. Can be used to separate pentests against different networks
2
+ # or different clients as reports are normally generated against all records in a workspace.
1
3
  class Mdm::Workspace < ActiveRecord::Base
2
-
3
- #
4
- # Callbacks
5
- #
6
-
7
- before_save :normalize
8
-
9
4
  #
10
5
  # CONSTANTS
11
6
  #
@@ -13,36 +8,121 @@ class Mdm::Workspace < ActiveRecord::Base
13
8
  DEFAULT = 'default'
14
9
 
15
10
  #
16
- # Relations
11
+ # Associations
17
12
  #
18
13
 
14
+ # Automatic exploitation runs against this workspace.
19
15
  has_many :automatic_exploitation_runs,
20
16
  class_name: 'MetasploitDataModels::AutomaticExploitation::Run',
21
17
  inverse_of: :workspace
22
18
 
19
+ # Automatic exploitation match sets generated against {#hosts} and {#services} in this workspace.
23
20
  has_many :automatic_exploitation_match_sets,
24
21
  class_name: 'MetasploitDataModels::AutomaticExploitation:MatchSet',
25
22
  inverse_of: :workspace
26
23
 
24
+ # @deprecated Use `Mdm::Workspace#core_credentials` defined by `Metasploit::Credential::Engine` to get
25
+ # `Metasploit::Credential::Core`s gathered from this workspace's {#hosts} and {#services}.
26
+ #
27
+ # Creds gathered from this workspace's {#hosts} and {#services}.
27
28
  has_many :creds, :through => :services, :class_name => 'Mdm::Cred'
29
+
30
+ # Events that occurred in this workspace.
28
31
  has_many :events, :class_name => 'Mdm::Event'
32
+
33
+ # Hosts in this workspace.
29
34
  has_many :hosts, :dependent => :destroy, :class_name => 'Mdm::Host'
35
+
36
+ # Listeners running for this workspace.
30
37
  has_many :listeners, :dependent => :destroy, :class_name => 'Mdm::Listener'
38
+
39
+ # Notes about this workspace.
31
40
  has_many :notes, :class_name => 'Mdm::Note'
41
+
42
+ # User that owns this workspace and has full permissions within this workspace even if they are not an
43
+ # {Mdm::User#admin administrator}.
32
44
  belongs_to :owner, :class_name => 'Mdm::User', :foreign_key => 'owner_id'
33
- has_many :tasks, -> { order('created_at DESC') }, :dependent => :destroy, :class_name => 'Mdm::Task'
34
- has_and_belongs_to_many :users, -> { uniq }, :join_table => 'workspace_members', :class_name => 'Mdm::User'
45
+
46
+ # Tasks run inside this workspace.
47
+ has_many :tasks,
48
+ -> { order('created_at DESC') },
49
+ class_name: 'Mdm::Task',
50
+ dependent: :destroy
51
+
52
+ # Users that are allowed to use this workspace. Does not necessarily include all users, as an {Mdm::User#admin
53
+ # administrator} can access any workspace, even ones where they are not a member.
54
+ has_and_belongs_to_many :users,
55
+ -> { uniq },
56
+ class_name: 'Mdm::User',
57
+ join_table: 'workspace_members'
35
58
 
36
59
  #
37
- # Through :hosts
60
+ # through: :hosts
38
61
  #
62
+
63
+ # Social engineering campaign or browser autopwn clients from {#hosts} in this workspace.
39
64
  has_many :clients, :through => :hosts, :class_name => 'Mdm::Client'
65
+
66
+ # Hosts exploited in this workspace.
40
67
  has_many :exploited_hosts, :through => :hosts, :class_name => 'Mdm::ExploitedHost'
68
+
69
+ # Loot gathered from {#hosts} in this workspace.
41
70
  has_many :loots, :through => :hosts, :class_name => 'Mdm::Loot'
71
+
72
+ # Services running on {#hosts} in this workspace.
73
+ has_many :services,
74
+ class_name: 'Mdm::Service',
75
+ foreign_key: :service_id,
76
+ through: :hosts
77
+
78
+ # Vulnerabilities found on {#hosts} in this workspace.
42
79
  has_many :vulns, :through => :hosts, :class_name => 'Mdm::Vuln'
43
- has_many :services, :through => :hosts, :class_name => 'Mdm::Service', :foreign_key => 'service_id'
80
+
81
+ # Sessions opened on {#hosts} in this workspace.
44
82
  has_many :sessions, :through => :hosts, :class_name => 'Mdm::Session'
45
83
 
84
+ #
85
+ # Attributes
86
+ #
87
+
88
+ # @!attribute boundary
89
+ # Comma separated list of IP ranges (in various formats) and IP addresses that users of this workspace are allowed
90
+ # to interact with if {#limit_to_network} is `true`.
91
+ #
92
+ # @return [String]
93
+
94
+ # @!attribute description
95
+ # Long description (beyond {#name}) that explains the purpose of this workspace.
96
+ #
97
+ # @return [String]
98
+
99
+ # @!attribute limit_to_network
100
+ # Whether {#boundary} is respected.
101
+ #
102
+ # @return [false] do not limit interactions to {#boundary}.
103
+ # @return [true] limit interactions to {#boundary}.
104
+
105
+ # @!attribute name
106
+ # Name of this workspace.
107
+ #
108
+ # @return [String]
109
+
110
+ # @!attribute created_at
111
+ # When this workspace was created.
112
+ #
113
+ # @return [DateTime]
114
+
115
+ # @!attribute updated_at
116
+ # The last time this workspace was updated.
117
+ #
118
+ # @return [DateTime]
119
+
120
+ #
121
+ # Callbacks
122
+ #
123
+
124
+ before_save :normalize
125
+
46
126
  #
47
127
  # Validations
48
128
  #
@@ -52,10 +132,15 @@ class Mdm::Workspace < ActiveRecord::Base
52
132
  validate :boundary_must_be_ip_range
53
133
 
54
134
  #
55
- # If limit_to_network is disabled, this will always return true.
56
- # Otherwise, return true only if all of the given IPs are within the project
57
- # boundaries.
135
+ # Instance Methods
58
136
  #
137
+
138
+ # If {#limit_to_network} is disabled, this will always return `true`. Otherwise, return `true` only if all of the
139
+ # given IPs are within the project {#boundary boundaries}.
140
+ #
141
+ # @param ips [String] IP range(s)
142
+ # @return [true] if actions on ips are allowed.
143
+ # @return [false] if actions are not allowed on ips.
59
144
  def allow_actions_on?(ips)
60
145
  return true unless limit_to_network
61
146
  return true unless boundary
@@ -72,10 +157,18 @@ class Mdm::Workspace < ActiveRecord::Base
72
157
  return allowed
73
158
  end
74
159
 
160
+ # Validates that {#boundary} is {#valid_ip_or_range? a valid IP address or IP address range}.
161
+ #
162
+ # @return [void]
75
163
  def boundary_must_be_ip_range
76
164
  errors.add(:boundary, "must be a valid IP range") unless valid_ip_or_range?(boundary)
77
165
  end
78
166
 
167
+ # @deprecated Use `Mdm::Workspace#credential_cores` when `Metasploit::Credential::Engine` is installed to get
168
+ # `Metasploit::Credential::Core`s. Use `Mdm::Service#logins` when `Metasploit::Credential::Engine` is installed to
169
+ # get `Metasploit::Credential::Login`s.
170
+ #
171
+ # @return [ActiveRecord::Relation<Mdm::Cred>]
79
172
  def creds
80
173
  Mdm::Cred.find(
81
174
  :all,
@@ -84,30 +177,52 @@ class Mdm::Workspace < ActiveRecord::Base
84
177
  )
85
178
  end
86
179
 
180
+ # Returns default {Mdm::Workspace}.
181
+ #
182
+ # @return [Mdm::Workspace]
87
183
  def self.default
88
184
  where(name: DEFAULT).first_or_create
89
185
  end
90
186
 
187
+ # Whether this is the {default} workspace.
188
+ #
189
+ # @return [true] if this is the {default} workspace.
190
+ # @return [false] if this is not the {default} workspace.
91
191
  def default?
92
192
  name == DEFAULT
93
193
  end
94
194
 
195
+ # @deprecated Use `workspace.credential_cores.each` when `Metasploit::Credential::Engine` is installed to enumerate
196
+ # `Metasploit::Credential::Core`s. Use `service.logins.each` when `Metasploit::Credential::Engine` is installed to
197
+ # enumerate `Metasploit::Credential::Login`s.
95
198
  #
96
- # This method iterates the creds table calling the supplied block with the
97
- # cred instance of each entry.
199
+ # Enumerates each element of {#creds}.
98
200
  #
201
+ # @yield [cred]
202
+ # @yieldparam cred [Mdm::Cred] Cred associated with {#hosts a host} or {#services a service} in this workspace.
203
+ # @yieldreturn [void]
204
+ # @return [void]
99
205
  def each_cred(&block)
100
206
  creds.each do |cred|
101
207
  block.call(cred)
102
208
  end
103
209
  end
104
210
 
211
+ # Enumerates each element of {#host_tags}.
212
+ #
213
+ # @yield [tag]
214
+ # @yieldparam tag [Mdm::Tag] a tag on {#hosts}.
215
+ # @yieldreturn [void]
216
+ # @return [void]
105
217
  def each_host_tag(&block)
106
218
  host_tags.each do |host_tag|
107
219
  block.call(host_tag)
108
220
  end
109
221
  end
110
222
 
223
+ # Tags on {#hosts}.
224
+ #
225
+ # @return [ActiveRecord::Relation<Mdm::Tag>]
111
226
  def host_tags
112
227
  Mdm::Tag.find(
113
228
  :all,
@@ -116,6 +231,9 @@ class Mdm::Workspace < ActiveRecord::Base
116
231
  )
117
232
  end
118
233
 
234
+ # Web forms found on {#web_sites}.
235
+ #
236
+ # @return [ActiveRecord::Relation<Mdm::WebForm>]
119
237
  def web_forms
120
238
  query = <<-EOQ
121
239
  SELECT DISTINCT web_forms.*
@@ -128,6 +246,10 @@ class Mdm::Workspace < ActiveRecord::Base
128
246
  Mdm::WebForm.find_by_sql(query)
129
247
  end
130
248
 
249
+
250
+ # Web pages found on {#web_sites}.
251
+ #
252
+ # @return [ActiveRecord::Relation<Mdm::WebPage>]
131
253
  def web_pages
132
254
  query = <<-EOQ
133
255
  SELECT DISTINCT web_pages.*
@@ -140,6 +262,9 @@ class Mdm::Workspace < ActiveRecord::Base
140
262
  Mdm::WebPage.find_by_sql(query)
141
263
  end
142
264
 
265
+ # Web sites running on {#services}.
266
+ #
267
+ # @return [ActiveRecord::Relation<Mdm::WebSite>]
143
268
  def web_sites
144
269
  query = <<-EOQ
145
270
  SELECT DISTINCT web_sites.*
@@ -151,6 +276,9 @@ class Mdm::Workspace < ActiveRecord::Base
151
276
  Mdm::WebSite.find_by_sql(query)
152
277
  end
153
278
 
279
+ # Web vulnerability found on {#web_sites}.
280
+ #
281
+ # @return [ActiveRecord::Relation<Mdm::WebVuln>]
154
282
  def web_vulns
155
283
  query = <<-EOQ
156
284
  SELECT DISTINCT web_vulns.*
@@ -163,6 +291,9 @@ class Mdm::Workspace < ActiveRecord::Base
163
291
  Mdm::WebVuln.find_by_sql(query)
164
292
  end
165
293
 
294
+ # Web forms on {#web_sites}.
295
+ #
296
+ # @return [ActiveRecord::Relation<Mdm::WebForm>]
166
297
  def unique_web_forms
167
298
  query = <<-EOQ
168
299
  SELECT DISTINCT web_forms.web_site_id, web_forms.path, web_forms.method, web_forms.query
@@ -175,6 +306,11 @@ class Mdm::Workspace < ActiveRecord::Base
175
306
  Mdm::WebForm.find_by_sql(query)
176
307
  end
177
308
 
309
+ # {#unique_web_forms} hosted on `addrs`.
310
+ #
311
+ # @param addrs [Array<IPAddr, String>] {Mdm::Host#address} for the {Mdm::Service#host} for the {Mdm::WebSite#service}
312
+ # for the {Mdm::WebForm#web_site}.
313
+ # @return [Array<Mdm::WebForm>]
178
314
  def web_unique_forms(addrs=nil)
179
315
  forms = unique_web_forms
180
316
  if addrs
@@ -185,10 +321,17 @@ class Mdm::Workspace < ActiveRecord::Base
185
321
 
186
322
  private
187
323
 
324
+ # Strips {#boundary}.
325
+ #
326
+ # @return [void]
188
327
  def normalize
189
328
  boundary.strip! if boundary
190
329
  end
191
330
 
331
+ # Returns whether `string` is a valid IP address or IP address range.
332
+ #
333
+ # @return [true] if valid IP address or IP address range.
334
+ # @return [false] otherwise.
192
335
  def valid_ip_or_range?(string)
193
336
  begin
194
337
  Rex::Socket::RangeWalker.new(string)
@@ -1,39 +1,29 @@
1
+ # Matches {#matchable} {Mdm::Service} or {Mdm::Vuln} to a {#module_detail Metasploit Module} that can exploit it.
1
2
  class MetasploitDataModels::AutomaticExploitation::Match < ActiveRecord::Base
2
-
3
3
  #
4
4
  # Associations
5
5
  #
6
6
 
7
- # @!attribute matchable
8
- # A (polymorphic) "matchable" entity like a {Mdm::Vuln} or {Mdm::Service}
7
+ # A (polymorphic) "matchable" entity like a {Mdm::Vuln} or {Mdm::Service}
9
8
  #
10
- # @return [Mdm::Vuln, Mdm::Service]
9
+ # @return [Mdm::Service, Mdm::Vuln]
11
10
  belongs_to :matchable, polymorphic: true
12
11
 
13
- # @!attribute module_detail
14
- # The MSF module that this match connects to
15
- #
16
- # @return [Mdm::Module::Detail]
17
- belongs_to :module_detail,
18
- class_name: 'Mdm::Module::Detail',
19
- foreign_key: :module_fullname,
20
- primary_key: :fullname
21
-
22
- # @!attribute match_set
23
- # The {MatchSet} this match is part of
24
- #
25
- # @return [MetasploitDataModels::AutomaticExploitation::MatchResult]
12
+ # The {MatchSet} this match is part of
26
13
  has_many :match_results,
27
- class_name: 'MetasploitDataModels::AutomaticExploitation::MatchResult',
28
- inverse_of: :match
14
+ class_name: 'MetasploitDataModels::AutomaticExploitation::MatchResult',
15
+ inverse_of: :match
29
16
 
30
- # @!attribute match_set
31
- # The {MatchSet} this match is part of
32
- #
33
- # @return [MetasploitDataModels::AutomaticExploitation::MatchSet]
17
+ # The {MatchSet} this match is part of
34
18
  belongs_to :match_set,
35
19
  class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
36
20
  inverse_of: :matches
37
21
 
22
+ # The Metasploit Module that this match connects to
23
+ belongs_to :module_detail,
24
+ class_name: 'Mdm::Module::Detail',
25
+ foreign_key: :module_fullname,
26
+ primary_key: :fullname
27
+
38
28
  Metasploit::Concern.run(self)
39
29
  end