Files
metasploit-gs/scripts/resource/meterpreter_compatibility.rc
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
Plaintext
Raw Normal View History

# Outputs to STDOUT the currently supported Meterpreter commands as JSON for the currently opened Meterpreter sessions
2022-02-13 15:53:44 +00:00
# Usage:
# msf> resource scripts/resource/meterpreter_compatibility.rc
<ruby>
require 'json'
# Attempt to load all known extensions
framework.sessions.values.map do |session|
next unless session.type == 'meterpreter'
Rex::Post::Meterpreter::ExtensionMapper.get_extension_names.sort.each do |extension_name|
puts "[#{Time.now}][#{extension_name}] Starting to loading extension"
2022-02-13 15:53:44 +00:00
session.core.use(extension_name)
puts "[#{Time.now}][#{extension_name}] Loaded extension"
2023-09-27 11:20:17 +01:00
rescue ::RuntimeError, ::MetasploitPayloads::Error
puts "[#{Time.now}][#{extension_name}] Failed loading"
2022-02-13 15:53:44 +00:00
# noop
end
end
# Create an array of supported session information
session_data = framework.sessions.values.map do |session|
next unless session.type == 'meterpreter'
supported_commands = session.commands.map do |command_id|
command_name = Rex::Post::Meterpreter::CommandMapper.get_command_name(command_id)
{
id: command_id,
name: command_name
}
end
{
session_type: session.session_type,
commands: supported_commands
}
end.compact
result = {
sessions: session_data
}
puts "[#{Time.now}] Generating result:"
2022-02-13 15:53:44 +00:00
puts JSON.fast_generate(result)
</ruby>