metasploit_data_models 0.17.0-java → 0.17.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/Gemfile +6 -1
- data/app/models/mdm/client.rb +3 -1
- data/app/models/mdm/cred.rb +7 -2
- data/app/models/mdm/event.rb +7 -2
- data/app/models/mdm/exploit_attempt.rb +43 -2
- data/app/models/mdm/exploited_host.rb +7 -2
- data/app/models/mdm/host.rb +85 -49
- data/app/models/mdm/host_detail.rb +4 -1
- data/app/models/mdm/host_tag.rb +41 -3
- data/app/models/mdm/listener.rb +7 -2
- data/app/models/mdm/loot.rb +25 -3
- data/app/models/mdm/nexpose_console.rb +13 -0
- data/app/models/mdm/note.rb +10 -3
- data/app/models/mdm/ref.rb +4 -2
- data/app/models/mdm/route.rb +7 -1
- data/app/models/mdm/service.rb +71 -28
- data/app/models/mdm/session.rb +28 -3
- data/app/models/mdm/session_event.rb +3 -1
- data/app/models/mdm/tag.rb +29 -10
- data/app/models/mdm/task.rb +56 -17
- data/app/models/mdm/task_cred.rb +7 -3
- data/app/models/mdm/task_host.rb +7 -3
- data/app/models/mdm/task_service.rb +7 -3
- data/app/models/mdm/task_session.rb +7 -2
- data/app/models/mdm/user.rb +9 -2
- data/app/models/mdm/vuln.rb +27 -7
- data/app/models/mdm/vuln_attempt.rb +37 -2
- data/app/models/mdm/vuln_detail.rb +9 -1
- data/app/models/mdm/vuln_ref.rb +7 -2
- data/app/models/mdm/web_form.rb +3 -1
- data/app/models/mdm/web_page.rb +3 -1
- data/app/models/mdm/web_site.rb +19 -4
- data/app/models/mdm/web_vuln.rb +3 -1
- data/lib/metasploit_data_models/version.rb +1 -1
- data/lib/tasks/yard.rake +7 -0
- data/metasploit_data_models.gemspec +3 -1
- data/spec/app/models/mdm/host_spec.rb +0 -67
- data/spec/app/models/mdm/host_tag_spec.rb +38 -7
- data/spec/app/models/mdm/tag_spec.rb +5 -23
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ac2acc96e06b312007386119fbcb18dd3b4eed
|
4
|
+
data.tar.gz: 5750da9112e3e3a3e503b6aea84332bc00d307ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e48421538862eb92a3b8fcd2665690699bbbbdb260fdf676b0eab113582e6504d50167fd3d513901c5d81d1b8ac36e6366266856311e37e7e62af9eeb1fc9e
|
7
|
+
data.tar.gz: 1085e221c71d39dea601afa46470158f6d6bb270840df5056524d19ecfa741496ffe7844901a840bc395eecc4d510797c83ba50ebe14cd6e780e7e3faed79b9e
|
data/.yardopts
CHANGED
data/Gemfile
CHANGED
@@ -3,6 +3,11 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in metasploit_data_models.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
group :development do
|
7
|
+
# embed ERDs on index, namespace Module and Class<ActiveRecord::Base> pages
|
8
|
+
gem 'yard-metasploit-erd', '~> 0.0.2'
|
9
|
+
end
|
10
|
+
|
6
11
|
# used by dummy application
|
7
12
|
group :development, :test do
|
8
13
|
# supplies factories for producing model instance for specs
|
@@ -12,7 +17,7 @@ group :development, :test do
|
|
12
17
|
gem 'factory_girl_rails'
|
13
18
|
# rails is only used for the dummy application in spec/dummy
|
14
19
|
# restrict from rails 4.0 as it requires protected_attributes gem and other changes for compatibility
|
15
|
-
# @see
|
20
|
+
# @see MSP-2971
|
16
21
|
gem 'rails', '>= 3.2', '< 4.0.0'
|
17
22
|
# Used to create fake data
|
18
23
|
gem "faker"
|
data/app/models/mdm/client.rb
CHANGED
data/app/models/mdm/cred.rb
CHANGED
@@ -19,13 +19,18 @@ class Mdm::Cred < ActiveRecord::Base
|
|
19
19
|
# The service this cred is for
|
20
20
|
#
|
21
21
|
# @return [Mdm::Service]
|
22
|
-
belongs_to :service,
|
22
|
+
belongs_to :service,
|
23
|
+
class_name: 'Mdm::Service',
|
24
|
+
inverse_of: :creds
|
23
25
|
|
24
26
|
# @!attribute [rw] task_creds
|
25
27
|
# Details about what Tasks touched this cred
|
26
28
|
#
|
27
29
|
# @return [Array<Mdm::TaskCred>]
|
28
|
-
has_many :task_creds,
|
30
|
+
has_many :task_creds,
|
31
|
+
class_name: 'Mdm::TaskCred',
|
32
|
+
dependent: :destroy,
|
33
|
+
inverse_of: :cred
|
29
34
|
|
30
35
|
# @!attribute [rw] tasks
|
31
36
|
# Tasks that touched this service
|
data/app/models/mdm/event.rb
CHANGED
@@ -3,8 +3,13 @@ class Mdm::Event < ActiveRecord::Base
|
|
3
3
|
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
belongs_to :host,
|
7
|
-
|
6
|
+
belongs_to :host,
|
7
|
+
class_name: 'Mdm::Host',
|
8
|
+
inverse_of: :events
|
9
|
+
|
10
|
+
belongs_to :workspace,
|
11
|
+
class_name: 'Mdm::Workspace',
|
12
|
+
inverse_of: :events
|
8
13
|
|
9
14
|
#
|
10
15
|
# Scopes
|
@@ -1,8 +1,49 @@
|
|
1
1
|
class Mdm::ExploitAttempt < ActiveRecord::Base
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Associations
|
4
4
|
#
|
5
|
-
|
5
|
+
|
6
|
+
# @!attribute host
|
7
|
+
# Host that was attempted to be exploited.
|
8
|
+
#
|
9
|
+
# @return [Mdm::Host]
|
10
|
+
belongs_to :host,
|
11
|
+
class_name: 'Mdm::Host',
|
12
|
+
counter_cache: :exploit_attempt_count,
|
13
|
+
inverse_of: :exploit_attempts
|
14
|
+
|
15
|
+
# @!attribute loot
|
16
|
+
# Loot gathers from the successful exploit.
|
17
|
+
#
|
18
|
+
# @return [Mdm::Loot, nil]
|
19
|
+
belongs_to :loot,
|
20
|
+
class_name: 'Mdm::Loot',
|
21
|
+
inverse_of: :exploit_attempt
|
22
|
+
|
23
|
+
# @!attribute service
|
24
|
+
# The service being exploited on {#host}.
|
25
|
+
#
|
26
|
+
# @return [Mdm::Service, nil]
|
27
|
+
belongs_to :service,
|
28
|
+
class_name: 'Mdm::Service',
|
29
|
+
inverse_of: :exploit_attempts
|
30
|
+
|
31
|
+
# @!attribute session
|
32
|
+
# The session that was established when this attempt was successful.
|
33
|
+
#
|
34
|
+
# @return [Mdm::Session]
|
35
|
+
# @return [nil] if session was not established.
|
36
|
+
belongs_to :session,
|
37
|
+
class_name: 'Mdm::Session',
|
38
|
+
inverse_of: :exploit_attempt
|
39
|
+
|
40
|
+
# @!attribute vuln
|
41
|
+
# The vulnerability that was attempted to be exploited.
|
42
|
+
#
|
43
|
+
# @return [Mdm::Vuln, nil]
|
44
|
+
belongs_to :vuln,
|
45
|
+
class_name: 'Mdm::Vuln',
|
46
|
+
inverse_of: :exploit_attempts
|
6
47
|
|
7
48
|
#
|
8
49
|
# Validations
|
@@ -3,8 +3,13 @@ class Mdm::ExploitedHost < ActiveRecord::Base
|
|
3
3
|
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
belongs_to :host,
|
7
|
-
|
6
|
+
belongs_to :host,
|
7
|
+
class_name: 'Mdm::Host',
|
8
|
+
inverse_of: :exploited_hosts
|
9
|
+
|
10
|
+
belongs_to :service,
|
11
|
+
class_name: 'Mdm::Service',
|
12
|
+
inverse_of: :exploited_hosts
|
8
13
|
|
9
14
|
ActiveSupport.run_load_hooks(:mdm_exploited_host, self)
|
10
15
|
end
|
data/app/models/mdm/host.rb
CHANGED
@@ -57,83 +57,122 @@ class Mdm::Host < ActiveRecord::Base
|
|
57
57
|
# Users connected to this host
|
58
58
|
#
|
59
59
|
# @return [Array<Mdm::Client>]
|
60
|
-
has_many :clients,
|
60
|
+
has_many :clients,
|
61
|
+
class_name: 'Mdm::Client',
|
62
|
+
dependent: :destroy,
|
63
|
+
inverse_of: :host
|
64
|
+
|
65
|
+
# @!attribute events
|
66
|
+
# Events that occurred on this host.
|
67
|
+
#
|
68
|
+
# @return [ActiveRecord::Relation<Mdm::Event>]
|
69
|
+
has_many :events,
|
70
|
+
class_name: 'Mdm::Event',
|
71
|
+
dependent: :destroy,
|
72
|
+
inverse_of: :host
|
61
73
|
|
62
74
|
# @!attribute [rw] task_hosts
|
63
75
|
# Details about what Tasks touched this host
|
64
76
|
#
|
65
77
|
# @return [Array<Mdm::TaskHost>]
|
66
|
-
has_many :task_hosts,
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
# @return [Array<Mdm::Task>]
|
72
|
-
has_many :tasks, :through => :task_hosts, :class_name => 'Mdm::Task'
|
78
|
+
has_many :task_hosts,
|
79
|
+
class_name: 'Mdm::TaskHost',
|
80
|
+
dependent: :destroy,
|
81
|
+
inverse_of: :host
|
73
82
|
|
74
83
|
# @!attribute [rw] exploit_attempts
|
75
84
|
# Attempts to run exploits against this host.
|
76
85
|
#
|
77
86
|
# @return [Array<Mdm::ExploitAttempt]
|
78
87
|
has_many :exploit_attempts,
|
79
|
-
:
|
80
|
-
:
|
81
|
-
|
82
|
-
|
83
|
-
#
|
84
|
-
# @
|
85
|
-
|
88
|
+
class_name: 'Mdm::ExploitAttempt',
|
89
|
+
dependent: :destroy,
|
90
|
+
inverse_of: :host
|
91
|
+
|
92
|
+
# @!attribute exploited_hosts
|
93
|
+
# @todo MSP-2732
|
94
|
+
# @return [ActiveRecord::Relation<Mdm::ExploitedHost>]
|
95
|
+
has_many :exploited_hosts,
|
96
|
+
class_name: 'Mdm::ExploitedHost',
|
97
|
+
dependent: :destroy,
|
98
|
+
inverse_of: :host
|
86
99
|
|
87
100
|
# @!attribute [rw] host_details
|
88
101
|
# @return [Array<Mdm::HostDetail>]
|
89
|
-
has_many :host_details,
|
102
|
+
has_many :host_details,
|
103
|
+
class_name: 'Mdm::HostDetail',
|
104
|
+
dependent: :destroy,
|
105
|
+
inverse_of: :host
|
90
106
|
|
91
|
-
# @!attribute
|
107
|
+
# @!attribute hosts_tags
|
92
108
|
# A join model between {Mdm::Tag} and {Mdm::Host}. Use {#tags} to get the actual {Mdm::Tag Mdm::Tags} on this host.
|
93
|
-
# {#hosts_tags} are cleaned up in a before_destroy: {#cleanup_tags}.
|
94
109
|
#
|
95
|
-
# @todo
|
96
|
-
# @return [
|
97
|
-
has_many :hosts_tags,
|
110
|
+
# @todo MSP-2723
|
111
|
+
# @return [ActiveRecord::Relation<Mdm::HostTag>]
|
112
|
+
has_many :hosts_tags,
|
113
|
+
class_name: 'Mdm::HostTag',
|
114
|
+
dependent: :destroy,
|
115
|
+
inverse_of: :host
|
98
116
|
|
99
|
-
# @!attribute
|
117
|
+
# @!attribute loots
|
100
118
|
# Loot gathered from the host with {Mdm::Loot#created_at newest loot} first.
|
101
119
|
#
|
102
|
-
# @todo
|
103
|
-
# @return [
|
104
|
-
has_many :loots,
|
120
|
+
# @todo MSP-3065
|
121
|
+
# @return [ActiveRecord::Relation<Mdm::Loot>]
|
122
|
+
has_many :loots,
|
123
|
+
class_name: 'Mdm::Loot',
|
124
|
+
dependent: :destroy,
|
125
|
+
inverse_of: :host,
|
126
|
+
order: 'loots.created_at DESC'
|
105
127
|
|
106
128
|
# @!attribute [rw] notes
|
107
129
|
# Notes about the host entered by a user with {Mdm::Note#created_at oldest notes} first.
|
108
130
|
#
|
109
131
|
# @return [Array<Mdm::Note>]
|
110
|
-
has_many :notes,
|
132
|
+
has_many :notes,
|
133
|
+
class_name: 'Mdm::Note',
|
134
|
+
inverse_of: :host,
|
135
|
+
dependent: :delete_all,
|
136
|
+
order: 'notes.created_at'
|
111
137
|
|
112
138
|
# @!attribute [rw] services
|
113
139
|
# The services running on {Mdm::Service#port ports} on the host with services ordered by {Mdm::Service#port port}
|
114
140
|
# and {Mdm::Service#proto protocol}.
|
115
141
|
#
|
116
142
|
# @return [Array<Mdm::Service>]
|
117
|
-
has_many :services,
|
143
|
+
has_many :services,
|
144
|
+
class_name: 'Mdm::Service',
|
145
|
+
dependent: :destroy,
|
146
|
+
inverse_of: :host,
|
147
|
+
order: 'services.port, services.proto'
|
118
148
|
|
119
149
|
# @!attribute [rw] sessions
|
120
150
|
# Sessions that are open or previously were open on the host ordered by {Mdm::Session#opened_at when the session was
|
121
151
|
# opened}
|
122
152
|
#
|
123
153
|
# @return [Array<Mdm::Session]
|
124
|
-
has_many :sessions,
|
154
|
+
has_many :sessions,
|
155
|
+
class_name: 'Mdm::Session',
|
156
|
+
dependent: :destroy,
|
157
|
+
inverse_of: :host,
|
158
|
+
order: 'sessions.opened_at'
|
125
159
|
|
126
160
|
# @!attribute [rw] vulns
|
127
161
|
# Vulnerabilities found on the host.
|
128
162
|
#
|
129
163
|
# @return [Array<Mdm::Vuln>]
|
130
|
-
has_many :vulns,
|
164
|
+
has_many :vulns,
|
165
|
+
class_name: 'Mdm::Vuln',
|
166
|
+
dependent: :delete_all,
|
167
|
+
inverse_of: :host
|
131
168
|
|
132
169
|
# @!attribute [rw] workspace
|
133
170
|
# The workspace in which this host was found.
|
134
171
|
#
|
135
172
|
# @return [Mdm::Workspace]
|
136
|
-
belongs_to :workspace,
|
173
|
+
belongs_to :workspace,
|
174
|
+
class_name: 'Mdm::Workspace',
|
175
|
+
inverse_of: :hosts
|
137
176
|
|
138
177
|
#
|
139
178
|
# Through host_tags
|
@@ -162,7 +201,10 @@ class Mdm::Host < ActiveRecord::Base
|
|
162
201
|
#
|
163
202
|
# @return [Array<Mdm::Note>]
|
164
203
|
# @see #services
|
165
|
-
has_many :service_notes,
|
204
|
+
has_many :service_notes,
|
205
|
+
class_name: 'Mdm::Note',
|
206
|
+
source: :notes,
|
207
|
+
through: :services
|
166
208
|
|
167
209
|
# @!attribute [r] web_sites
|
168
210
|
# {Mdm::WebSite Web sites} running on top of {#services} on this host.
|
@@ -171,6 +213,18 @@ class Mdm::Host < ActiveRecord::Base
|
|
171
213
|
# @see services
|
172
214
|
has_many :web_sites, :class_name => 'Mdm::WebSite', :through => :services
|
173
215
|
|
216
|
+
#
|
217
|
+
# through: :task_hosts
|
218
|
+
#
|
219
|
+
|
220
|
+
# @!attribute tasks
|
221
|
+
# Tasks that touched this service
|
222
|
+
#
|
223
|
+
# @return [ActiveRecord::Relation<Mdm::Task>]
|
224
|
+
has_many :tasks,
|
225
|
+
class_name: 'Mdm::Task',
|
226
|
+
through: :task_hosts
|
227
|
+
|
174
228
|
#
|
175
229
|
# Through vulns
|
176
230
|
#
|
@@ -351,12 +405,6 @@ class Mdm::Host < ActiveRecord::Base
|
|
351
405
|
#
|
352
406
|
# @return [Integer]
|
353
407
|
|
354
|
-
#
|
355
|
-
# Callbacks
|
356
|
-
#
|
357
|
-
|
358
|
-
before_destroy :cleanup_tags
|
359
|
-
|
360
408
|
#
|
361
409
|
# Nested Attributes
|
362
410
|
# @note Must be declared after relations being referenced.
|
@@ -423,18 +471,6 @@ class Mdm::Host < ActiveRecord::Base
|
|
423
471
|
n && n.data[:locked]
|
424
472
|
end
|
425
473
|
|
426
|
-
# Destroys any {Mdm::Tag Mdm::Tags} that will have no {Mdm::Tag#hosts} left after this host is deleted.
|
427
|
-
#
|
428
|
-
# @return [void]
|
429
|
-
def cleanup_tags
|
430
|
-
# No need to keep tags with no hosts
|
431
|
-
tags.each do |tag|
|
432
|
-
tag.destroy if tag.hosts == [self]
|
433
|
-
end
|
434
|
-
# Clean up association table records
|
435
|
-
Mdm::HostTag.delete_all("host_id = #{self.id}")
|
436
|
-
end
|
437
|
-
|
438
474
|
# This is replicated by the IpAddressValidator class. Had to put it here as well to avoid
|
439
475
|
# SQL errors when checking address uniqueness.
|
440
476
|
#
|
@@ -3,7 +3,10 @@ class Mdm::HostDetail < ActiveRecord::Base
|
|
3
3
|
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
belongs_to :host,
|
6
|
+
belongs_to :host,
|
7
|
+
class_name: 'Mdm::Host',
|
8
|
+
counter_cache: :host_detail_count,
|
9
|
+
inverse_of: :host_details
|
7
10
|
|
8
11
|
#
|
9
12
|
# Validations
|
data/app/models/mdm/host_tag.rb
CHANGED
@@ -2,11 +2,49 @@ class Mdm::HostTag < ActiveRecord::Base
|
|
2
2
|
self.table_name = "hosts_tags"
|
3
3
|
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# Associations
|
6
6
|
#
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# @!attribute host
|
9
|
+
# Host with {#tag}.
|
10
|
+
#
|
11
|
+
# @todo MSP-2723
|
12
|
+
# @return [Mdm::Host]
|
13
|
+
belongs_to :host,
|
14
|
+
class_name: 'Mdm::Host',
|
15
|
+
inverse_of: :hosts_tags
|
16
|
+
|
17
|
+
# @!attribute tag
|
18
|
+
# Tag on {#host}.
|
19
|
+
#
|
20
|
+
# @todo MSP-2723
|
21
|
+
# @return [Mdm::Tag]
|
22
|
+
belongs_to :tag,
|
23
|
+
class_name: 'Mdm::Tag',
|
24
|
+
inverse_of: :hosts_tags
|
25
|
+
|
26
|
+
#
|
27
|
+
# Callbacks
|
28
|
+
#
|
29
|
+
|
30
|
+
# @see http://stackoverflow.com/a/11694704
|
31
|
+
after_destroy :destroy_orphan_tag
|
32
|
+
|
33
|
+
#
|
34
|
+
# Instance Methods
|
35
|
+
#
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# Destroys {#tag} if it is orphaned
|
40
|
+
#
|
41
|
+
# @see http://stackoverflow.com/a/11694704
|
42
|
+
# @return [void]
|
43
|
+
def destroy_orphan_tag
|
44
|
+
tag.destroy_if_orphaned
|
45
|
+
end
|
46
|
+
|
47
|
+
public
|
10
48
|
|
11
49
|
ActiveSupport.run_load_hooks(:mdm_host_tag, self)
|
12
50
|
end
|
data/app/models/mdm/listener.rb
CHANGED
@@ -3,8 +3,13 @@ class Mdm::Listener < ActiveRecord::Base
|
|
3
3
|
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
belongs_to :task,
|
7
|
-
|
6
|
+
belongs_to :task,
|
7
|
+
class_name: 'Mdm::Task',
|
8
|
+
inverse_of: :listeners
|
9
|
+
|
10
|
+
belongs_to :workspace,
|
11
|
+
class_name: 'Mdm::Workspace',
|
12
|
+
inverse_of: :listeners
|
8
13
|
|
9
14
|
#
|
10
15
|
# Serializations
|