Path: blob/master/lib/msf/base/sessions/meterpreter_options/common.rb
21094 views
# -*- coding: binary -*-12require 'shellwords'34module Msf5module Sessions6#7# Defines common options across all Meterpreter implementations8#9module MeterpreterOptions::Common1011TIMEOUT_SESSION = 24 * 3600 * 7 # 1 week12TIMEOUT_COMMS = 300 # 5 minutes13TIMEOUT_RETRY_TOTAL = 60 * 60 # 1 hour14TIMEOUT_RETRY_WAIT = 10 # 10 seconds1516def initialize(info = {})17super(info)1819register_advanced_options(20[21OptBool.new(22'AutoLoadStdapi',23[true, "Automatically load the Stdapi extension", true]24),25OptInt.new(26'AutoVerifySessionTimeout',27[false, "Timeout period to wait for session validation to occur, in seconds", 30]28),29OptString.new(30'InitialAutoRunScript',31[false, "An initial script to run on session creation (before AutoRunScript)", '']32),33OptString.new(34'AutoRunScript',35[false, "A script to run automatically on session creation.", '']36),37OptBool.new(38'AutoSystemInfo',39[true, "Automatically capture system information on initialization.", true]40),41OptBool.new(42'EnableUnicodeEncoding',43[true, "Automatically encode UTF-8 strings as hexadecimal", Rex::Compat.is_windows]44),45OptPath.new(46'HandlerSSLCert',47[false, "Path to a SSL certificate in unified PEM format, ignored for HTTP transports"]48),49OptInt.new(50'SessionRetryTotal',51[false, "Number of seconds try reconnecting for on network failure", TIMEOUT_RETRY_TOTAL]52),53OptInt.new(54'SessionRetryWait',55[false, "Number of seconds to wait between reconnect attempts", TIMEOUT_RETRY_WAIT]56),57OptInt.new(58'SessionExpirationTimeout',59[ false, 'The number of seconds before this session should be forcibly shut down', TIMEOUT_SESSION]60),61OptInt.new(62'SessionCommunicationTimeout',63[ false, 'The number of seconds of no activity before this session should be killed', TIMEOUT_COMMS]64),65OptBool.new(66'MeterpreterDebugBuild',67[false, 'Use a debug version of Meterpreter']68),69OptMeterpreterDebugLogging.new(70'MeterpreterDebugLogging',71[false, 'The Meterpreter debug logging configuration, see https://docs.metasploit.com/docs/using-metasploit/advanced/meterpreter/meterpreter-debugging-meterpreter-sessions.html']72)73],74self.class75)76end7778def meterpreter_logging_config(opts = {})79ds = opts[:datastore] || datastore80{81debug_build: (ds[:debug_build] || datastore['MeterpreterDebugBuild']),82log_path: (ds[:log_path] || parse_rpath)83}84end8586def mettle_logging_config(opts = {})87ds = opts[:datastore] || datastore88debug_build = ds[:debug_build] || datastore['MeterpreterDebugBuild']89log_path = ds[:log_path] || parse_rpath90{91debug: debug_build ? 3 : 0,92log_file: log_path93}94end9596private9798def parse_rpath99Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]100end101end102end103end104105106