class Mdm::Workspace
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.
Constants
- DEFAULT
CONSTANTS
Public Class Methods
Returns default {Mdm::Workspace}.
@return [Mdm::Workspace]
# File app/models/mdm/workspace.rb, line 153 def self.default where(name: DEFAULT).first_or_create end
Public Instance Methods
@deprecated 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.
@return [ActiveRecord::Relation<Mdm::Cred>]
# File app/models/mdm/workspace.rb, line 142 def creds Mdm::Cred .joins(service: :host) .where(hosts: { workspace_id: self.id }) end
Whether this is the {default} workspace.
@return [true] if this is the {default} workspace. @return [false] if this is not the {default} workspace.
# File app/models/mdm/workspace.rb, line 161 def default? name == DEFAULT end
@deprecated 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.
Enumerates each element of {#creds}.
@yield [cred] @yieldparam cred [Mdm::Cred] Cred associated with {#hosts a host} or {#services a service} in this workspace. @yieldreturn [void] @return [void]
# File app/models/mdm/workspace.rb, line 175 def each_cred(&block) creds.each do |cred| block.call(cred) end end
Enumerates each element of {#host_tags}.
@yield [tag] @yieldparam tag [Mdm::Tag] a tag on {#hosts}. @yieldreturn [void] @return [void]
# File app/models/mdm/workspace.rb, line 187 def each_host_tag(&block) host_tags.each do |host_tag| block.call(host_tag) end end
Web forms on {#web_sites}.
@return [ActiveRecord::Relation<Mdm::WebForm>]
# File app/models/mdm/workspace.rb, line 255 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 found on {#web_sites}.
@return [ActiveRecord::Relation<Mdm::WebForm>]
# File app/models/mdm/workspace.rb, line 207 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)).uniq end
Web pages found on {#web_sites}.
@return [ActiveRecord::Relation<Mdm::WebPage>]
# File app/models/mdm/workspace.rb, line 220 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)).uniq end
Web sites running on {#services}.
@return [ActiveRecord::Relation<Mdm::WebSite>]
# File app/models/mdm/workspace.rb, line 232 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)).uniq end
{#unique_web_forms} hosted on `addrs`.
@param addrs [Array<IPAddr, String>] {Mdm::Host#address} for the {Mdm::Service#host} for the {Mdm::WebSite#service}
for the {Mdm::WebForm#web_site}.
@return [Array<Mdm::WebForm>]
# File app/models/mdm/workspace.rb, line 264 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 vulnerability found on {#web_sites}.
@return [ActiveRecord::Relation<Mdm::WebVuln>]
# File app/models/mdm/workspace.rb, line 243 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)).uniq end
Private Instance Methods
Strips {#boundary}.
@return [void]
# File app/models/mdm/workspace.rb, line 277 def normalize boundary.strip! if boundary end