Working meterpreter from inside msfweb

git-svn-id: file:///home/svn/framework3/trunk@4357 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-02-11 19:33:01 +00:00
parent 628e3e786e
commit c46c1c2d04
4 changed files with 22 additions and 54 deletions

View File

@ -643,7 +643,7 @@ class Core
rescue IOError, EOFError, Rex::StreamClosedError
print_status("Session stream closed.")
rescue
log_error("Session manipulation failed: #{$!}")
log_error("Session manipulation failed: #{$!} #{$!.backtrace.inspect}")
end
return true

View File

@ -18,58 +18,15 @@ class WebConsole
class WebConsolePipe < Rex::IO::BidirectionalPipe
attr_accessor :input
attr_accessor :output
attr_accessor :prompt
attr_accessor :killed
def intrinsic_shell?
true
end
def supports_readline
false
end
def _print_prompt
end
#
# Wrapper methods around input pipe
#
def close
self.pipe_input.close
end
def put(*args)
self.pipe_input.put(*args)
end
def gets
self.pipe_input.gets
end
def pgets
self.pipe_input.gets
end
def eof?
self.pipe_input.eof?
end
=begin
def fd(*args)
# Remove the following line to enable full sessions via the console
# We really should just hook the on_session() instead...
raise ::RuntimeError, "Session interaction should be performed via the Sessions tab"
self.pipe_input.fd(*args)
end
def sysread(*args)
self.pipe_input.sysread(*args)
end
=end
end
#
@ -91,7 +48,6 @@ class WebConsole
# Create a new pipe
self.pipe = WebConsolePipe.new
self.pipe.input = self.pipe.pipe_input
# Create a read subscriber
self.pipe.create_subscriber('msfweb')

View File

@ -12,6 +12,10 @@ class BidirectionalPipe < Rex::Ui::Text::Input
@subscribers_ref = {}
@subscribers_idx = 0
@pipe_input = Rex::Ui::Text::Input::Buffer.new
# We are the shell, the input, and the output
self.output = self
self.input = self
end
def pipe_input
@ -64,8 +68,10 @@ class BidirectionalPipe < Rex::Ui::Text::Input
@subscribers_ref[id] ? @subscribers_ref[id].call(msg) : buf.print(msg)
rescue ::Exception => e
$stderr.puts "Error handling subscriber #{id}: #{e.to_s} #{e.backtrace.inspect}"
raise e
end
}
msg
end
def print_error(msg)
@ -118,6 +124,9 @@ class BidirectionalPipe < Rex::Ui::Text::Input
#
# Wrappers for shell methods
#
attr_accessor :output, :prompt, :input
def intrinsic_shell?
true
end
@ -126,6 +135,10 @@ class BidirectionalPipe < Rex::Ui::Text::Input
false
end
def supports_color?
false
end
def pgets
gets
end

View File

@ -178,6 +178,8 @@ module Shell
# console.
#
def supports_color?
return false
begin
(ENV['TERM'].match(/(?:vt10[03]|xterm(?:-color)?|linux|screen)/i) != nil)
rescue
@ -196,16 +198,14 @@ module Shell
# Returns colorized text if it's supported, otherwise an empty string.
#
def colorize(*color)
# This check is busted atm...
#return (supports_color? == false) ? '' : Rex::Ui::Text::Color.ansi(color)
return do_colorize(*color)
end
#
# Colorize regardless of terminal support.
# Colorize if this shell supports it
#
def do_colorize(*color)
return Rex::Ui::Text::Color.ansi(*color)
def do_colorize(*color)
supports_color?() ? Rex::Ui::Text::Color.ansi(*color) : ''
end
#
@ -245,7 +245,6 @@ module Shell
#
def print(msg)
return if (disable_output == true)
log_output(output.print(msg))
end