@@ -45,7 +45,8 @@ class Core
45
45
"-K" => [ false , "Terminate all sessions" ] ,
46
46
"-s" => [ true , "Run a script on the session given with -i, or all" ] ,
47
47
"-r" => [ false , "Reset the ring buffer for the session given with -i, or all" ] ,
48
- "-u" => [ true , "Upgrade a shell to a meterpreter session on many platforms" ] )
48
+ "-u" => [ true , "Upgrade a shell to a meterpreter session on many platforms" ] ,
49
+ "-t" => [ true , "Set a response timeout (default: 15)" ] )
49
50
50
51
@@jobs_opts = Rex ::Parser ::Arguments . new (
51
52
"-h" => [ false , "Help banner." ] ,
@@ -1222,7 +1223,7 @@ def cmd_route(*args)
1222
1223
Rex ::Socket ::SwitchBoard . flush_routes
1223
1224
1224
1225
when "print"
1225
- tbl = Table . new (
1226
+ tbl = Table . new (
1226
1227
Table ::Style ::Default ,
1227
1228
'Header' => "Active Routing Table" ,
1228
1229
'Prefix' => "\n " ,
@@ -1597,6 +1598,7 @@ def cmd_sessions(*args)
1597
1598
cmds = [ ]
1598
1599
script = nil
1599
1600
reset_ring = false
1601
+ response_timeout = 15
1600
1602
1601
1603
# any arguments that don't correspond to an option or option arg will
1602
1604
# be put in here
@@ -1646,6 +1648,10 @@ def cmd_sessions(*args)
1646
1648
when "-h"
1647
1649
cmd_sessions_help
1648
1650
return false
1651
+ when "-t"
1652
+ if val . to_s =~ /^\d +$/
1653
+ response_timeout = val . to_i
1654
+ end
1649
1655
else
1650
1656
extra << val
1651
1657
end
@@ -1684,6 +1690,7 @@ def cmd_sessions(*args)
1684
1690
session = verify_session ( s )
1685
1691
next unless session
1686
1692
print_status ( "Running '#{ cmd } ' on #{ session . type } session #{ s } (#{ session . session_host } )" )
1693
+ session . response_timeout = response_timeout
1687
1694
1688
1695
if session . type == 'meterpreter'
1689
1696
# If session.sys is nil, dont even try..
@@ -1720,6 +1727,7 @@ def cmd_sessions(*args)
1720
1727
session_list . each do |sess_id |
1721
1728
session = framework . sessions . get ( sess_id )
1722
1729
if session
1730
+ session . response_timeout = response_timeout
1723
1731
print_status ( "Killing session #{ sess_id } " )
1724
1732
session . kill
1725
1733
else
@@ -1730,21 +1738,26 @@ def cmd_sessions(*args)
1730
1738
print_status ( "Killing all sessions..." )
1731
1739
framework . sessions . each_sorted do |s |
1732
1740
session = framework . sessions . get ( s )
1733
- session . kill if session
1741
+ if session
1742
+ session . response_timeout = response_timeout
1743
+ session . kill
1744
+ end
1734
1745
end
1735
1746
when 'detach'
1736
1747
print_status ( "Detaching the following session(s): #{ session_list . join ( ', ' ) } " )
1737
1748
session_list . each do |sess_id |
1738
1749
session = verify_session ( sess_id )
1739
1750
# if session is interactive, it's detachable
1740
1751
if session
1752
+ session . response_timeout = response_timeout
1741
1753
print_status ( "Detaching session #{ sess_id } " )
1742
1754
session . detach
1743
1755
end
1744
1756
end
1745
1757
when 'interact'
1746
1758
session = verify_session ( sid )
1747
1759
if session
1760
+ session . response_timeout = response_timeout
1748
1761
print_status ( "Starting interaction with #{ session . name } ...\n " ) unless quiet
1749
1762
self . active_session = session
1750
1763
session . interact ( driver . input . dup , driver . output )
@@ -1770,6 +1783,7 @@ def cmd_sessions(*args)
1770
1783
session = framework . sessions . get ( sess_id )
1771
1784
end
1772
1785
if session
1786
+ session . response_timeout = response_timeout
1773
1787
if script_paths [ session . type ]
1774
1788
print_status ( "Session #{ sess_id } (#{ session . session_host } ):" )
1775
1789
print_status ( "Running script #{ script } on #{ session . type } session" +
@@ -1790,6 +1804,7 @@ def cmd_sessions(*args)
1790
1804
session_list . each do |sess_id |
1791
1805
session = verify_session ( sess_id )
1792
1806
if session
1807
+ session . response_timeout = response_timeout
1793
1808
if session . type == 'shell'
1794
1809
session . init_ui ( driver . input , driver . output )
1795
1810
session . execute_script ( 'post/multi/manage/shell_to_meterpreter' )
0 commit comments