From f956bb9943a2a1164470cc270089001786e7f95e Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 2 Apr 2018 22:57:15 -0500 Subject: [PATCH] Land #9787, Fix adding IPv6 routes with subnets or CIDR masks --- lib/msf/ui/console/command_dispatcher/core.rb | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index 85cd12da4a..44e12adecf 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -867,15 +867,14 @@ class Core action = args.shift case action - when "add", "remove", "del" subnet = args.shift - subnet,cidr_mask = subnet.split("/") - if Rex::Socket.is_ipv4?(args.first) + subnet, cidr_mask = subnet.split("/") + + if Rex::Socket.is_ip_addr?(args.first) netmask = args.shift - else - cidr_mask = '32' if cidr_mask.nil? - netmask = Rex::Socket.addr_ctoa(cidr_mask.to_i) + elsif Rex::Socket.is_ip_addr?(subnet) + netmask = Rex::Socket.addr_ctoa(cidr_mask, v6: Rex::Socket.is_ipv6?(subnet)) end netmask = args.shift if netmask.nil? @@ -886,8 +885,6 @@ class Core return false end - gateway = nil - case gateway_name when /local/i gateway = Rex::Socket::Comm::Local @@ -2439,8 +2436,6 @@ class Core all_lines.slice(start..finish) end - - end end end end end