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

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

Overview

This class represents a logical physical interface on the remote machine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip, netmask, mac_addr, mac_name) ⇒ Interface

Returns a logical interface and initializes it to the supplied parameters.



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

def initialize(ip, netmask, mac_addr, mac_name)
	self.ip       = IPAddr.ntop(ip)
	self.netmask  = IPAddr.ntop(netmask)
	self.mac_addr = mac_addr
	self.mac_name = mac_name
end

Instance Attribute Details

#ipObject

The IP address bound to the interface.



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

def ip
  @ip
end

#mac_addrObject

The physical (MAC) address of the NIC.



65
66
67
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb', line 65

def mac_addr
  @mac_addr
end

#mac_nameObject

The name of the interface.



69
70
71
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb', line 69

def mac_name
  @mac_name
end

#netmaskObject

The subnet mask associated with the interface.



61
62
63
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb', line 61

def netmask
  @netmask
end

Instance Method Details

#prettyObject

Returns a pretty string representation of the interface’s properties.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb', line 40

def pretty
	macocts = []
	mac_addr.each_byte { |o| macocts << o }
	macocts += [0] * (6 - macocts.size) if macocts.size < 6
	return sprintf(
			"#{mac_name}\n" +
			"Hardware MAC: %02x:%02x:%02x:%02x:%02x:%02x\n" +
			"IP Address  : %s\n" +
			"Netmask     : %s\n" +
			"\n", 
			macocts[0], macocts[1], macocts[2], macocts[3], 
			macocts[4], macocts[5], ip, netmask)
end