Land #14282, More descript error logging for extrnal modules

This commit is contained in:
Grant Willcox
2020-10-29 16:16:56 -05:00
2 changed files with 16 additions and 4 deletions
+5 -1
View File
@@ -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)
+11 -3
View File
@@ -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.