Class: Rex::Post::Meterpreter::Extensions::Stdapi::Net::Arp

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb

Overview

This class represents an arp entry on the remote machine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Arp

Returns an arp entry and initializes it to the supplied parameters.



30
31
32
33
34
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb', line 30

def initialize(opts={})
  self.ip_addr   = IPAddr.new_ntoh(opts[:ip_addr]).to_s
  self.mac_addr  = mac_to_string(opts[:mac_addr])
  self.interface = opts[:interface]
end

Instance Attribute Details

#interfaceObject

The name of the interface.



56
57
58
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb', line 56

def interface
  @interface
end

#ip_addrObject

The ip address corresponding to the arp address.



48
49
50
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb', line 48

def ip_addr
  @ip_addr
end

#mac_addrObject

The physical (MAC) address of the ARP entry



52
53
54
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb', line 52

def mac_addr
  @mac_addr
end

Instance Method Details

#mac_to_string(mac_addr) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb', line 36

def mac_to_string(mac_addr)
  macocts = []
  mac_addr.each_byte { |o| macocts << o }
  macocts += [0] * (6 - macocts.size) if macocts.size < 6
  return sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
    macocts[0], macocts[1], macocts[2],
    macocts[3], macocts[4], macocts[5])
end