Class: Ronin::DB::OpenPort

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::LastScannedAt
Defined in:
lib/ronin/db/open_port.rb

Overview

Represents a open port at a specified IP address.

Instance Attribute Summary collapse

Attributes included from Model::LastScannedAt

#last_scanned_at

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::LastScannedAt

included

Methods included from Model

included

Instance Attribute Details

#advisoriesArray<Advisory>

The advisories that the open port is vulnerable to.

Returns:

Since:

  • 0.2.0



111
# File 'lib/ronin/db/open_port.rb', line 111

has_many :advisories, through: :vulnerabilities

#certCert?

The SSL/TLS certificate used by the open port.

Returns:



77
# File 'lib/ronin/db/open_port.rb', line 77

belongs_to :cert, optional: true

#created_atTime (readonly)

Define the created_at timestamp

Returns:

  • (Time)


83
# File 'lib/ronin/db/open_port.rb', line 83

attribute :created_at, :datetime

#credentialsArray<Credential>

The credentials that will work with this open port.

Returns:



95
# File 'lib/ronin/db/open_port.rb', line 95

has_many :credentials, through: :service_credentials

#idInteger

The primary key of the open port.

Returns:

  • (Integer)


40
# File 'lib/ronin/db/open_port.rb', line 40

attribute :id, :integer

#ip_addressIPAddress

The IP Address that was scanned.

Returns:



46
47
# File 'lib/ronin/db/open_port.rb', line 46

belongs_to :ip_address, required: true,
class_name: 'IPAddress'

#notesArray<Note>

The associated notes.

Returns:

Since:

  • 0.2.0



119
# File 'lib/ronin/db/open_port.rb', line 119

has_many :notes, dependent: :destroy

#portPort

The port.

Returns:



53
# File 'lib/ronin/db/open_port.rb', line 53

belongs_to :port, required: true

#serviceService?

The service detected on the port

Returns:



59
# File 'lib/ronin/db/open_port.rb', line 59

belongs_to :service, optional: true

#service_credentialsArray<ServiceCredential>

Credentials used by the service running on the port

Returns:



89
# File 'lib/ronin/db/open_port.rb', line 89

has_many :service_credentials, dependent: :destroy

#softwareSoftware

The software running on the open port

Returns:



65
# File 'lib/ronin/db/open_port.rb', line 65

belongs_to :software, optional: true

#sslBoolean

Specifies whether the service requires SSL.

Returns:

  • (Boolean)


71
# File 'lib/ronin/db/open_port.rb', line 71

attribute :ssl, :boolean

#vulnerabilitiesArray<Vulnerability>

The vulnerabilities which reference the open port.

Returns:

Since:

  • 0.2.0



103
# File 'lib/ronin/db/open_port.rb', line 103

has_many :vulnerabilities, dependent: :destroy

Class Method Details

.with_ip_address(address) ⇒ Array<OpenPort>

Queries all open ports associated with the IP address.

Parameters:

  • address (String)

    The IP address to search by.

Returns:

  • (Array<OpenPort>)

    The open ports associated with the IP address.

Since:

  • 0.2.0



185
186
187
# File 'lib/ronin/db/open_port.rb', line 185

def self.with_ip_address(address)
  joins(:ip_address).where(ip_address: {address: address})
end

.with_port_number(number) ⇒ Array<OpenPort>

Queries all open ports with the port number.

Parameters:

  • number (Integer)

    The port number to search for.

Returns:

  • (Array<OpenPort>)

    The open ports that use the port number.

Since:

  • 0.2.0



134
135
136
# File 'lib/ronin/db/open_port.rb', line 134

def self.with_port_number(number)
  joins(:port).where(port: {number: number})
end

.with_protocol(protocol) ⇒ Array<OpenPort>

Queries all open ports with the protocol.

Parameters:

  • protocol (:tcp, ;udp)

    The protocol to search for.

Returns:

  • (Array<OpenPort>)

    The open ports that use the protocol.

Since:

  • 0.2.0



151
152
153
# File 'lib/ronin/db/open_port.rb', line 151

def self.with_protocol(protocol)
  joins(:port).where(port: {protocol: protocol})
end

.with_service_name(name) ⇒ Array<OpenPort>

Queries all open ports associated with the service name.

Parameters:

  • name (String)

    The service name to search for.

Returns:

  • (Array<OpenPort>)

    The open ports associated with the service name.

Since:

  • 0.2.0



168
169
170
# File 'lib/ronin/db/open_port.rb', line 168

def self.with_service_name(name)
  joins(:service).where(service: {name: name})
end

Instance Method Details

#addressString

The IP Address of the open port.

Returns:

  • (String)

    The IP Address.



197
198
199
# File 'lib/ronin/db/open_port.rb', line 197

def address
  self.ip_address.address
end

#numberInteger

The port number.

Returns:

  • (Integer)

    The port number.



209
210
211
# File 'lib/ronin/db/open_port.rb', line 209

def number
  self.port.number
end

#to_iInteger

Converts the open port to an integer.

Returns:

  • (Integer)

    The port number.



221
222
223
# File 'lib/ronin/db/open_port.rb', line 221

def to_i
  self.port.to_i
end

#to_sString

Converts the open port to a string.

Returns:

  • (String)

    The information of the open port.



233
234
235
236
237
# File 'lib/ronin/db/open_port.rb', line 233

def to_s
  if self.service then "#{self.ip_address} #{self.port} (#{self.service})"
  else                 "#{self.ip_address} #{self.port}"
  end
end