adds -s <string> Execute the specified string as console commands to msfconsole

for convenience when you don't need/want a full resource file, you just
want to run something quick
example usage:
# say you have a saved config ready to go on load
./msfconsole -s 'exploit -j'
# you can run multiple commands too
./msfconsole -s 'set ConsoleLogging true\nshow options'
This commit is contained in:
kernelsmith 2012-09-20 12:23:48 -05:00 committed by Tod Beardsley
parent 4362854a43
commit d7727c880a
2 changed files with 12 additions and 0 deletions

View File

@ -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['SCommands'] and opts['SCommands'].kind_of? Array
opts['SCommands'].each { |c|
run_single(c)
}
end
end
#

View File

@ -101,6 +101,11 @@ class OptsConsole
options['DisableBanner'] = true
end
opts.on("-s", "-s <string>", "Execute the specified string as console commands") do |s|
options['SCommands'] ||= []
options['SCommands'] += s.split('\n')
end
opts.separator ""
opts.separator "Common options:"