Fixes #180. Places all exploit and auxiliary options into a nice scrolling window. Solves a crash when validation fails in the wizard

git-svn-id: file:///home/svn/framework3/trunk@5360 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2008-01-27 02:03:10 +00:00
parent e17f43b9d5
commit c66f8706ef
3 changed files with 212 additions and 172 deletions

View File

@ -46,19 +46,15 @@ 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,6 +89,11 @@ 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
# Evasion
@options_evasion.each do |widget|
@options_evasion.remove(widget)
end
#
# Display options view
#
def options_completion
self.page = "options"
# 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)
# Title and three sets of options
title = Gtk::Label.new
title.set_markup("<big><b>#{@mydriver.exploit.name}</b></big>")
@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)
# 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
# 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
# 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
@frame_advanced.set_label("Advanced")
@frame_advanced.add(@options_advanced)
@frame_evasion.set_label("Evasion")
@frame_evasion.add(@options_evasion)
# 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)
self.main.show_all
end
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)
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 = "<big><b>#{txt}</b></big>"
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 << "<b>#{key}</b> : #{value}\n"
review << "<b>#{key}</b>: #{value}\n"
end
label.set_markup(review)

View File

@ -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("<big><b>#{@mydriver.exploit.name}</b></big>")
@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
# Pack
self.main.pack_start(@options_required, false, false, 10)
# 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
# TODO
#self.main.pack_start(@frame_advanced, false, false, 10)
#self.main.pack_start(@frame_evasion, false, false, 10)
# 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
#scrl = Gtk::ScrolledWindow.new
#scrl.shadow_type = Gtk::SHADOW_NONE
#scrl.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
# 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
#vscr = Gtk::VBox.new
# 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)
#vscr.pack_start(@options_required, false, false, 10)
#vscr.pack_start(@frame_advanced, false, false, 10)
#vscr.pack_start(@frame_evasion, false, false, 10)
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)
#scrl.add_with_viewport(vscr)
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)
#self.main.pack_start(scrl, false, false, 20)
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 = "<big><b>#{txt}</b></big>"
end
# Payload options
@mydriver.payload = framework.payloads.create(@hash["PAYLOAD"])
# Stuff it into a viewport
@viewport.add(@framer)
# 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
# Stuff the viewport into a scrolledwindow
@scroller.add(@viewport)
# 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 this into main and call it done
self.main.pack_start(@scroller, true, true, 10)
self.main.show_all
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
# 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
#
# 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

View File

@ -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