new release for msfassistant
git-svn-id: file:///home/svn/framework3/trunk@4965 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
0f70d5bdb0
commit
01454f3ae6
Binary file not shown.
After Width: | Height: | Size: 789 B |
|
@ -1,3 +1,4 @@
|
|||
require 'msf/ui/gtk2/assistant/skeleton'
|
||||
require 'msf/ui/gtk2/assistant/types'
|
||||
require 'msf/ui/gtk2/assistant/tips'
|
||||
require 'msf/ui/gtk2/assistant/exploit'
|
||||
|
|
|
@ -65,8 +65,13 @@ module Msf
|
|||
|
||||
|
||||
# Main interface
|
||||
@model_required = Gtk::ListStore.new(String, String, String, String)
|
||||
@model_advanced = Gtk::ListStore.new(String, String, String, String)
|
||||
@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)
|
||||
|
||||
# Begin the wizard
|
||||
target_completion()
|
||||
|
||||
# Build the left frame
|
||||
|
@ -95,14 +100,14 @@ module Msf
|
|||
#
|
||||
def save
|
||||
@mydriver.exploit.datastore.import_options_from_hash(@hash, imported = false)
|
||||
|
||||
|
||||
# If payload
|
||||
begin
|
||||
@mydriver.payload.share_datastore(@mydriver.exploit.datastore)
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
# TODO: choose the $gtk2driver or @mydriver.exploit ?
|
||||
$gtk2driver.active_module = @mydriver.exploit
|
||||
$gtk2driver.save_config
|
||||
|
@ -132,43 +137,29 @@ module Msf
|
|||
[@label_options], # actual
|
||||
[@label_review] # next
|
||||
)
|
||||
button_forward.set_sensitive(false)
|
||||
#button_forward.set_sensitive(false)
|
||||
display()
|
||||
options_completion()
|
||||
elsif (self.page == "options")
|
||||
self.page = "end"
|
||||
refresh_label( [@label_target, @label_payload, @label_options],
|
||||
[@label_review],
|
||||
nil
|
||||
)
|
||||
display()
|
||||
review_completion()
|
||||
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)
|
||||
if not validate()
|
||||
self.page = "options"
|
||||
refresh_label( [@label_target, @label_payload], # historic
|
||||
[@label_options], # actual
|
||||
[@label_review] # next
|
||||
)
|
||||
#button_forward.set_sensitive(false)
|
||||
display()
|
||||
options_completion()
|
||||
else
|
||||
self.page = "end"
|
||||
refresh_label( [@label_target, @label_payload, @label_options],
|
||||
[@label_review],
|
||||
nil
|
||||
)
|
||||
display()
|
||||
review_completion()
|
||||
end
|
||||
end
|
||||
|
||||
if (errors.empty? == false)
|
||||
button_forward.set_sensitive(false)
|
||||
# MsfDialog::Error.new(self, "Failed to validate : #{errors.join(', ')}")
|
||||
else
|
||||
button_forward.set_sensitive(true)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -312,32 +303,43 @@ module Msf
|
|||
# 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
|
||||
|
||||
#
|
||||
@button_forward.set_sensitive(false)
|
||||
# Required
|
||||
@options_required.each do |widget|
|
||||
@options_required.remove(widget)
|
||||
end
|
||||
|
||||
# Clear treeview
|
||||
@model_required.clear
|
||||
@model_advanced.clear
|
||||
# Advanced
|
||||
@options_advanced.each do |widget|
|
||||
@options_advanced.remove(widget)
|
||||
end
|
||||
|
||||
# Evasion
|
||||
@options_evasion.each do |widget|
|
||||
@options_evasion.remove(widget)
|
||||
end
|
||||
|
||||
# An expander view for advanced options
|
||||
frame_advanced = Gtk::Expander.new('Advanced')
|
||||
|
||||
# TreeView
|
||||
@treeview_required = Gtk::TreeView.new(@model_required)
|
||||
@treeview_advanced = Gtk::TreeView.new(@model_advanced)
|
||||
|
||||
# Column
|
||||
add_columns(@treeview_required, @model_required)
|
||||
add_columns(@treeview_advanced, @model_advanced)
|
||||
# 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)
|
||||
|
||||
|
||||
# Payload options
|
||||
@mydriver.payload = framework.payloads.create(@hash["PAYLOAD"])
|
||||
@mydriver.payload.options.each do |key, opt|
|
||||
if (opt.required?)
|
||||
pack(@model_required, key, opt, @mydriver.exploit.datastore[key])
|
||||
@options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
|
||||
else
|
||||
pack(@model_advanced, key, opt, @mydriver.exploit.datastore[key])
|
||||
@options_advanced.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -345,18 +347,82 @@ module Msf
|
|||
@mydriver.exploit.options.sorted.each do |key, opt|
|
||||
next if (opt.evasion?)
|
||||
if (opt.required?)
|
||||
pack(@model_required, key, opt, @mydriver.exploit.datastore[key])
|
||||
@options_required.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
|
||||
else
|
||||
pack(@model_advanced, key, opt, @mydriver.exploit.datastore[key])
|
||||
@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
|
||||
|
||||
@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
|
||||
|
||||
#
|
||||
# Validate options in datastore
|
||||
#
|
||||
def validate
|
||||
@options_required.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
|
||||
|
||||
# add treeview to frame
|
||||
self.main.pack_start(@treeview_required, false, false, 0)
|
||||
self.main.pack_start(frame_advanced, false, false, 10)
|
||||
frame_advanced.add(@treeview_advanced)
|
||||
@options_advanced.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
|
||||
|
||||
self.main.show_all
|
||||
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)
|
||||
MsfDialog::Error.new(self, "Failed to validate : #{errors.join(', ')}")
|
||||
false
|
||||
else
|
||||
true
|
||||
#button_forward.set_sensitive(true)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -379,82 +445,6 @@ module Msf
|
|||
self.main.show_all
|
||||
end
|
||||
|
||||
#
|
||||
# Add column and tips
|
||||
#
|
||||
def add_columns(treeview, model)
|
||||
# column for KEY
|
||||
renderer = Gtk::CellRendererText.new
|
||||
column = Gtk::TreeViewColumn.new('Name',
|
||||
renderer,
|
||||
'text' => KEY)
|
||||
column.set_sort_column_id(KEY)
|
||||
treeview.append_column(column)
|
||||
|
||||
# column for DEFAULT
|
||||
renderer = Gtk::CellRendererText.new
|
||||
column = Gtk::TreeViewColumn.new('Default',
|
||||
renderer,
|
||||
'text' => DEFAULT)
|
||||
column.set_sort_column_id(DEFAULT)
|
||||
treeview.append_column(column)
|
||||
|
||||
# column for VALUE
|
||||
renderer = Gtk::CellRendererText.new
|
||||
renderer.background = "#f6ffd6"
|
||||
renderer.editable = true
|
||||
renderer.signal_connect("edited") do |rend, path, text|
|
||||
updatevalue(model, VALUE, path, text)
|
||||
end
|
||||
column = Gtk::TreeViewColumn.new('Value',
|
||||
renderer,
|
||||
'text' => VALUE)
|
||||
column.set_sort_column_id(VALUE)
|
||||
column.set_resizable(true)
|
||||
column.set_min_width(100)
|
||||
treeview.append_column(column)
|
||||
|
||||
# Init tips on the treeview
|
||||
tips = AssistantTips.new(column)
|
||||
tips.add_view(@treeview_required)
|
||||
tips.add_view(@treeview_advanced)
|
||||
end
|
||||
|
||||
#
|
||||
# Display values on the treeview
|
||||
#
|
||||
def pack(model, key, opt, value = "")
|
||||
default = ""
|
||||
if (opt.default.to_s.length > 50)
|
||||
size = opt.default.to_s.length
|
||||
default = "[...]" + opt.default.to_s[size - 27, size]
|
||||
else
|
||||
default = opt.default.to_s
|
||||
end
|
||||
iter = model.append
|
||||
iter[KEY] = key
|
||||
iter[DEFAULT] = default
|
||||
iter[DESC] = opt.desc.to_s
|
||||
if (key == "LHOST" and value == "")
|
||||
iter[VALUE] = Rex::Socket.source_address
|
||||
@hash['LHOST'] = Rex::Socket.source_address
|
||||
else
|
||||
iter[VALUE] = value.to_s
|
||||
@hash['LHOST'] = value
|
||||
end
|
||||
validate()
|
||||
end
|
||||
|
||||
#
|
||||
# Update changing value
|
||||
#
|
||||
def updatevalue(model, column, path, text)
|
||||
iter = model.get_iter(path)
|
||||
iter[column] = text
|
||||
@hash[iter.get_value(KEY)] = text
|
||||
validate()
|
||||
end
|
||||
|
||||
#
|
||||
# Fire !!
|
||||
#
|
||||
|
|
|
@ -11,7 +11,7 @@ module Msf
|
|||
include Msf::Ui::Gtk2::MyControls
|
||||
|
||||
attr_accessor :vbox, :hbox, :main, :page, :bbox, :vbox_left, :vbox_label, :save_button
|
||||
attr_accessor :button_forward
|
||||
attr_accessor :button_back, :button_forward, :option_state
|
||||
|
||||
def initialize(title)
|
||||
super
|
||||
|
@ -32,6 +32,9 @@ module Msf
|
|||
# HBox
|
||||
@hbox = Gtk::HBox.new(false, 10)
|
||||
@vbox.pack_start(@hbox, true, false, 0)
|
||||
|
||||
# Option state
|
||||
@option_state = true
|
||||
|
||||
# Left frame
|
||||
@vbox_left = Gtk::VBox.new(false, 5)
|
||||
|
@ -120,7 +123,7 @@ module Msf
|
|||
if state
|
||||
label.set_markup("<span foreground=\"black\"><b>#{text}</b></span>")
|
||||
else
|
||||
label.set_markup("<span foreground=\"#C0C0C0\">#{text}</span>")
|
||||
label.set_markup("<span foreground=\"white\">#{text}</span>")
|
||||
end
|
||||
return label
|
||||
end
|
||||
|
@ -191,7 +194,7 @@ module Msf
|
|||
def refresh_label(hist, actual , nex)
|
||||
if not (hist == nil)
|
||||
hist.each do |label|
|
||||
label.set_markup("<span foreground=\"white\"><i>#{label.text}</i></span>")
|
||||
label.set_markup("<span foreground=\"black\"><i>#{label.text}</i></span>")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,11 +204,46 @@ module Msf
|
|||
|
||||
if not (nex == nil)
|
||||
nex.each do |label|
|
||||
label.set_markup("<span foreground=\"#C0C0C0\"><b>#{label.text}</b></span>")
|
||||
label.set_markup("<span foreground=\"white\">#{label.text}</span>")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Options stuff
|
||||
#
|
||||
def add_option(key, opt, store="")
|
||||
type = opt.type
|
||||
|
||||
if (type == "string")
|
||||
MsfTypes::String.new(key, opt, store)
|
||||
elsif (type == "raw")
|
||||
MsfTypes::Raw.new(key, opt)
|
||||
elsif (type == "bool")
|
||||
MsfTypes::Bool.new(key, opt)
|
||||
elsif (type == "port")
|
||||
MsfTypes::Port.new(key, opt)
|
||||
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)
|
||||
elsif (type == "enum")
|
||||
MsfTypes::String.new(key, opt, store)
|
||||
elsif (type == "addressrange")
|
||||
MsfTypes::String.new(key, opt, store)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Dummy function
|
||||
#
|
||||
def options_validate
|
||||
raise NotImplementedError, "Subclass must implement options_validate"
|
||||
end
|
||||
|
||||
|
||||
#########
|
||||
private #
|
||||
#########
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
###
|
||||
#
|
||||
# Core option types. The core supported option types are:
|
||||
#
|
||||
# OptString - Multi-byte character string
|
||||
# OptRaw - Multi-byte raw string
|
||||
# OptBool - Boolean true or false indication
|
||||
# OptPort - TCP/UDP service port
|
||||
# OptAddress - IP address or hostname
|
||||
# OptPath - Path name on disk
|
||||
# OptInt - An integer value
|
||||
# OptEnum - Select from a set of valid values
|
||||
# OptAddressRange - A subnet or range of addresses
|
||||
#
|
||||
###
|
||||
|
||||
require 'msf/ui/gtk2/assistant/types/skeleton'
|
||||
|
||||
require 'msf/ui/gtk2/assistant/types/string'
|
||||
require 'msf/ui/gtk2/assistant/types/raw'
|
||||
require 'msf/ui/gtk2/assistant/types/bool'
|
||||
require 'msf/ui/gtk2/assistant/types/port'
|
||||
require 'msf/ui/gtk2/assistant/types/address'
|
||||
#require 'msf/ui/gtk2/assistant/types/path'
|
||||
require 'msf/ui/gtk2/assistant/types/integer'
|
||||
#require 'msf/ui/gtk2/assistant/types/enum'
|
||||
#require 'msf/ui/gtk2/assistant/types/addressrange'
|
|
@ -0,0 +1,72 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptRaw - Multi-byte raw string
|
||||
#
|
||||
class Address < Msf::Ui::Gtk2::SkeletonType
|
||||
|
||||
def initialize(key, opt, store)
|
||||
super()
|
||||
|
||||
pack_description(opt.desc.to_s + " :")
|
||||
pack_address(key, opt.default, store)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_address(name, value, 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)
|
||||
else
|
||||
@entry.set_text(value)
|
||||
end
|
||||
@entry.set_width_chars(15)
|
||||
@entry.set_max_length(15)
|
||||
hbox.pack_start(@entry, false, false, 0)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
if (@entry.text == "")
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @entry.text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,57 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptBool - Boolean true or false indication
|
||||
#
|
||||
class Bool < Msf::Ui::Gtk2::SkeletonType
|
||||
|
||||
def initialize(key, opt)
|
||||
super()
|
||||
|
||||
pack_description(opt.desc.to_s + " :")
|
||||
pack_bool(key, opt.default)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_bool(name, value)
|
||||
hbox = Gtk::HBox.new(false, 0)
|
||||
self.pack_start(hbox, false, false, 0)
|
||||
|
||||
@name = name
|
||||
|
||||
@checkbutton = Gtk::CheckButton.new(@name, true)
|
||||
hbox.pack_start(@checkbutton, true, true, 0)
|
||||
|
||||
@checkbutton.set_active(value)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
return @checkbutton.active?
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @checkbutton.active?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,68 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptString - Multi-byte character string
|
||||
#
|
||||
class Integer < 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)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_integer(name, value)
|
||||
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)
|
||||
hbox.pack_start(@entry, false, false, 0)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
if (@entry.text == "")
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @entry.text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,66 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptRaw - Multi-byte raw string
|
||||
#
|
||||
class Port < Msf::Ui::Gtk2::SkeletonType
|
||||
|
||||
def initialize(key, opt)
|
||||
super()
|
||||
|
||||
pack_description(opt.desc.to_s + " :")
|
||||
pack_port(key, opt.default)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_port(name, value)
|
||||
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)
|
||||
hbox.pack_start(@entry, false, false, 0)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
if (@entry.text == "")
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @entry.text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,67 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptRaw - Multi-byte raw string
|
||||
#
|
||||
class Raw < Msf::Ui::Gtk2::SkeletonType
|
||||
|
||||
def initialize(key, opt)
|
||||
super()
|
||||
|
||||
pack_description(opt.desc.to_s + " :")
|
||||
pack_raw(key, opt.default)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_raw(name, value)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
hbox.pack_start(@combo, false, false, 0)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
return @combo.active
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @combo.active_text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
class SkeletonType < Gtk::VBox
|
||||
|
||||
def initialize
|
||||
super(false, 0)
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_description(description)
|
||||
label = Gtk::Label.new
|
||||
label.set_alignment(0, 1)
|
||||
label.set_markup("<i>#{description}</i>")
|
||||
self.pack_start(label, false, false, 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,76 @@
|
|||
module Msf
|
||||
module Ui
|
||||
module Gtk2
|
||||
|
||||
class MsfTypes
|
||||
|
||||
#
|
||||
# OptString - Multi-byte character string
|
||||
#
|
||||
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)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def pack_string(name, value, 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
|
||||
@entry.set_text(store)
|
||||
end
|
||||
if (name == "Locale")
|
||||
@entry.set_width_chars(15)
|
||||
@entry.set_max_length(15)
|
||||
hbox.pack_start(@entry, false, false, 0)
|
||||
else
|
||||
hbox.pack_start(@entry, true, true, 0)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def check?
|
||||
if (@entry.text == "")
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
def get_pair
|
||||
return @name, @entry.text
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -29,10 +29,11 @@ module Msf
|
|||
#
|
||||
###
|
||||
class Driver < Msf::Ui::Driver
|
||||
|
||||
|
||||
# main view
|
||||
attr_accessor :session_tree, :module_tree, :job_tree, :log_text, :module_model
|
||||
attr_accessor :module_completion, :main, :tips
|
||||
|
||||
|
||||
include Msf::Ui::Gtk2::FrameworkEventManager
|
||||
|
||||
ConfigCore = "framework/core"
|
||||
|
|
|
@ -117,7 +117,7 @@ module Msf
|
|||
if (type == "Standard")
|
||||
MsfAssistant::Exploit.new(active_module.get_value(MODULE))
|
||||
elsif (type == "Payloads")
|
||||
MsfAssistant::Payload.new(active_module.get_value(MODULE))
|
||||
MsfDialog::Error.new($gtk2driver.main, "Not available")
|
||||
else
|
||||
MsfDialog::Error.new($gtk2driver.main, "Not available")
|
||||
end
|
||||
|
|
|
@ -20,18 +20,21 @@ module Msf
|
|||
@client = client
|
||||
|
||||
# call the parent
|
||||
super("MsfBrowser on #{@client.tunnel_peer}")
|
||||
super("File Browser on #{@client.tunnel_peer}")
|
||||
|
||||
# Define the models (navigation, view)
|
||||
# TODO: model for navigation
|
||||
@model_view = Gtk::ListStore.new(String, String, TrueClass, Gdk::Pixbuf)
|
||||
@model_local = Gtk::TreeStore.new(String, String, TrueClass, Gdk::Pixbuf)
|
||||
|
||||
# Define the parent the parent
|
||||
# Define thes parents
|
||||
@parent = "/"
|
||||
@parent_local = "/"
|
||||
|
||||
# Define the icons for folders and files
|
||||
@file_pixbuf = Gdk::Pixbuf.new(driver.get_image("msf_file.png"))
|
||||
@folder_pixbuf = Gdk::Pixbuf.new(driver.get_image("msf_folder.png"))
|
||||
@local_folder_pixbuf = Gdk::Pixbuf.new(driver.get_image("msf_local_folder.png"))
|
||||
|
||||
@model_view.set_default_sort_func do |a, b|
|
||||
if !a[COL_IS_DIR] and b[COL_IS_DIR]
|
||||
|
@ -58,6 +61,25 @@ module Msf
|
|||
hbox.pack_start(vbox_left, false, false, 0)
|
||||
hbox.pack_start(vbox_right, true, true, 0)
|
||||
|
||||
# Local
|
||||
@treeview_local = Gtk::TreeView.new(@model_local)
|
||||
vbox_left.pack_start(@treeview_local, true, true, 0)
|
||||
renderer_pix = Gtk::CellRendererPixbuf.new
|
||||
renderer_name = Gtk::CellRendererText.new
|
||||
|
||||
column_name = Gtk::TreeViewColumn.new
|
||||
column_name.pack_start(renderer_pix, false)
|
||||
column_name.set_cell_data_func(renderer_pix) do |column, cell, model, iter|
|
||||
cell.pixbuf = iter[COL_PIXBUF]
|
||||
end
|
||||
column_name.pack_start(renderer_name, true)
|
||||
column_name.set_cell_data_func(renderer_name) do |column, cell, model, iter|
|
||||
cell.text = iter[COL_DISPLAY_NAME]
|
||||
end
|
||||
@treeview_local.append_column(column_name)
|
||||
|
||||
# Remote
|
||||
|
||||
# Label, Entry and Signal for the path selection
|
||||
hbox_path = Gtk::HBox.new(false, 0)
|
||||
vbox_right.pack_start(hbox_path, false, true, 0)
|
||||
|
@ -88,6 +110,7 @@ module Msf
|
|||
end
|
||||
|
||||
# Populate the view
|
||||
local_ls
|
||||
cmd_ls
|
||||
|
||||
sw.add(iconview)
|
||||
|
@ -100,6 +123,7 @@ module Msf
|
|||
# Lists file on the remote machine
|
||||
#
|
||||
def cmd_ls(*args)
|
||||
# Try to list the remote path
|
||||
begin
|
||||
# Just ignore the invalid UTF8
|
||||
# Don't know why GLib.filename_to_utf8() don't work ;-(
|
||||
|
@ -123,12 +147,25 @@ module Msf
|
|||
iter[COL_IS_DIR] = is_dir
|
||||
iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf
|
||||
end
|
||||
# If not possible return a *warning***
|
||||
rescue
|
||||
MsfDialog::Warning.new(self, "No entries exist in #{path}")
|
||||
cmd_ls
|
||||
end
|
||||
end # cmd_ls
|
||||
|
||||
def local_ls(*args)
|
||||
Dir.glob(File.join(@parent_local, "*")).each do |path|
|
||||
if FileTest.directory?(path)
|
||||
iter = @model_local.append(nil)
|
||||
iter[COL_DISPLAY_NAME] = GLib.filename_to_utf8(File.basename(path))
|
||||
iter[COL_PATH] = path
|
||||
iter[COL_IS_DIR] = true
|
||||
iter[COL_PIXBUF] = @local_folder_pixbuf
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end # Fs
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue