From 233cd61c8645ffcb98da8cbbd88552ff64c33b7b Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Mon, 5 Aug 2024 12:07:57 -0400 Subject: [PATCH] Check dependencies when loading --- plugins/fzuse.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/fzuse.rb b/plugins/fzuse.rb index 1eb44d5f08..e565049959 100644 --- a/plugins/fzuse.rb +++ b/plugins/fzuse.rb @@ -43,11 +43,6 @@ module Msf # This method handles the fuzzy_use command. # def cmd_fzuse(*args) - unless Msf::Util::Helper.which('fzf') - print_error('This command requires that the `fzf` utility be installed.') - return - end - previewer = File.join(Msf::Config.install_root, 'tools', 'modules', 'print.py') module_types = framework.modules.module_types @@ -87,6 +82,17 @@ module Msf # def initialize(framework, opts) super + + missing_requirements = [] + missing_requirements << 'fzf' unless Msf::Util::Helper.which('fzf') + missing_requirements << 'python' unless Msf::Util::Helper.which('python') + missing_requirements << 'python-rich' unless system("python -c 'import rich'", out: File::NULL, err: File::NULL) + + unless missing_requirements.empty? + print_error("The FuzzyUse plugin has loaded but the following requirements are missing: #{missing_requirements.join(', ')}") + print_error("Please install the missing requirements, then reload the plugin by running: `unload fzuse` and `load fzuse`.") + return + end # If this plugin is being loaded in the context of a console application # that uses the framework's console user interface driver, register