@@ -1327,24 +1327,20 @@ def cmd_route_help
1327
1327
# which session a given subnet should route through.
1328
1328
#
1329
1329
def cmd_route ( *args )
1330
- if ( args . length == 0 )
1331
- cmd_route_help
1332
- return false
1333
- end
1330
+ args << 'print' if args . length == 0
1334
1331
1335
1332
action = args . shift
1336
1333
case action
1337
1334
1338
1335
when "add" , "remove" , "del"
1339
1336
subnet = args . shift
1340
- subnet , cidr_mask = subnet . split ( "/" )
1341
-
1342
- if cidr_mask
1343
- netmask = Rex ::Socket . addr_ctoa ( cidr_mask . to_i )
1344
- else
1345
- 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
1346
1341
end
1347
1342
1343
+ netmask = args . shift if netmask . nil?
1348
1344
gateway_name = args . shift
1349
1345
1350
1346
if ( subnet . nil? || netmask . nil? || gateway_name . nil? )
@@ -1357,15 +1353,15 @@ def cmd_route(*args)
1357
1353
case gateway_name
1358
1354
when /local/i
1359
1355
gateway = Rex ::Socket ::Comm ::Local
1360
- when /^[0-9]+$/
1356
+ when /^(-1| [0-9]+) $/
1361
1357
session = framework . sessions . get ( gateway_name )
1362
1358
if session . kind_of? ( Msf ::Session ::Comm )
1363
1359
gateway = session
1364
1360
elsif session . nil?
1365
1361
print_error ( "Not a session: #{ gateway_name } " )
1366
1362
return false
1367
1363
else
1368
- print_error ( "Cannout route through specified session (not a Comm)" )
1364
+ print_error ( "Cannot route through the specified session (not a Comm)" )
1369
1365
return false
1370
1366
end
1371
1367
else
@@ -1421,7 +1417,6 @@ def cmd_route(*args)
1421
1417
} )
1422
1418
1423
1419
Rex ::Socket ::SwitchBoard . each { |route |
1424
-
1425
1420
if ( route . comm . kind_of? ( Msf ::Session ) )
1426
1421
gw = "Session #{ route . comm . sid } "
1427
1422
else
@@ -1431,7 +1426,11 @@ def cmd_route(*args)
1431
1426
tbl << [ route . subnet , route . netmask , gw ]
1432
1427
}
1433
1428
1434
- print ( tbl . to_s )
1429
+ if tbl . rows . length == 0
1430
+ print_status ( 'There are currently no routes defined.' )
1431
+ else
1432
+ print ( tbl . to_s )
1433
+ end
1435
1434
else
1436
1435
cmd_route_help
1437
1436
end
0 commit comments