Class: Ronin::Recon::Values::Wildcard

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

Overview

Represents a wildcard host-name (ex: *.example.com).

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(template) ⇒ Wildcard

Initializes the wildcard host object.

Parameters:

  • template (String)


46
47
48
49
50
# File 'lib/ronin/recon/values/wildcard.rb', line 46

def initialize(template)
  @template = template

  @prefix, @suffix = template.split('*',2)
end

Instance Attribute Details

#templateString (readonly)

The wildcard host name.

Returns:

  • (String)


39
40
41
# File 'lib/ronin/recon/values/wildcard.rb', line 39

def template
  @template
end

Class Method Details

.value_type:wildcard

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:

  • (:wildcard)


133
134
135
# File 'lib/ronin/recon/values/wildcard.rb', line 133

def self.value_type
  :wildcard
end

Instance Method Details

#===(other) ⇒ Boolean

Case equality method used for fuzzy matching.

Parameters:

Returns:

  • (Boolean)

    Imdicates whether the other value is either a Domain and has the same domain name, or a Host and shares the same domain name.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ronin/recon/values/wildcard.rb', line 73

def ===(other)
  case other
  when Wildcard
    eql?(other)
  when Domain, Host
    name = other.name

    name.start_with?(@prefix) && name.end_with?(@suffix)
  when URL
    host = other.uri.host

    host.start_with?(@prefix) && host.end_with?(@suffix)
  else
    false
  end
end

#as_jsonHash{Symbol => Object}

Coerces the wildcard value into JSON.

Returns:

  • (Hash{Symbol => Object})

    The Ruby Hash that will be converted into JSON.



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

def as_json
  {type: :wildcard, template: @template}
end

#eql?(other) ⇒ Boolean

Compares the value to another value.

Parameters:

Returns:

  • (Boolean)


59
60
61
# File 'lib/ronin/recon/values/wildcard.rb', line 59

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

#hashInteger

The "hash" value of the wildcard host name.

Returns:



96
97
98
# File 'lib/ronin/recon/values/wildcard.rb', line 96

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

#to_sString Also known as: to_str

Converts the wildcard host object to a String.

Returns:

  • (String)

    The wildcard host name.



106
107
108
# File 'lib/ronin/recon/values/wildcard.rb', line 106

def to_s
  @template.to_s
end