add -q option to suppress banner, improve -n warning

git-svn-id: file:///home/svn/framework3/trunk@11642 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Joshua Drake 2011-01-25 22:58:21 +00:00
parent a0a8ea8cbd
commit a2e6f0e96c
3 changed files with 17 additions and 16 deletions

View File

@ -42,9 +42,9 @@ class DBManager
self.framework = framework
@usable = false
# Don't load the database is the user said they didn't need it.
# Don't load the database if the user said they didn't need it.
if (opts['DisableDatabase'])
self.error = "User Disabled Database Support"
self.error = "disabled"
return
end

View File

@ -120,7 +120,11 @@ class Driver < Msf::Ui::Driver
enstack_dispatcher(CommandDispatcher::Db)
else
print_error("***")
print_error("* WARNING: No database support: #{framework.db.error.class} #{framework.db.error}")
if framework.db.error == "disabled"
print_error("* WARNING: Database support has been disabled")
else
print_error("* WARNING: No database support: #{framework.db.error.class} #{framework.db.error}")
end
print_error("***")
end
@ -183,7 +187,7 @@ class Driver < Msf::Ui::Driver
# Process things before we actually display the prompt and get rocking
on_startup
on_startup(opts)
# Process the resource script
if opts['Resource'] and opts['Resource'].kind_of? Array
@ -338,7 +342,7 @@ class Driver < Msf::Ui::Driver
# Called before things actually get rolling such that banners can be
# displayed, scripts can be processed, and other fun can be had.
#
def on_startup
def on_startup(opts = {})
# Check for modules that failed to load
if (framework.modules.failed.length > 0)
print_error("WARNING! The following modules could not be loaded!")
@ -348,8 +352,8 @@ class Driver < Msf::Ui::Driver
end
framework.events.on_ui_start(Msf::Framework::Revision)
# Build the banner message
run_single("banner")
run_single("banner") unless opts['DisableBanner']
self.on_command_proc = Proc.new { |command| framework.events.on_ui_command(command) }
end

View File

@ -65,22 +65,24 @@ class OptsConsole
opts.on("-e", "--environment <production|development>", "Specify the database environment to load from the YAML") do |m|
options['DatabaseEnv'] = m
end
# Boolean switch.
# Boolean switches
opts.on("-v", "--version", "Show version") do |v|
options['Version'] = true
end
# Boolean switch.
opts.on("-L", "--real-readline", "Use the system Readline library instead of RbReadline") do |v|
options['RealReadline'] = true
end
# Boolean switch.
opts.on("-n", "--no-database", "Disable database support") do |v|
options['DisableDatabase'] = true
end
opts.on("-q", "--quiet", "Do not print the banner on start up") do |v|
options['DisableBanner'] = true
end
opts.separator ""
opts.separator "Common options:"
@ -114,11 +116,6 @@ require 'msf/ui'
# Everything below this line requires the framework.
#
#
# XXX: It would be nice to not have to load the entire framework just to get
# the version number.
#
if (options['Version'])
$stderr.puts 'Framework Version: ' + Msf::Framework::Version
exit