diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 399c0781c2..eac24a576d 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -249,6 +249,13 @@ class Driver < Msf::Ui::Driver # If the opt is nil here, we load ~/.msf3/msfconsole.rc load_resource(opts['Resource']) end + + # Process any additional startup commands + if opts['XCommands'] and opts['XCommands'].kind_of? Array + opts['XCommands'].each { |c| + run_single(c) + } + end end # diff --git a/msfconsole b/msfconsole index c21594147f..ea8add619e 100755 --- a/msfconsole +++ b/msfconsole @@ -101,6 +101,11 @@ class OptsConsole options['DisableBanner'] = true end + opts.on("-x", "-x ", "Execute the specified string as console commands (use ; for multiples)") do |s| + options['XCommands'] ||= [] + options['XCommands'] += s.split(/\s*;\s*/) + end + opts.separator "" opts.separator "Common options:"