Skip to content

Commit

Permalink
Land rapid7#18925: Update RPC API to include Auxiliary and Exploit mo…
Browse files Browse the repository at this point in the history
…dules in `session.compatible_modules` response
  • Loading branch information
ekalinichev-r7 authored Mar 27, 2024
2 parents 8654404 + 88585ba commit c499510
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/msf/core/rpc/v10/rpc_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,24 +457,25 @@ def rpc_meterpreter_directory_separator(sid)
end


# Returns all the compatible post modules for this session.
# Returns all the compatible modules for this session.
#
# @param [Integer] sid Session ID.
# @return [Hash] Post modules. It contains the following key:
# * 'modules' [Array<string>] An array of post module names. Example: ['post/windows/wlan/wlan_profile']
# @return [Hash] Modules. It contains the following key:
# * 'modules' [Array<string>] An array of module names. Example: ['post/windows/wlan/wlan_profile', 'auxiliary/scanner/postgres_version', 'exploit/windows/local/alpc_taskscheduler']
# @example Here's how you would use this from the client:
# rpc.call('session.compatible_modules', 3)
def rpc_compatible_modules( sid)
ret = []

mtype = "post"
names = self.framework.post.module_refnames.map{ |x| "post/#{x}" }
names.each do |mname|
m = _find_module(mtype, mname)
next if not m.session_compatible?(sid)
ret << m.fullname
def rpc_compatible_modules(sid)
session_type = self.framework.sessions[sid].type
search_params = { 'session_type' => [[session_type], []] }
cached_modules = Msf::Modules::Metadata::Cache.instance.find(search_params)

compatible_modules = []
cached_modules.each do |cached_module|
m = _find_module(cached_module.type, cached_module.fullname)
compatible_modules << m.fullname if m.session_compatible?(sid)
end
{ "modules" => ret }

{ "modules" => compatible_modules }
end

private
Expand Down

0 comments on commit c499510

Please sign in to comment.