Skip to content

Commit 233cd61

Browse files
committed
Check dependencies when loading
1 parent 32d242c commit 233cd61

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

plugins/fzuse.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ def commands
4343
# This method handles the fuzzy_use command.
4444
#
4545
def cmd_fzuse(*args)
46-
unless Msf::Util::Helper.which('fzf')
47-
print_error('This command requires that the `fzf` utility be installed.')
48-
return
49-
end
50-
5146
previewer = File.join(Msf::Config.install_root, 'tools', 'modules', 'print.py')
5247

5348
module_types = framework.modules.module_types
@@ -87,6 +82,17 @@ def cmd_fzuse(*args)
8782
#
8883
def initialize(framework, opts)
8984
super
85+
86+
missing_requirements = []
87+
missing_requirements << 'fzf' unless Msf::Util::Helper.which('fzf')
88+
missing_requirements << 'python' unless Msf::Util::Helper.which('python')
89+
missing_requirements << 'python-rich' unless system("python -c 'import rich'", out: File::NULL, err: File::NULL)
90+
91+
unless missing_requirements.empty?
92+
print_error("The FuzzyUse plugin has loaded but the following requirements are missing: #{missing_requirements.join(', ')}")
93+
print_error("Please install the missing requirements, then reload the plugin by running: `unload fzuse` and `load fzuse`.")
94+
return
95+
end
9096

9197
# If this plugin is being loaded in the context of a console application
9298
# that uses the framework's console user interface driver, register

0 commit comments

Comments
 (0)