CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/net/route.rb
Views: 11797
1
# -*- coding: binary -*-
2
3
require 'ipaddr'
4
5
module Rex
6
module Post
7
module Meterpreter
8
module Extensions
9
module Stdapi
10
module Net
11
12
###
13
#
14
# Represents a logical network route.
15
#
16
###
17
class Route
18
19
##
20
#
21
# Constructor
22
#
23
##
24
25
#
26
# Initializes a route instance.
27
#
28
def initialize(subnet, netmask, gateway, interface='', metric=0)
29
self.subnet = IPAddr.new_ntoh(subnet).to_s
30
self.netmask = IPAddr.new_ntoh(netmask).to_s
31
self.gateway = IPAddr.new_ntoh(gateway).to_s
32
self.interface = interface
33
self.metric = metric
34
end
35
36
#
37
# Provides a pretty version of the route.
38
#
39
def pretty
40
return sprintf("%16s %16s %16s %d %16s", subnet, netmask, gateway, metric, interface)
41
end
42
43
#
44
# The subnet mask associated with the route.
45
#
46
attr_accessor :subnet
47
#
48
# The netmask of the subnet route.
49
#
50
attr_accessor :netmask
51
#
52
# The gateway to take for the subnet route.
53
#
54
attr_accessor :gateway
55
#
56
# The interface to take for the subnet route.
57
#
58
attr_accessor :interface
59
#
60
# The metric of the route.
61
#
62
attr_accessor :metric
63
64
65
end
66
67
end; end; end; end; end; end
68
69