validate datastore and source address completion
git-svn-id: file:///home/svn/framework3/trunk@4901 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
dc40c7b68a
commit
49d5cc272c
|
@ -102,6 +102,28 @@ class MsfAssistant
|
||||||
|
|
||||||
self.show_all
|
self.show_all
|
||||||
end
|
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
|
# Action when Forward button was clicked
|
||||||
|
@ -121,9 +143,10 @@ class MsfAssistant
|
||||||
[@label_options], # actual
|
[@label_options], # actual
|
||||||
[@label_review] # next
|
[@label_review] # next
|
||||||
)
|
)
|
||||||
|
button_forward.set_sensitive(false)
|
||||||
display()
|
display()
|
||||||
options_completion()
|
options_completion()
|
||||||
elsif (self.page == "options")
|
elsif (self.page == "options")
|
||||||
self.page = "end"
|
self.page = "end"
|
||||||
refresh_label( [@label_target, @label_payload, @label_options],
|
refresh_label( [@label_target, @label_payload, @label_options],
|
||||||
[@label_review],
|
[@label_review],
|
||||||
|
@ -134,6 +157,32 @@ class MsfAssistant
|
||||||
end
|
end
|
||||||
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
|
# Action when Back button was clicked
|
||||||
#
|
#
|
||||||
|
@ -149,8 +198,8 @@ class MsfAssistant
|
||||||
elsif (self.page == "options")
|
elsif (self.page == "options")
|
||||||
self.page = "payload"
|
self.page = "payload"
|
||||||
refresh_label( [@label_target], # historic
|
refresh_label( [@label_target], # historic
|
||||||
[@label_payload], # actual
|
[@label_payload], # actual
|
||||||
[@label_options, @label_review] # next
|
[@label_options, @label_review] # next
|
||||||
)
|
)
|
||||||
display()
|
display()
|
||||||
payload_completion()
|
payload_completion()
|
||||||
|
@ -195,7 +244,6 @@ class MsfAssistant
|
||||||
# Signal for combo payload
|
# Signal for combo payload
|
||||||
combo_target.signal_connect('changed') do ||
|
combo_target.signal_connect('changed') do ||
|
||||||
@hash["TARGET"] = combo_target.active_iter[1]
|
@hash["TARGET"] = combo_target.active_iter[1]
|
||||||
#@myassistant.set_page_complete(@target_page, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.main.pack_start(combo_target, true, false, 0)
|
self.main.pack_start(combo_target, true, false, 0)
|
||||||
|
@ -260,6 +308,9 @@ class MsfAssistant
|
||||||
# Display options view
|
# Display options view
|
||||||
#
|
#
|
||||||
def options_completion
|
def options_completion
|
||||||
|
|
||||||
|
#
|
||||||
|
@button_forward.set_sensitive(false)
|
||||||
|
|
||||||
# Clear treeview
|
# Clear treeview
|
||||||
@model_required.clear
|
@model_required.clear
|
||||||
|
@ -370,7 +421,11 @@ class MsfAssistant
|
||||||
def pack(model, key, opt)
|
def pack(model, key, opt)
|
||||||
iter = model.append
|
iter = model.append
|
||||||
iter[KEY] = key
|
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
|
iter[DESC] = opt.desc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -381,12 +436,14 @@ class MsfAssistant
|
||||||
iter = model.get_iter(path)
|
iter = model.get_iter(path)
|
||||||
iter[column] = text
|
iter[column] = text
|
||||||
@hash[iter.get_value(KEY)] = text
|
@hash[iter.get_value(KEY)] = text
|
||||||
|
validate()
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fire !!
|
# Fire !!
|
||||||
#
|
#
|
||||||
def apply
|
def apply
|
||||||
|
|
||||||
# Import options from the supplied assistant
|
# Import options from the supplied assistant
|
||||||
@mydriver.exploit.datastore.import_options_from_hash(@hash)
|
@mydriver.exploit.datastore.import_options_from_hash(@hash)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ class Assistant < Gtk::Window
|
||||||
|
|
||||||
include Msf::Ui::Gtk2::MyControls
|
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)
|
def initialize(title)
|
||||||
super
|
super
|
||||||
|
@ -18,6 +19,7 @@ class Assistant < Gtk::Window
|
||||||
self.set_default_size(600, 400)
|
self.set_default_size(600, 400)
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
|
# First page
|
||||||
@page = "intro"
|
@page = "intro"
|
||||||
|
|
||||||
# VBox
|
# VBox
|
||||||
|
@ -69,15 +71,22 @@ class Assistant < Gtk::Window
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# TODO: Add this fun feature
|
# Save configuration for MsfAssistant
|
||||||
#
|
#
|
||||||
def create_save
|
def create_save
|
||||||
save_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
@save_button = Gtk::Button.new(Gtk::Stock::SAVE)
|
||||||
$gtk2driver.tips.set_tip(save_button, "Save your configuration", nil)
|
$gtk2driver.tips.set_tip(@save_button, "Save your configuration", nil)
|
||||||
save_button.signal_connect('clicked') do
|
@save_button.signal_connect('clicked') do
|
||||||
MsfDialog::Error.new(self, "Not available")
|
save()
|
||||||
end
|
end
|
||||||
return save_button
|
return @save_button
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dummy function
|
||||||
|
#
|
||||||
|
def save
|
||||||
|
raise NotImplementedError, "Subclass must implement save_config()"
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue