1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-07-18 18:31:41 +02:00

Swap around rbreadline - load it by default, but also allow the old readline with the -L (--real-readline) parameter to msfconsole. This also fixes absolute path handling for msfconsole command passthrough

git-svn-id: file:///home/svn/framework3/trunk@7115 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2009-10-02 14:17:03 +00:00
parent 45372a6870
commit 35fcf8c2b2
6 changed files with 44 additions and 16 deletions

View File

@ -46,13 +46,25 @@ class Driver < Msf::Ui::Driver
# Whether or not unknown commands should be passed through and executed by
# the local system.
#
# RealReadline
#
# Whether or to use the system Readline or the RBReadline (default)
#
def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
if (Rex::Compat.is_windows())
# Disable the color support
prompt = "msf"
prompt_char = ">"
# Choose a readline library before calling the parent
rl = false
begin
if(opts['RealReadline'])
require 'readline'
rl = true
end
rescue ::LoadError
end
# Default to the RbReadline wrapper
require 'readline_compatible' if(not rl)
# Call the parent
super(prompt, prompt_char)
@ -65,7 +77,7 @@ class Driver < Msf::Ui::Driver
# Initialize attributes
self.framework = opts['Framework'] || Msf::Simple::Framework.create
# Initialize the user interface to use a different input and output
# handle if one is supplied
if (opts['LocalInput'] or opts['LocalOutput'])

View File

@ -59,7 +59,7 @@ module Readline
raise IOError, "stdin closed"
end
RbReadline.rl_instream = $stdin
RbReadline.rl_instream = $stdin
RbReadline.rl_outstream = $stdout
status = 0

View File

@ -16,6 +16,12 @@ module FileUtils
# a fully qualified path to the supplied file name.
#
def self.find_full_path(file_name)
# Check for the absolute fast first
if (file_name[0,1] == "/" and ::File::Stat.new(file_name))
return file_name
end
path = Rex::Compat.getenv('PATH')
if (path)
path.split(::File::PATH_SEPARATOR).each { |base|

View File

@ -5,7 +5,6 @@ module Ui
module Text
begin
require 'readline'
###
#
@ -14,12 +13,24 @@ begin
#
###
class Input::Readline < Rex::Ui::Text::Input
include ::Readline
#
# Initializes the readline-aware Input instance for text.
#
def initialize(tab_complete_proc = nil)
if(not Object.const_defined?('Readline'))
$stderr.puts "TRYING TO FIGURE OUT WHICH READLINE LIBRARY: #{caller}"
begin
require 'readline'
rescue ::LoadError
require 'readline_compat'
end
end
self.extend(::Readline)
if (tab_complete_proc)
::Readline.basic_word_break_characters = "\x00"
::Readline.completion_proc = tab_complete_proc

View File

@ -56,7 +56,12 @@ class OptsConsole
opts.on("-v", "--version", "Show version") do |v|
options['Version'] = true
end
# Boolean switch.
opts.on("-L", "--real-readline", "Use the system Readline library instead of RbReadline") do |v|
options['RealReadline'] = true
end
opts.separator ""
opts.separator "Common options:"

View File

@ -1,6 +0,0 @@
#!/usr/bin/env
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__))), '..', 'lib')
require 'rex'
require 'msf/core'