Module: Msf::Sessions::MeterpreterOptions

Included in:
Payload::Android::MeterpreterLoader, Payload::Java::MeterpreterLoader, Payload::Python::MeterpreterLoader
Defined in:
lib/msf/base/sessions/meterpreter_options.rb

Overview

Defines common options across all Meterpreter implementations

Constant Summary collapse

TIMEOUT_SESSION =

1 week

24 * 3600 * 7
TIMEOUT_COMMS =

5 minutes

300
TIMEOUT_RETRY_TOTAL =

1 hour

60 * 60
TIMEOUT_RETRY_WAIT =

10 seconds

10

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/msf/base/sessions/meterpreter_options.rb', line 17

def initialize(info = {})
  super(info)

  register_advanced_options(
    [
      OptBool.new(
        'AutoLoadStdapi',
        [true, "Automatically load the Stdapi extension", true]
      ),
      OptInt.new(
        'AutoVerifySessionTimeout',
        [false, "Timeout period to wait for session validation to occur, in seconds", 30]
      ),
      OptString.new(
        'InitialAutoRunScript',
        [false, "An initial script to run on session creation (before AutoRunScript)", '']
      ),
      OptString.new(
        'AutoRunScript',
        [false, "A script to run automatically on session creation.", '']
      ),
      OptBool.new(
        'AutoSystemInfo',
        [true, "Automatically capture system information on initialization.", true]
      ),
      OptBool.new(
        'EnableUnicodeEncoding',
        [true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]
      ),
      OptPath.new(
        'HandlerSSLCert',
        [false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"]
      ),
      OptInt.new(
        'SessionRetryTotal',
        [false, "Number of seconds try reconnecting for on network failure", TIMEOUT_RETRY_TOTAL]
      ),
      OptInt.new(
        'SessionRetryWait',
        [false, "Number of seconds to wait between reconnect attempts", TIMEOUT_RETRY_WAIT]
      ),
      OptInt.new(
        'SessionExpirationTimeout',
        [ false, 'The number of seconds before this session should be forcibly shut down', TIMEOUT_SESSION]
      ),
      OptInt.new(
        'SessionCommunicationTimeout',
        [ false, 'The number of seconds of no activity before this session should be killed', TIMEOUT_COMMS]
      ),
      OptString.new(
        'PayloadProcessCommandLine',
        [ false, 'The displayed command line that will be used by the payload', '']
      ),
      OptBool.new(
        'AutoUnhookProcess',
        [true, "Automatically load the unhook extension and unhook the process", false]
      ),
      OptBool.new(
        'MeterpreterDebugBuild',
        [false, 'Use a debug version of Meterpreter']
      ),
      OptMeterpreterDebugLogging.new(
        'MeterpreterDebugLogging',
        [false, 'The Meterpreter debug logging configuration, see https://docs.metasploit.com/docs/using-metasploit/advanced/meterpreter/meterpreter-debugging-meterpreter-sessions.html']
      )
    ],
    self.class
  )
end

#meterpreter_logging_config(opts = {}) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/msf/base/sessions/meterpreter_options.rb', line 87

def meterpreter_logging_config(opts = {})
  ds = opts[:datastore] || datastore
  {
    debug_build: (ds[:debug_build] || datastore['MeterpreterDebugBuild']),
    log_path:    (ds[:log_path] || parse_rpath)
  }
end

#mettle_logging_config(opts = {}) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/msf/base/sessions/meterpreter_options.rb', line 95

def mettle_logging_config(opts = {})
  ds = opts[:datastore] || datastore
  debug_build = ds[:debug_build] || datastore['MeterpreterDebugBuild']
  log_path = ds[:log_path] || parse_rpath
  {
    debug: debug_build ? 3 : 0,
    log_file: log_path
  }
end