validate datastore and source address completion
git-svn-id: file:///home/svn/framework3/trunk@4901 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
dc40c7b68a
commit
49d5cc272c
|
@ -102,6 +102,28 @@ class MsfAssistant
|
|||
|
||||
self.show_all
|
||||
end
|
||||
|
||||
#
|
||||
# Save configuration for MsfAssistant
|
||||
#
|
||||
def save
|
||||
# Save the console config
|
||||
$gtk2driver.save_config(@mydriver.exploit)
|
||||
|
||||
# Save the framework's datastore
|
||||
begin
|
||||
framework.save_config
|
||||
|
||||
if (@mydriver.exploit)
|
||||
@mydriver.exploit.save_config
|
||||
end
|
||||
rescue
|
||||
MsfDialog::Error.new(self, "Failed to save config file")
|
||||
return false
|
||||
end
|
||||
|
||||
$gtk2driver.append_log_view("Saved configuration to: #{Msf::Config.config_file}\n")
|
||||
end
|
||||
|
||||
#
|
||||
# Action when Forward button was clicked
|
||||
|
@ -121,9 +143,10 @@ class MsfAssistant
|
|||
[@label_options], # actual
|
||||
[@label_review] # next
|
||||
)
|
||||
button_forward.set_sensitive(false)
|
||||
display()
|
||||
options_completion()
|
||||
elsif (self.page == "options")
|
||||
elsif (self.page == "options")
|
||||
self.page = "end"
|
||||
refresh_label( [@label_target, @label_payload, @label_options],
|
||||
[@label_review],
|
||||
|
@ -134,6 +157,32 @@ class MsfAssistant
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Validate options in datastore
|
||||
#
|
||||
def validate
|
||||
errors = []
|
||||
@mydriver.exploit.datastore.import_options_from_hash(@hash)
|
||||
|
||||
@mydriver.exploit.options.each_pair do |name, option|
|
||||
if (!option.valid?(@mydriver.exploit.datastore[name]))
|
||||
errors << name
|
||||
|
||||
# If the option is valid, normalize its format to the correct type.
|
||||
elsif ((val = option.normalize(@mydriver.exploit.datastore[name])) != nil)
|
||||
@mydriver.exploit.datastore.update_value(name, val)
|
||||
end
|
||||
end
|
||||
|
||||
if (errors.empty? == false)
|
||||
button_forward.set_sensitive(false)
|
||||
p errors.join(', ')
|
||||
# MsfDialog::Error.new(self, "Failed to validate : #{errors.join(', ')}")
|
||||
else
|
||||
button_forward.set_sensitive(true)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Action when Back button was clicked
|
||||
#
|
||||
|
@ -149,8 +198,8 @@ class MsfAssistant
|
|||
elsif (self.page == "options")
|
||||
self.page = "payload"
|
||||
refresh_label( [@label_target], # historic
|
||||
[@label_payload], # actual
|
||||
[@label_options, @label_review] # next
|
||||
[@label_payload], # actual
|
||||
[@label_options, @label_review] # next
|
||||
)
|
||||
display()
|
||||
payload_completion()
|
||||
|
@ -195,7 +244,6 @@ class MsfAssistant
|
|||
# Signal for combo payload
|
||||
combo_target.signal_connect('changed') do ||
|
||||
@hash["TARGET"] = combo_target.active_iter[1]
|
||||
#@myassistant.set_page_complete(@target_page, true)
|
||||
end
|
||||
|
||||
self.main.pack_start(combo_target, true, false, 0)
|
||||
|
@ -260,6 +308,9 @@ class MsfAssistant
|
|||
# Display options view
|
||||
#
|
||||
def options_completion
|
||||
|
||||
#
|
||||
@button_forward.set_sensitive(false)
|
||||
|
||||
# Clear treeview
|
||||
@model_required.clear
|
||||
|
@ -370,7 +421,11 @@ class MsfAssistant
|
|||
def pack(model, key, opt)
|
||||
iter = model.append
|
||||
iter[KEY] = key
|
||||
iter[DEFAULT] = opt.default.to_s
|
||||
if (key == "LHOST")
|
||||
iter[VALUE] = Rex::Socket.source_address
|
||||
@hash['LHOST'] = Rex::Socket.source_address
|
||||
end
|
||||
iter[DEFAULT] = opt.default.to_s
|
||||
iter[DESC] = opt.desc.to_s
|
||||
end
|
||||
|
||||
|
@ -381,12 +436,14 @@ class MsfAssistant
|
|||
iter = model.get_iter(path)
|
||||
iter[column] = text
|
||||
@hash[iter.get_value(KEY)] = text
|
||||
validate()
|
||||
end
|
||||
|
||||
#
|
||||
# Fire !!
|
||||
#
|
||||
def apply
|
||||
|
||||
# Import options from the supplied assistant
|
||||
@mydriver.exploit.datastore.import_options_from_hash(@hash)
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ class Assistant < Gtk::Window
|
|||
|
||||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
attr_accessor :vbox, :hbox, :main, :page, :bbox, :vbox_left, :vbox_label
|
||||
attr_accessor :vbox, :hbox, :main, :page, :bbox, :vbox_left, :vbox_label, :save_button
|
||||
attr_accessor :button_forward
|
||||
|
||||
def initialize(title)
|
||||
super
|
||||
|
@ -18,6 +19,7 @@ class Assistant < Gtk::Window
|
|||
self.set_default_size(600, 400)
|
||||
self.title = title
|
||||
|
||||
# First page
|
||||
@page = "intro"
|
||||
|
||||
# VBox
|
||||
|
@ -69,15 +71,22 @@ class Assistant < Gtk::Window
|
|||
end
|
||||
|
||||
#
|
||||
# TODO: Add this fun feature
|
||||
# Save configuration for MsfAssistant
|
||||
#
|
||||
def create_save
|
||||
save_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
||||
$gtk2driver.tips.set_tip(save_button, "Save your configuration", nil)
|
||||
save_button.signal_connect('clicked') do
|
||||
MsfDialog::Error.new(self, "Not available")
|
||||
@save_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
||||
$gtk2driver.tips.set_tip(@save_button, "Save your configuration", nil)
|
||||
@save_button.signal_connect('clicked') do
|
||||
save()
|
||||
end
|
||||
return save_button
|
||||
return @save_button
|
||||
end
|
||||
|
||||
#
|
||||
# Dummy function
|
||||
#
|
||||
def save
|
||||
raise NotImplementedError, "Subclass must implement save_config()"
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue