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" \
{-p,--plugin}"[Load a plugin on startup]:plugin file:_files" \
{-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]" \
{-x,--execute-command}"[Execute the specified string as console commands]:commands" \
{-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
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
end

View File

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