Command shell now working in the GUI

git-svn-id: file:///home/svn/framework3/trunk@4340 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-02-10 05:01:48 +00:00
parent 590fede74c
commit 1bf2db7a56
4 changed files with 84 additions and 42 deletions

View File

@ -11,26 +11,39 @@ class BidirectionalPipe < Rex::IO::BidirectionalPipe
def initialize(buffer)
@buffer = buffer
if (not @buffer.get_mark('end_mark')
@buffer.create_mark('end_mark', @buffer.end_iter, false)
end
super()
end
def print_error(msg)
@buffer.insert_at_cursor('[-] ' + msg)
@buffer.insert(@buffer.end_iter, '[-] ' + msg)
print_line
scroll_line
end
def print_line(msg = "")
@buffer.insert_at_cursor(msg + "\n")
@buffer.insert(@buffer.end_iter, msg + "\n")
scroll_line
end
def print_good(msg)
@buffer.insert_at_cursor('[+] ' + msg)
@buffer.insert(@buffer.end_iter, '[+] ' + msg)
print_line
scroll_line
end
def print_status(msg)
@buffer.insert_at_cursor('[*] ' + msg)
@buffer.insert(@buffer.end_iter, '[*] ' + msg)
print_line
scroll_line
end
def scroll_line
@buffer.move_mark('end_mark', @buffer.end_iter)
@textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))
end
protected

View File

@ -420,7 +420,7 @@ class MsfAssistant
pipe = Msf::Ui::Gtk2::Stream::GtkConsolePipe.new(@buffer)
input = pipe.fd
input = pipe.pipe_input
output = pipe
@mydriver.exploit.init_ui(input, output)

View File

@ -9,6 +9,7 @@ class Console < MyGlade
super('console2')
@textview.set_buffer(buffer)
@textview.editable = false
@buffer = buffer
@session = session
@ -16,6 +17,7 @@ class Console < MyGlade
@output = output
@pipe = pipe
# Create a read subscriber
@pipe.create_subscriber(@session.sid)
@ -23,7 +25,32 @@ class Console < MyGlade
@output.print_line("\n")
@session.init_ui(@input, @output)
Thread.new{@session.interact}
# One thread to interact
@t_mon = Thread.new do
@session.interact
end
# Another to monitor the output and update the UI
@t_rdr = Thread.new do
if (not @buffer.get_mark('end_mark'))
@buffer.create_mark('end_mark', @buffer.end_iter, false)
end
while(true)
data = @pipe.read_subscriber(@session.sid)
if (data and data.length > 0)
@buffer.insert(@buffer.end_iter, data)
@buffer.move_mark('end_mark', @buffer.end_iter)
@textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))
else
select(nil, nil, nil, 0.10)
end
end
end
if @console2.run == Gtk::Dialog::RESPONSE_OK
puts "ok"
@ -31,6 +58,10 @@ class Console < MyGlade
end
# Kill off the helper threads
@t_rdr.kill
@t_mon.kill
update_access
@console2.destroy
@ -57,10 +88,8 @@ class Console < MyGlade
update_access
# Puts cmd
puts cmd
@input.put(cmd)
@pipe.read_subscriber(@session.sid)
# Write the command plus a newline to the input
@input.put(cmd + "\n")
# Clear entry
@cmd_entry.set_text("")
@ -68,6 +97,7 @@ class Console < MyGlade
end
require 'rex/io/bidirectional_pipe'
class GtkConsolePipe < Rex::IO::BidirectionalPipe
attr_accessor :input

View File

@ -7,7 +7,6 @@ module Msf
module Ui
module Web
require 'msf/ui/web/comm'
require 'rex/io/bidirectional_pipe'
###