Skip to content

Commit

Permalink
Add log path session config option
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Apr 25, 2022
1 parent 969419f commit 7bfb1fb
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/msf/core/payload/windows/meterpreter_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def generate_config(opts={})
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)

Expand Down
3 changes: 2 additions & 1 deletion lib/msf/core/payload/windows/x64/meterpreter_loader_x64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def generate_config(opts={})
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
Expand Down
8 changes: 5 additions & 3 deletions lib/rex/payloads/meterpreter/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +34,7 @@ def is_x86?
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
Expand All @@ -58,16 +60,16 @@ def session_block(opts)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down
3 changes: 2 additions & 1 deletion modules/payloads/singles/windows/meterpreter_bind_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down
3 changes: 2 additions & 1 deletion modules/payloads/singles/windows/meterpreter_reverse_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def generate_config(opts={})
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
Expand Down
3 changes: 2 additions & 1 deletion modules/payloads/singles/windows/meterpreter_reverse_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down
3 changes: 2 additions & 1 deletion modules/payloads/singles/windows/x64/meterpreter_bind_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def generate_config(opts={})
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def generate_config(opts={})
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
Expand Down

0 comments on commit 7bfb1fb

Please sign in to comment.