Add log path session config option

This commit is contained in:
dwelch-r7
2022-04-11 16:11:12 +01:00
parent c994f8e933
commit ec9f0b5242
15 changed files with 33 additions and 18 deletions
@@ -82,9 +82,9 @@ module Payload::Windows::MeterpreterLoader
transports: opts[:transport_config] || [transport_config(opts)],
extensions: [],
stageless: opts[:stageless] == true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(ds['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
config = Rex::Payloads::Meterpreter::Config.new(config_opts)
@@ -85,7 +85,8 @@ module Payload::Windows::MeterpreterLoader_x64
transports: opts[:transport_config] || [transport_config(opts)],
extensions: [],
stageless: opts[:stageless] == true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(ds['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
+5 -3
View File
@@ -12,6 +12,7 @@ class Rex::Payloads::Meterpreter::Config
PROXY_USER_SIZE = 64
PROXY_PASS_SIZE = 64
CERT_HASH_SIZE = 20
LOG_PATH_SIZE = 260 # https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
def initialize(opts={})
@opts = opts
@@ -33,6 +34,7 @@ private
end
def to_str(item, size)
if item.size >= size # ">=" instead of only ">", because we need space for a terminating null byte (for string handling in C)
raise Msf::PayloadItemSizeError.new(item, size - 1)
end
@@ -58,16 +60,16 @@ private
else
session_guid = [SecureRandom.uuid.gsub(/-/, '')].pack('H*')
end
session_data = [
0, # comms socket, patched in by the stager
exit_func, # exit function identifer
opts[:expiration], # Session expiry
uuid, # the UUID
session_guid # the Session GUID
session_guid, # the Session GUID
to_str(opts[:log_path] || '', LOG_PATH_SIZE) # Path to log file on remote target
]
session_data.pack('QVVA*A*')
session_data.pack('QVVA*A*A*')
end
def transport_block(opts)
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -56,7 +56,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -56,7 +56,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -52,7 +52,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -56,7 +56,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -56,7 +56,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -52,7 +52,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters
@@ -51,7 +51,8 @@ module MetasploitModule
extensions: (datastore['EXTENSIONS'] || '').split(','),
ext_init: (datastore['EXTINIT'] || ''),
stageless: true,
debug_build: datastore['MeterpreterDebugBuild']
debug_build: datastore['MeterpreterDebugBuild'],
log_path: Msf::OptMeterpreterDebugLogging.parse_logging_options(datastore['MeterpreterDebugLogging'])[:rpath]
}
# create the configuration instance based off the parameters