diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index d5101a629d..17827406b3 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -673,6 +673,24 @@ class Exploit < Msf::Module return payloads; end + # + # Returns a list of compatible encoders based on architecture + # + def compatible_encoders + encoders = [] + + c_platform = (target and target.platform) ? target.platform : platform + c_arch = (target and target.arch) ? target.arch : (arch == []) ? nil : arch + + framework.encoders.each_module( + 'Arch' => c_arch) { |name, mod| + + encoders << [ name, mod ] + } + + return encoders; + end + # # This method returns the number of bytes that should be adjusted to the # stack pointer prior to executing any code. The number of bytes to adjust diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index 47951a9f6a..d196617975 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -1272,11 +1272,23 @@ protected # # Module list enumeration # - + def show_encoders # :nodoc: - show_module_set("Encoders", framework.encoders) - end + # If an active module has been selected and it's an exploit, get the + # list of compatible encoders and display them + if (active_module and active_module.exploit? == true) + tbl = generate_module_table("Compatible encoders") + + active_module.compatible_encoders.each { |refname, encoder| + tbl << [ refname, encoder.new.name ] + } + print(tbl.to_s) + else + show_module_set("Encoders", framework.encoders) + end + end + def show_nops # :nodoc: show_module_set("NOP Generators", framework.nops) end