Class: Ronin::Recon::Values::URL

Inherits:
Ronin::Recon::Value show all
Defined in:
lib/ronin/recon/values/url.rb

Overview

Represents a discovered URL.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ronin::Recon::Value

#==, parse, #to_csv, #to_json

Constructor Details

#initialize(url, status: nil, headers: nil, body: nil) ⇒ URL

Initializes the URL object.

Parameters:

  • url (URI::HTTP, URI::HTTPS, String)
  • status (Integer, nil) (defaults to: nil)

    The optional HTTP status of the URI.

  • headers (Hash{String => String}, nil) (defaults to: nil)

    The optional HTTP response headers for the URI.

  • body (String, nil) (defaults to: nil)

    The optional HTTP response body for the URI.



69
70
71
72
73
74
75
# File 'lib/ronin/recon/values/url.rb', line 69

def initialize(url, status: nil, headers: nil, body: nil)
  @uri = URI(url)

  @status  = status
  @headers = headers
  @body    = body
end

Instance Attribute Details

#bodyString? (readonly)

The HTTP response body for the URI.

Returns:

  • (String, nil)


53
54
55
# File 'lib/ronin/recon/values/url.rb', line 53

def body
  @body
end

#headersHash{String => String}? (readonly)

The HTTP response headers for the URI.

Returns:

  • (Hash{String => String}, nil)


48
49
50
# File 'lib/ronin/recon/values/url.rb', line 48

def headers
  @headers
end

#statusInteger? (readonly)

The HTTP status of the URI.

Returns:

  • (Integer, nil)


43
44
45
# File 'lib/ronin/recon/values/url.rb', line 43

def status
  @status
end

#uriURI::HTTP, URI::HTTPS (readonly) Also known as: to_uri

The parsed URI.

Returns:

  • (URI::HTTP, URI::HTTPS)


38
39
40
# File 'lib/ronin/recon/values/url.rb', line 38

def uri
  @uri
end

Class Method Details

.value_type:url

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.

Note:

This is used internally to map a recon value class to a printable type.

Returns the type or kind of recon value.

Returns:

  • (:url)


210
211
212
# File 'lib/ronin/recon/values/url.rb', line 210

def self.value_type
  :url
end

Instance Method Details

#as_jsonHash{Symbol => Object}

Coerces the URL value into JSON.

Returns:

  • (Hash{Symbol => Object})

    The Ruby Hash that will be converted into JSON.



190
191
192
193
194
195
196
197
# File 'lib/ronin/recon/values/url.rb', line 190

def as_json
  hash = {type: :url, url: @uri.to_s}

  hash[:status]  = @status  if @status
  hash[:headers] = @headers if @headers

  return hash
end

#eql?(other) ⇒ Boolean

Compares the value to another value.

Parameters:

Returns:

  • (Boolean)


156
157
158
# File 'lib/ronin/recon/values/url.rb', line 156

def eql?(other)
  other.kind_of?(self.class) && @uri == other.uri
end

#fragmentString?

The URL's fragment string.

Returns:

  • (String, nil)


145
146
147
# File 'lib/ronin/recon/values/url.rb', line 145

def fragment
  @uri.fragment
end

#hashInteger

The "hash" value of the URL.

Returns:

  • (Integer)

    The hash value of #uri.



166
167
168
# File 'lib/ronin/recon/values/url.rb', line 166

def hash
  [self.class, @uri].hash
end

#hostString

The URL's host name.

Returns:

  • (String)


100
101
102
# File 'lib/ronin/recon/values/url.rb', line 100

def host
  @uri.host
end

#pathString

The URL's path.

Returns:

  • (String)


118
119
120
# File 'lib/ronin/recon/values/url.rb', line 118

def path
  @uri.path
end

#portInteger

The URL's port.

Returns:

  • (Integer)


109
110
111
# File 'lib/ronin/recon/values/url.rb', line 109

def port
  @uri.port
end

#queryString?

The URL's query string.

Returns:

  • (String, nil)


127
128
129
# File 'lib/ronin/recon/values/url.rb', line 127

def query
  @uri.query
end

#query_paramsHash{String => String}?

The URL's query params.

Returns:

  • (Hash{String => String}, nil)


136
137
138
# File 'lib/ronin/recon/values/url.rb', line 136

def query_params
  @uri.query_params
end

#schemeString

The scheme of the URL.

Returns:

  • (String)


82
83
84
# File 'lib/ronin/recon/values/url.rb', line 82

def scheme
  @uri.scheme
end

#to_sString Also known as: to_str

Converts the URL object to a String.

Returns:

  • (String)

    The URL string.



178
179
180
# File 'lib/ronin/recon/values/url.rb', line 178

def to_s
  @uri.to_s
end

#userinfoString?

The URI's user information.

Returns:

  • (String, nil)


91
92
93
# File 'lib/ronin/recon/values/url.rb', line 91

def userinfo
  @uri.userinfo
end