From c25b08452b834a0f823b56ea2a1b5cb2de8b8787 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Wed, 29 Dec 2010 02:15:18 +0000 Subject: [PATCH] remove LocalInput as a string (no Rex::Ui::Text::Input::File class exists), see #3426 git-svn-id: file:///home/svn/framework3/trunk@11440 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/ui/console/driver.rb | 24 ++++++++---------------- lib/rex/ui/text/output/file.rb | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index edf5f62851..bc689cfdaa 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -86,27 +86,19 @@ class Driver < Msf::Ui::Driver # Initialize the user interface to use a different input and output # handle if one is supplied + input = opts['LocalInput'] + input ||= Rex::Ui::Text::Input::Stdio.new - if (opts['LocalInput']) - if (opts['LocalInput'].kind_of?(String)) - input = Rex::Ui::Text::Input::File.new(opts['LocalInput']) - else - input = opts['LocalInput'] - end - else - input = Rex::Ui::Text::Input::Stdio.new - end - if (opts['LocalOutput']) if (opts['LocalOutput'].kind_of?(String)) output = Rex::Ui::Text::Output::File.new(opts['LocalOutput']) - else + else output = opts['LocalOutput'] end else output = Rex::Ui::Text::Output::Stdio.new end - + init_ui(input, output) init_tab_complete @@ -164,7 +156,7 @@ class Driver < Msf::Ui::Driver if @defanged self.command_passthru = false end - + # Parse any specified database.yml file if framework.db.usable # Look for our database configuration in the following places, in order: @@ -178,7 +170,7 @@ class Driver < Msf::Ui::Driver dbinfo = YAML.load(File.read(dbfile)) dbenv = opts['DatabaseEnv'] || "production" db = dbinfo[dbenv] - + if not db print_error("No database definition for environment #{dbenv}") else @@ -186,9 +178,9 @@ class Driver < Msf::Ui::Driver print_error("Failed to connect to the database: #{framework.db.error} #{db.inspect} #{framework.db.error.backtrace}") end end - end + end end - + # Process things before we actually display the prompt and get rocking on_startup diff --git a/lib/rex/ui/text/output/file.rb b/lib/rex/ui/text/output/file.rb index c90c8fbb9d..f0a78a7172 100644 --- a/lib/rex/ui/text/output/file.rb +++ b/lib/rex/ui/text/output/file.rb @@ -14,7 +14,7 @@ class Output::File < Rex::Ui::Text::Output attr_accessor :fd def initialize(path) - self.fd = ::File.open(path, "w") + self.fd = ::File.open(path, "wb") end def supports_color?