update for MsfAssistant

git-svn-id: file:///home/svn/framework3/trunk@4966 4d416f70-5f16-0410-b530-b9f4589650da
unstable
fab 2007-05-26 22:21:40 +00:00
parent 01454f3ae6
commit 6b78c4575d
9 changed files with 159 additions and 132 deletions

View File

@ -99,6 +99,9 @@ module Msf
# Save configuration for MsfAssistant
#
def save
dump_to_hash()
@mydriver.exploit.datastore.import_options_from_hash(@hash, imported = false)
# If payload
@ -303,7 +306,7 @@ module Msf
# Display options view
#
def options_completion
# Expanded frame
@frame_advanced.each do |widget|
@frame_advanced.remove(widget)
@ -321,7 +324,7 @@ module Msf
@options_advanced.each do |widget|
@options_advanced.remove(widget)
end
# Evasion
@options_evasion.each do |widget|
@options_evasion.remove(widget)
@ -331,11 +334,14 @@ module Msf
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)
# Payload options
@mydriver.payload = framework.payloads.create(@hash["PAYLOAD"])
# Pack all options
@mydriver.payload.options.each do |key, opt|
next if (opt.evasion?)
if (opt.required?)
@options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
else
@ -345,25 +351,22 @@ module Msf
# Exploits options
@mydriver.exploit.options.sorted.each do |key, opt|
next if (opt.evasion?)
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
# Evasion options
@mydriver.exploit.options.sorted.each do |key, opt|
if (opt.evasion?)
@options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
end
end
# If backup or save ?
#@options.required
# Display
@frame_advanced.set_label("Advanced")
@frame_advanced.add(@options_advanced)
@frame_evasion.set_label("Evasion")
@ -373,9 +376,9 @@ module Msf
end
#
# Validate options in datastore
# Put all values in a hash
#
def validate
def dump_to_hash
@options_required.each do |widget|
name, value = widget.get_pair
begin
@ -402,6 +405,27 @@ module Msf
end
end
@options_evasion.each do |widget|
name, value = widget.get_pair
begin
if (@mydriver.exploit.options[name].default.to_s == value)
nil
else
@hash[name] = value
end
rescue
nil
end
end
end
#
# Validate options in datastore
#
def validate
dump_to_hash()
errors = []
@mydriver.exploit.datastore.import_options_from_hash(@hash)

View File

@ -212,23 +212,23 @@ module Msf
#
# Options stuff
#
def add_option(key, opt, store="")
def add_option(key, opt, store=nil)
type = opt.type
if (type == "string")
MsfTypes::String.new(key, opt, store)
elsif (type == "raw")
MsfTypes::Raw.new(key, opt)
MsfTypes::Raw.new(key, opt, store)
elsif (type == "bool")
MsfTypes::Bool.new(key, opt)
MsfTypes::Bool.new(key, opt, store)
elsif (type == "port")
MsfTypes::Port.new(key, opt)
MsfTypes::Port.new(key, opt, store)
elsif (type == "address")
MsfTypes::Address.new(key, opt, store)
elsif (type == "path")
MsfTypes::String.new(key, opt, store)
elsif (type == "integer")
MsfTypes::Integer.new(key, opt)
MsfTypes::Int.new(key, opt, store)
elsif (type == "enum")
MsfTypes::String.new(key, opt, store)
elsif (type == "addressrange")

View File

