metasploit_data_models 0.7.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.travis.yml +1 -0
- data/app/models/mdm/host.rb +352 -26
- data/app/models/mdm/loot.rb +72 -7
- data/app/models/mdm/{module_action.rb → module/action.rb} +3 -3
- data/app/models/mdm/{module_arch.rb → module/arch.rb} +3 -3
- data/app/models/mdm/{module_author.rb → module/author.rb} +3 -3
- data/app/models/mdm/module/detail.rb +280 -0
- data/app/models/mdm/{module_mixin.rb → module/mixin.rb} +3 -3
- data/app/models/mdm/{module_platform.rb → module/platform.rb} +3 -3
- data/app/models/mdm/module/ref.rb +48 -0
- data/app/models/mdm/{module_target.rb → module/target.rb} +3 -3
- data/app/models/mdm/note.rb +61 -6
- data/app/models/mdm/ref.rb +39 -1
- data/app/models/mdm/service.rb +85 -7
- data/app/models/mdm/session.rb +100 -6
- data/app/models/mdm/vuln.rb +104 -24
- data/db/migrate/20130228214900_change_required_columns_to_null_false_in_web_vulns.rb +1 -17
- data/db/migrate/20130412154159_change_foreign_key_in_module_actions.rb +25 -0
- data/db/migrate/20130412171844_change_foreign_key_in_module_archs.rb +25 -0
- data/db/migrate/20130412173121_change_foreign_key_in_module_authors.rb +25 -0
- data/db/migrate/20130412173640_change_foreign_key_in_module_mixins.rb +25 -0
- data/db/migrate/20130412174254_change_foreign_key_in_module_platforms.rb +25 -0
- data/db/migrate/20130412174719_change_foreign_key_in_module_refs.rb +25 -0
- data/db/migrate/20130412175040_change_foreign_key_in_module_targets.rb +25 -0
- data/db/migrate/20130430151353_change_required_columns_to_null_false_in_hosts.rb +11 -0
- data/db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb +23 -0
- data/lib/mdm/module.rb +4 -0
- data/lib/metasploit_data_models.rb +1 -0
- data/lib/metasploit_data_models/change_required_columns_to_null_false.rb +23 -0
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/host_spec.rb +411 -0
- data/spec/app/models/mdm/host_tag_spec.rb +13 -0
- data/spec/app/models/mdm/{module_action_spec.rb → module/action_spec.rb} +6 -6
- data/spec/app/models/mdm/{module_arch_spec.rb → module/arch_spec.rb} +6 -6
- data/spec/app/models/mdm/{module_author_spec.rb → module/author_spec.rb} +6 -6
- data/spec/app/models/mdm/{module_detail_spec.rb → module/detail_spec.rb} +101 -11
- data/spec/app/models/mdm/{module_mixin_spec.rb → module/mixin_spec.rb} +6 -6
- data/spec/app/models/mdm/{module_platform_spec.rb → module/platform_spec.rb} +6 -6
- data/spec/app/models/mdm/module/ref_spec.rb +62 -0
- data/spec/app/models/mdm/{module_target_spec.rb → module/target_spec.rb} +6 -6
- data/spec/app/models/mdm/ref_spec.rb +62 -0
- data/spec/app/models/mdm/tag_spec.rb +13 -0
- data/spec/app/models/mdm/vuln_ref_spec.rb +13 -0
- data/spec/app/models/mdm/vuln_spec.rb +231 -0
- data/spec/dummy/db/schema.rb +20 -20
- data/spec/factories/mdm/host_tags.rb +9 -0
- data/spec/factories/mdm/hosts.rb +65 -0
- data/spec/factories/mdm/module/actions.rb +14 -0
- data/spec/factories/mdm/module/archs.rb +14 -0
- data/spec/factories/mdm/{module_authors.rb → module/authors.rb} +4 -4
- data/spec/factories/mdm/module/details.rb +66 -0
- data/spec/factories/mdm/module/mixins.rb +14 -0
- data/spec/factories/mdm/module/platforms.rb +14 -0
- data/spec/factories/mdm/module/refs.rb +14 -0
- data/spec/factories/mdm/{module_targets.rb → module/targets.rb} +3 -3
- data/spec/factories/mdm/refs.rb +9 -0
- data/spec/factories/mdm/tags.rb +14 -0
- data/spec/factories/mdm/vuln_refs.rb +4 -0
- data/spec/factories/mdm/vulns.rb +20 -0
- metadata +78 -45
- data/app/models/mdm/module_detail.rb +0 -59
- data/app/models/mdm/module_ref.rb +0 -24
- data/spec/app/models/mdm/module_ref_spec.rb +0 -38
- data/spec/factories/mdm/module_actions.rb +0 -14
- data/spec/factories/mdm/module_archs.rb +0 -14
- data/spec/factories/mdm/module_details.rb +0 -9
- data/spec/factories/mdm/module_mixins.rb +0 -14
- data/spec/factories/mdm/module_platforms.rb +0 -14
- data/spec/factories/mdm/module_refs.rb +0 -14
@@ -1,11 +1,11 @@
|
|
1
|
-
class Mdm::
|
1
|
+
class Mdm::Module::Mixin < ActiveRecord::Base
|
2
2
|
self.table_name = 'module_mixins'
|
3
3
|
|
4
4
|
#
|
5
5
|
# Associations
|
6
6
|
#
|
7
7
|
|
8
|
-
belongs_to :
|
8
|
+
belongs_to :detail, :class_name => 'Mdm::Module::Detail'
|
9
9
|
|
10
10
|
#
|
11
11
|
# Mass Assignment Security
|
@@ -17,7 +17,7 @@ class Mdm::ModuleMixin < ActiveRecord::Base
|
|
17
17
|
# Validation
|
18
18
|
#
|
19
19
|
|
20
|
-
validates :
|
20
|
+
validates :detail, :presence => true
|
21
21
|
validates :name, :presence => true
|
22
22
|
|
23
23
|
ActiveSupport.run_load_hooks(:mdm_module_mixin, self)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class Mdm::
|
1
|
+
class Mdm::Module::Platform < ActiveRecord::Base
|
2
2
|
self.table_name = 'module_platforms'
|
3
3
|
|
4
4
|
#
|
5
5
|
# Associations
|
6
6
|
#
|
7
7
|
|
8
|
-
belongs_to :
|
8
|
+
belongs_to :detail, :class_name => 'Mdm::Module::Detail'
|
9
9
|
|
10
10
|
#
|
11
11
|
# Mass Assignment Security
|
@@ -17,7 +17,7 @@ class Mdm::ModulePlatform < ActiveRecord::Base
|
|
17
17
|
# Validations
|
18
18
|
#
|
19
19
|
|
20
|
-
validates :
|
20
|
+
validates :detail, :presence => true
|
21
21
|
validates :name, :presence => true
|
22
22
|
|
23
23
|
ActiveSupport.run_load_hooks(:mdm_module_platform, self)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# External references to the vulnerability exploited by this module.
|
2
|
+
class Mdm::Module::Ref < ActiveRecord::Base
|
3
|
+
self.table_name = 'module_refs'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Associations
|
7
|
+
#
|
8
|
+
|
9
|
+
# @!attribute [rw] detail
|
10
|
+
# The root of the module metadata tree.
|
11
|
+
#
|
12
|
+
# @return [Mdm::Module::Detail]
|
13
|
+
belongs_to :detail, :class_name => 'Mdm::Module::Detail'
|
14
|
+
|
15
|
+
# @!attribute [r] refs
|
16
|
+
# References with the same name attached to {Mdm::Vuln Mdm::Vulns}.
|
17
|
+
#
|
18
|
+
# @return [Array<Mdm::Ref>]
|
19
|
+
has_many :refs,
|
20
|
+
:class_name => 'Mdm::Ref',
|
21
|
+
:foreign_key => :name,
|
22
|
+
:primary_key => :name
|
23
|
+
|
24
|
+
#
|
25
|
+
# Attributes
|
26
|
+
#
|
27
|
+
|
28
|
+
# @!attribute [rw] name
|
29
|
+
# Designation for external reference. May include a prefix for the authority, such as 'CVE-', in which case the
|
30
|
+
# rest of the name is the designation assigned by that authority.
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
|
34
|
+
#
|
35
|
+
# Mass Assignment Security
|
36
|
+
#
|
37
|
+
|
38
|
+
attr_accessible :name
|
39
|
+
|
40
|
+
#
|
41
|
+
# Validations
|
42
|
+
#
|
43
|
+
|
44
|
+
validates :detail, :presence => true
|
45
|
+
validates :name, :presence => true
|
46
|
+
|
47
|
+
ActiveSupport.run_load_hooks(:mdm_module_ref, self)
|
48
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class Mdm::
|
1
|
+
class Mdm::Module::Target < ActiveRecord::Base
|
2
2
|
self.table_name = 'module_targets'
|
3
3
|
|
4
4
|
#
|
5
5
|
# Associations
|
6
6
|
#
|
7
7
|
|
8
|
-
belongs_to :
|
8
|
+
belongs_to :detail, :class_name => 'Mdm::Module::Detail'
|
9
9
|
|
10
10
|
#
|
11
11
|
# Mass Assignment Security
|
@@ -18,8 +18,8 @@ class Mdm::ModuleTarget < ActiveRecord::Base
|
|
18
18
|
# Validators
|
19
19
|
#
|
20
20
|
|
21
|
+
validates :detail, :presence => true
|
21
22
|
validates :index, :presence => true
|
22
|
-
validates :module_detail, :presence => true
|
23
23
|
validates :name, :presence => true
|
24
24
|
|
25
25
|
ActiveSupport.run_load_hooks(:mdm_module_target, self)
|
data/app/models/mdm/note.rb
CHANGED
@@ -1,17 +1,68 @@
|
|
1
|
+
# Data gathered or derived from the {#host} or {#service} such as its {#ntype fingerprint}.
|
1
2
|
class Mdm::Note < ActiveRecord::Base
|
2
3
|
#
|
3
|
-
#
|
4
|
+
# Associations
|
4
5
|
#
|
5
6
|
|
6
|
-
|
7
|
+
# @!attribute [rw] host
|
8
|
+
# The host to which this note is attached.
|
9
|
+
#
|
10
|
+
# @return [Mdm::Host] if note is attached to an {Mdm::Host}.
|
11
|
+
# @return [nil] if note is attached to an {Mdm::Service}.
|
12
|
+
belongs_to :host, :class_name => 'Mdm::Host', :counter_cache => :note_count
|
7
13
|
|
14
|
+
# @!attribute [rw] service
|
15
|
+
# The service to which this note is attached.
|
8
16
|
#
|
9
|
-
#
|
17
|
+
# @return [Mdm::Service] if note is attached to an {Mdm::Service}.
|
18
|
+
# @return [nil] if not is attached to an {Mdm::Host}.
|
19
|
+
belongs_to :service, :class_name => 'Mdm::Service'
|
20
|
+
|
21
|
+
# @!attribute [rw] workspace
|
22
|
+
# The workspace in which the {#host} or {#service} exists.
|
10
23
|
#
|
24
|
+
# @return [Mdm::Workspace]
|
25
|
+
belongs_to :workspace, :class_name => 'Mdm::Workspace'
|
11
26
|
|
12
|
-
|
13
|
-
|
14
|
-
|
27
|
+
#
|
28
|
+
# Attributes
|
29
|
+
#
|
30
|
+
|
31
|
+
# @!attribute [rw] created_at
|
32
|
+
# When the note was created.
|
33
|
+
#
|
34
|
+
# @return [DateTime]
|
35
|
+
|
36
|
+
# @!attribute [rw] critical
|
37
|
+
# Whether this note is critical or not.
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
|
41
|
+
# @!attribute [rw] data
|
42
|
+
# A Hash of data about the {#host} or {#service}.
|
43
|
+
#
|
44
|
+
# @return [Hash]
|
45
|
+
|
46
|
+
# @!attribute [rw] ntype
|
47
|
+
# The type of note. Usually a dot-separateed name like 'host.updated.<foo>'.
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
|
51
|
+
# @!attribute [rw] seen
|
52
|
+
# Whether any user has seen this note.
|
53
|
+
#
|
54
|
+
# @return [Boolean]
|
55
|
+
|
56
|
+
# @!attribute [rw] updated_at
|
57
|
+
# The last time the note was updated.
|
58
|
+
#
|
59
|
+
# @return [DateTime]
|
60
|
+
|
61
|
+
#
|
62
|
+
# Callbacks
|
63
|
+
#
|
64
|
+
|
65
|
+
after_save :normalize
|
15
66
|
|
16
67
|
#
|
17
68
|
# Scopes
|
@@ -38,6 +89,10 @@ class Mdm::Note < ActiveRecord::Base
|
|
38
89
|
|
39
90
|
private
|
40
91
|
|
92
|
+
# {Mdm::Host::OperatingSystemNormalization#normalize_os Normalizes the host operating system} if the note is a
|
93
|
+
# {#ntype fingerprint}.
|
94
|
+
#
|
95
|
+
# @return [void]
|
41
96
|
def normalize
|
42
97
|
if data_changed? and ntype =~ /fingerprint/
|
43
98
|
host.normalize_os
|
data/app/models/mdm/ref.rb
CHANGED
@@ -1,14 +1,52 @@
|
|
1
|
+
# An external vulnerability reference for vulnerabilities that aren't part of a module. {Mdm::Module::Ref} should be
|
2
|
+
# used whenever possible and Mdm::Ref should only be used when the vulnerability is from an import and can't be
|
3
|
+
# correlated to a module and its {Mdm::Module::Detail}.
|
1
4
|
class Mdm::Ref < ActiveRecord::Base
|
2
5
|
#
|
3
|
-
#
|
6
|
+
# Associations
|
4
7
|
#
|
5
8
|
|
9
|
+
# @!attribute [r] module_refs
|
10
|
+
# {Mdm::Module::Ref Mdm::Module::Refs} with the same name as this ref.
|
11
|
+
#
|
12
|
+
# @return [Array<Mdm::Module::Ref>]
|
13
|
+
has_many :module_refs,
|
14
|
+
:class_name => 'Mdm::Module::Ref',
|
15
|
+
:foreign_key => :name,
|
16
|
+
:primary_key => :name
|
17
|
+
|
18
|
+
# @!attribute [rw] vulns_refs
|
19
|
+
# Join model to {Mdm::Vuln Mdm::Vulns}. Use {#vulns} to get the actual {Mdm::Vuln Mdm::Vulns}.
|
20
|
+
#
|
21
|
+
# @todo https://www.pivotaltracker.com/story/show/48915453
|
22
|
+
# @return [Array<Mdm::VulnRef>]
|
6
23
|
has_many :vulns_refs, :class_name => 'Mdm::VulnRef'
|
7
24
|
|
8
25
|
#
|
9
26
|
# Through :vuln_refs
|
10
27
|
#
|
28
|
+
|
29
|
+
# @!attribute [rw] vulns
|
30
|
+
# Vulnerabilities referenced by this reference.
|
31
|
+
#
|
32
|
+
# @return [Array<Mdm::Vuln>]
|
11
33
|
has_many :vulns, :class_name => 'Mdm::Vuln', :through => :vulns_refs
|
12
34
|
|
35
|
+
#
|
36
|
+
# Attributes
|
37
|
+
#
|
38
|
+
|
39
|
+
# @!attribute [rw] name
|
40
|
+
# Designation for external reference. May include a prefix for the authority, such as 'CVE-', in which case the
|
41
|
+
# rest of the name is the designation assigned by that authority.
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
|
45
|
+
#
|
46
|
+
# Mass Assignment Security
|
47
|
+
#
|
48
|
+
|
49
|
+
attr_accessible :name
|
50
|
+
|
13
51
|
ActiveSupport.run_load_hooks(:mdm_ref, self)
|
14
52
|
end
|
data/app/models/mdm/service.rb
CHANGED
@@ -1,34 +1,108 @@
|
|
1
|
+
# A service, such as an ssh server or web server, running on a {#host}.
|
1
2
|
class Mdm::Service < ActiveRecord::Base
|
2
|
-
#
|
3
|
-
# Callbacks
|
4
|
-
#
|
5
|
-
|
6
|
-
after_save :normalize_host_os
|
7
|
-
|
8
3
|
#
|
9
4
|
# CONSTANTS
|
10
5
|
#
|
11
6
|
|
7
|
+
# Valid values for {#state}.
|
12
8
|
STATES = ['open', 'closed', 'filtered', 'unknown']
|
13
9
|
|
14
10
|
#
|
15
|
-
#
|
11
|
+
# Associations
|
16
12
|
#
|
17
13
|
|
14
|
+
# @!attribute [rw] creds
|
15
|
+
# Credentials gathered from this service.
|
16
|
+
#
|
17
|
+
# @return [Array<Mdm::Cred>]
|
18
18
|
has_many :creds, :dependent => :destroy, :class_name => 'Mdm::Cred'
|
19
|
+
|
20
|
+
# @!attribute [rw] exploited_hosts
|
21
|
+
# @todo https://www.pivotaltracker.com/story/show/48993731
|
22
|
+
# @return [Array<Mdm::ExploitHost>]
|
19
23
|
has_many :exploited_hosts, :dependent => :destroy, :class_name => 'Mdm::ExploitedHost'
|
24
|
+
|
25
|
+
# @!attribute [rw] host
|
26
|
+
# The host on which this service runs.
|
27
|
+
#
|
28
|
+
# @return [Mdm::Host]
|
20
29
|
belongs_to :host, :class_name => 'Mdm::Host', :counter_cache => :service_count
|
30
|
+
|
31
|
+
# @!attribute [rw] notes
|
32
|
+
# Notes about this service.
|
33
|
+
#
|
34
|
+
# @return [Array<Mdm::Note>]
|
21
35
|
has_many :notes, :dependent => :destroy, :class_name => 'Mdm::Note'
|
36
|
+
|
37
|
+
# @!attribute [rw] vulns
|
38
|
+
# Vulnerabilities found in this service.
|
39
|
+
#
|
40
|
+
# @return [Array<Mdm::Vuln>]
|
22
41
|
has_many :vulns, :dependent => :destroy, :class_name => 'Mdm::Vuln'
|
42
|
+
|
43
|
+
# @!attribute [rw] web_sites
|
44
|
+
# Web sites running on top of this service.
|
45
|
+
#
|
46
|
+
# @return [Array<Mdm::WebSite>]
|
23
47
|
has_many :web_sites, :dependent => :destroy, :class_name => 'Mdm::WebSite'
|
24
48
|
|
25
49
|
#
|
26
50
|
# Through :web_sites
|
27
51
|
#
|
52
|
+
|
53
|
+
# @!attribute [r] web_pages
|
54
|
+
# Web pages in the {#web_sites} on top of this service.
|
55
|
+
#
|
56
|
+
# @return [Array<Mdm::WebPages>]
|
28
57
|
has_many :web_pages, :through => :web_sites, :class_name => 'Mdm::WebPage'
|
58
|
+
|
59
|
+
# @!attribute [r] web_forms
|
60
|
+
# Form in the {#web_sites} on top of this service.
|
61
|
+
#
|
62
|
+
# @return [Array<Mdm::WebForm>]
|
29
63
|
has_many :web_forms, :through => :web_sites, :class_name => 'Mdm::WebForm'
|
64
|
+
|
65
|
+
# @!attribute [r] web_vulns
|
66
|
+
# Vulnerabilities found in the {#web_sites} on top of this service.
|
67
|
+
#
|
68
|
+
# @return [Array<Mdm::WebVuln>]
|
30
69
|
has_many :web_vulns, :through => :web_sites, :class_name => 'Mdm::WebVuln'
|
31
70
|
|
71
|
+
#
|
72
|
+
# Attributes
|
73
|
+
#
|
74
|
+
|
75
|
+
# @!attribute [rw] info
|
76
|
+
# Additional information about the service that does not fit in the {#name} or {#proto}.
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
|
80
|
+
# @!attribute [rw] port
|
81
|
+
# The port on which this service runs on the {#host}.
|
82
|
+
#
|
83
|
+
# @return [Integer]
|
84
|
+
|
85
|
+
# @!attribute [rw] name
|
86
|
+
# The name of the service.
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
|
90
|
+
# @!attribute [rw] proto
|
91
|
+
# The protocol used by this service
|
92
|
+
#
|
93
|
+
# @return [String]
|
94
|
+
|
95
|
+
# @!attribute [rw] state
|
96
|
+
# Whether this service is opened, closed, filtered, or in an unknown state.
|
97
|
+
#
|
98
|
+
# @return [String] element of {STATES}.
|
99
|
+
|
100
|
+
#
|
101
|
+
# Callbacks
|
102
|
+
#
|
103
|
+
|
104
|
+
after_save :normalize_host_os
|
105
|
+
|
32
106
|
#
|
33
107
|
# Scopes
|
34
108
|
#
|
@@ -45,6 +119,10 @@ class Mdm::Service < ActiveRecord::Base
|
|
45
119
|
])
|
46
120
|
}
|
47
121
|
|
122
|
+
# {Mdm::Host::OperatingSystemNormalization#normalize_os Normalizes the host operating system} whenever {#info} has
|
123
|
+
# changed.
|
124
|
+
#
|
125
|
+
# @return [void]
|
48
126
|
def normalize_host_os
|
49
127
|
if info_changed?
|
50
128
|
host.normalize_os
|
data/app/models/mdm/session.rb
CHANGED
@@ -1,23 +1,109 @@
|
|
1
|
+
# A session opened on a {#host} using an {#via_exploit exploit} and controlled through a {#via_payload payload} to
|
2
|
+
# connect back to the local host using meterpreter or a cmd shell.
|
1
3
|
class Mdm::Session < ActiveRecord::Base
|
2
4
|
#
|
3
|
-
#
|
5
|
+
# Associations
|
4
6
|
#
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
# @!attribute [rw] events
|
9
|
+
# Events that occurred when this session was open.
|
8
10
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
11
|
+
# @return [Array<Mdm::Event>]
|
12
12
|
has_many :events, :class_name => 'Mdm::SessionEvent', :order => 'created_at', :dependent => :delete_all
|
13
|
+
|
14
|
+
# @!attribute [rw] host
|
15
|
+
# {Mdm::Host Host} on which this session was opened.
|
16
|
+
#
|
17
|
+
# @return [Mdm::Host]
|
13
18
|
belongs_to :host, :class_name => 'Mdm::Host'
|
19
|
+
|
20
|
+
# @!attribute [rw] routes
|
21
|
+
# Routes tunneled throug this session.
|
22
|
+
#
|
23
|
+
# @return [Array<Mdm::Route>]
|
14
24
|
has_many :routes, :class_name => 'Mdm::Route', :dependent => :delete_all
|
15
25
|
|
16
26
|
#
|
17
27
|
# Through :host
|
18
28
|
#
|
29
|
+
|
30
|
+
# @!attribute [r] workspace
|
31
|
+
# The workspace in which this session exists.
|
32
|
+
#
|
33
|
+
# @return [Mdm::Workspace]
|
19
34
|
has_one :workspace, :through => :host, :class_name => 'Mdm::Workspace'
|
20
35
|
|
36
|
+
#
|
37
|
+
# Attributes
|
38
|
+
#
|
39
|
+
|
40
|
+
# @!attribute [rw] closed_at
|
41
|
+
# When the session was closed on {#host}.
|
42
|
+
#
|
43
|
+
# @return [DateTime]
|
44
|
+
|
45
|
+
# @!attribute [rw] close_reason
|
46
|
+
# Why the session was closed. Used to differentiate between user killing it local and the session being killed on
|
47
|
+
# the remote end.
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
|
51
|
+
# @!attribute [rw] datastore
|
52
|
+
# Options for {#via_exploit exploit} and {#via_payload} modules.
|
53
|
+
#
|
54
|
+
# @return [Hash]
|
55
|
+
|
56
|
+
# @!attribute [rw] desc
|
57
|
+
# Description of session.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
|
61
|
+
# @!attribute [rw] last_seen
|
62
|
+
# The last time the session was checked to see that it was still open.
|
63
|
+
#
|
64
|
+
# @return [DateTime]
|
65
|
+
|
66
|
+
# @!attribute [rw] local_id
|
67
|
+
# The ID number of the in-memory session.
|
68
|
+
#
|
69
|
+
# @return [Integer]
|
70
|
+
|
71
|
+
# @!attribute [rw] opened_at
|
72
|
+
# When the session was opened on {#host}.
|
73
|
+
#
|
74
|
+
# @return [DateTime]
|
75
|
+
|
76
|
+
# @!attribute [rw] platform
|
77
|
+
# The {#host} platform.
|
78
|
+
#
|
79
|
+
# @return [String]
|
80
|
+
|
81
|
+
# @!attribute [rw] port
|
82
|
+
# The remote port on which this session is running on {#host}.
|
83
|
+
#
|
84
|
+
# @return [Integer]
|
85
|
+
|
86
|
+
# @!attribute [rw] stype
|
87
|
+
# The type of the session.
|
88
|
+
#
|
89
|
+
# @return [String]
|
90
|
+
|
91
|
+
# @!attribute [rw] via_exploit
|
92
|
+
# The {Mdm::Module::Detail#fullname full name} of the exploit module that opened this session.
|
93
|
+
#
|
94
|
+
# @return [String]
|
95
|
+
|
96
|
+
# @!attribute [rw] via_payload
|
97
|
+
# The {Mdm::Module::Detail#fullname full name} if the payload module that's running this session.
|
98
|
+
#
|
99
|
+
# @return [String]
|
100
|
+
|
101
|
+
#
|
102
|
+
# Callbacks
|
103
|
+
#
|
104
|
+
|
105
|
+
before_destroy :stop
|
106
|
+
|
21
107
|
#
|
22
108
|
# Scopes
|
23
109
|
#
|
@@ -32,12 +118,20 @@ class Mdm::Session < ActiveRecord::Base
|
|
32
118
|
|
33
119
|
serialize :datastore, ::MetasploitDataModels::Base64Serializer.new
|
34
120
|
|
121
|
+
# Returns whether the session can be upgraded to a meterpreter session from a shell session on Windows.
|
122
|
+
#
|
123
|
+
# @return [true] if {#platform} is some version of Windows and {#stype} is `'shell'`.
|
124
|
+
# @return [false] otherwise.
|
35
125
|
def upgradeable?
|
36
126
|
(self.platform =~ /win/ and self.stype == 'shell')
|
37
127
|
end
|
38
128
|
|
39
129
|
private
|
40
130
|
|
131
|
+
# Stops and closes the session.
|
132
|
+
#
|
133
|
+
# @todo https://www.pivotaltracker.com/story/show/49026497
|
134
|
+
# @return [void]
|
41
135
|
def stop
|
42
136
|
c = Pro::Client.get rescue nil
|
43
137
|
# ignore exceptions (XXX - ideally, stopped an already-stopped session wouldn't throw XMLRPCException)
|