Class: Ronin::Recon::Values::OpenPort
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::OpenPort
- Defined in:
- lib/ronin/recon/values/open_port.rb
Overview
Represents a discovered open port.
Instance Attribute Summary collapse
-
#address ⇒ String
readonly
The IP address that the open port listens on.
-
#host ⇒ String?
readonly
The optional hostname associated with the address.
-
#number ⇒ Integer
readonly
The port number.
-
#protocol ⇒ :tcp, :udp
readonly
The protocol of the port.
-
#service ⇒ String?
readonly
The optional service information.
-
#ssl ⇒ Boolean
readonly
Indiciates whether the open port uses SSL.
Class Method Summary collapse
-
.value_type ⇒ :open_port
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the open port value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value of the open port.
-
#initialize(address, number, host: nil, protocol: :tcp, service: nil, ssl: false) ⇒ OpenPort
constructor
Initializes the open port.
-
#ssl? ⇒ Boolean
Determines whether the open port uses SSL/TLS.
-
#to_i ⇒ Integer
(also: #to_int)
Converts the open port into an Integer.
-
#to_s ⇒ String
Converts the open port into a String.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(address, number, host: nil, protocol: :tcp, service: nil, ssl: false) ⇒ OpenPort
Initializes the open port.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ronin/recon/values/open_port.rb', line 84 def initialize(address,number, host: nil, protocol: :tcp, service: nil, ssl: false) @address = address @number = number @host = host @protocol = protocol @service = service @ssl = ssl end |
Instance Attribute Details
#address ⇒ String (readonly)
The IP address that the open port listens on.
36 37 38 |
# File 'lib/ronin/recon/values/open_port.rb', line 36 def address @address end |
#host ⇒ String? (readonly)
The optional hostname associated with the address.
46 47 48 |
# File 'lib/ronin/recon/values/open_port.rb', line 46 def host @host end |
#number ⇒ Integer (readonly)
The port number.
41 42 43 |
# File 'lib/ronin/recon/values/open_port.rb', line 41 def number @number end |
#protocol ⇒ :tcp, :udp (readonly)
The protocol of the port.
51 52 53 |
# File 'lib/ronin/recon/values/open_port.rb', line 51 def protocol @protocol end |
#service ⇒ String? (readonly)
The optional service information.
56 57 58 |
# File 'lib/ronin/recon/values/open_port.rb', line 56 def service @service end |
#ssl ⇒ Boolean (readonly)
Indiciates whether the open port uses SSL.
61 62 63 |
# File 'lib/ronin/recon/values/open_port.rb', line 61 def ssl @ssl end |
Class Method Details
.value_type ⇒ :open_port
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.
183 184 185 |
# File 'lib/ronin/recon/values/open_port.rb', line 183 def self.value_type :open_port end |
Instance Method Details
#as_json ⇒ Hash{Symbol => Object}
Coerces the open port value into JSON.
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/ronin/recon/values/open_port.rb', line 158 def as_json hash = { type: :open_port, address: @address, protocol: @protocol, number: @number } hash[:service] = @service if @service hash[:ssl] = @ssl if @ssl return hash end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
112 113 114 115 116 117 118 119 |
# File 'lib/ronin/recon/values/open_port.rb', line 112 def eql?(other) other.kind_of?(self.class) && @address == other.address && @number == other.number && @protocol == other.protocol && @service == other.service && @ssl == other.ssl end |
#hash ⇒ Integer
The "hash" value of the open port.
126 127 128 |
# File 'lib/ronin/recon/values/open_port.rb', line 126 def hash [self.class, @address, @number, @protocol, @service, @ssl].hash end |
#ssl? ⇒ Boolean
Determines whether the open port uses SSL/TLS.
101 102 103 |
# File 'lib/ronin/recon/values/open_port.rb', line 101 def ssl? @ssl end |
#to_i ⇒ Integer Also known as: to_int
Converts the open port into an Integer.
146 147 148 |
# File 'lib/ronin/recon/values/open_port.rb', line 146 def to_i @number.to_i end |
#to_s ⇒ String
Converts the open port into a String.
136 137 138 |
# File 'lib/ronin/recon/values/open_port.rb', line 136 def to_s "#{@address}:#{@number}" end |