@ -5,39 +5,36 @@ module Msf
class MsfTypes
#
# OptRaw - Multi-byte raw string
# OptAddress - IP address or hostname
#
class Address < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
super()
pack_description(opt.desc.to_s + " :")
pack_address(key, opt.default, store)
super(key, opt, store)
return self
end
#
# Pack OptAddress into an Gtk::Entry
#
#
def pack_address(name, value, store)
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 10)
self.pack_start(hbox, false, false, 0)
@name = name
label = Gtk::Label.new
label.set_markup("<span foreground=\"black\">#{@name} :</span>")
hbox.pack_start(label, false, false, 0)
@entry = Gtk::Entry.new
if (name == "LHOST" and store == "")
@entry.set_text(Rex::Socket.source_address)
elsif (not store == "")
@entry.set_text(store)
# With reverse type payload, prepend the local ip address
# if store not equal "", dump the content into the Gtk::Entry
# or filled it with the default value
if (self.key == "LHOST")
if store
@entry.set_text(store)
else
@entry.set_text(Rex::Socket.source_address)
end
else
@entry.set_text(value)
@entry.set_text(default)
end
@entry.set_width_chars(15)
@entry.set_max_length(15)
@ -45,7 +42,7 @@ module Msf
end
#
#
# Check if an IP address filled the entry ... or not !
#
def check?
if (@entry.text == "")
@ -56,10 +53,10 @@ module Msf
end
#
#
# Return key/value pair
#
def get_pair
return @name, @entry.text
return self.key, @entry.text
end
end

View File

@ -9,42 +9,50 @@ module Msf
#
class Bool < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt)
super()
pack_description(opt.desc.to_s + " :")
pack_bool(key, opt.default)
def initialize(key, opt, store)
super(key, opt, store)
return self
end
#
# Pack OptBool into a Gtk::CheckButton
#
#
def pack_bool(name, value)
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 0)
self.pack_start(hbox, false, false, 0)
@name = name
@checkbutton = Gtk::CheckButton.new(@name, true)
@checkbutton = Gtk::CheckButton.new(self.key)
hbox.pack_start(@checkbutton, true, true, 0)
@checkbutton.set_active(value)
# Define the CheckButton state
if store
if (store.to_s.downcase == "false")
@checkbutton.set_active(false)
else
@checkbutton.set_active(true)
end
elsif
if (default.to_s.downcase == "false")
@checkbutton.set_active(false)
else
@checkbutton.set_active(true)
end
end
end
#
#
# Check if the button is activate ... or not !
#
def check?
return @checkbutton.active?
end
#
#
# Return key/value pair
#
def get_pair
return @name, @checkbutton.active?
return self.key, @checkbutton.active?
end
end

View File

@ -5,43 +5,40 @@ module Msf
class MsfTypes
#
# OptString - Multi-byte character string
# OptInt - An integer value
#
class Integer < Msf::Ui::Gtk2::SkeletonType
class Int < Msf::Ui::Gtk2::SkeletonType
include Msf::Ui::Gtk2::MyControls
def initialize(key, opt)
super()
pack_description(opt.desc.to_s + " :")
pack_integer(key, opt.default.to_s)
def initialize(key, opt, store)
super(key, opt, store)
return self
end
#
# Pack OptInt into an Gtk::Entry
#
#
def pack_integer(name, value)
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 10)
self.pack_start(hbox, false, false, 0)
@name = name
label = Gtk::Label.new
label.set_markup("<span foreground=\"black\">#{@name} :</span>")
hbox.pack_start(label, false, false, 0)
@entry = Gtk::Entry.new
@entry.set_text(value.to_s)
@entry.set_width_chars(15)
@entry.set_max_length(15)
if store
@entry.set_text(store.to_s)
else
@entry.set_text(default.to_s)
end
hbox.pack_start(@entry, false, false, 0)
end
#
#
# Check if the entry is empty ... or not !
#
def check?
if (@entry.text == "")
@ -52,10 +49,10 @@ module Msf
end
#
#
# Return key/value pair
#
def get_pair
return @name, @entry.text
return self.key, @entry.text
end
end
@ -63,6 +60,5 @@ module Msf
end
end
end
end

View File

@ -5,15 +5,12 @@ module Msf
class MsfTypes
#
# OptRaw - Multi-byte raw string
# OptPort - TCP/UDP service port
#
class Port < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt)
super()
pack_description(opt.desc.to_s + " :")
pack_port(key, opt.default)
def initialize(key, opt, store)
super(key, opt, store)
return self
end
@ -21,25 +18,25 @@ module Msf
#
#
#
def pack_port(name, value)
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 10)
self.pack_start(hbox, false, false, 0)
@name = name
label = Gtk::Label.new
label.set_markup("<span foreground=\"black\">#{@name} :</span>")
hbox.pack_start(label, false, false, 0)
@entry = Gtk::Entry.new
@entry.set_text(value.to_s)
@entry.set_width_chars(5)
@entry.set_max_length(5)
if store
@entry.set_text(store.to_s)
else
@entry.set_text(default.to_s)
end
hbox.pack_start(@entry, false, false, 0)
end
#
#
# Check if the entry is empty ... or not !
#
def check?
if (@entry.text == "")
@ -50,10 +47,10 @@ module Msf
end
#
#
# Return the the pair key/value
#
def get_pair
return @name, @entry.text
return self.key, @entry.text
end
end

