CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/base/sessions/meterpreter_options.rb
Views: 11784
1
# -*- coding: binary -*-
2
3
require 'shellwords'
4
5
module Msf
6
module Sessions
7
#
8
# Defines common options across all Meterpreter implementations
9
#
10
module MeterpreterOptions
11
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
16
17
def initialize(info = {})
18
super(info)
19
20
register_advanced_options(
21
[
22
OptBool.new(
23
'AutoLoadStdapi',
24
[true, "Automatically load the Stdapi extension", true]
25
),
26
OptInt.new(
27
'AutoVerifySessionTimeout',
28
[false, "Timeout period to wait for session validation to occur, in seconds", 30]
29
),
30
OptString.new(
31
'InitialAutoRunScript',
32
[false, "An initial script to run on session creation (before AutoRunScript)", '']
33
),
34
OptString.new(
35
'AutoRunScript',
36
[false, "A script to run automatically on session creation.", '']
37
),
38
OptBool.new(
39
'AutoSystemInfo',
40
[true, "Automatically capture system information on initialization.", true]
41
),
42
OptBool.new(
43
'EnableUnicodeEncoding',
44
[true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]
45
),
46
OptPath.new(
47
'HandlerSSLCert',
48
[false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"]
49
),
50
OptInt.new(
51
'SessionRetryTotal',
52
[false, "Number of seconds try reconnecting for on network failure", TIMEOUT_RETRY_TOTAL]
53
),
54
OptInt.new(
55
'SessionRetryWait',
56
[false, "Number of seconds to wait between reconnect attempts", TIMEOUT_RETRY_WAIT]
57
),
58
OptInt.new(
59
'SessionExpirationTimeout',
60
[ false, 'The number of seconds before this session should be forcibly shut down', TIMEOUT_SESSION]
61
),
62
OptInt.new(
63
'SessionCommunicationTimeout',
64
[ false, 'The number of seconds of no activity before this session should be killed', TIMEOUT_COMMS]
65
),
66
OptString.new(
67
'PayloadProcessCommandLine',
68
[ false, 'The displayed command line that will be used by the payload', '']
69
),
70
OptBool.new(
71
'AutoUnhookProcess',
72
[true, "Automatically load the unhook extension and unhook the process", false]
73
),
74
OptBool.new(
75
'MeterpreterDebugBuild',
76
[false, 'Use a debug version of Meterpreter']
77
),
78
OptMeterpreterDebugLogging.new(
79
'MeterpreterDebugLogging',
80
[false, 'The Meterpreter debug logging configuration, see https://docs.metasploit.com/docs/using-metasploit/advanced/meterpreter/meterpreter-debugging-meterpreter-sessions.html']
81
)
82
],
83
self.class
84
)
85
end
86
87
def meterpreter_logging_config(opts = {})
88
ds = opts[:datastore] || datastore
89
{
90
debug_build: (ds[:debug_build] || datastore['MeterpreterDebugBuild']),
91
log_path: (ds[:log_path] || parse_rpath)
92
}
93
end
94
95
def mettle_logging_config(opts = {})
96
ds = opts[:datastore] || datastore
97
debug_build = ds[:debug_build] || datastore['MeterpreterDebugBuild']
98
log_path = ds[:log_path] || parse_rpath
99
{
100
debug: debug_build ? 3 : 0,
101
log_file: log_path
102
}
103
end
104
105
private
106
107
def parse_rpath
108
Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
109
end
110
end
111
end
112
end
113
114