diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index f58a2e909e..775fae8c63 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -243,16 +243,16 @@ class Core args.each do |res| good_res = nil - if (File.file? res and File.readable? res) + if ::File.exists?(res) good_res = res elsif # let's check to see if it's in the scripts/resource dir (like when tab completed) [ - ::Msf::Config.script_directory + File::SEPARATOR + "resource", - ::Msf::Config.user_script_directory + File::SEPARATOR + "resource" + ::Msf::Config.script_directory + ::File::SEPARATOR + "resource", + ::Msf::Config.user_script_directory + ::File::SEPARATOR + "resource" ].each do |dir| - res_path = dir + File::SEPARATOR + res - if (File.file?(res_path) and File.readable?(res_path)) + res_path = dir + ::File::SEPARATOR + res + if ::File.exists?(res_path) good_res = res_path break end diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 6760f09909..d4d7b30953 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -235,7 +235,8 @@ class Driver < Msf::Ui::Driver # Process any resource scripts if opts['Resource'].blank? # None given, load the default - load_resource(File.join(Msf::Config.config_directory, 'msfconsole.rc')) + default_resource = ::File.join(Msf::Config.config_directory, 'msfconsole.rc') + load_resource(default_resource) if ::File.exists?(default_resource) else opts['Resource'].each { |r| load_resource(r) @@ -420,7 +421,7 @@ class Driver < Msf::Ui::Driver if path == '-' resource_file = $stdin.read path = 'stdin' - elsif ::File.readable?(path) + elsif ::File.exists?(path) resource_file = ::File.read(path) else print_error("Cannot find resource script: #{path}")