Class: Msf::OptAddressLocal

Inherits:
OptAddressRoutable show all
Defined in:
lib/msf/core/opt_address_local.rb

Overview

Network address option that allows referencing an address based on the name of the interface it’s associated with.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required

Instance Method Summary collapse

Methods inherited from OptAddressRoutable

#interfaces, #normalize

Methods inherited from OptAddress

#type

Methods inherited from OptBase

#advanced?, #display_value, #empty_required_value?, #evasion?, #initialize, #invalid_value_length?, #normalize, #required?, #type?, #validate_on_assignment?

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#valid?(value, check_empty: true, datastore: nil) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/msf/core/opt_address_local.rb', line 13

def valid?(value, check_empty: true, datastore: nil)
  return false if check_empty && empty_required_value?(value)
  return false unless value.kind_of?(String) || value.kind_of?(NilClass)

  return true if interfaces.include?(value)

  # the 0.0.0.0 / :: addresses are valid local addresses for the purpose of binding
  return true if Rex::Socket.is_ip_addr?(value) && Rex::Socket.addr_atoi(value) == 0

  # todo: this should probably have additional validation to ensure that the address is able to be bound to, this
  # would mean that the address is either locally available, or available via a Rex::Socket channel, e.g. a Meterpreter
  # session

  super
end