Class: Ronin::Recon::Values::Website
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::Website
- Defined in:
- lib/ronin/recon/values/website.rb
Overview
Represents a discovered website (ex: https://example.com
).
Constant Summary collapse
- URI_CLASSES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mapping of #scheme values to URI classes.
{ 'https' => URI::HTTPS, 'http' => URI::HTTP }
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
The website's host name.
-
#port ⇒ Integer
readonly
The website's port number.
-
#scheme ⇒ 'http', 'https'
readonly
Indicates whether the website uses
http://
orhttps://
.
Class Method Summary collapse
-
.http(host, port = 80) ⇒ Website
Initializes a new
http://
website. -
.https(host, port = 443) ⇒ Website
Initializes a new
https://
website. -
.parse(url) ⇒ Website
Parses a URL.
-
.value_type ⇒ :website
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the website value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value of the wildcard host name.
-
#initialize(scheme, host, port) ⇒ Website
constructor
Initializes the website.
-
#to_s ⇒ String
Converts the website to a String.
-
#to_uri ⇒ URI::HTTP, URI::HTTPS
Converts the website into a URI.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(scheme, host, port) ⇒ Website
Initializes the website.
64 65 66 67 68 |
# File 'lib/ronin/recon/values/website.rb', line 64 def initialize(scheme,host,port) @scheme = scheme @host = host @port = port end |
Instance Attribute Details
#host ⇒ String (readonly)
The website's host name.
45 46 47 |
# File 'lib/ronin/recon/values/website.rb', line 45 def host @host end |
#port ⇒ Integer (readonly)
The website's port number.
50 51 52 |
# File 'lib/ronin/recon/values/website.rb', line 50 def port @port end |
Class Method Details
.http(host, port = 80) ⇒ Website
Initializes a new http://
website.
82 83 84 |
# File 'lib/ronin/recon/values/website.rb', line 82 def self.http(host,port=80) new('http',host,port) end |
.https(host, port = 443) ⇒ Website
Initializes a new https://
website.
98 99 100 |
# File 'lib/ronin/recon/values/website.rb', line 98 def self.https(host,port=443) new('https',host,port) end |
.parse(url) ⇒ Website
Parses a URL.
111 112 113 114 115 |
# File 'lib/ronin/recon/values/website.rb', line 111 def self.parse(url) uri = URI.parse(url) Values::Website.new(uri.scheme,uri.host,uri.port) end |
.value_type ⇒ :website
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
221 222 223 |
# File 'lib/ronin/recon/values/website.rb', line 221 def self.value_type :website end |
Instance Method Details
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ronin/recon/values/website.rb', line 142 def ===(other) case other when Website self == other when URL @scheme == other.scheme && @host == other.host && @port == other.port when EmailAddress other.address.end_with?("@#{@host}") else false end end |
#as_json ⇒ Hash{Symbol => Object}
Coerces the website value into JSON.
206 207 208 |
# File 'lib/ronin/recon/values/website.rb', line 206 def as_json {type: :website, scheme: @scheme, host: @host, port: @port} end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
124 125 126 127 128 129 |
# File 'lib/ronin/recon/values/website.rb', line 124 def eql?(other) self.class == other.class && @scheme == other.scheme && @host == other.host && @port == other.port end |
#hash ⇒ Integer
The "hash" value of the wildcard host name.
163 164 165 |
# File 'lib/ronin/recon/values/website.rb', line 163 def hash [self.class, @scheme, @host, @port].hash end |
#to_s ⇒ String
Converts the website to a String.
191 192 193 194 195 196 197 198 |
# File 'lib/ronin/recon/values/website.rb', line 191 def to_s if ((@scheme == 'https') && (@port != 443)) || ((@scheme == 'http') && (@port != 80)) "#{@scheme}://#{@host}:#{@port}" else "#{@scheme}://#{@host}" end end |
#to_uri ⇒ URI::HTTP, URI::HTTPS
Converts the website into a URI.
181 182 183 |
# File 'lib/ronin/recon/values/website.rb', line 181 def to_uri URI_CLASSES.fetch(@scheme).build(host: @host, port: @port, path: '/') end |