From 365289b19e71e43c5e1ab07041532d6155479fe1 Mon Sep 17 00:00:00 2001 From: William Vu Date: Wed, 16 May 2018 12:03:54 -0500 Subject: [PATCH] Add janky regex check if we're reloading a module --- lib/msf/ui/console/command_dispatcher/modules.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/msf/ui/console/command_dispatcher/modules.rb b/lib/msf/ui/console/command_dispatcher/modules.rb index 6c92112258..8b27773e75 100644 --- a/lib/msf/ui/console/command_dispatcher/modules.rb +++ b/lib/msf/ui/console/command_dispatcher/modules.rb @@ -73,6 +73,12 @@ module Msf return end + # The file must exist to reach this, so we try our best here + if path =~ %r{^(?:\./)?modules/} + print_error('Reloading Metasploit modules is not supported (try "reload")') + return + end + print_status("Reloading #{path}") load path end @@ -642,7 +648,7 @@ module Msf # Ensure we have a reference name and not a path if mod_name.start_with?('./', 'modules/') - mod_name.sub!(/^(?:\.\/)?modules\//, '') + mod_name.sub!(%r{^(?:\./)?modules/}, '') end if mod_name.end_with?('.rb') mod_name.sub!(/\.rb$/, '')