diff --git a/lib/msf/core/modules/external/shim.rb b/lib/msf/core/modules/external/shim.rb index e9dd1a0f63..be79240b65 100644 --- a/lib/msf/core/modules/external/shim.rb +++ b/lib/msf/core/modules/external/shim.rb @@ -4,7 +4,11 @@ require 'msf/core/modules/external' class Msf::Modules::External::Shim def self.generate(module_path, framework) mod = Msf::Modules::External.new(module_path, framework: framework) - return nil unless mod.meta + # first check if meta exists and raise an issue if not, #14281 + # raise instead of returning nil to avoid confusion + unless mod.meta + raise LoadError, " Try running file manually to check for errors or dependency issues." + end case mod.meta['type'] when 'remote_exploit' remote_exploit(mod) diff --git a/lib/msf/core/modules/loader/base.rb b/lib/msf/core/modules/loader/base.rb index be290f6e91..d542716fd0 100644 --- a/lib/msf/core/modules/loader/base.rb +++ b/lib/msf/core/modules/loader/base.rb @@ -466,9 +466,17 @@ class Msf::Modules::Loader::Base # Tries to determine if a file might be executable, def script_path?(path) - File.executable?(path) && - !File.directory?(path) && - ['#!', '//'].include?(File.read(path, 2)) + # warn users if their external modules aren't marked executable + # per #14281 + if File.directory?(path) || !['#!', '//'].include?(File.read(path, 2)) + false + elsif File.executable?(path) + true + else + # prefer elog since load_error clutters the UI on potential false positives + elog("Unable to load module #{path} - LoadError Possible non-executable external module.") + false + end end # Changes a file name path to a canonical module reference name.