View File

@ -9,11 +9,8 @@ module Msf
#
class Raw < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt)
super()
pack_description(opt.desc.to_s + " :")
pack_raw(key, opt.default)
def initialize(key, opt, store)
super(key, opt, store)
return self
end
@ -21,40 +18,45 @@ module Msf
#
#
#
def pack_raw(name, value)
def pack_option(default, store)
lock_by_store = nil
lock_by_default = nil
hbox = Gtk::HBox.new(false, 10)
self.pack_start(hbox, false, false, 0)
@name = name
label = Gtk::Label.new
label.set_markup("<span foreground=\"black\">#{@name} :</span>")
hbox.pack_start(label, false, false, 0)
@combo = Gtk::ComboBox.new(true)
exitfunc = ["seh", "thread", "process"]
exitfunc.each_with_index do |val, idx|
@combo.prepend_text(val)
if (val == value)
@combo.set_active(idx)
if (val == store)
lock_by_store = idx
elsif (val == default)
lock_by_default = idx
end
end
if lock_by_store
@combo.set_active(lock_by_store)
else
@combo.set_active(lock_by_default)
end
hbox.pack_start(@combo, false, false, 0)
end
#
#
# Check if an option is activate
#
def check?
return @combo.active
end
#
#
# Return the the pair key/value
#
def get_pair
return @name, @combo.active_text
return self.key, @combo.active_text
end
end
@ -62,6 +64,5 @@ module Msf
end
end
end
end

View File

@ -6,20 +6,35 @@ module Msf
#
#
class SkeletonType < Gtk::VBox
attr_reader :key
def initialize
def initialize(key, opt, store)
super(false, 0)
@key = key
pack_description(opt.desc.to_s)
pack_option(opt.default.to_s, store)
end
#
#
# Pack the description
#
def pack_description(description)
label = Gtk::Label.new
label.set_alignment(0, 1)
label.set_markup("<i>#{description}</i>")
label.set_markup("<b>#{@key}</b> : <i>#{description}</i>")
self.pack_start(label, false, false, 0)
end
#
# Dummy function, must be implemented by the subclass
#
def pack_option(default, store)
raise NotImplementedError, "Subclass must implement pack_option"
end
end

View File

@ -9,37 +9,27 @@ module Msf
#
class String < Msf::Ui::Gtk2::SkeletonType
include Msf::Ui::Gtk2::MyControls
def initialize(key, opt, store)
super()
pack_description(opt.desc.to_s + " :")
pack_string(key, opt.default.to_s, store)
super(key, opt, store)
return self
end
#
# Pack OptString into an Gtk::Entry
#
#
def pack_string(name, value, store)
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 10)
self.pack_start(hbox, false, false, 0)
@name = name
label = Gtk::Label.new
label.set_markup("<span foreground=\"black\">#{@name} :</span>")
hbox.pack_start(label, false, false, 0)
@entry = Gtk::Entry.new
if (store == "")
@entry.set_text(value)
else
if store
@entry.set_text(store)
else
@entry.set_text(default)
end
if (name == "Locale")
if (self.key == "Locale")
@entry.set_width_chars(15)
@entry.set_max_length(15)
hbox.pack_start(@entry, false, false, 0)
@ -49,7 +39,7 @@ module Msf
end
#
#
# Check if the option is empty ... or not !
#
def check?
if (@entry.text == "")
@ -60,15 +50,14 @@ module Msf
end
#
#
# Return the the pair key/value
#
def get_pair
return @name, @entry.text
return self.key, @entry.text
end
end
end
end