@@ -890,9 +890,10 @@ def cmd_route(*args)
890
890
Rex ::Socket ::SwitchBoard . flush_routes
891
891
892
892
when "print"
893
- tbl = Table . new (
893
+ # IPv4 Table
894
+ tbl_ipv4 = Table . new (
894
895
Table ::Style ::Default ,
895
- 'Header' => "Active Routing Table" ,
896
+ 'Header' => "IPv4 Active Routing Table" ,
896
897
'Prefix' => "\n " ,
897
898
'Postfix' => "\n " ,
898
899
'Columns' =>
@@ -907,21 +908,48 @@ def cmd_route(*args)
907
908
'Netmask' => { 'MaxWidth' => 17 } ,
908
909
} )
909
910
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
910
930
Rex ::Socket ::SwitchBoard . each { |route |
911
931
if ( route . comm . kind_of? ( Msf ::Session ) )
912
932
gw = "Session #{ route . comm . sid } "
913
933
else
914
934
gw = route . comm . name . split ( /::/ ) [ -1 ]
915
935
end
916
936
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 )
918
939
}
919
940
920
- if tbl . rows . length == 0
921
- print_status ( 'There are currently no routes defined.' )
922
- else
923
- print ( tbl . to_s )
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
946
+ print_status ( "There are currently no routes defined." )
947
+ elsif ( tbl_ipv4 . rows . length < 1 ) && ( tbl_ipv6 . rows . length > 0 )
948
+ print_status ( "There are currently no IPv4 routes defined." )
949
+ elsif ( tbl_ipv4 . rows . length > 0 ) && ( tbl_ipv6 . rows . length < 1 )
950
+ print_status ( "There are currently no IPv6 routes defined." )
924
951
end
952
+
925
953
else
926
954
cmd_route_help
927
955
end
0 commit comments