Skip to content

Commit d8ee415

Browse files
author
Brent Cook
committed
move client core constants closer to where they are actually used
1 parent 5b579ba commit d8ee415

File tree

2 files changed

+67
-28
lines changed

2 files changed

+67
-28
lines changed

lib/msf/base/sessions/meterpreter_options.rb

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,74 @@
33
require 'shellwords'
44

55
module Msf
6-
module Sessions
7-
module MeterpreterOptions
6+
module Sessions
7+
#
8+
# Defines common options across all Meterpreter implementations
9+
#
10+
module MeterpreterOptions
811

9-
def initialize(info = {})
10-
super(info)
12+
TIMEOUT_SESSION = 24 * 3600 * 7 # 1 week
13+
TIMEOUT_COMMS = 300 # 5 minutes
14+
TIMEOUT_RETRY_TOTAL = 60 * 60 # 1 hour
15+
TIMEOUT_RETRY_WAIT = 10 # 10 seconds
1116

12-
register_advanced_options(
13-
[
14-
OptBool.new('AutoLoadStdapi', [true, "Automatically load the Stdapi extension", true]),
15-
OptBool.new('AutoVerifySession', [true, "Automatically verify and drop invalid sessions", true]),
16-
OptInt.new('AutoVerifySessionTimeout', [false, "Timeout period to wait for session validation to occur, in seconds", 30]),
17-
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session creation (before AutoRunScript)", '']),
18-
OptString.new('AutoRunScript', [false, "A script to run automatically on session creation.", '']),
19-
OptBool.new('AutoSystemInfo', [true, "Automatically capture system information on initialization.", true]),
20-
OptBool.new('EnableUnicodeEncoding', [true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]),
21-
OptPath.new('HandlerSSLCert', [false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"]),
22-
OptInt.new('SessionRetryTotal', [false, "Number of seconds try reconnecting for on network failure", Rex::Post::Meterpreter::ClientCore::TIMEOUT_RETRY_TOTAL]),
23-
OptInt.new('SessionRetryWait', [false, "Number of seconds to wait between reconnect attempts", Rex::Post::Meterpreter::ClientCore::TIMEOUT_RETRY_WAIT]),
24-
OptInt.new('SessionExpirationTimeout', [ false, 'The number of seconds before this session should be forcibly shut down', Rex::Post::Meterpreter::ClientCore::TIMEOUT_SESSION]),
25-
OptInt.new('SessionCommunicationTimeout', [ false, 'The number of seconds of no activity before this session should be killed', Rex::Post::Meterpreter::ClientCore::TIMEOUT_COMMS])
26-
], self.class)
27-
end
17+
def initialize(info = {})
18+
super(info)
2819

20+
register_advanced_options(
21+
[
22+
OptBool.new(
23+
'AutoLoadStdapi',
24+
[true, "Automatically load the Stdapi extension", true]
25+
),
26+
OptBool.new(
27+
'AutoVerifySession',
28+
[true, "Automatically verify and drop invalid sessions", true]
29+
),
30+
OptInt.new(
31+
'AutoVerifySessionTimeout',
32+
[false, "Timeout period to wait for session validation to occur, in seconds", 30]
33+
),
34+
OptString.new(
35+
'InitialAutoRunScript',
36+
[false, "An initial script to run on session creation (before AutoRunScript)", '']
37+
),
38+
OptString.new(
39+
'AutoRunScript',
40+
[false, "A script to run automatically on session creation.", '']
41+
),
42+
OptBool.new(
43+
'AutoSystemInfo',
44+
[true, "Automatically capture system information on initialization.", true]
45+
),
46+
OptBool.new(
47+
'EnableUnicodeEncoding',
48+
[true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]
49+
),
50+
OptPath.new(
51+
'HandlerSSLCert',
52+
[false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"]
53+
),
54+
OptInt.new(
55+
'SessionRetryTotal',
56+
[false, "Number of seconds try reconnecting for on network failure", TIMEOUT_RETRY_TOTAL]
57+
),
58+
OptInt.new(
59+
'SessionRetryWait',
60+
[false, "Number of seconds to wait between reconnect attempts", TIMEOUT_RETRY_WAIT]
61+
),
62+
OptInt.new(
63+
'SessionExpirationTimeout',
64+
[ false, 'The number of seconds before this session should be forcibly shut down', TIMEOUT_SESSION]
65+
),
66+
OptInt.new(
67+
'SessionCommunicationTimeout',
68+
[ false, 'The number of seconds of no activity before this session should be killed', TIMEOUT_COMMS]
69+
)
70+
],
71+
self.class
72+
)
73+
end
74+
end
75+
end
2976
end
30-
end
31-
end
32-

lib/rex/post/meterpreter/client_core.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ module Meterpreter
3434
###
3535
class ClientCore < Extension
3636

37-
TIMEOUT_SESSION = 24*3600*7 # 1 week
38-
TIMEOUT_COMMS = 300 # 5 minutes
39-
TIMEOUT_RETRY_TOTAL = 60*60 # 1 hour
40-
TIMEOUT_RETRY_WAIT = 10 # 10 seconds
41-
4237
VALID_TRANSPORTS = [
4338
'reverse_tcp',
4439
'reverse_http',

0 commit comments

Comments
 (0)