Class: Ronin::DB::MACAddress

Inherits:
Address
  • Object
show all
Defined in:
lib/ronin/db/mac_address.rb

Overview

Represents MAC addresses and their associated IP addresses.

Instance Attribute Summary collapse

Attributes inherited from Address

#created_at, #id

Attributes included from Ronin::DB::Model::LastScannedAt

#last_scanned_at

Instance Method Summary collapse

Methods inherited from Address

import, lookup, #to_s

Methods included from Ronin::DB::Model::LastScannedAt

included

Methods included from Ronin::DB::Model::Importable

included

Methods included from Model

included

Instance Attribute Details

#addressString

The MAC address.

Returns:

  • (String)


37
# File 'lib/ronin/db/mac_address.rb', line 37

attribute :address, :string

#advisoriesArray<Advisory>

The advisories that the MAC Address is vulnerable to.

Returns:

Since:

  • 0.2.0



74
# File 'lib/ronin/db/mac_address.rb', line 74

has_many :advisories, through: :vulnerabilities

#ip_address_mac_addressesArray<IPAddressMACAddress>

The IP Addresses the MAC Address hosts

Returns:



50
51
# File 'lib/ronin/db/mac_address.rb', line 50

has_many :ip_address_mac_addresses, dependent: :destroy,
class_name: 'IPAddressMACAddress'

#ip_addressesArray<IPAddress>

The IP Addresses associated with the MAC Address

Returns:



57
58
# File 'lib/ronin/db/mac_address.rb', line 57

has_many :ip_addresses, through:    :ip_address_mac_addresses,
class_name: 'IPAddress'

#notesArray<Note>

The associated notes.

Returns:

Since:

  • 0.2.0



82
# File 'lib/ronin/db/mac_address.rb', line 82

has_many :notes, dependent: :destroy

#vulnerabilitiesArray<Vulnerability>

The vulnerabilities which reference the MAC Address.

Returns:

Since:

  • 0.2.0



66
# File 'lib/ronin/db/mac_address.rb', line 66

has_many :vulnerabilities, dependent: :destroy

Instance Method Details

#recent_ip_addressIPAddress

The IP Address that most recently used the MAC Address.

Returns:

  • (IPAddress)

    The IP Address that most recently used the MAC Address.



92
93
94
# File 'lib/ronin/db/mac_address.rb', line 92

def recent_ip_address
  self.ip_address_mac_addresses.order('created_at DESC').ip_addresses.first
end

#to_iInteger

Converts the MAC address to an Integer.

Returns:

  • (Integer)

    The network representation of the MAC address.



104
105
106
107
108
# File 'lib/ronin/db/mac_address.rb', line 104

def to_i
  self.address.split(':').reduce(0) do |bits,char|
    ((bits << 8) | char.hex)
  end
end