Land #14282, More descript error logging for extrnal modules
This commit is contained in:
+5
-1
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user