metasploit_data_models 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- 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 +11 -27
data/app/models/mdm/loot.rb
CHANGED
@@ -16,23 +16,45 @@ class Mdm::Loot < ActiveRecord::Base
|
|
16
16
|
# Associations
|
17
17
|
#
|
18
18
|
|
19
|
+
# @!attribute exploit_attempt
|
20
|
+
# Exploit attempt where this loot was gathered.
|
21
|
+
#
|
22
|
+
# @return [Mdm::ExploitAttempt]
|
23
|
+
has_one :exploit_attempt,
|
24
|
+
class_name: 'Mdm::ExploitAttempt',
|
25
|
+
inverse_of: :loot
|
26
|
+
|
19
27
|
# @!attribute [rw] host
|
20
28
|
# The host from which the loot was gathered.
|
21
29
|
#
|
22
30
|
# @return [Mdm::Host]
|
23
|
-
belongs_to :host,
|
31
|
+
belongs_to :host,
|
32
|
+
class_name: 'Mdm::Host',
|
33
|
+
inverse_of: :loots
|
24
34
|
|
25
35
|
# @!attribute [rw] service
|
26
36
|
# The service running on the {#host} from which the loot was gathered.
|
27
37
|
#
|
28
38
|
# @return [Mdm::Service]
|
29
|
-
belongs_to :service,
|
39
|
+
belongs_to :service,
|
40
|
+
class_name: 'Mdm::Service',
|
41
|
+
inverse_of: :loots
|
42
|
+
|
43
|
+
# @!attribute vuln_attempt
|
44
|
+
# Vuln attempt that gathered this loot.
|
45
|
+
#
|
46
|
+
# @return [Mdm::VulnAttempt]
|
47
|
+
has_one :vuln_attempt,
|
48
|
+
class_name: 'Mdm::VulnAttempt',
|
49
|
+
inverse_of: :loot
|
30
50
|
|
31
51
|
# @!attribute [rw] workspace
|
32
52
|
# The workspace in which the loot is stored and the {#host} exists.
|
33
53
|
#
|
34
54
|
# @return [Mdm::Workspace]
|
35
|
-
belongs_to :workspace,
|
55
|
+
belongs_to :workspace,
|
56
|
+
class_name: 'Mdm::Workspace',
|
57
|
+
inverse_of: :loots
|
36
58
|
|
37
59
|
#
|
38
60
|
# Attributes
|
@@ -1,4 +1,17 @@
|
|
1
1
|
class Mdm::NexposeConsole < ActiveRecord::Base
|
2
|
+
#
|
3
|
+
# Associations
|
4
|
+
#
|
5
|
+
|
6
|
+
# @!attribute vuln_details
|
7
|
+
# Details for vulnerabilities supplied by this Nexpose console.
|
8
|
+
#
|
9
|
+
# @return [ActiveRecord::Relation<Mdm::VulnDetail>]
|
10
|
+
has_many :vuln_details,
|
11
|
+
class_name: 'Mdm::VulnDetail',
|
12
|
+
foreign_key: :nx_console_id,
|
13
|
+
inverse_of: :nexpose_console
|
14
|
+
|
2
15
|
#
|
3
16
|
# Serializations
|
4
17
|
#
|
data/app/models/mdm/note.rb
CHANGED
@@ -9,20 +9,27 @@ class Mdm::Note < ActiveRecord::Base
|
|
9
9
|
#
|
10
10
|
# @return [Mdm::Host] if note is attached to an {Mdm::Host}.
|
11
11
|
# @return [nil] if note is attached to an {Mdm::Service}.
|
12
|
-
belongs_to :host,
|
12
|
+
belongs_to :host,
|
13
|
+
class_name: 'Mdm::Host',
|
14
|
+
counter_cache: :note_count,
|
15
|
+
inverse_of: :notes
|
13
16
|
|
14
17
|
# @!attribute [rw] service
|
15
18
|
# The service to which this note is attached.
|
16
19
|
#
|
17
20
|
# @return [Mdm::Service] if note is attached to an {Mdm::Service}.
|
18
21
|
# @return [nil] if not is attached to an {Mdm::Host}.
|
19
|
-
belongs_to :service,
|
22
|
+
belongs_to :service,
|
23
|
+
class_name: 'Mdm::Service',
|
24
|
+
inverse_of: :notes
|
20
25
|
|
21
26
|
# @!attribute [rw] workspace
|
22
27
|
# The workspace in which the {#host} or {#service} exists.
|
23
28
|
#
|
24
29
|
# @return [Mdm::Workspace]
|
25
|
-
belongs_to :workspace,
|
30
|
+
belongs_to :workspace,
|
31
|
+
class_name: 'Mdm::Workspace',
|
32
|
+
inverse_of: :notes
|
26
33
|
|
27
34
|
#
|
28
35
|
# Attributes
|
data/app/models/mdm/ref.rb
CHANGED
@@ -18,9 +18,11 @@ class Mdm::Ref < ActiveRecord::Base
|
|
18
18
|
# @!attribute [rw] vulns_refs
|
19
19
|
# Join model to {Mdm::Vuln Mdm::Vulns}. Use {#vulns} to get the actual {Mdm::Vuln Mdm::Vulns}.
|
20
20
|
#
|
21
|
-
# @todo
|
21
|
+
# @todo MSP-3066
|
22
22
|
# @return [Array<Mdm::VulnRef>]
|
23
|
-
has_many :vulns_refs,
|
23
|
+
has_many :vulns_refs,
|
24
|
+
:class_name => 'Mdm::VulnRef',
|
25
|
+
inverse_of: :ref
|
24
26
|
|
25
27
|
#
|
26
28
|
# Through :vuln_refs
|
data/app/models/mdm/route.rb
CHANGED
@@ -3,7 +3,13 @@ class Mdm::Route < ActiveRecord::Base
|
|
3
3
|
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
|
6
|
+
# @!attribute [rw] session
|
7
|
+
# The session over which this route traverses.
|
8
|
+
#
|
9
|
+
# @return [Mdm::Session]
|
10
|
+
belongs_to :session,
|
11
|
+
class_name: 'Mdm::Session',
|
12
|
+
inverse_of: :routes
|
7
13
|
|
8
14
|
ActiveSupport.run_load_hooks(:mdm_route, self)
|
9
15
|
end
|
data/app/models/mdm/service.rb
CHANGED
@@ -11,52 +11,95 @@ class Mdm::Service < ActiveRecord::Base
|
|
11
11
|
# Associations
|
12
12
|
#
|
13
13
|
|
14
|
-
# @!attribute
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# @return [Array<Mdm::TaskService>]
|
18
|
-
has_many :task_services, :dependent => :destroy, :class_name => 'Mdm::TaskService'
|
19
|
-
|
20
|
-
# @!attribute [rw] tasks
|
21
|
-
# Tasks that touched this service
|
14
|
+
# @!attribute creds
|
15
|
+
# Credentials gathered from this service.
|
22
16
|
#
|
23
|
-
# @return [
|
24
|
-
has_many :
|
17
|
+
# @return [ActiveRecord::Relation<Mdm::Cred>]
|
18
|
+
has_many :creds,
|
19
|
+
class_name: 'Mdm::Cred',
|
20
|
+
dependent: :destroy,
|
21
|
+
inverse_of: :service
|
25
22
|
|
26
|
-
# @!attribute
|
27
|
-
#
|
23
|
+
# @!attribute exploit_attempts
|
24
|
+
# Exploit attempts against this service.
|
28
25
|
#
|
29
|
-
# @return [
|
30
|
-
has_many :
|
26
|
+
# @return [ActiveRecord::Relation<Mdm::ExploitAttempt>]
|
27
|
+
has_many :exploit_attempts,
|
28
|
+
class_name: 'Mdm::ExploitAttempt',
|
29
|
+
dependent: :destroy,
|
30
|
+
inverse_of: :service
|
31
31
|
|
32
|
-
# @!attribute
|
33
|
-
# @todo
|
32
|
+
# @!attribute exploited_hosts
|
33
|
+
# @todo MSP-2732
|
34
34
|
# @return [Array<Mdm::ExploitHost>]
|
35
|
-
has_many :exploited_hosts,
|
35
|
+
has_many :exploited_hosts,
|
36
|
+
class_name: 'Mdm::ExploitedHost',
|
37
|
+
dependent: :destroy,
|
38
|
+
inverse_of: :service
|
36
39
|
|
37
|
-
# @!attribute
|
40
|
+
# @!attribute host
|
38
41
|
# The host on which this service runs.
|
39
42
|
#
|
40
43
|
# @return [Mdm::Host]
|
41
|
-
belongs_to :host,
|
44
|
+
belongs_to :host,
|
45
|
+
class_name: 'Mdm::Host',
|
46
|
+
counter_cache: :service_count,
|
47
|
+
inverse_of: :services
|
42
48
|
|
43
|
-
# @!attribute
|
49
|
+
# @!attribute loots
|
50
|
+
# Loot gathers from this service.
|
51
|
+
#
|
52
|
+
# @return [ActiveRecord::Relation<Mdm::Loot>]
|
53
|
+
has_many :loots,
|
54
|
+
class_name: 'Mdm::Loot',
|
55
|
+
dependent: :destroy,
|
56
|
+
inverse_of: :service
|
57
|
+
|
58
|
+
# @!attribute notes
|
44
59
|
# Notes about this service.
|
45
60
|
#
|
46
|
-
# @return [
|
47
|
-
has_many :notes,
|
61
|
+
# @return [ActiveRecord::Relation<Mdm::Note>]
|
62
|
+
has_many :notes,
|
63
|
+
class_name: 'Mdm::Note',
|
64
|
+
dependent: :destroy,
|
65
|
+
inverse_of: :service
|
48
66
|
|
49
|
-
# @!attribute [rw]
|
67
|
+
# @!attribute [rw] task_services
|
68
|
+
# Details about what Tasks touched this service
|
69
|
+
#
|
70
|
+
# @return [Array<Mdm::TaskService>]
|
71
|
+
has_many :task_services,
|
72
|
+
class_name: 'Mdm::TaskService',
|
73
|
+
dependent: :destroy,
|
74
|
+
inverse_of: :service
|
75
|
+
|
76
|
+
# @!attribute vulns
|
50
77
|
# Vulnerabilities found in this service.
|
51
78
|
#
|
52
|
-
# @return [
|
53
|
-
has_many :vulns,
|
79
|
+
# @return [ActiveRecord::Relation<Mdm::Vuln>]
|
80
|
+
has_many :vulns,
|
81
|
+
class_name: 'Mdm::Vuln',
|
82
|
+
dependent: :destroy,
|
83
|
+
inverse_of: :service
|
54
84
|
|
55
|
-
# @!attribute
|
85
|
+
# @!attribute web_sites
|
56
86
|
# Web sites running on top of this service.
|
57
87
|
#
|
58
|
-
# @return [
|
59
|
-
has_many :web_sites,
|
88
|
+
# @return [ActiveRecord::Relation<Mdm::WebSite>]
|
89
|
+
has_many :web_sites,
|
90
|
+
class_name: 'Mdm::WebSite',
|
91
|
+
dependent: :destroy,
|
92
|
+
inverse_of: :service
|
93
|
+
|
94
|
+
#
|
95
|
+
# through: :task_services
|
96
|
+
#
|
97
|
+
|
98
|
+
# @!attribute [rw] tasks
|
99
|
+
# Tasks that touched this service
|
100
|
+
#
|
101
|
+
# @return [Array<Mdm::Task>]
|
102
|
+
has_many :tasks, :through => :task_services, :class_name => 'Mdm::Task'
|
60
103
|
|
61
104
|
#
|
62
105
|
# Through :web_sites
|
data/app/models/mdm/session.rb
CHANGED
@@ -9,19 +9,44 @@ class Mdm::Session < ActiveRecord::Base
|
|
9
9
|
# Events that occurred when this session was open.
|
10
10
|
#
|
11
11
|
# @return [Array<Mdm::Event>]
|
12
|
-
has_many :events,
|
12
|
+
has_many :events,
|
13
|
+
class_name: 'Mdm::SessionEvent',
|
14
|
+
dependent: :delete_all,
|
15
|
+
inverse_of: :session,
|
16
|
+
order: 'created_at'
|
17
|
+
|
18
|
+
# @!attribute exploit_attempt
|
19
|
+
# Exploit attempt that created this session.
|
20
|
+
#
|
21
|
+
# @return [Mdm::ExploitAttempt]
|
22
|
+
has_one :exploit_attempt,
|
23
|
+
class_name: 'Mdm::ExploitAttempt',
|
24
|
+
inverse_of: :session
|
13
25
|
|
14
26
|
# @!attribute [rw] host
|
15
27
|
# {Mdm::Host Host} on which this session was opened.
|
16
28
|
#
|
17
29
|
# @return [Mdm::Host]
|
18
|
-
belongs_to :host,
|
30
|
+
belongs_to :host,
|
31
|
+
class_name: 'Mdm::Host',
|
32
|
+
inverse_of: :sessions
|
19
33
|
|
20
34
|
# @!attribute [rw] routes
|
21
35
|
# Routes tunneled throug this session.
|
22
36
|
#
|
23
37
|
# @return [Array<Mdm::Route>]
|
24
|
-
has_many :routes,
|
38
|
+
has_many :routes,
|
39
|
+
class_name: 'Mdm::Route',
|
40
|
+
dependent: :delete_all,
|
41
|
+
inverse_of: :session
|
42
|
+
|
43
|
+
# @!attribute vuln_attempt
|
44
|
+
# Vulnerability attempt that created this session.
|
45
|
+
#
|
46
|
+
# @return [Mdm::VulnAttempt]
|
47
|
+
has_one :vuln_attempt,
|
48
|
+
class_name: 'Mdm::VulnAttempt',
|
49
|
+
inverse_of: :session
|
25
50
|
|
26
51
|
#
|
27
52
|
# Through :host
|
data/app/models/mdm/tag.rb
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
class Mdm::Tag < ActiveRecord::Base
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Relations
|
4
4
|
#
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
# Relations
|
6
|
+
# @!attribute hosts_tags
|
7
|
+
# Joins {#hosts} to this tag.
|
10
8
|
#
|
9
|
+
# @return [ActiveRecord::Relation<Mdm::HostTag>]
|
10
|
+
has_many :hosts_tags,
|
11
|
+
class_name: 'Mdm::HostTag',
|
12
|
+
dependent: :destroy,
|
13
|
+
inverse_of: :tag
|
11
14
|
|
12
|
-
|
13
|
-
|
15
|
+
belongs_to :user,
|
16
|
+
class_name: 'Mdm::User',
|
17
|
+
inverse_of: :tags
|
14
18
|
|
15
19
|
#
|
16
20
|
# Through :hosts_tags
|
17
21
|
#
|
22
|
+
|
23
|
+
# @!attribute [r] hosts
|
24
|
+
# Host that are tagged with this tag.
|
25
|
+
#
|
26
|
+
# @return [ActiveRecord::Relation<Mdm::Host>]
|
18
27
|
has_many :hosts, :through => :hosts_tags, :class_name => 'Mdm::Host'
|
19
28
|
|
20
29
|
|
@@ -33,9 +42,19 @@ class Mdm::Tag < ActiveRecord::Base
|
|
33
42
|
},
|
34
43
|
:presence => true
|
35
44
|
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
#
|
46
|
+
# Instance Methods
|
47
|
+
#
|
48
|
+
|
49
|
+
# Destroy this tag if it has no {#hosts_tags}
|
50
|
+
#
|
51
|
+
# @return [void]
|
52
|
+
def destroy_if_orphaned
|
53
|
+
self.class.transaction do
|
54
|
+
if hosts_tags.empty?
|
55
|
+
destroy
|
56
|
+
end
|
57
|
+
end
|
39
58
|
end
|
40
59
|
|
41
60
|
def to_s
|
data/app/models/mdm/task.rb
CHANGED
@@ -9,17 +9,62 @@ class Mdm::Task < ActiveRecord::Base
|
|
9
9
|
# Relations
|
10
10
|
#
|
11
11
|
|
12
|
+
# @!attribute listeners
|
13
|
+
# Listeners spawned by this task
|
14
|
+
#
|
15
|
+
# @return [ActiveRecord::Relation<Mdm::Listener>]
|
16
|
+
has_many :listeners,
|
17
|
+
class_name: 'Mdm::Listener',
|
18
|
+
dependent: :destroy,
|
19
|
+
inverse_of: :task
|
20
|
+
|
21
|
+
# @!attribute [rw] task_creds
|
22
|
+
# Joins this to {#creds}.
|
23
|
+
#
|
24
|
+
# @return [ActiveRecord::Relation<Mdm::TaskCred>]
|
25
|
+
has_many :task_creds,
|
26
|
+
class_name: 'Mdm::TaskCred',
|
27
|
+
dependent: :destroy,
|
28
|
+
inverse_of: :task
|
29
|
+
|
30
|
+
# @!attribute task_hosts
|
31
|
+
# Joins this to {#hosts}.
|
32
|
+
#
|
33
|
+
# @return [ActiveRecord::Relation<Mdm::TaskHost>]
|
34
|
+
has_many :task_hosts,
|
35
|
+
class_name: 'Mdm::TaskHost',
|
36
|
+
dependent: :destroy,
|
37
|
+
inverse_of: :task
|
38
|
+
|
39
|
+
# @!attribute task_services
|
40
|
+
# Joins this to {#services}.
|
41
|
+
#
|
42
|
+
# @return [ActiveRecord::Relation<Mdm::TaskService>]
|
43
|
+
has_many :task_services,
|
44
|
+
class_name: 'Mdm::TaskService',
|
45
|
+
dependent: :destroy,
|
46
|
+
inverse_of: :task
|
47
|
+
|
48
|
+
# @!attribute task_sessions
|
49
|
+
# Joins this to {#sessions}.
|
50
|
+
#
|
51
|
+
# @return [ActiveRecord::Relation<Mdm::TaskSession>]
|
52
|
+
has_many :task_sessions,
|
53
|
+
class_name: 'Mdm::TaskSession',
|
54
|
+
dependent: :destroy,
|
55
|
+
inverse_of: :task
|
56
|
+
|
12
57
|
# @!attribute [rw] workspace
|
13
58
|
# The Workspace the Task belongs to
|
14
59
|
#
|
15
60
|
# @return [Mdm::Workspace]
|
16
|
-
belongs_to :workspace,
|
61
|
+
belongs_to :workspace,
|
62
|
+
class_name: 'Mdm::Workspace',
|
63
|
+
inverse_of: :tasks
|
17
64
|
|
18
|
-
# @!attribute [rw] task_creds
|
19
|
-
# Details about creds this task touched
|
20
65
|
#
|
21
|
-
#
|
22
|
-
|
66
|
+
# through: :task_creds
|
67
|
+
#
|
23
68
|
|
24
69
|
# @!attribute [rw] creds
|
25
70
|
# Creds this task touched
|
@@ -27,11 +72,9 @@ class Mdm::Task < ActiveRecord::Base
|
|
27
72
|
# @return [Array<Mdm::Cred>]
|
28
73
|
has_many :creds, :through => :task_creds, :class_name => 'Mdm::Cred'
|
29
74
|
|
30
|
-
# @!attribute [rw] task_hosts
|
31
|
-
# Details about hosts this task touched
|
32
75
|
#
|
33
|
-
#
|
34
|
-
|
76
|
+
# through: :task_hosts
|
77
|
+
#
|
35
78
|
|
36
79
|
# @!attribute [rw] hosts
|
37
80
|
# Hosts this task touched
|
@@ -39,11 +82,9 @@ class Mdm::Task < ActiveRecord::Base
|
|
39
82
|
# @return [Array<Mdm::Host>
|
40
83
|
has_many :hosts, :through => :task_hosts, :class_name => 'Mdm::Host'
|
41
84
|
|
42
|
-
# @!attribute [rw] task_services
|
43
|
-
# Details about services this task touched
|
44
85
|
#
|
45
|
-
#
|
46
|
-
|
86
|
+
# through: :task_services
|
87
|
+
#
|
47
88
|
|
48
89
|
# @!attribute [rw] services
|
49
90
|
# Services this task touched
|
@@ -51,11 +92,9 @@ class Mdm::Task < ActiveRecord::Base
|
|
51
92
|
# @return [Array<Mdm::Service>
|
52
93
|
has_many :services, :through => :task_services, :class_name => 'Mdm::Service'
|
53
94
|
|
54
|
-
# @!attribute [rw] task_sessions
|
55
|
-
# Details about sessions this task touched
|
56
95
|
#
|
57
|
-
#
|
58
|
-
|
96
|
+
# through: :task_sessions
|
97
|
+
#
|
59
98
|
|
60
99
|
# @!attribute [rw] sessions
|
61
100
|
# Session this task touched
|