From 58708378d1b221f0ed08738664fc3ad19522aeaa Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Sat, 24 Feb 2007 05:29:05 +0000 Subject: [PATCH] ensure that module counts are reflected accurately, and add option to specify a module path to msfconsole, fixes #25 git-svn-id: file:///home/svn/framework3/trunk@4462 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/module_manager.rb | 12 +++++++++++- lib/msf/ui/console/driver.rb | 3 +++ msfconsole | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/module_manager.rb b/lib/msf/core/module_manager.rb index 012a7fefc7..9a92afce46 100644 --- a/lib/msf/core/module_manager.rb +++ b/lib/msf/core/module_manager.rb @@ -610,7 +610,17 @@ class ModuleManager < ModuleSet # We only do this if the caller wanted us to check the cache in the # first place. By default, check_cache will be true. One scenario # where it will be false is from the loadpath command in msfconsole. - save_module_cache if (!using_cache and check_cache) + if !using_cache and check_cache + save_module_cache + # If we're by default using the cache and we were told not to + # invalidate/use it, then we should update the cached counts to include + # what we've just added so that the banner will reflect the changes + # correctly. + elsif using_cache and !check_cache + cached_counts.each_key { |k| + cached_counts[k] += counts[k] if counts[k] + } + end return counts end diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index d80ea6da74..5064339f7e 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -87,6 +87,9 @@ class Driver < Msf::Ui::Driver # Re-enable output self.disable_output = false + # Load additional modules as necessary + self.framework.modules.add_module_path(opts['ModulePath'], false) if opts['ModulePath'] + # Process things before we actually display the prompt and get rocking on_startup diff --git a/msfconsole b/msfconsole index 1f2efaa31e..73aad0eb57 100755 --- a/msfconsole +++ b/msfconsole @@ -43,6 +43,10 @@ class OptsConsole options['Config'] = c end + opts.on("-m", "-m ", "Specifies an additional module search path") do |m| + options['ModulePath'] = m + end + # Boolean switch. opts.on("-v", "--version", "Show version") do |v| options['Version'] = true