Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/base/sessions/meterpreter_options/common.rb
21094 views
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::Common
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
OptBool.new(
67
'MeterpreterDebugBuild',
68
[false, 'Use a debug version of Meterpreter']
69
),
70
OptMeterpreterDebugLogging.new(
71
'MeterpreterDebugLogging',
72
[false, 'The Meterpreter debug logging configuration, see https://docs.metasploit.com/docs/using-metasploit/advanced/meterpreter/meterpreter-debugging-meterpreter-sessions.html']
73
)
74
],
75
self.class
76
)
77
end
78
79
def meterpreter_logging_config(opts = {})
80
ds = opts[:datastore] || datastore
81
{
82
debug_build: (ds[:debug_build] || datastore['MeterpreterDebugBuild']),
83
log_path: (ds[:log_path] || parse_rpath)
84
}
85
end
86
87
def mettle_logging_config(opts = {})
88
ds = opts[:datastore] || datastore
89
debug_build = ds[:debug_build] || datastore['MeterpreterDebugBuild']
90
log_path = ds[:log_path] || parse_rpath
91
{
92
debug: debug_build ? 3 : 0,
93
log_file: log_path
94
}
95
end
96
97
private
98
99
def parse_rpath
100
Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
101
end
102
end
103
end
104
end
105
106