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,63 +1,42 @@
1
+ # A task run by Metasploit Pro.
1
2
  class Mdm::Task < ActiveRecord::Base
2
3
  #
3
- # Callbacks
4
4
  #
5
-
6
- before_destroy :delete_file
7
-
5
+ # Associations
8
6
  #
9
- # Relations
10
7
  #
11
8
 
12
- # @!attribute listeners
13
- # Listeners spawned by this task
14
- #
15
- # @return [ActiveRecord::Relation<Mdm::Listener>]
9
+ # Listeners spawned by this task
16
10
  has_many :listeners,
17
11
  class_name: 'Mdm::Listener',
18
12
  dependent: :destroy,
19
13
  inverse_of: :task
20
14
 
21
- # @!attribute [rw] task_creds
22
- # Joins this to {#creds}.
23
- #
24
- # @return [ActiveRecord::Relation<Mdm::TaskCred>]
15
+ # Joins this to {#creds}.
25
16
  has_many :task_creds,
26
17
  class_name: 'Mdm::TaskCred',
27
18
  dependent: :destroy,
28
19
  inverse_of: :task
29
20
 
30
- # @!attribute task_hosts
31
- # Joins this to {#hosts}.
32
- #
33
- # @return [ActiveRecord::Relation<Mdm::TaskHost>]
21
+ # Joins this to {#hosts}.
34
22
  has_many :task_hosts,
35
23
  class_name: 'Mdm::TaskHost',
36
24
  dependent: :destroy,
37
25
  inverse_of: :task
38
26
 
39
- # @!attribute task_services
40
- # Joins this to {#services}.
41
- #
42
- # @return [ActiveRecord::Relation<Mdm::TaskService>]
27
+ # Joins this to {#services}.
43
28
  has_many :task_services,
44
29
  class_name: 'Mdm::TaskService',
45
30
  dependent: :destroy,
46
31
  inverse_of: :task
47
32
 
48
- # @!attribute task_sessions
49
- # Joins this to {#sessions}.
50
- #
51
- # @return [ActiveRecord::Relation<Mdm::TaskSession>]
33
+ # Joins this to {#sessions}.
52
34
  has_many :task_sessions,
53
35
  class_name: 'Mdm::TaskSession',
54
36
  dependent: :destroy,
55
37
  inverse_of: :task
56
38
 
57
- # @!attribute [rw] workspace
58
- # The Workspace the Task belongs to
59
- #
60
- # @return [Mdm::Workspace]
39
+ # The Workspace the Task belongs to
61
40
  belongs_to :workspace,
62
41
  class_name: 'Mdm::Workspace',
63
42
  inverse_of: :tasks
@@ -66,53 +45,112 @@ class Mdm::Task < ActiveRecord::Base
66
45
  # through: :task_creds
67
46
  #
68
47
 
69
- # @!attribute [rw] creds
70
- # Creds this task touched
71
- #
72
- # @return [Array<Mdm::Cred>]
48
+ # Creds this task touched
73
49
  has_many :creds, :through => :task_creds, :class_name => 'Mdm::Cred'
74
50
 
75
51
  #
76
52
  # through: :task_hosts
77
53
  #
78
54
 
79
- # @!attribute [rw] hosts
80
- # Hosts this task touched
81
- #
82
- # @return [Array<Mdm::Host>
55
+ # Hosts this task touched
83
56
  has_many :hosts, :through => :task_hosts, :class_name => 'Mdm::Host'
84
57
 
85
58
  #
86
59
  # through: :task_services
87
60
  #
88
61
 
89
- # @!attribute [rw] services
90
- # Services this task touched
91
- #
92
- # @return [Array<Mdm::Service>
62
+ # Services this task touched
93
63
  has_many :services, :through => :task_services, :class_name => 'Mdm::Service'
94
64
 
95
65
  #
96
66
  # through: :task_sessions
97
67
  #
98
68
 
99
- # @!attribute [rw] sessions
100
- # Session this task touched
101
- #
102
- # @return [Array<Mdm::Session>
69
+ # Session this task touched
103
70
  has_many :sessions, :through => :task_sessions, :class_name => 'Mdm::Session'
