Class: Mdm::Workspace
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Mdm::Workspace
- Defined in:
- app/models/mdm/workspace.rb
Overview
Workspace to separate different collections of #hosts. Can be used to separate pentests against different networks or different clients as reports are normally generated against all records in a workspace.
Constant Summary collapse
- DEFAULT =
CONSTANTS
'default'
Instance Attribute Summary collapse
-
#boundary ⇒ String
Comma separated list of IP ranges (in various formats) and IP addresses that users of this workspace are allowed to interact with if #limit_to_network is
true
. -
#created_at ⇒ DateTime
When this workspace was created.
-
#description ⇒ String
Long description (beyond #name) that explains the purpose of this workspace.
-
#limit_to_network ⇒ false, true
Whether #boundary is respected.
-
#name ⇒ String
Name of this workspace.
-
#updated_at ⇒ DateTime
The last time this workspace was updated.
Class Method Summary collapse
-
.default ⇒ Mdm::Workspace
Returns default Workspace.
Instance Method Summary collapse
-
#creds ⇒ ActiveRecord::Relation<Mdm::Cred>
deprecated
Deprecated.
Use
Mdm::Workspace#credential_cores
whenMetasploit::Credential::Engine
is installed to getMetasploit::Credential::Core
s. UseMdm::Service#logins
whenMetasploit::Credential::Engine
is installed to getMetasploit::Credential::Login
s. -
#default? ⇒ true, false
Whether this is the Workspace.default workspace.
-
#each_cred {|cred| ... } ⇒ void
deprecated
Deprecated.
Use
workspace.credential_cores.each
whenMetasploit::Credential::Engine
is installed to enumerateMetasploit::Credential::Core
s. Useservice.logins.each
whenMetasploit::Credential::Engine
is installed to enumerateMetasploit::Credential::Login
s. -
#each_host_tag {|tag| ... } ⇒ void
Enumerates each element of #host_tags.
-
#host_tags ⇒ ActiveRecord::Relation<Mdm::Tag>
Tags on #hosts.
-
#unique_web_forms ⇒ ActiveRecord::Relation<Mdm::WebForm>
Web forms on #web_sites.
-
#web_forms ⇒ ActiveRecord::Relation<Mdm::WebForm>
Web forms found on #web_sites.
-
#web_pages ⇒ ActiveRecord::Relation<Mdm::WebPage>
Web pages found on #web_sites.
-
#web_sites ⇒ ActiveRecord::Relation<Mdm::WebSite>
Web sites running on #services.
-
#web_unique_forms(addrs = nil) ⇒ Array<Mdm::WebForm>
#unique_web_forms hosted on
addrs
. -
#web_vulns ⇒ ActiveRecord::Relation<Mdm::WebVuln>
Web vulnerability found on #web_sites.
Instance Attribute Details
#boundary ⇒ String
Comma separated list of IP ranges (in various formats) and IP addresses that users of this workspace are allowed
to interact with if #limit_to_network is true
.
|
# File 'app/models/mdm/workspace.rb', line 89
|
#created_at ⇒ DateTime
When this workspace was created.
|
# File 'app/models/mdm/workspace.rb', line 111
|
#description ⇒ String
Long description (beyond #name) that explains the purpose of this workspace.
|
# File 'app/models/mdm/workspace.rb', line 95
|
#limit_to_network ⇒ false, true
Whether #boundary is respected.
|
# File 'app/models/mdm/workspace.rb', line 100
|
#name ⇒ String
Name of this workspace.
|
# File 'app/models/mdm/workspace.rb', line 106
|
#updated_at ⇒ DateTime
The last time this workspace was updated.
|
# File 'app/models/mdm/workspace.rb', line 116
|
Class Method Details
.default ⇒ Mdm::Workspace
Returns default Mdm::Workspace.
154 155 156 |
# File 'app/models/mdm/workspace.rb', line 154 def self.default where(name: DEFAULT).first_or_create end |
Instance Method Details
#creds ⇒ ActiveRecord::Relation<Mdm::Cred>
Use Mdm::Workspace#credential_cores
when Metasploit::Credential::Engine
is installed to get
Metasploit::Credential::Core
s. Use Mdm::Service#logins
when Metasploit::Credential::Engine
is installed to
get Metasploit::Credential::Login
s.
143 144 145 146 147 148 149 |
# File 'app/models/mdm/workspace.rb', line 143 def creds Mdm::Cred .joins(service: :host) .where(hosts: { workspace_id: self.id }) end |
#default? ⇒ true, false
Whether this is the default workspace.
162 163 164 |
# File 'app/models/mdm/workspace.rb', line 162 def default? name == DEFAULT end |
#each_cred {|cred| ... } ⇒ void
Use workspace.credential_cores.each
when Metasploit::Credential::Engine
is installed to enumerate
Metasploit::Credential::Core
s. Use service.logins.each
when Metasploit::Credential::Engine
is installed to
enumerate Metasploit::Credential::Login
s.
This method returns an undefined value.
Enumerates each element of #creds.
176 177 178 179 180 |
# File 'app/models/mdm/workspace.rb', line 176 def each_cred(&block) creds.each do |cred| block.call(cred) end end |
#each_host_tag {|tag| ... } ⇒ void
This method returns an undefined value.
Enumerates each element of #host_tags.
188 189 190 191 192 |
# File 'app/models/mdm/workspace.rb', line 188 def each_host_tag(&block) .each do |host_tag| block.call(host_tag) end end |
#host_tags ⇒ ActiveRecord::Relation<Mdm::Tag>
Tags on #hosts.
197 198 199 200 201 202 203 |
# File 'app/models/mdm/workspace.rb', line 197 def Mdm::Tag .joins(:hosts) .where(hosts: { workspace_id: self.id }) end |
#unique_web_forms ⇒ ActiveRecord::Relation<Mdm::WebForm>
Web forms on #web_sites.
256 257 258 |
# File 'app/models/mdm/workspace.rb', line 256 def unique_web_forms web_forms.select('web_forms.id, web_forms.web_site_id, web_forms.path, web_forms.method, web_forms.query') end |
#web_forms ⇒ ActiveRecord::Relation<Mdm::WebForm>
Web forms found on #web_sites.
208 209 210 211 212 213 214 215 |
# File 'app/models/mdm/workspace.rb', line 208 def web_forms Mdm::WebForm.joins( Mdm::WebForm.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) ).where(Mdm::Workspace[:id].eq(id)).distinct end |
#web_pages ⇒ ActiveRecord::Relation<Mdm::WebPage>
Web pages found on #web_sites.
221 222 223 224 225 226 227 228 |
# File 'app/models/mdm/workspace.rb', line 221 def web_pages Mdm::WebPage.joins( Mdm::WebPage.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) ).where(Mdm::Workspace[:id].eq(id)).distinct end |
#web_sites ⇒ ActiveRecord::Relation<Mdm::WebSite>
Web sites running on #services.
233 234 235 236 237 238 239 |
# File 'app/models/mdm/workspace.rb', line 233 def web_sites Mdm::WebSite.joins( Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) ).where(Mdm::Workspace[:id].eq(id)).distinct end |
#web_unique_forms(addrs = nil) ⇒ Array<Mdm::WebForm>
#unique_web_forms hosted on addrs
.
265 266 267 268 269 270 271 |
# File 'app/models/mdm/workspace.rb', line 265 def web_unique_forms(addrs=nil) forms = unique_web_forms if addrs forms.to_a.reject!{|f| not addrs.include?( f.web_site.service.host.address.to_s ) } end forms end |
#web_vulns ⇒ ActiveRecord::Relation<Mdm::WebVuln>
Web vulnerability found on #web_sites.
244 245 246 247 248 249 250 251 |
# File 'app/models/mdm/workspace.rb', line 244 def web_vulns Mdm::WebVuln.joins( Mdm::WebVuln.join_association(:web_site), Mdm::WebSite.join_association(:service), Mdm::Service.join_association(:host), Mdm::Host.join_association(:workspace) ).where(Mdm::Workspace[:id].eq(id)).distinct end |