From a2592959c326646a1433f8bd881e328d7dfb3899 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sat, 29 Jul 2006 23:01:38 +0000 Subject: [PATCH] Readline mode disabledby defualt for interactive sessios Fixed an issue with exploit.rb directly running a session command after the session command had been renamed git-svn-id: file:///home/svn/framework3/trunk@3774 4d416f70-5f16-0410-b530-b9f4589650da --- .../ui/console/command_dispatcher/exploit.rb | 2 +- lib/rex/ui/text/input/readline.rb | 26 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index cff8cc5b2c..3c25522094 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -138,7 +138,7 @@ class Exploit if (bg == false and session.interactive?) print_line - driver.run_single("session -q -i #{session.sid}") + driver.run_single("sessions -q -i #{session.sid}") # Otherwise, log that we created a session else print_status("Session #{session.sid} created in the background.") diff --git a/lib/rex/ui/text/input/readline.rb b/lib/rex/ui/text/input/readline.rb index 656208a015..f30332e9f8 100644 --- a/lib/rex/ui/text/input/readline.rb +++ b/lib/rex/ui/text/input/readline.rb @@ -16,10 +16,20 @@ begin class Input::Readline < Rex::Ui::Text::Input include ::Readline - @@rl_thread = nil - @@rl_pipes = nil - @@rl_prompt = '' - @@rl_history = true; + @@rl_thread = nil + @@rl_pipes = nil + @@rl_prompt = '' + @@rl_history = true + + # + # Enable readline mode by setting rl_usestdio to false + # Address the following items before switching: + # + # XXX: Find a way to emulate ^Z when in readline mode + # XXX: Create histories/tab completion for shells + # XXX: Capture remote shell prompt and use for readline + # + @@rl_usestdio = true # # Initializes the readline-aware Input instance for text. @@ -35,6 +45,7 @@ begin # Start the readline thread # def readline_start + return if @@rl_usestdio return if @@rl_thread @@rl_pipes = Rex::Compat.pipe @@rl_thread = ::Thread.new do @@ -84,6 +95,8 @@ begin # Calls sysread on the standard input handle. # def sysread(len = 1) + return $stdin.sysread(len) if @@rl_usestdio + if (! readline_status) $stderr.puts "ERROR: sysread() called outside of thread mode: " + caller(1).to_s return '' @@ -95,6 +108,8 @@ begin # Fake gets using readline # def gets() + return $stdin.gets() if @@rl_usestdio + if (! readline_status) $stderr.puts "ERROR: gets() called outside of thread mode: " + caller(1).to_s return '' @@ -113,7 +128,6 @@ begin # # Prompt-based getline using readline. - # XXX: Incompatible with thread mode # def pgets if (readline_status) @@ -134,6 +148,8 @@ begin # Returns the output pipe handle # def fd + return $stdin if @@rl_usestdio + if (! readline_status) $stderr.puts "fd called outside of thread mode: " + caller(1).to_s return ''