From c23760c445b79eacc8a886b4e954697860f09bd3 Mon Sep 17 00:00:00 2001 From: fab <> Date: Mon, 5 Feb 2007 22:36:43 +0000 Subject: [PATCH] - Gtk::Entry on the console is done, cmd redirects to stdout git-svn-id: file:///home/svn/framework3/trunk@4328 4d416f70-5f16-0410-b530-b9f4589650da --- data/msfgui/msfgui.glade | 1 + lib/msf/ui/gtk2/dialogs.rb | 3 ++- lib/msf/ui/gtk2/frame.rb | 7 ++++-- lib/msf/ui/gtk2/stream/console.rb | 37 ++++++++++++++++++++++++++++++- lib/msf/ui/gtk2/stream/session.rb | 4 ++-- 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/data/msfgui/msfgui.glade b/data/msfgui/msfgui.glade index 381fd255db..b35ecf31f9 100644 --- a/data/msfgui/msfgui.glade +++ b/data/msfgui/msfgui.glade @@ -1052,6 +1052,7 @@ True * True + 0 diff --git a/lib/msf/ui/gtk2/dialogs.rb b/lib/msf/ui/gtk2/dialogs.rb index 4a9d7aba44..b1f0e29343 100644 --- a/lib/msf/ui/gtk2/dialogs.rb +++ b/lib/msf/ui/gtk2/dialogs.rb @@ -397,7 +397,8 @@ class MsfAssistant Msf::Ui::Gtk2::Stream::Session.new(@buffer, @session_tree, @hash, - session, + session, + pipe, input, output) } diff --git a/lib/msf/ui/gtk2/frame.rb b/lib/msf/ui/gtk2/frame.rb index 7a706e74de..baf962ee41 100644 --- a/lib/msf/ui/gtk2/frame.rb +++ b/lib/msf/ui/gtk2/frame.rb @@ -402,7 +402,7 @@ class MyTargetTree < MyGlade end #class MyTargetTree class MySessionTree - ID_SESSION, TARGET, PAYLOAD, O_SESSION, BUFFER, INPUT, OUTPUT = *(0..7).to_a + ID_SESSION, TARGET, PAYLOAD, O_SESSION, BUFFER, PIPE, INPUT, OUTPUT = *(0..8).to_a def initialize(treeview) @treeview = treeview @@ -411,6 +411,7 @@ class MySessionTree String, # Payload Type Object, # Session Object Object, # Gtk::TextBuffer Object + Object, # Bidirectional_pipe Object, # Input Object Object # Output Object ) @@ -497,6 +498,7 @@ class MySessionTree if current = @selection.selected Msf::Ui::Gtk2::Stream::Console.new(current[O_SESSION], current[BUFFER], + current[PIPE], current[INPUT], current[OUTPUT] ) @@ -505,13 +507,14 @@ class MySessionTree end # def initialize - def add_session(session, options, buffer, input, output) + def add_session(session, options, buffer, pipe, input, output) iter = @model.append iter[ID_SESSION] = session.sid.to_s iter[TARGET] = options['RHOST'] iter[PAYLOAD] = options['PAYLOAD'] iter[O_SESSION] = session iter[BUFFER] = buffer + iter[PIPE] = pipe iter[INPUT] = input iter[OUTPUT] = output diff --git a/lib/msf/ui/gtk2/stream/console.rb b/lib/msf/ui/gtk2/stream/console.rb index e96ab3f843..9a359f9183 100644 --- a/lib/msf/ui/gtk2/stream/console.rb +++ b/lib/msf/ui/gtk2/stream/console.rb @@ -5,16 +5,20 @@ module Stream class Console < MyGlade - def initialize(session, buffer, input, output) + def initialize(session, buffer, pipe, input, output) super('console2') @textview.set_buffer(buffer) @buffer = buffer @session = session + @pipe = pipe @input = input @output = output + # Create a read subscriber + @pipe.create_subscriber(@session.sid) + @output.print_status("Session #{@session.sid} created, interacting") @output.print_line @@ -25,9 +29,40 @@ class Console < MyGlade @session.init_ui(@input, @output) @session.interact + update_access + @console2.destroy end + + # + # update access + # + def update_access + last_access = Time.now + end + # + # Signal for user entry + # + def on_cmd_entry_activate + send_cmd(@cmd_entry.text) + end + + # + # Send command to bidirectionnal_pipe + # + def send_cmd(cmd) + + update_access + + # Puts cmd + puts cmd + @pipe.write_input(cmd) + @pipe.read_subscriber(@session.sid) + + # Clear entry + @cmd_entry.set_text("") + end end end diff --git a/lib/msf/ui/gtk2/stream/session.rb b/lib/msf/ui/gtk2/stream/session.rb index 6f0b107ae2..a27aa7fceb 100644 --- a/lib/msf/ui/gtk2/stream/session.rb +++ b/lib/msf/ui/gtk2/stream/session.rb @@ -5,12 +5,12 @@ module Stream class Session - def initialize(buffer, session_tree, options, session, input, output) + def initialize(buffer, session_tree, options, session, pipe, input, output) @session_tree = session_tree @session = session - @session_tree.add_session(@session, options, buffer, input, output) + @session_tree.add_session(@session, options, buffer, pipe, input, output) end end