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-b9f4589650daunstable
parent
45372a6870
commit
35fcf8c2b2
|
@ -46,13 +46,25 @@ class Driver < Msf::Ui::Driver
|
||||||
# Whether or not unknown commands should be passed through and executed by
|
# Whether or not unknown commands should be passed through and executed by
|
||||||
# the local system.
|
# the local system.
|
||||||
#
|
#
|
||||||
|
# RealReadline
|
||||||
|
#
|
||||||
|
# Whether or to use the system Readline or the RBReadline (default)
|
||||||
|
#
|
||||||
def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
|
def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
|
||||||
|
|
||||||
if (Rex::Compat.is_windows())
|
# Choose a readline library before calling the parent
|
||||||
# Disable the color support
|
rl = false
|
||||||
prompt = "msf"
|
begin
|
||||||
prompt_char = ">"
|
if(opts['RealReadline'])
|
||||||
|
require 'readline'
|
||||||
|
rl = true
|
||||||
|
end
|
||||||
|
rescue ::LoadError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Default to the RbReadline wrapper
|
||||||
|
require 'readline_compatible' if(not rl)
|
||||||
|
|
||||||
|
|
||||||
# Call the parent
|
# Call the parent
|
||||||
super(prompt, prompt_char)
|
super(prompt, prompt_char)
|
||||||
|
@ -65,7 +77,7 @@ class Driver < Msf::Ui::Driver
|
||||||
|
|
||||||
# Initialize attributes
|
# Initialize attributes
|
||||||
self.framework = opts['Framework'] || Msf::Simple::Framework.create
|
self.framework = opts['Framework'] || Msf::Simple::Framework.create
|
||||||
|
|
||||||
# Initialize the user interface to use a different input and output
|
# Initialize the user interface to use a different input and output
|
||||||
# handle if one is supplied
|
# handle if one is supplied
|
||||||
if (opts['LocalInput'] or opts['LocalOutput'])
|
if (opts['LocalInput'] or opts['LocalOutput'])
|
||||||
|
|
|
@ -59,7 +59,7 @@ module Readline
|
||||||
raise IOError, "stdin closed"
|
raise IOError, "stdin closed"
|
||||||
end
|
end
|
||||||
|
|
||||||
RbReadline.rl_instream = $stdin
|
RbReadline.rl_instream = $stdin
|
||||||
RbReadline.rl_outstream = $stdout
|
RbReadline.rl_outstream = $stdout
|
||||||
|
|
||||||
status = 0
|
status = 0
|
|
@ -16,6 +16,12 @@ module FileUtils
|
||||||
# a fully qualified path to the supplied file name.
|
# a fully qualified path to the supplied file name.
|
||||||
#
|
#
|
||||||
def self.find_full_path(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')
|
path = Rex::Compat.getenv('PATH')
|
||||||
if (path)
|
if (path)
|
||||||
path.split(::File::PATH_SEPARATOR).each { |base|
|
path.split(::File::PATH_SEPARATOR).each { |base|
|
||||||
|
|
|
@ -5,7 +5,6 @@ module Ui
|
||||||
module Text
|
module Text
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'readline'
|
|
||||||
|
|
||||||
###
|
###
|
||||||
#
|
#
|
||||||
|
@ -14,12 +13,24 @@ begin
|
||||||
#
|
#
|
||||||
###
|
###
|
||||||
class Input::Readline < Rex::Ui::Text::Input
|
class Input::Readline < Rex::Ui::Text::Input
|
||||||
include ::Readline
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Initializes the readline-aware Input instance for text.
|
# Initializes the readline-aware Input instance for text.
|
||||||
#
|
#
|
||||||
def initialize(tab_complete_proc = nil)
|
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)
|
if (tab_complete_proc)
|
||||||
::Readline.basic_word_break_characters = "\x00"
|
::Readline.basic_word_break_characters = "\x00"
|
||||||
::Readline.completion_proc = tab_complete_proc
|
::Readline.completion_proc = tab_complete_proc
|
||||||
|
|
|
@ -56,7 +56,12 @@ class OptsConsole
|
||||||
opts.on("-v", "--version", "Show version") do |v|
|
opts.on("-v", "--version", "Show version") do |v|
|
||||||
options['Version'] = true
|
options['Version'] = true
|
||||||
end
|
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 ""
|
||||||
opts.separator "Common options:"
|
opts.separator "Common options:"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/usr/bin/env
|
|
||||||
|
|
||||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__))), '..', 'lib')
|
|
||||||
|
|
||||||
require 'rex'
|
|
||||||
require 'msf/core'
|
|
Loading…
Reference in New Issue