Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/net/arp.rb
19513 views
# -*- coding: binary -*-12require 'ipaddr'34module Rex5module Post6module Meterpreter7module Extensions8module Stdapi9module Net1011###12#13# This class represents an arp entry14# on the remote machine.15#16###17class Arp1819##20#21# Constructor22#23##2425#26# Returns an arp entry and initializes it to the supplied27# parameters.28#29def initialize(opts={})30self.ip_addr = IPAddr.new_ntoh(opts[:ip_addr]).to_s31self.mac_addr = mac_to_string(opts[:mac_addr])32self.interface = opts[:interface]33end3435def mac_to_string(mac_addr)36macocts = []37mac_addr.each_byte { |o| macocts << o }38macocts += [0] * (6 - macocts.size) if macocts.size < 639return sprintf("%02x:%02x:%02x:%02x:%02x:%02x",40macocts[0], macocts[1], macocts[2],41macocts[3], macocts[4], macocts[5])42end4344#45# The ip address corresponding to the arp address.46#47attr_accessor :ip_addr48#49# The physical (MAC) address of the ARP entry50#51attr_accessor :mac_addr52#53# The name of the interface.54#55attr_accessor :interface56end5758end; end; end; end; end; end596061