Skip to content

Commit 79b92cc

Browse files
committed
Fix for Route Print IPv6 Error
1 parent 9a5d5ee commit 79b92cc

File tree

1 file changed

+30
-6
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+30
-6
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,10 @@ def cmd_route(*args)
890890
Rex::Socket::SwitchBoard.flush_routes
891891

892892
when "print"
893-
tbl = Table.new(
893+
# IPv4 Table
894+
tbl_ipv4 = Table.new(
894895
Table::Style::Default,
895-
'Header' => "Active Routing Table",
896+
'Header' => "IPv4 Active Routing Table",
896897
'Prefix' => "\n",
897898
'Postfix' => "\n",
898899
'Columns' =>
@@ -907,21 +908,44 @@ def cmd_route(*args)
907908
'Netmask' => { 'MaxWidth' => 17 },
908909
})
909910

911+
# IPv6 Table
912+
tbl_ipv6 = Table.new(
913+
Table::Style::Default,
914+
'Header' => "IPv6 Active Routing Table",
915+
'Prefix' => "\n",
916+
'Postfix' => "\n",
917+
'Columns' =>
918+
[
919+
'Subnet',
920+
'Netmask',
921+
'Gateway',
922+
],
923+
'ColProps' =>
924+
{
925+
'Subnet' => { 'MaxWidth' => 17 },
926+
'Netmask' => { 'MaxWidth' => 17 },
927+
})
928+
929+
# Populate Route Tables
910930
Rex::Socket::SwitchBoard.each { |route|
911931
if (route.comm.kind_of?(Msf::Session))
912932
gw = "Session #{route.comm.sid}"
913933
else
914934
gw = route.comm.name.split(/::/)[-1]
915935
end
916936

917-
tbl << [ route.subnet, route.netmask, gw ]
937+
tbl_ipv4 << [ route.subnet, route.netmask, gw ] if Rex::Socket.is_ipv4?(route.netmask)
938+
tbl_ipv6 << [ route.subnet, route.netmask, gw ] if Rex::Socket.is_ipv6?(route.netmask)
918939
}
919940

920-
if tbl.rows.length == 0
941+
# Print Route Tables
942+
print(tbl_ipv4.to_s) if tbl_ipv4.rows.length > 0
943+
print(tbl_ipv6.to_s) if tbl_ipv6.rows.length > 0
944+
945+
if (tbl_ipv4.rows.length + tbl_ipv6.rows.length) < 1
921946
print_status('There are currently no routes defined.')
922-
else
923-
print(tbl.to_s)
924947
end
948+
925949
else
926950
cmd_route_help
927951
end

0 commit comments

Comments
 (0)