Skip to content

Commit 08836a3

Browse files
committed
Fix "route add" error and support using session -1
1 parent 0671e85 commit 08836a3

File tree

1 file changed

+7
-8
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,14 +1334,13 @@ def cmd_route(*args)
13341334

13351335
when "add", "remove", "del"
13361336
subnet = args.shift
1337-
subnet,cidr_mask = subnet.split("/")
1338-
1339-
if cidr_mask
1340-
netmask = Rex::Socket.addr_ctoa(cidr_mask.to_i)
1341-
else
1342-
netmask = args.shift
1337+
netmask = nil
1338+
if subnet
1339+
subnet, cidr_mask = subnet.split("/")
1340+
netmask = Rex::Socket.addr_ctoa(cidr_mask.to_i) if cidr_mask
13431341
end
13441342

1343+
netmask = args.shift if netmask.nil?
13451344
gateway_name = args.shift
13461345

13471346
if (subnet.nil? || netmask.nil? || gateway_name.nil?)
@@ -1354,15 +1353,15 @@ def cmd_route(*args)
13541353
case gateway_name
13551354
when /local/i
13561355
gateway = Rex::Socket::Comm::Local
1357-
when /^[0-9]+$/
1356+
when /^(-1|[0-9]+)$/
13581357
session = framework.sessions.get(gateway_name)
13591358
if session.kind_of?(Msf::Session::Comm)
13601359
gateway = session
13611360
elsif session.nil?
13621361
print_error("Not a session: #{gateway_name}")
13631362
return false
13641363
else
1365-
print_error("Cannout route through specified session (not a Comm)")
1364+
print_error("Cannot route through the specified session (not a Comm)")
13661365
return false
13671366
end
13681367
else

0 commit comments

Comments
 (0)