diff --git a/lib/msf/ui/gtk2/assistant/auxiliary.rb b/lib/msf/ui/gtk2/assistant/auxiliary.rb index cacf8f00da..d0b5490e84 100644 --- a/lib/msf/ui/gtk2/assistant/auxiliary.rb +++ b/lib/msf/ui/gtk2/assistant/auxiliary.rb @@ -46,20 +46,16 @@ module Msf @hash = {} # Call the parent - super(@active_module.refname) + super(@active_module.name) # Initialize exploit driver's exploit instance @mydriver = $gtk2driver @mydriver.exploit = framework.auxiliary.create(@active_module.refname) @mydriver.active_module = @active_module - # Main interface - @frame_advanced = Gtk::Expander.new("Advanced") - @frame_evasion = Gtk::Expander.new("Evasion") - @options_required = Gtk::VBox.new(false, 0) - @options_advanced = Gtk::VBox.new(false, 0) - @options_evasion = Gtk::VBox.new(false, 0) + initialize_options() + # Begin the wizard options_completion() @@ -93,7 +89,12 @@ module Msf # Save the framework's datastore framework.save_config @mydriver.exploit.datastore.to_file(Msf::Config.config_file, @mydriver.exploit.refname) - + MsfDialog::Information.new(self, + "Configuration Saved", + "Settings for auxiliary module #{@mydriver.exploit.refname} have been saved to #{Msf::Config.config_file}. " + + "These settings will be loaded the next time this module is accessed." + ) + $gtk2driver.append_log_view("Saved configuration to: #{Msf::Config.config_file}\n") end @@ -109,6 +110,7 @@ module Msf [@label_review] # next ) display() + initialize_options() options_completion() else self.page = "end" @@ -117,6 +119,7 @@ module Msf nil ) display() + initialize_options() review_completion() end end @@ -137,73 +140,103 @@ module Msf end end - # - # Display options view - # - def options_completion - self.page = "options" + # + # Instantiate the options page controls + # + def initialize_options + @frame_standard = Gtk::Expander.new("Standard") + @frame_advanced = Gtk::Expander.new("Advanced") + @frame_evasion = Gtk::Expander.new("Evasion") + @options_standard = Gtk::VBox.new(false, 0) + @options_advanced = Gtk::VBox.new(false, 0) + @options_evasion = Gtk::VBox.new(false, 0) - # Expanded frame - @frame_advanced.each do |widget| - @frame_advanced.remove(widget) - end - @frame_evasion.each do |widget| - @frame_evasion.remove(widget) - end + @framer = Gtk::VBox.new(false, 10) + @scroller = Gtk::ScrolledWindow.new + @scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + @scroller.set_size_request(580, 420) - # Required - @options_required.each do |widget| - @options_required.remove(widget) - end + @viewport = Gtk::Viewport.new(@scroller.hadjustment, @scroller.vadjustment) - # Advanced - @options_advanced.each do |widget| - @options_advanced.remove(widget) - end + @frame_standard.expanded = true + end + + # + # Display options view + # + def options_completion + self.page = "options" - # Evasion - @options_evasion.each do |widget| - @options_evasion.remove(widget) - end + # Title and three sets of options + title = Gtk::Label.new + title.set_markup("#{@mydriver.exploit.name}") + @framer.pack_start(title, false, true, 5) + @framer.pack_start(@frame_standard, false, false, 10) + @framer.pack_start(@frame_advanced, false, false, 10) + @framer.pack_start(@frame_evasion, false, false, 10) - # 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) + # Standard options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (opt.evasion?) + next if (opt.advanced?) + @options_standard.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end - # Standards options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (opt.evasion?) - next if (opt.advanced?) - @options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end + # Advanced options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (!opt.advanced?) + @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end - # Advanced options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (!opt.advanced?) - @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end + # Evasion options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (!opt.evasion?) + @options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end - # Evasion options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (!opt.evasion?) - @options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end + # Display + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_standard, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_standard.add(indent) - # Display - @frame_advanced.set_label("Advanced") - @frame_advanced.add(@options_advanced) - @frame_evasion.set_label("Evasion") - @frame_evasion.add(@options_evasion) + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_advanced, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_advanced.add(indent) - self.main.show_all - end + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_evasion, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_evasion.add(indent) + + labels = ["Standard", "Advanced", "Evasion"] + [@frame_standard, @frame_advanced, @frame_evasion].each do |obj| + txt = labels.shift + obj.spacing = 10 + obj.use_markup = true + obj.label = "#{txt}" + end + + # Stuff it into a viewport + @viewport.add(@framer) + + # Stuff the viewport into a scrolledwindow + @scroller.add(@viewport) + + # Stuff this into main and call it done + self.main.pack_start(@scroller, true, true, 10) + self.main.show_all + end # # Put all values in a hash # def dump_to_hash - @options_required.each do |widget| + @options_standard.each do |widget| name, value = widget.get_pair begin if (@mydriver.exploit.options[name].default.to_s == value) @@ -263,7 +296,7 @@ module Msf end if (errors.empty? == false) - MsfDialog::Error.new(self, "Failed to validate : #{errors.join(', ')}") + MsfDialog::Error.new(self, "Failed to validate: #{errors.join(', ')}") false else true @@ -281,7 +314,7 @@ module Msf label = Gtk::Label.new review = "\n\n" @hash.each do |key, value| - review << "#{key} : #{value}\n" + review << "#{key}: #{value}\n" end label.set_markup(review) diff --git a/lib/msf/ui/gtk2/assistant/exploit.rb b/lib/msf/ui/gtk2/assistant/exploit.rb index 8bcf00f65a..3934f44944 100644 --- a/lib/msf/ui/gtk2/assistant/exploit.rb +++ b/lib/msf/ui/gtk2/assistant/exploit.rb @@ -56,7 +56,7 @@ module Msf @hash = {} # Call the parent - super(@active_module.refname) + super(@active_module.name) # Initialize exploit driver's exploit instance @mydriver = Msf::ExploitDriver.new(framework) @@ -65,12 +65,7 @@ module Msf # Populate the datastore if possible @mydriver.exploit.load_config - # Main interface - @frame_advanced = Gtk::Expander.new("Advanced") - @frame_evasion = Gtk::Expander.new("Evasion") - @options_required = Gtk::VBox.new(false, 0) - @options_advanced = Gtk::VBox.new(false, 0) - @options_evasion = Gtk::VBox.new(false, 0) + initialize_options() # Begin the wizard target_completion() @@ -141,6 +136,7 @@ module Msf [@label_review] # next ) display() + initialize_options() options_completion() elsif (self.page == "options") if not validate() @@ -150,6 +146,7 @@ module Msf [@label_review] # next ) display() + initialize_options() options_completion() else self.page = "end" @@ -190,6 +187,7 @@ module Msf [@label_review] ) display() + initialize_options() options_completion() end end @@ -301,105 +299,117 @@ module Msf self.main.show_all end - # - # Display options view - # - def options_completion - # Expanded frame - @frame_advanced.each do |widget| - @frame_advanced.remove(widget) - end - @frame_evasion.each do |widget| - @frame_evasion.remove(widget) - end + # + # Instantiate the options page controls + # + def initialize_options + @frame_standard = Gtk::Expander.new("Standard") + @frame_advanced = Gtk::Expander.new("Advanced") + @frame_evasion = Gtk::Expander.new("Evasion") + @options_standard = Gtk::VBox.new(false, 0) + @options_advanced = Gtk::VBox.new(false, 0) + @options_evasion = Gtk::VBox.new(false, 0) - # Required - @options_required.each do |widget| - @options_required.remove(widget) - end + @framer = Gtk::VBox.new(false, 10) + @scroller = Gtk::ScrolledWindow.new + @scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + @scroller.set_size_request(580, 420) - # Advanced - @options_advanced.each do |widget| - @options_advanced.remove(widget) - end + @viewport = Gtk::Viewport.new(@scroller.hadjustment, @scroller.vadjustment) - # Evasion - @options_evasion.each do |widget| - @options_evasion.remove(widget) - end + @frame_standard.expanded = true + end + + # + # Display options view + # + def options_completion + self.page = "options" + # Title and three sets of options + title = Gtk::Label.new + title.set_markup("#{@mydriver.exploit.name}") + @framer.pack_start(title, false, true, 5) + @framer.pack_start(@frame_standard, false, false, 10) + @framer.pack_start(@frame_advanced, false, false, 10) + @framer.pack_start(@frame_evasion, false, false, 10) + # Standard options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (opt.evasion?) + next if (opt.advanced?) + @options_standard.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end + + # Advanced options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (!opt.advanced?) + @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end + + # Evasion options + @mydriver.exploit.options.sorted.each do |key, opt| + next if (!opt.evasion?) + @options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end + + # Payload options + @mydriver.payload = framework.payloads.create(@hash["PAYLOAD"]) + @mydriver.payload.options.each do |key, opt| + next if (opt.advanced?) + next if (opt.evasion?) + if (opt.required?) + @options_standard.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + else + @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) + end + end - - # Pack - self.main.pack_start(@options_required, false, false, 10) - - # TODO - #self.main.pack_start(@frame_advanced, false, false, 10) - #self.main.pack_start(@frame_evasion, false, false, 10) + # Display + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_standard, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_standard.add(indent) - #scrl = Gtk::ScrolledWindow.new - #scrl.shadow_type = Gtk::SHADOW_NONE - #scrl.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_advanced, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_advanced.add(indent) - #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"]) + indent = Gtk::HBox.new(false, 5) + indent.pack_start(Gtk::Label.new(""), false, false, 5) + indent.pack_start(@options_evasion, false, false, 0) + indent.pack_start(Gtk::Label.new(""),true, true, 5) + @frame_evasion.add(indent) - # Pack all options - @mydriver.payload.options.each do |key, opt| - next if (opt.advanced?) - next if (opt.evasion?) - if (opt.required?) - @options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - else - @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end - end + labels = ["Standard", "Advanced", "Evasion"] + [@frame_standard, @frame_advanced, @frame_evasion].each do |obj| + txt = labels.shift + obj.spacing = 10 + obj.use_markup = true + obj.label = "#{txt}" + end - # Standards options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (opt.evasion?) - next if (opt.advanced?) - @options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end + # Stuff it into a viewport + @viewport.add(@framer) - # Advanced options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (!opt.advanced?) - @options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end - - # Evasion options - @mydriver.exploit.options.sorted.each do |key, opt| - next if (!opt.evasion?) - @options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10) - end - - # TODO: Display temporaly desactived - #@frame_advanced.set_label("Advanced") - #@frame_advanced.add(@options_advanced) - #@frame_evasion.set_label("Evasion") - #@frame_evasion.add(@options_evasion) - - self.main.show_all - end + # Stuff the viewport into a scrolledwindow + @scroller.add(@viewport) + # Stuff this into main and call it done + self.main.pack_start(@scroller, true, true, 10) + self.main.show_all + end + + # # Put all values in a hash # def dump_to_hash - @options_required.each do |widget| + @options_standard.each do |widget| name, value = widget.get_pair begin @hash[name] = value @@ -455,7 +465,7 @@ module Msf end if (errors.empty? == false) - MsfDialog::Error.new(self, "Failed to validate : #{errors.join(', ')}") + MsfDialog::Error.new(self, "Failed to validate: #{errors.join(', ')}") false else true diff --git a/lib/msf/ui/gtk2/assistant/skeleton.rb b/lib/msf/ui/gtk2/assistant/skeleton.rb index dd798a4fff..b64fe55766 100644 --- a/lib/msf/ui/gtk2/assistant/skeleton.rb +++ b/lib/msf/ui/gtk2/assistant/skeleton.rb @@ -253,27 +253,24 @@ module Msf # def create_banner - # - # Not use for this moment ... - # - # da = Gtk::DrawingArea.new - # da.set_size_request(600, 60) - # - # # Signal - # da.signal_connect('expose-event') do |widget, event| - # cr = widget.window.create_cairo_context - # cr.scale(*widget.window.size) - # cr.set_line_width(0.04) - # - # cr.new_path - # image = Cairo::ImageSurface.from_png(driver.get_image("banner_assistant.png")) - # cr.scale(1.0 / image.width, 1.0 / image.height) - # cr.set_source(image, 0, 0) - # - # cr.paint - # end + da = Gtk::DrawingArea.new + da.set_size_request(600, 60) - da = Gtk::Image.new(driver.get_image("banner_assistant.png")) + Signal + da.signal_connect('expose-event') do |widget, event| + cr = widget.window.create_cairo_context + cr.scale(*widget.window.size) + cr.set_line_width(0.04) + + cr.new_path + image = Cairo::ImageSurface.from_png(driver.get_image("banner_assistant.png")) + cr.scale(1.0 / image.width, 1.0 / image.height) + cr.set_source(image, 0, 0) + + cr.paint + end + + # da = Gtk::Image.new(driver.get_image("banner_assistant.png")) return da end