From 8235380a905f3a6479b45d49b6b005c9a907e1ba Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Wed, 24 Apr 2019 05:17:15 -0500 Subject: [PATCH] Land #11768, implement faster compatible payload logic --- lib/msf/core/exploit.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index b1be00f70d..4526f22f0b 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -762,12 +762,19 @@ class Exploit < Msf::Module c_platform, c_arch = normalize_platform_arch - framework.payloads.each_module( - 'Arch' => c_arch, 'Platform' => c_platform) { |name, mod| - payloads << [ name, mod ] if is_payload_compatible?(name) - } + results = Msf::Modules::Metadata::Cache.instance.find( + 'type' => [['payload'], []], + 'platform' => [[*c_platform.names, 'All'], []], # "All" for generic + 'arch' => [c_arch, []] + ) - return payloads; + results.each do |res| + if is_payload_compatible?(res.ref_name) + payloads << [res.ref_name, framework.payloads[res.ref_name]] + end + end + + payloads end #