104
-
71
+
72
+
73
+
74
+
75
+ # @!attribute created_by
76
+ # {Mdm::User#username Name of user} that created this task.
77
+ #
78
+ # @return [String]
79
+
80
+ # @!attribute description
81
+ # Description of what the this task does.
82
+ #
83
+ # @return [String]
84
+
85
+ # @!attribute error
86
+ # Error raised while task was running that caused this task to fail.
87
+ #
88
+ # @return [String]
89
+
90
+ # @!attribute info
91
+ # Information about the task's current status. What the task is currently doing.
92
+ #
93
+ # @return [String]
94
+
95
+ # @!attribute module
96
+ # {Mdm::Module::Class#full_name Module full name} that was run for this task.
97
+ #
98
+ # @return [String]
99
+
100
+ # @!attribute module_uuid
101
+ # UUID of `#module` that was run by this task.
102
+ #
103
+ # @return [String]
104
+
105
+ # @!attribute path
106
+ # Path to the log for this task.
107
+ #
108
+ # @return [String]
109
+
110
+ # @!attribute progress
111
+ # Percentage complete.
112
+ #
113
+ # @return [Integer]
114
+
115
+ # @!attribute updated_at
116
+ # When this task was last updated.
117
+ #
118
+ # @return [DateTime]
119
+
120
+ #
121
+ # Callbacks
122
+ #
123
+
124
+ before_destroy :delete_file
105
125
 
106
126
  #
107
127
  # Serializations
108
128
  #
109
129
 
130
+ # Options passed to `#module`.
131
+ #
132
+ # @return [Hash]
110
133
  serialize :options, MetasploitDataModels::Base64Serializer.new
134
+
135
+ # Result of task running.
136
+ #
137
+ # @return [Hash]
111
138
  serialize :result, MetasploitDataModels::Base64Serializer.new
139
+
140
+ # Settings used to configure this task outside of the {#options module options}.
141
+ #
142
+ # @return [Hash]
112
143
  serialize :settings, MetasploitDataModels::Base64Serializer.new
113
144
 
145
+ #
146
+ # Instance Methods
147
+ #
148
+
114
149
  private
115
150
 
151
+ # Deletes {#path log} on-disk, so that disk is cleaned up when this task is deleted from the database.
152
+ #
153
+ # @return [void]
116
154
  def delete_file
117
155
  c = Pro::Client.get rescue nil
118
156
  if c
@@ -122,6 +160,7 @@ class Mdm::Task < ActiveRecord::Base
122
160
  end
123
161
  end
124
162
 
163
+ # Restore public for load hooks
125
164
  public
126
165
 
127
166
  Metasploit::Concern.run(self)
@@ -1,12 +1,41 @@
1
+ # @deprecated {Mdm::Task} has and belongs to many `Metasploit::Credential::Cores` in `Mdm::Task#credential_cores` and
2
+ # has and belongs to many `Metasploit::Credential::Logins` in `Mdm::Task#credential_logins` when the
3
+ # `Metasploit::Credential::Engine` is installed.
4
+ #
5
+ # Join model between {Mdm::Cred} and {Mdm::Task} that signifies that the {#task} found the {#cred}.
1
6
  class Mdm::TaskCred < ActiveRecord::Base
7
+ #
8
+ # Associations
9
+ #
10
+
11
+ # The {Mdm::Cred} found by {#task}.
2
12
  belongs_to :cred,
3
13
  class_name: 'Mdm::Cred',
4
14
  inverse_of: :task_creds
5
15
 
16
+ # An {Mdm::Task} that found {#cred}.
6
17
  belongs_to :task,
7
18
  class_name: 'Mdm::Task',
8
19
  inverse_of: :task_creds
9
20
 
21
+ #
22
+ # Attributes
23
+ #
24
+
25
+ # @!attribute [rw] created_at
26
+ # When this task cred was created.
27
+ #
28
+ # @return [DateTime]
29
+
30
+ # @!attribute [rw] updated_at
31
+ # The last time this task cred was updated.
32
+ #
33
+ # @return [DateTime]
34
+
35
+ #
36
+ # Validations
37
+ #
38
+
10
39
  validates :cred_id,
