add -n (disable database) option for msfconsole, gives 33% startup time reduction
git-svn-id: file:///home/svn/framework3/trunk@9959 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
4a796f794a
commit
53e2a010cd
|
@ -18,6 +18,7 @@ class DBManager
|
|||
|
||||
# Returns true if we are ready to load/store data
|
||||
def active
|
||||
return false if not @usable
|
||||
(ActiveRecord::Base.connected? && ActiveRecord::Base.connection.active?)
|
||||
end
|
||||
|
||||
|
@ -36,11 +37,24 @@ class DBManager
|
|||
# Stores a TaskManager for serializing database events
|
||||
attr_accessor :sink
|
||||
|
||||
def initialize(framework)
|
||||
def initialize(framework, opts = {})
|
||||
|
||||
self.framework = framework
|
||||
@usable = false
|
||||
|
||||
# Don't load the database is the user said they didn't need it.
|
||||
if (opts['DisableDatabase'])
|
||||
self.error = "User Disabled Database Support"
|
||||
return
|
||||
end
|
||||
|
||||
initialize_database_support
|
||||
end
|
||||
|
||||
#
|
||||
# Do what is necessary to load our database support
|
||||
#
|
||||
def initialize_database_support
|
||||
#
|
||||
# Prefer our local copy of active_record and active_support
|
||||
#
|
||||
|
@ -70,7 +84,7 @@ class DBManager
|
|||
rescue ::Exception => e
|
||||
self.error = e
|
||||
elog("DB is not enabled due to load error: #{e}")
|
||||
return
|
||||
return false
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -82,6 +96,8 @@ class DBManager
|
|||
# Instantiate the database sink
|
||||
#
|
||||
initialize_sink
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -77,7 +77,7 @@ class Framework
|
|||
self.datastore = DataStore.new
|
||||
self.jobs = Rex::JobContainer.new
|
||||
self.plugins = PluginManager.new(self)
|
||||
self.db = DBManager.new(self)
|
||||
self.db = DBManager.new(self, opts)
|
||||
|
||||
subscriber = FrameworkEventSubscriber.new(self)
|
||||
events.add_exploit_subscriber(subscriber)
|
||||
|
|
|
@ -82,7 +82,7 @@ class Driver < Msf::Ui::Driver
|
|||
load_preconfig
|
||||
|
||||
# Initialize attributes
|
||||
self.framework = opts['Framework'] || Msf::Simple::Framework.create
|
||||
self.framework = opts['Framework'] || Msf::Simple::Framework.create(opts)
|
||||
|
||||
# Initialize the user interface to use a different input and output
|
||||
# handle if one is supplied
|
||||
|
@ -106,7 +106,7 @@ class Driver < Msf::Ui::Driver
|
|||
end
|
||||
|
||||
# Add the database dispatcher if it is usable
|
||||
if(framework.db.usable)
|
||||
if (framework.db.usable)
|
||||
require 'msf/ui/console/command_dispatcher/db'
|
||||
enstack_dispatcher(CommandDispatcher::Db)
|
||||
else
|
||||
|
|
|
@ -66,6 +66,11 @@ class OptsConsole
|
|||
options['RealReadline'] = true
|
||||
end
|
||||
|
||||
# Boolean switch.
|
||||
opts.on("-n", "--no-database", "Disable database support") do |v|
|
||||
options['DisableDatabase'] = true
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "Common options:"
|
||||
|
||||
|
|
Loading…
Reference in New Issue