Class: Mdm::WebSite

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/mdm/web_site.rb

Overview

A Web Site running on a #service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentsString

User entered comments about this web site.

Returns:

  • (String)

# File 'app/models/mdm/web_site.rb', line 36

#created_atDateTime

When this web site was created.

Returns:

  • (DateTime)

# File 'app/models/mdm/web_site.rb', line 41

#optionsObject

TODO:

Determine format and purpose of Mdm::WebSite#options.


63
# File 'app/models/mdm/web_site.rb', line 63

serialize :options, ::MetasploitDataModels::Base64Serializer.new

#updated_atDateTime

The last time this web site was updated.

Returns:

  • (DateTime)

# File 'app/models/mdm/web_site.rb', line 46

#vhostString

The virtual host for the web site in case service.host.name or service.host.address is no the host for this web site.

Returns:

  • (String)

# File 'app/models/mdm/web_site.rb', line 51

Instance Method Details

#form_countInteger

Number of #web_forms.

Returns:

  • (Integer)

72
73
74
# File 'app/models/mdm/web_site.rb', line 72

def form_count
  web_forms.size
end

#page_countInteger

Number of #web_pages.

Returns:

  • (Integer)

79
80
81
# File 'app/models/mdm/web_site.rb', line 79

def page_count
  web_pages.size
end

#to_url(ignore_vhost = false) ⇒ String

Converts this web site to its URL, including scheme, host and port.

Parameters:

  • ignore_vhost (Boolean) (defaults to: false)

    if false use #vhost for host portion of URL. If true use Host#address of Service#host of #service for host portion of URL.

Returns:

  • (String)

    ://[:]


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/models/mdm/web_site.rb', line 88

def to_url(ignore_vhost=false)
  proto = self.service.name == "https" ? "https" : "http"
  host = ignore_vhost ? self.service.host.address.to_s : self.vhost
  port = self.service.port

  if Rex::Socket.is_ipv6?(host)
    host = "[#{host}]"
  end

  url = "#{proto}://#{host}"
  if not ((proto == "http" and port == 80) or (proto == "https" and port == 443))
    url += ":#{port}"
  end
  url
end

#vuln_countInteger

Number of #web_vulns.

Returns:

  • (Integer)

107
108
109
# File 'app/models/mdm/web_site.rb', line 107

def vuln_count
  web_vulns.size
end