Files
metasploit-gs/lib/rex/post/meterpreter/extensions/stdapi/net/interface.rb
T

70 lines
1.2 KiB
Ruby
Raw Normal View History

2005-12-17 06:46:23 +00:00
#!/usr/bin/env ruby
2005-04-17 08:02:01 +00:00
2005-04-17 09:04:22 +00:00
require 'ipaddr'
2005-04-17 08:02:01 +00:00
module Rex
module Post
module Meterpreter
module Extensions
module Stdapi
module Net
###
#
# This class represents a logical physical interface
# on the remote machine.
#
###
class Interface
##
#
# Constructor
#
##
2005-11-15 05:22:13 +00:00
#
# Returns a logical interface and initializes it to the supplied
# parameters.
#
2005-04-17 08:02:01 +00:00
def initialize(ip, netmask, mac_addr, mac_name)
2005-04-17 09:04:22 +00:00
self.ip = IPAddr.ntop(ip)
self.netmask = IPAddr.ntop(netmask)
2005-04-17 08:02:01 +00:00
self.mac_addr = mac_addr
self.mac_name = mac_name
end
2005-11-15 05:22:13 +00:00
#
# Returns a pretty string representation of the interface's properties.
#
2005-04-17 08:02:01 +00:00
def pretty
return sprintf(
"#{mac_name}\n" +
"Hardware MAC: %02x:%02x:%02x:%02x:%02x:%02x\n" +
"IP Address : %s\n" +
"Netmask : %s\n" +
"\n",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3],
mac_addr[4], mac_addr[5], ip, netmask)
end
2005-11-15 05:22:13 +00:00
#
# The IP address bound to the interface.
#
attr_accessor :ip
#
# The subnet mask associated with the interface.
#
attr_accessor :netmask
#
# The physical (MAC) address of the NIC.
#
attr_accessor :mac_addr
#
# The name of the interface.
#
attr_accessor :mac_name
2005-04-17 08:02:01 +00:00
end
2008-10-19 21:03:39 +00:00
end; end; end; end; end; end