Class: Rex::Post::Meterpreter::Extensions::Stdapi::Net::Config
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Extensions::Stdapi::Net::Config
- Defined in:
- lib/rex/post/meterpreter/extensions/stdapi/net/config.rb
Overview
This class provides an interface to the network configuration that exists on the remote machine, such as interfaces, and routes.
Instance Method Summary collapse
-
#add_route(subnet, netmask, gateway) ⇒ Object
Adds a route to the target machine.
-
#each_interface(&block) ⇒ Object
Enumerates each interface.
-
#each_route(&block) ⇒ Object
Enumerates each route.
-
#get_interfaces ⇒ Object
(also: #interfaces)
Returns an array of network interfaces with each element.
-
#get_routes ⇒ Object
(also: #routes)
Returns an array of routes with each element being a Route.
-
#initialize(client) ⇒ Config
constructor
Initializes a Config instance that is used to get information about the network configuration of the remote machine.
-
#remove_route(subnet, netmask, gateway) ⇒ Object
Removes a route from the target machine.
Constructor Details
#initialize(client) ⇒ Config
Initializes a Config instance that is used to get information about the network configuration of the remote machine.
33 34 35 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 33 def initialize(client) self.client = client end |
Instance Method Details
#add_route(subnet, netmask, gateway) ⇒ Object
Adds a route to the target machine.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 111 def add_route(subnet, netmask, gateway) request = Packet.create_request('stdapi_net_config_add_route') request.add_tlv(TLV_TYPE_SUBNET_STRING, subnet) request.add_tlv(TLV_TYPE_NETMASK_STRING, netmask) request.add_tlv(TLV_TYPE_GATEWAY_STRING, gateway) response = client.send_request(request) return true end |
#each_interface(&block) ⇒ Object
Enumerates each interface.
46 47 48 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 46 def each_interface(&block) get_interfaces().each(&block) end |
#each_route(&block) ⇒ Object
Enumerates each route.
82 83 84 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 82 def each_route(&block) get_routes().each(&block) end |
#get_interfaces ⇒ Object Also known as: interfaces
Returns an array of network interfaces with each element.
being an Interface
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 54 def get_interfaces request = Packet.create_request('stdapi_net_config_get_interfaces') ifaces = [] response = client.send_request(request) response.each(TLV_TYPE_NETWORK_INTERFACE) { |iface| ifaces << Interface.new( iface.get_tlv_value(TLV_TYPE_IP), iface.get_tlv_value(TLV_TYPE_NETMASK), iface.get_tlv_value(TLV_TYPE_MAC_ADDRESS), iface.get_tlv_value(TLV_TYPE_MAC_NAME)) } return ifaces end |
#get_routes ⇒ Object Also known as: routes
Returns an array of routes with each element being a Route.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 89 def get_routes request = Packet.create_request('stdapi_net_config_get_routes') routes = [] response = client.send_request(request) # Build out the array of routes response.each(TLV_TYPE_NETWORK_ROUTE) { |route| routes << Route.new( route.get_tlv_value(TLV_TYPE_SUBNET), route.get_tlv_value(TLV_TYPE_NETMASK), route.get_tlv_value(TLV_TYPE_GATEWAY)) } return routes end |
#remove_route(subnet, netmask, gateway) ⇒ Object
Removes a route from the target machine.
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/config.rb', line 126 def remove_route(subnet, netmask, gateway) request = Packet.create_request('stdapi_net_config_remove_route') request.add_tlv(TLV_TYPE_SUBNET_STRING, subnet) request.add_tlv(TLV_TYPE_NETMASK_STRING, netmask) request.add_tlv(TLV_TYPE_GATEWAY_STRING, gateway) response = client.send_request(request) return true end |