11
40
  :uniqueness => {
12
41
  :scope => :task_id
@@ -1,12 +1,37 @@
1
+ # Join model between {Mdm::Host} and {Mdm::Task} that signifies that the {#task} found the {#host}.
1
2
  class Mdm::TaskHost < ActiveRecord::Base
3
+ #
4
+ # Associations
5
+ #
6
+
7
+ # The {Mdm::Host} found by {#task}.
2
8
  belongs_to :host,
3
9
  class_name: 'Mdm::Host',
4
10
  inverse_of: :task_hosts
5
11
 
12
+ # An {Mdm::Task} that found {#host}.
6
13
  belongs_to :task,
7
14
  class_name: 'Mdm::Task',
8
15
  inverse_of: :task_hosts
9
16
 
17
+ #
18
+ # Attributes
19
+ #
20
+
21
+ # @!attribute created_at
22
+ # When this task host was created.
23
+ #
24
+ # @return [DateTime]
25
+
26
+ # @!attribute updated_at
27
+ # The last time this task host was updated.
28
+ #
29
+ # @return [DateTime]
30
+
31
+ #
32
+ # Validations
33
+ #
34
+
10
35
  validates :host_id,
11
36
  :uniqueness => {
12
37
  :scope => :task_id
@@ -1,12 +1,37 @@
1
+ # Join model between {Mdm::Service} and {Mdm::Task} that signifies that the {#task} found the {#service}.
1
2
  class Mdm::TaskService < ActiveRecord::Base
3
+ #
4
+ # Associations
5
+ #
6
+
7
+ # The {Mdm::Service} found by {#task}.
2
8
  belongs_to :service,
3
9
  class_name: 'Mdm::Service',
4
10
  inverse_of: :task_services
5
11
 
12
+ # An {Mdm::Task} that found {#service}.
6
13
  belongs_to :task,
7
14
  class_name: 'Mdm::Task',
8
15
  inverse_of: :task_services
9
16
 
17
+ #
18
+ # Attributes
19
+ #
20
+
21
+ # @!attribute created_at
22
+ # When this task service was created.
23
+ #
24
+ # @return [DateTime]
25
+
26
+ # @!attribute updated_at
27
+ # The last time this task service was updated.
28
+ #
29
+ # @return [DateTime]
30
+
31
+ #
32
+ # Validations
33
+ #
34
+
10
35
  validates :service_id,
11
36
  :uniqueness => {
12
37
  :scope => :task_id
@@ -1,12 +1,37 @@
1
+ # Join model between {Mdm::Session} and {Mdm::Task} that signifies that the {#task} spawned the {#session}.
1
2
  class Mdm::TaskSession < ActiveRecord::Base
3
+ #
4
+ # Associations
5
+ #
6
+
7
+ # The {Mdm::Session} found by {#task}.
2
8
  belongs_to :session,
3
9
  class_name: 'Mdm::Session',
4
10
  inverse_of: :task_sessions
5
11
 
12
+ # An {Mdm::Task} that found {#session}
6
13
  belongs_to :task,
7
14
  class_name: 'Mdm::Task',
8
15
  inverse_of: :task_sessions
9
16
 
17
+ #
18
+ # Attributes
19
+ #
20
+
21
+ # @!attribute created_at
22
+ # When this task session was created.
23
+ #
24
+ # @return [DateTime]
25
+
26
+ # @!attribute updated_at
27
+ # The last time this task session was updated.
28
+ #
29
+ # @return [DateTime]
30
+
31
+ #
32
+ # Validations
33
+ #
34
+
10
35
  validates :session_id,
11
36
  :uniqueness => {
12
37
  :scope => :task_id
@@ -1,3 +1,4 @@
1
+ # A user of metasploit-framework or metasploit-pro.
1
2
  class Mdm::User < ActiveRecord::Base
2
3
  extend MetasploitDataModels::SerializedPrefs
3
4
 
@@ -5,40 +6,225 @@ class Mdm::User < ActiveRecord::Base
5
6
  # Associations
6
7
  #
7
8
 
9
+ # Automatic exploitation runs started by this user.
8
10
  has_many :automatic_exploitation_runs,
9
11
  class_name: 'MetasploitDataModels::AutomaticExploitation::Run',
10
12
  inverse_of: :user
11
13
 
14
+ # Automatic exploitation match sets created by this user for {#automatic_exploitation_runs}.
12
15
  has_many :automatic_exploitation_match_sets,
13
16
  class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
14
17
  inverse_of: :user
15
18
 
19
+ # {Mdm::Workspace Workspaces} owned by this user. Owned workspaces allow user complete permissions without the need
20
+ # or the user to be an {#admin administrator}.
16
21
  has_many :owned_workspaces,
17
22
  class_name: 'Mdm::Workspace',
18
23
  foreign_key: 'owner_id',
19
24
  inverse_of: :owner
20
25
 
26
+ # Runs of Metasploit Modules by this user.
21
27
  has_many :module_runs,
22
28
  class_name: 'MetasploitDataModels::ModuleRun',
23
29
  inverse_of: :user
24
30
 
31
+ # Tags created by the user.
25
32
  has_many :tags,
26
33
  class_name: 'Mdm::Tag',
27
34
  inverse_of: :user
28
35
 
29
- has_and_belongs_to_many :workspaces, -> { uniq }, :join_table => 'workspace_members', :class_name => 'Mdm::Workspace'
36
+ # {Mdm::Workspace Workspace} where this user has access. If a user is an {#admin administrator} they have access
37
+ # to all workspaces even if they are not a member of that workspace.
38
+ has_and_belongs_to_many :workspaces,
39
+ -> { uniq },
40
+ class_name: 'Mdm::Workspace',
41
+ join_table: 'workspace_members'
42
+
43
+ #
44
+ # Attributes
45
+ #
46
+
47
+ # @!attribute admin
48
+ # Whether this user is an administrator. Administrator permissions are only enforced in metasploit-pro through the
49
+ # controllers.
50
+ #
51
+ # @return [false] if this is a normal user that must be added to each workspace.
52
+ # @return [true] if this user is an administrator and have access to all workspaces without being added to the
53
+ # workspace explicitly. User is also allowed to add other users to workspaces or make other users admins.
54
+
55
+ # @!attribute company
56
+ # Company at which user works.
57
+ #
58
+ # @return [String, nil]
59
+
60
+ # @!attribute created_at
61
+ # When the user was created.
62
+ #
63
+ # @return [DateTime]
64
+
65
+ # @!attribute crypted_password
66
+ # Hashed password (salted with {#password_salt}) by Authlogic in metasploit-pro.
67
+ #
68
+ # @return [String]
69
+
70
+ # @!attribute email
71
+ # The user's email address.
72
+ #
73
+ # @return [String, nil]
74
+
75
+ # @!attribute fullname
76
+ # The user's normal human name.
77
+ #
78
+ # @return [String, nil]
79
+
80
+ # @!attribute password_salt
81
+ # Salt used when hashing password into {#crypted_password} by Authlogic in metasploit-pro.
82
+ #
83
+ # @return [String]
84
+
85
+ # @!attribute persistence_token
86
+ # Token used for session and cookie when user is logged using Authlogic in metasploit-pro.
87
+ #
88
+ # @return [String]
89
+
90
+ # @!attribute phone
91
+ # Phone number for user.
92
+ #
93
+ # @return [String, nil]
94
+
95
+ # @!attribute updated_at
96
+ # When the user was last updated.
97
+ #
98
+ # @return [DateTime]
99
+
100
+ # @!attribute username
101
+ # Username for this user. Used to log into metasploit-pro.
102
+ #
103
+ # @return [String]
30
104
 
31
105
  #
32
106
  # Serialziations
33
107
  #
34
108
 
109
+ # Hash of user preferences
110
+ #
111
+ # @return [Hash]
35
112
  serialize :prefs, MetasploitDataModels::Base64Serializer.new
36
113
 
37
- serialized_prefs_attr_accessor :nexpose_host, :nexpose_port, :nexpose_user, :nexpose_pass, :nexpose_creds_type, :nexpose_creds_user, :nexpose_creds_pass
38
- serialized_prefs_attr_accessor :http_proxy_host, :http_proxy_port, :http_proxy_user, :http_proxy_pass
39
- serialized_prefs_attr_accessor :time_zone, :session_key
40
- serialized_prefs_attr_accessor :last_login_address # specifically NOT last_login_ip to prevent confusion with AuthLogic magic columns (which dont work for serialized fields)
41
-
114
+ # @!attribute time_zone
115
+ # User's preferred time zone.
116
+ #
117
+ # @return [String, nil]
118
+ serialized_prefs_attr_accessor :time_zone
119
+
120
+ #
121
+ # @!group Duplicate Login Monitoring
122
+ #
123
+
124
+ # @!attribute last_login_address
125
+ # @note specifically NOT last_login_ip to prevent confusion with AuthLogic magic columns (which dont work for
126
+ # serialized fields)
127
+ #
128
+ # Last IP address from which this user logged in. Used to report currently active user session's IP when the user
129
+ # is logged off because theire `session[:session_id]` does not match {#session_key}.
130
+ #
131
+ # @return [String, nil]
132
+ serialized_prefs_attr_accessor :last_login_address
133
+
134
+ # @!attribute session_key
135
+ # Holds `session[:session_id]` so user can only be logged in once. Only enforced in metasploit-pro.
136
+ #
137
+ # @return [String, nil]
138
+ serialized_prefs_attr_accessor :session_key
139
+
140
+ #
141
+ # @!endgroup
142
+ #
143
+
144
+ #
145
+ # @!group HTTP Proxy
146
+ #
147
+
148
+ # @!attribute http_proxy_host
149
+ # Proxy host.
150
+ #
151
+ # @return [String, nil]
152
+ serialized_prefs_attr_accessor :http_proxy_host
153
+
154
+ # @!attribute http_proxy_pass
155
+ # Password used to login as {#http_proxy_user} to proxy.
156
+ #
157
+ # @return [String, nil]
158
+ serialized_prefs_attr_accessor :http_proxy_pass
159
+
160
+ # @!attribute http_proxy_port
161
+ # Port on which proxy run on {#http_proxy_host}.
162
+ #
163
+ # @return [String, Integer, nil]
164
+ serialized_prefs_attr_accessor :http_proxy_port
165
+
166
+ # @!attribute http_proxy_user
167
+ # User used to log into proxy.
168
+ #
169
+ # @return [String, nil]
170
+ serialized_prefs_attr_accessor :http_proxy_user
171
+
172
+ #
173
+ # @!endgroup
174
+ #
175
+
176
+ #
177
+ # @!group Nexpose
178
+ #
179
+
180
+ # @!attribute nexpose_host
181
+ # Host name for server running Nexpose.
182
+ #
183
+ # @return [String, nil]
184
+ serialized_prefs_attr_accessor :nexpose_host
185
+
186
+ # @!attribute nexpose_pass
187
+ # Password to log into Nexpose.
188
+ #
189
+ # @return [String, nil]
190
+ serialized_prefs_attr_accessor :nexpose_pass
191
+
192
+ # @!attribute nexpose_port
193
+ # Port on {#nexpose_host} on which Nexpose is running.
194
+ #
195
+ # @return [String, Integer. nil]
196
+ serialized_prefs_attr_accessor :nexpose_port
197
+
198
+ # @!attribute nexpose_user
199
+ # User used to log into Nexpose.
200
+ #
201
+ # @return [String, nil]
202
+ serialized_prefs_attr_accessor :nexpose_user
203
+
204
+ #
205
+ # @!endgroup
206
+ #
207
+
208
+ #
209
+ # @!group Nexpose Authenticated Scan Credentials
210
+ #
211
+
212
+ # @!attribute nexpose_creds_pass
213
+ # @return [String, nil]
214
+ serialized_prefs_attr_accessor :nexpose_creds_pass
215
+
216
+ # @!attribute nexpose_creds_type
217
+ # @return [String, nil]
218
+ serialized_prefs_attr_accessor :nexpose_creds_type
219
+
220
+ # @!attribute nexpose_creds_user
221
+ # @return [String, nil]
222
+ serialized_prefs_attr_accessor :nexpose_creds_user
223
+
224
+ #
225
+ # @!endgroup
226
+ #
227
+
42
228
  Metasploit::Concern.run(self)
43
229
  end
44
230