@@ -103,37 +103,70 @@ def delete_all_routes
103
103
end
104
104
end
105
105
106
+ # Print all of the active routes defined on the framework
107
+ #
106
108
# Identical functionality to command_dispatcher/core.rb, and
107
109
# nearly identical code
110
+ #
111
+ # @return [void] A useful return value is not expected here
108
112
def print_routes
109
- if Rex ::Socket ::SwitchBoard . routes . size > 0
110
- tbl = Msf ::Ui ::Console ::Table . new (
111
- Msf ::Ui ::Console ::Table ::Style ::Default ,
112
- 'Header' => "Active Routing Table" ,
113
- 'Prefix' => "\n " ,
114
- 'Postfix' => "\n " ,
115
- 'Columns' => [
113
+ # IPv4 Table
114
+ tbl_ipv4 = Msf ::Ui ::Console ::Table . new (
115
+ Msf ::Ui ::Console ::Table ::Style ::Default ,
116
+ 'Header' => "IPv4 Active Routing Table" ,
117
+ 'Prefix' => "\n " ,
118
+ 'Postfix' => "\n " ,
119
+ 'Columns' =>
120
+ [
116
121
'Subnet' ,
117
122
'Netmask' ,
118
123
'Gateway' ,
119
124
] ,
120
- 'ColProps' => {
125
+ 'ColProps' =>
126
+ {
121
127
'Subnet' => { 'MaxWidth' => 17 } ,
122
128
'Netmask' => { 'MaxWidth' => 17 } ,
123
129
} )
124
- ret = [ ]
125
130
126
- Rex ::Socket ::SwitchBoard . each { |route |
127
- if ( route . comm . kind_of? ( Msf ::Session ) )
128
- gw = "Session #{ route . comm . sid } "
129
- else
130
- gw = route . comm . name . split ( /::/ ) [ -1 ]
131
- end
132
- tbl << [ route . subnet , route . netmask , gw ]
133
- }
134
- print_line tbl . to_s
135
- else
136
- print_status "No routes have been added yet"
131
+ # IPv6 Table
132
+ tbl_ipv6 = Msf ::Ui ::Console ::Table . new (
133
+ Msf ::Ui ::Console ::Table ::Style ::Default ,
134
+ 'Header' => "IPv6 Active Routing Table" ,
135
+ 'Prefix' => "\n " ,
136
+ 'Postfix' => "\n " ,
137
+ 'Columns' =>
138
+ [
139
+ 'Subnet' ,
140
+ 'Netmask' ,
141
+ 'Gateway' ,
142
+ ] ,
143
+ 'ColProps' =>
144
+ {
145
+ 'Subnet' => { 'MaxWidth' => 17 } ,
146
+ 'Netmask' => { 'MaxWidth' => 17 } ,
147
+ } )
148
+
149
+ # Populate Route Tables
150
+ Rex ::Socket ::SwitchBoard . each { |route |
151
+ if ( route . comm . kind_of? ( Msf ::Session ) )
152
+ gw = "Session #{ route . comm . sid } "
153
+ else
154
+ gw = route . comm . name . split ( /::/ ) [ -1 ]
155
+ end
156
+
157
+ tbl_ipv4 << [ route . subnet , route . netmask , gw ] if Rex ::Socket . is_ipv4? ( route . netmask )
158
+ tbl_ipv6 << [ route . subnet , route . netmask , gw ] if Rex ::Socket . is_ipv6? ( route . netmask )
159
+ }
160
+
161
+ # Print Route Tables
162
+ print ( tbl_ipv4 . to_s ) if tbl_ipv4 . rows . length > 0
163
+ print ( tbl_ipv6 . to_s ) if tbl_ipv6 . rows . length > 0
164
+ if ( tbl_ipv4 . rows . length + tbl_ipv6 . rows . length ) < 1
165
+ print_status ( "There are currently no routes defined." )
166
+ elsif ( tbl_ipv4 . rows . length < 1 ) && ( tbl_ipv6 . rows . length > 0 )
167
+ print_status ( "There are currently no IPv4 routes defined." )
168
+ elsif ( tbl_ipv4 . rows . length > 0 ) && ( tbl_ipv6 . rows . length < 1 )
169
+ print_status ( "There are currently no IPv6 routes defined." )
137
170
end
138
171
end
139
172
0 commit comments