Land #4674, @wvu-r7 teaches msfconsole to read stdin as -

bug/bundler_fix
Brent Cook 2015-01-30 18:10:11 -06:00
commit cf891efc14
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
3 changed files with 10 additions and 4 deletions

View File

@ -33,7 +33,7 @@ _arguments \
{-o,--output}"[Output to the specified file]:output file" \ {-o,--output}"[Output to the specified file]:output file" \
{-p,--plugin}"[Load a plugin on startup]:plugin file:_files" \ {-p,--plugin}"[Load a plugin on startup]:plugin file:_files" \
{-q,--quiet}"[Do not print the banner on start up]" \ {-q,--quiet}"[Do not print the banner on start up]" \
{-r,--resource}"[Execute the specified resource file]:resource file:_files" \ {-r,--resource}"[Execute the specified resource file (- for stdin)]:resource file:_files" \
{-v,--version}"[Show version]" \ {-v,--version}"[Show version]" \
{-x,--execute-command}"[Execute the specified string as console commands]:commands" \ {-x,--execute-command}"[Execute the specified string as console commands]:commands" \
{-y,--yaml}"[Specify a YAML file containing database settings]:yaml file:_files" {-y,--yaml}"[Specify a YAML file containing database settings]:yaml file:_files"

View File

@ -60,7 +60,7 @@ class Metasploit::Framework::ParsedOptions::Console < Metasploit::Framework::Par
options.console.quiet = true options.console.quiet = true
end end
option_parser.on('-r', '--resource FILE', 'Execute the specified resource file') do |file| option_parser.on('-r', '--resource FILE', 'Execute the specified resource file (- for stdin)') do |file|
options.console.resources << file options.console.resources << file
end end

View File

@ -417,8 +417,14 @@ class Driver < Msf::Ui::Driver
# @param path [String] Path to a resource file to run # @param path [String] Path to a resource file to run
# @return [void] # @return [void]
def load_resource(path) def load_resource(path)
return if not ::File.readable?(path) if path == '-'
resource_file = ::File.read(path) resource_file = $stdin.read
path = 'stdin'
elsif ::File.readable?(path)
resource_file = ::File.read(path)
else
return
end
self.active_resource = resource_file self.active_resource = resource_file