From 289d280291c1d06ac55b37c7a4c70e03c206f908 Mon Sep 17 00:00:00 2001 From: HD Moore Date: Sun, 20 Jan 2008 22:40:11 +0000 Subject: [PATCH] More UI updates git-svn-id: file:///home/svn/framework3/trunk@5293 4d416f70-5f16-0410-b530-b9f4589650da --- data/msfgui/msfgui.glade | 8 +++ lib/msf/core/session/interactive.rb | 4 +- lib/msf/ui/gtk2/assistant/auxiliary.rb | 2 +- lib/msf/ui/gtk2/assistant/exploit.rb | 23 ++++++-- lib/msf/ui/gtk2/assistant/skeleton.rb | 9 +-- lib/msf/ui/gtk2/dialog/confirm.rb | 38 ++++++++++++ lib/msf/ui/gtk2/dialog/skeleton_alert.rb | 2 +- lib/msf/ui/gtk2/dialogs.rb | 3 +- lib/msf/ui/gtk2/frame/modules_tree.rb | 73 +++++++++++++++++++++--- lib/msf/ui/gtk2/search.rb | 4 ++ lib/msf/ui/gtk2/window.rb | 3 +- lib/msf/ui/gtk2/window/codeview.rb | 55 ++++++++++++++++++ lib/msf/ui/gtk2/window/consoles.rb | 35 +++++++++++- 13 files changed, 235 insertions(+), 24 deletions(-) create mode 100644 lib/msf/ui/gtk2/dialog/confirm.rb create mode 100644 lib/msf/ui/gtk2/window/codeview.rb diff --git a/data/msfgui/msfgui.glade b/data/msfgui/msfgui.glade index 4347278de7..1ef273cec0 100644 --- a/data/msfgui/msfgui.glade +++ b/data/msfgui/msfgui.glade @@ -689,6 +689,14 @@ True + + + + True + gtk-open + True + + diff --git a/lib/msf/core/session/interactive.rb b/lib/msf/core/session/interactive.rb index fb1d0df948..2a55c5b2df 100644 --- a/lib/msf/core/session/interactive.rb +++ b/lib/msf/core/session/interactive.rb @@ -44,9 +44,9 @@ module Interactive # def tunnel_peer begin - rstream.peerinfo + @peer_info = rstream.peerinfo rescue - framework.sessions.deregister(self) + @peer_info end end diff --git a/lib/msf/ui/gtk2/assistant/auxiliary.rb b/lib/msf/ui/gtk2/assistant/auxiliary.rb index 48f3130d3e..352841b66f 100644 --- a/lib/msf/ui/gtk2/assistant/auxiliary.rb +++ b/lib/msf/ui/gtk2/assistant/auxiliary.rb @@ -26,7 +26,7 @@ module Msf ["Select your options", "option", true, true, true, false], ], ['Review', - ["Check your review", "end", true, true, true, true], + ["Confirm settings", "end", true, true, true, true], ], ].collect do |item, state| WIZARD2[item] = WizardStruct2.new( diff --git a/lib/msf/ui/gtk2/assistant/exploit.rb b/lib/msf/ui/gtk2/assistant/exploit.rb index 7336c51e31..c757fb5b51 100644 --- a/lib/msf/ui/gtk2/assistant/exploit.rb +++ b/lib/msf/ui/gtk2/assistant/exploit.rb @@ -34,7 +34,7 @@ module Msf ["Select your options", "option", true, true, true, false], ], ['Review', - ["Check your review", "end", true, true, true, true], + ["Confirm settings", "end", true, true, true, true], ], ].collect do |item, state| WIZARD[item] = WizardStruct.new( @@ -329,13 +329,28 @@ module Msf @options_evasion.remove(widget) end - # Pack - self.main.pack_start(@options_required, false, false, 10) - # TODO: Display temporaly desactived + + + # Pack + #self.main.pack_start(@options_required, false, false, 10) #self.main.pack_start(@frame_advanced, false, false, 10) #self.main.pack_start(@frame_evasion, false, false, 10) + scrl = Gtk::ScrolledWindow.new + scrl.shadow_type = Gtk::SHADOW_NONE + scrl.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + + vscr = Gtk::VBox.new + + vscr.pack_start(@options_required, false, false, 10) + vscr.pack_start(@frame_advanced, false, false, 10) + vscr.pack_start(@frame_evasion, false, false, 10) + + scrl.add_with_viewport(vscr) + + self.main.pack_start(scrl, false, false, 20) + # Payload options @mydriver.payload = framework.payloads.create(@hash["PAYLOAD"]) diff --git a/lib/msf/ui/gtk2/assistant/skeleton.rb b/lib/msf/ui/gtk2/assistant/skeleton.rb index ee3f4bc12f..2959165129 100644 --- a/lib/msf/ui/gtk2/assistant/skeleton.rb +++ b/lib/msf/ui/gtk2/assistant/skeleton.rb @@ -18,9 +18,10 @@ module Msf def initialize(title) super() self.resizable = false - self.set_default_size(600, 400) + self.set_window_position(Gtk::Window::POS_CENTER) self.title = title - + self.set_border_width(1) + # First page @page = "intro" @@ -42,8 +43,8 @@ module Msf @vbox_left.pack_start(create_save(), false, false, 5) # Main frame - @main = Gtk::VBox.new(false, 5) - @hbox.pack_start(@main, true, true, 5) + @main = Gtk::VBox.new(false, 10) + @hbox.pack_start(@main, true, true, 10) # Separator separator = Gtk::HSeparator.new diff --git a/lib/msf/ui/gtk2/dialog/confirm.rb b/lib/msf/ui/gtk2/dialog/confirm.rb new file mode 100644 index 0000000000..30294ae12a --- /dev/null +++ b/lib/msf/ui/gtk2/dialog/confirm.rb @@ -0,0 +1,38 @@ +module Msf + module Ui + module Gtk2 + + class MsfDialog + ## + # Display an error Gtk style + # parent: the Gtk parent widget + # title: the error title + # message: the error + ## + class Confirm < Msf::Ui::Gtk2::SkeletonAlert + def initialize(parent, title, message=nil) + super(parent, title, Gtk::Stock::DIALOG_WARNING, + [ + [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL], + [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_OK] + ], + message + ) + self.default_response = Gtk::Dialog::RESPONSE_CANCEL + + signal_connect("response") do |dialog,res_id| + if(res_id == Gtk::Dialog::RESPONSE_OK) + yield() + end + end + + show_all and run + destroy + end + end + + end + + end + end +end diff --git a/lib/msf/ui/gtk2/dialog/skeleton_alert.rb b/lib/msf/ui/gtk2/dialog/skeleton_alert.rb index 13c7f9fb75..98746e4c11 100644 --- a/lib/msf/ui/gtk2/dialog/skeleton_alert.rb +++ b/lib/msf/ui/gtk2/dialog/skeleton_alert.rb @@ -39,4 +39,4 @@ module Msf end end end -end \ No newline at end of file +end diff --git a/lib/msf/ui/gtk2/dialogs.rb b/lib/msf/ui/gtk2/dialogs.rb index ae91255501..4791e732e6 100644 --- a/lib/msf/ui/gtk2/dialogs.rb +++ b/lib/msf/ui/gtk2/dialogs.rb @@ -7,4 +7,5 @@ require 'msf/ui/gtk2/dialog/skeleton_browser' require 'msf/ui/gtk2/dialog/payload' require 'msf/ui/gtk2/dialog/error' require 'msf/ui/gtk2/dialog/warning' -require 'msf/ui/gtk2/dialog/information' \ No newline at end of file +require 'msf/ui/gtk2/dialog/information' +require 'msf/ui/gtk2/dialog/confirm' diff --git a/lib/msf/ui/gtk2/frame/modules_tree.rb b/lib/msf/ui/gtk2/frame/modules_tree.rb index 734b06da04..3b37934523 100644 --- a/lib/msf/ui/gtk2/frame/modules_tree.rb +++ b/lib/msf/ui/gtk2/frame/modules_tree.rb @@ -138,7 +138,19 @@ module Gtk2 end end end - + + @view_code.signal_connect('activate') do |item| + if active_module = @selection.selected + type = active_module.get_value(TYPE) + if (type == EXP or type == AUX) + MsfWindow::CodeView.new(active_module.get_value(MOD)) + elsif (type == DIR) + # Ignore + else + MsfDialog::Error.new($gtk2driver.main, "Not available") + end + end + end # Add modules in the Gtk::TreeView add_modules() @@ -178,6 +190,32 @@ module Gtk2 end end + # + # Prune empty module directories from the hash + # + def prune_hash(key, hash) + + cnt = 0 + + hash.keys.each do |k| + if(hash[k].class != ::Hash) + cnt += 1 + next + end + + num = prune_hash(k, hash[k]) + if (num == 0) + hash.delete(k) + end + + cnt += num + end + + # $stdout.puts "#{key} == #{cnt}" + + cnt + end + # # Add Exploits module in the treeview # @@ -193,10 +231,20 @@ module Gtk2 ref[part] ||= {} ref = ref[part] end - - ref[name] = obj.new + + ins = obj.new + if ( + mod =~ filter or + ins.name =~ filter or + ins.description.gsub(/\s+/, " ") =~ filter or + ins.author_to_s =~ filter or + ins.references.map {|x| x.to_s}.join(" ") =~ filter + ) + ref[name] = obj.new + end end + prune_hash("exploits", mod_exploits) mod_auxiliary = {} framework.auxiliary.each_module do |mod, obj| @@ -208,9 +256,21 @@ module Gtk2 ref = ref[part] end - ref[name] = obj.new + ins = obj.new + if ( + mod =~ filter or + ins.name =~ filter or + ins.description.gsub(/\s+/, " ") =~ filter or + ins.author_to_s =~ filter or + ins.references.map {|x| x.to_s}.join(" ") =~ filter + ) + ref[name] = obj.new + end end + prune_hash("auxiliary", mod_auxiliary) + + add_modules_to_store( @model, nil, "Exploits", mod_exploits, { @@ -232,7 +292,6 @@ module Gtk2 :type => AUX } ) - # # TODO: To implement later ... @@ -307,9 +366,9 @@ module Gtk2 # # Refresh the module treeview with all msf modules # - def refresh + def refresh(filter=/.*/) @model.clear() - add_modules() + add_modules(filter) end # diff --git a/lib/msf/ui/gtk2/search.rb b/lib/msf/ui/gtk2/search.rb index d4370dc339..611ab8b3af 100644 --- a/lib/msf/ui/gtk2/search.rb +++ b/lib/msf/ui/gtk2/search.rb @@ -58,6 +58,10 @@ module Msf found = [] filter = Regexp.new(text, Regexp::IGNORECASE) + $gtk2driver.module_tree.refresh(filter) + $gtk2driver.module_tree.expand + return + i_type = Msf::Ui::Gtk2::MyModuleTree::TYPE i_type_dir = Msf::Ui::Gtk2::MyModuleTree::DIR i_desc = Msf::Ui::Gtk2::MyModuleTree::DESC diff --git a/lib/msf/ui/gtk2/window.rb b/lib/msf/ui/gtk2/window.rb index 5ad103a257..8447164c53 100644 --- a/lib/msf/ui/gtk2/window.rb +++ b/lib/msf/ui/gtk2/window.rb @@ -1,5 +1,4 @@ require 'msf/ui/gtk2/window/logs' require 'msf/ui/gtk2/window/auxiliary' require 'msf/ui/gtk2/window/consoles' - - +require 'msf/ui/gtk2/window/codeview' diff --git a/lib/msf/ui/gtk2/window/codeview.rb b/lib/msf/ui/gtk2/window/codeview.rb new file mode 100644 index 0000000000..95af07eb5b --- /dev/null +++ b/lib/msf/ui/gtk2/window/codeview.rb @@ -0,0 +1,55 @@ +module Msf +module Ui +module Gtk2 + +class MsfWindow + + # + # This class performs a Gtk::Window to display logs from framework + # + class CodeView < Msf::Ui::Gtk2::SkeletonBasic + + include Msf::Ui::Gtk2::MyControls + + def initialize(m) + + # call the parent + super("Source Code of #{m.type.capitalize} #{m.refname}") + + # Define the size and border + set_default_size(600, 480) + set_border_width(10) + + # Main hbox + vbox = Gtk::VBox.new(false, 0) + add(vbox) + + textview = Gtk::TextView.new + textview.set_editable(false) + + sw = Gtk::ScrolledWindow.new() + sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + vbox.pack_start(sw, true, true, 0) + + sw.add(textview) + + + buff = textview.buffer + fixr = buff.create_tag("fixr", + { + "font" => "Courier" + } + ) + + buff.insert(buff.end_iter, File.read(m.file_path), "fixr") + + show_all + end + + end + +end + +end +end +end diff --git a/lib/msf/ui/gtk2/window/consoles.rb b/lib/msf/ui/gtk2/window/consoles.rb index 8cbd565f87..9f08e6258b 100644 --- a/lib/msf/ui/gtk2/window/consoles.rb +++ b/lib/msf/ui/gtk2/window/consoles.rb @@ -13,6 +13,7 @@ class MsfWindow attr_accessor :input, :prompt attr_accessor :pipe, :console attr_accessor :console_thread, :reader_thread + attr_accessor :console_window class MyPipe < Rex::IO::BidirectionalPipe def prompting? @@ -126,18 +127,43 @@ class MsfWindow self.output.buffer.text = "" self.history = [] self.hindex = 0 + when 'irb' + skip = true end self.history.push(line) self.hindex = self.history.length - 1 + self.output.append_output(self.output.prompt.text) if not self.output.console.busy + self.output.append_output(line + "\n") self.output.pipe.write_input(line+"\n") if not skip - + obj.text = '' end self.signal_connect('key-press-event') do |obj, key| case key.keyval + + when "c"[0] + if (key.state.name == "GDK_CONTROL_MASK") + if(self.output.console.active_session) + MsfDialog::Confirm.new(self.output.console_window, "Close Session", "Close this session?") { + self.output.append_output("\n[*] Closing session...\n") + self.output.console.active_session.kill() + } + end + true + end + when "z"[0] + if (key.state.name == "GDK_CONTROL_MASK") + if(self.output.console.active_session) + MsfDialog::Confirm.new(self.output.console_window, "Suspend Session", "Suspend this session?") { + self.output.append_output("\n[*] Suspending session...\n") + self.output.console.active_session.detach() + } + end + true + end when Gdk::Keyval::GDK_Up if history.length > 0 self.text = history[hindex] @@ -246,6 +272,8 @@ class MsfWindow vbox = Gtk::VBox.new scrl = Gtk::ScrolledWindow.new text = ConsoleOutput.new + + text.console_window = self text.editable = false text.accepts_tab = false @@ -267,7 +295,6 @@ class MsfWindow input = MyInput.new(text) input.set_size_request(-1, 25) input.has_frame = false - input.focus = true text.prompt = prompt @@ -285,6 +312,7 @@ class MsfWindow tab.set_page(tab.page_num(vbox)) input.can_focus = true input.has_focus = true + input.focus = true label_btn.signal_connect("clicked") do |obj| idx = tab.page_num(vbox) @@ -316,6 +344,9 @@ class MsfWindow hbox = Gtk::HBox.new btn = Gtk::Button.new("New Console") + btn.set_image(Gtk::Image.new(Gtk::Stock::NEW, Gtk::IconSize::MENU)) + btn.relief = Gtk::RELIEF_NONE + hbox.add(btn) vbox.pack_start(hbox, false, false, 0)