|
3 | 3 | require 'shellwords'
|
4 | 4 |
|
5 | 5 | module Msf
|
6 |
| -module Sessions |
7 |
| -module MeterpreterOptions |
| 6 | + module Sessions |
| 7 | + # |
| 8 | + # Defines common options across all Meterpreter implementations |
| 9 | + # |
| 10 | + module MeterpreterOptions |
8 | 11 |
|
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 |
11 | 16 |
|
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) |
28 | 19 |
|
| 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 |
29 | 76 | end
|
30 |
| -end |
31 |
| -end |
32 |
| - |
|
0 commit comments