- test the new GtkConsolePipe (currently under devel)

git-svn-id: file:///home/svn/framework3/trunk@4339 4d416f70-5f16-0410-b530-b9f4589650da
unstable
fab 2007-02-10 03:03:17 +00:00
parent d1136c7286
commit 590fede74c
7 changed files with 123 additions and 23 deletions

View File

@ -1076,8 +1076,8 @@
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">True</property>
<signal name="activate" handler="on_cmd_entry_activate" last_modification_time="Mon, 05 Feb 2007 21:24:46 GMT"/>
<property name="activates_default">False</property>
<signal name="activate" handler="on_cmd_entry_activate" last_modification_time="Sat, 10 Feb 2007 02:15:00 GMT"/>
</widget>
<packing>
<property name="padding">0</property>

View File

@ -418,13 +418,9 @@ class MsfAssistant
@mydriver.target_idx = (@mydriver.exploit.datastore['TARGET']).to_i
# input = Msf::Ui::Gtk2::Stream::Input.new(@buffer)
# output = Msf::Ui::Gtk2::Stream::Output.new(@buffer)
pipe = Msf::Ui::Gtk2::Stream::GtkConsolePipe.new(@buffer)
pipe = BidirectionalPipe.new(@buffer)
# pipe.input = pipe.pipe_input
input = pipe
input = pipe.fd
output = pipe
@mydriver.exploit.init_ui(input, output)

View File

@ -10,7 +10,7 @@ require 'msf/ui/gtk2/dialogs'
require 'msf/ui/gtk2/logs'
require 'msf/ui/gtk2/stream'
require 'msf/ui/gtk2/view'
require 'msf/ui/gtk2/bidirectional_pipe'
# require 'msf/ui/gtk2/stream/bidirectional_pipe'
module Msf
module Ui

View File

@ -0,0 +1,57 @@
module Msf
module Ui
module Gtk2
###
#
# Handles events of various types that are sent from the framework.
#
###
module FrameworkEventManager
include Msf::SessionEvent
#
# Subscribes to the framework as a subscriber of various events.
#
def register_event_handlers
framework.events.add_session_subscriber(self)
end
#
# Unsubscribes from the framework.
#
def deregister_event_handlers
framework.events.remove_session_subscriber(self)
end
#
# Called when a session is registered with the framework.
#
def on_session_open(session)
output.print_status("#{session.desc} session #{session.name} opened (#{session.tunnel_to_s})")
if (Msf::Logging.session_logging_enabled? == true)
Msf::Logging.start_session_log(session)
end
end
#
# Called when a session is closed and removed from the framework.
#
def on_session_close(session)
if (session.interacting == true)
output.print_line
end
# If logging had been enabled for this session, stop it now.
Msf::Logging::stop_session_log(session)
output.print_status("#{session.desc} session #{session.name} closed.")
end
end
end
end
end

View File

@ -12,23 +12,25 @@ class Console < MyGlade
@buffer = buffer
@session = session
@pipe = pipe
@input = input
@output = output
@pipe = pipe
# Create a read subscriber
@pipe.create_subscriber(@session.sid)
@output.print_status("Session #{@session.sid} created, interacting")
@output.print_line
@output.print_line("\n")
@session.init_ui(@input, @output)
Thread.new{@session.interact}
if @console2.run == Gtk::Dialog::RESPONSE_OK
puts "ok"
@console2.destroy
end
@session.init_ui(@input, @output)
@session.interact
update_access
@console2.destroy
@ -57,7 +59,7 @@ class Console < MyGlade
# Puts cmd
puts cmd
@pipe.write_input(cmd)
@input.put(cmd)
@pipe.read_subscriber(@session.sid)
# Clear entry
@ -65,6 +67,45 @@ class Console < MyGlade
end
end
require 'rex/io/bidirectional_pipe'
class GtkConsolePipe < Rex::IO::BidirectionalPipe
attr_accessor :input
attr_accessor :output
attr_accessor :prompt
attr_accessor :killed
def initialize(buffer)
@buffer = buffer
super()
end
def eof?
self.pipe_input.eof?
end
def intrinsic_shell?
true
end
def supports_readline
false
end
def _print_prompt
end
def pgets
self.pipe_input.gets
end
def print_line(msg = "")
@buffer.insert_at_cursor(msg + "\n")
end
end
end
end
end

View File

@ -10,30 +10,30 @@ module Stream
###
class Input < Rex::Ui::Text::Input
def initialize(buffer)
self.eof = false
def initialize(buffer, entry)
@buffer = buffer
@entry = entry
end
#
# Reads text from standard input.
#
def sysread(len = 1)
$stdin.sysread(len)
return true
end
#
# Wait for a line of input to be read from standard input.
#
def gets
return $stdin.gets
return @entry.text
end
#
# Print a prompt and flush standard output.
#
def _print_prompt(prompt)
$stdout.print(prompt)
$stdout.flush
@buffer.insert_at_cursor(prompt)
end
#
@ -48,15 +48,17 @@ class Input < Rex::Ui::Text::Input
# Returns whether or not EOF has been reached on stdin.
#
def eof?
$stdin.closed?
return true
end
#
# Returns the file descriptor associated with standard input.
#
def fd
return $stdin
a = ::IO.new(0, "w")
return a
end
end
end

View File

@ -3,7 +3,7 @@ module Ui
module Gtk2
module Stream
class Output < Rex::Ui::Output
class Output < Rex::Ui::Text::Output
def initialize(buffer)
@buffer = buffer
@ -24,6 +24,10 @@ class Output < Rex::Ui::Output
def print_line(msg = '')
@buffer.insert_at_cursor(msg + "\n")
end
def print(msg = '')
@buffer.insert_at_cursor(msg + "\n")
end
end
end