Add comments and cleanup

git-svn-id: file:///home/svn/framework3/trunk@5011 4d416f70-5f16-0410-b530-b9f4589650da
unstable
fab 2007-07-02 15:57:36 +00:00
parent 91f65449aa
commit 7ebcf6413a
17 changed files with 161 additions and 104 deletions

View File

@ -2,16 +2,24 @@ module Msf
module Ui
module Gtk2
###
#
# This class provides the about button
#
###
class MyAbout < Gtk::AboutDialog
include Msf::Ui::Gtk2::MyControls
Gtk::AboutDialog.set_email_hook {|about, link|
# TODO
Gtk::AboutDialog.set_email_hook do |about, link|
puts "Mail to #{link}"
}
Gtk::AboutDialog.set_url_hook {|about, link|
end
# TODO
Gtk::AboutDialog.set_url_hook do |about, link|
puts "Launch a browser to url #{link}"
}
end
def initialize(parent)
super()

View File

@ -2,9 +2,11 @@ module Msf
module Ui
module Gtk2
##
###
#
# This class help us to wait the next release of ruby-libglade2 package
##
#
###
class GladeXML < GladeXML
def connect(source, target, signal, handler, data, after = false)
@handler_proc ||= Proc.new{}
@ -52,11 +54,12 @@ module Msf
end
end
##
###
#
# This class help us to retreive all glade widgets and place them in your user instance
# like @windows, @widget, ...
##
#
###
class MyGlade
include Msf::Ui::Gtk2::MyControls
@ -75,9 +78,11 @@ module Msf
end
end
##
# This is the main class
##
###
#
# This class provides the main window.
#
###
class MyApp < MyGlade
include Msf::Ui::Gtk2::MyControls
@ -246,6 +251,7 @@ module Msf
framework.stats.num_auxiliary.to_s + " auxiliary"
)
end
end
end

View File

@ -2,19 +2,24 @@ module Msf
module Ui
module Gtk2
##
# This class perform an assistant to configure module
##
###
#
# This class provides an assistant to configure module
#
###
class MsfAssistant
###
#
# This class provides an assistant to configure auxiliary module
#
###
class Auxiliary < Msf::Ui::Gtk2::Assistant
# to stock our values
WIZARD2 = {}
WizardStruct2 = Struct.new('Wizard2',
:description, :page,
:options_state, :review_state)
WizardStruct2 = Struct.new('Wizard2', :description, :page, :options_state, :review_state)
ARRAY2 = [
['Options',
@ -34,9 +39,6 @@ module Msf
include Msf::Ui::Gtk2::MyControls
#
# Init
#
def initialize(active_module)
@active_module = active_module
@ -47,16 +49,10 @@ module Msf
super(@active_module.refname)
# Initialize exploit driver's exploit instance
#@mydriver = Msf::ExploitDriver.new(framework)
#@mydriver.exploit = framework.auxiliary.create(@active_module.refname)
@mydriver = $gtk2driver
@mydriver.exploit = framework.auxiliary.create(@active_module.refname)
@mydriver.active_module = @active_module
# Populate the datastore if possible
#@mydriver.exploit.load_config
# Main interface
@frame_advanced = Gtk::Expander.new("Advanced")
@frame_evasion = Gtk::Expander.new("Evasion")
@ -86,7 +82,6 @@ module Msf
# Save configuration for MsfAssistant
#
def save
dump_to_hash()
@mydriver.exploit.datastore.import_options_from_hash(@hash, imported = false)
@ -113,7 +108,6 @@ module Msf
[@label_options], # actual
[@label_review] # next
)
#button_forward.set_sensitive(false)
display()
options_completion()
else
@ -147,7 +141,6 @@ module Msf
# Display options view
#
def options_completion
self.page = "options"
# Expanded frame
@ -254,7 +247,6 @@ module Msf
# Validate options in datastore
#
def validate
dump_to_hash()
errors = []
@ -340,12 +332,11 @@ module Msf
MsfDialog::Error.new(self, "Auxiliary failed", e.to_s)
return false
end
end
end
end
end # MsfAssistant::Auxiliary
end # Auxiliary
end
end

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class provides an assistant to configure module
#
###
class MsfAssistant
##
# This class perform an assistant to configure exploit
##
###
#
# This class perform an assistant to configure and launch exploit
#
###
class Exploit < Msf::Ui::Gtk2::Assistant
# to stock our values
@ -42,9 +49,6 @@ module Msf
include Msf::Ui::Gtk2::MyControls
#
# Init
#
def initialize(active_module)
@active_module = active_module
@session_tree = $gtk2driver.session_tree
@ -60,8 +64,6 @@ module Msf
# Populate the datastore if possible
@mydriver.exploit.load_config
# p @mydriver.exploit.datastore
# Main interface
@frame_advanced = Gtk::Expander.new("Advanced")
@ -98,7 +100,6 @@ module Msf
# Save configuration for MsfAssistant
#
def save
dump_to_hash()
@mydriver.exploit.datastore.import_options_from_hash(@hash, imported = false)
@ -139,7 +140,6 @@ module Msf
[@label_options], # actual
[@label_review] # next
)
#button_forward.set_sensitive(false)
display()
options_completion()
elsif (self.page == "options")
@ -149,7 +149,6 @@ module Msf
[@label_options], # actual
[@label_review] # next
)
#button_forward.set_sensitive(false)
display()
options_completion()
else
@ -266,6 +265,7 @@ module Msf
rescue
combo_all.active = 0
end
# Pack & renderer combo_all
renderer = Gtk::CellRendererText.new
combo_all.pack_start(renderer, true)
@ -332,11 +332,10 @@ module Msf
# Pack
self.main.pack_start(@options_required, false, false, 10)
# Display temporaly desactived
# TODO: Display temporaly desactived
#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"])
@ -370,7 +369,7 @@ module Msf
@options_evasion.pack_start(add_option(key, opt, @mydriver.exploit.datastore[key]), false, false, 10)
end
# Display temporaly desactived
# TODO: Display temporaly desactived
#@frame_advanced.set_label("Advanced")
#@frame_advanced.add(@options_advanced)
#@frame_evasion.set_label("Evasion")
@ -423,7 +422,6 @@ module Msf
# Validate options in datastore
#
def validate
dump_to_hash()
errors = []
@ -440,12 +438,10 @@ module Msf
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
@ -473,7 +469,6 @@ module Msf
# Fire !!
#
def apply
# Import options from the supplied assistant
@mydriver.exploit.datastore.import_options_from_hash(@hash)
@ -487,8 +482,6 @@ module Msf
@mydriver.exploit.init_ui(@pipe, @pipe)
@mydriver.payload.init_ui(@pipe, @pipe)
# Session registration is done by event handler
# XXX: No output from the exploit when this is set!
@mydriver.use_job = true
@pipe.create_subscriber_proc() do |msg|
@ -503,7 +496,6 @@ module Msf
end
end
@pipe.print_status("Launching exploit #{@mydriver.exploit.refname}...")
begin
@ -512,9 +504,10 @@ module Msf
@pipe.print_error("Exploit failed: #{e}")
end
end
end
end
end # MsfAssistant::Exploit
end # Exploit
end
end

View File

@ -3,9 +3,11 @@ module Msf
module Gtk2
##
# This class perform a wizard
##
###
#
# This class provides a skeleton wizard (assitant) to configure the MSF module
#
###
class Assistant < Gtk::Window
include Msf::Ui::Gtk2::MyControls
@ -14,7 +16,7 @@ module Msf
attr_accessor :button_back, :button_forward
def initialize(title)
super
super()
self.resizable = false
self.set_default_size(600, 400)
self.title = title
@ -286,7 +288,8 @@ module Msf
return frame_label
end
end
end # Assistant
end
end

View File

@ -2,9 +2,11 @@ module Msf
module Ui
module Gtk2
###
#
# Subclass the TreeViewTooltips to add our get_tooltip function
#
###
class AssistantTips < Msf::Ui::Gtk2::TreeViewTooltips
def initialize(column)
@ -19,8 +21,8 @@ module Msf
return iter.get_value(3)
end
end
end
end # AssistantTips
end
end

View File

@ -23,5 +23,7 @@ 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'
# TODO
#require 'msf/ui/gtk2/assistant/types/enum'
#require 'msf/ui/gtk2/assistant/types/addressrange'

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptAddress - IP address or hostname
#
###
class Address < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
@ -63,11 +70,10 @@ module Msf
return self.key, @entry.text
end
end
end # MsfTypes::Address
end # MsfTypes
end
end
end
end

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptBool - Boolean true or false indication
#
###
class Bool < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
@ -55,11 +62,10 @@ module Msf
return self.key, @checkbutton.active?
end
end
end # MsfTypes::Bool
end # MSfTypes
end
end
end
end

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptInt - An integer value
#
###
class Int < Msf::Ui::Gtk2::SkeletonType
include Msf::Ui::Gtk2::MyControls
@ -55,9 +62,9 @@ module Msf
return self.key, @entry.text
end
end
end # MSfTypes::Integer
end
end # MsfTypes
end
end

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptPath - Path name on disk
#
###
class Path < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
@ -51,11 +58,10 @@ module Msf
return self.key, @button.filename
end
end
end # MsfTypes::Path
end # MsfTypes
end
end
end
end

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptPort - TCP/UDP service port
#
###
class Port < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
@ -16,7 +23,7 @@ module Msf
end
#
#
# An entry port port
#
def pack_option(default, store)
hbox = Gtk::HBox.new(false, 10)

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptRaw - Multi-byte raw string
#
###
class Raw < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)
@ -16,7 +23,7 @@ module Msf
end
#
#
# Pack a ComboBox to choose between seh, raw and process
#
def pack_option(default, store)
lock_by_store = nil

View File

@ -2,11 +2,18 @@ module Msf
module Ui
module Gtk2
###
#
# This class is dedicated to support all MSF options by a Gtk2 widget
#
###
class MsfTypes
###
#
# OptString - Multi-byte character string
#
###
class String < Msf::Ui::Gtk2::SkeletonType
def initialize(key, opt, store)

View File

@ -4,38 +4,38 @@ module Msf
class Console
###
#
# Classic console herited from Gtk::Window
# Classic console herited from SkeletonConsole
#
###
class Shell < Msf::Ui::Gtk2::SkeletonConsole
def initialize(iter)
super(iter)
end
end # Shell
end # Console::Shell
###
#
# Meterpreter Console
# Meterpreter Console herited from SkeletonConsole
#
###
class Meterpreter < Msf::Ui::Gtk2::SkeletonConsole
def initialize(iter)
def initialize(iter)
# meterpreter client
client = iter[3]
# call the parent
super(iter)
# Not sexy
# TODO: use the API
# TODO: use the API instead writing into the pipe
send_cmd("execute -f cmd.exe -i -H")
end
end # Meterpreter
end # Console::Meterpreter
end # Console

View File

@ -2,6 +2,11 @@ module Msf
module Ui
module Gtk2
###
#
# This class perform the sessions display
#
###
class MySessionTree
ID_SESSION, PEER, TYPE, O_SESSION, O_BUFFER = *(0..5).to_a

View File

@ -133,19 +133,20 @@ module Msf
end
# Go through each source item and upload them
src_items.each { |src|
src_items.each do |src|
stat = ::File.stat(src)
if (stat.directory?)
@client.fs.dir.upload(dest, src, recursive) { |step, src, dst|
@client.fs.dir.upload(dest, src, recursive) do |step, src, dst|
$gtk2driver.append_log_view("#{step.ljust(11)}: #{src} -> #{dst}\n")
}
elsif (stat.file?)
@client.fs.file.upload(dest, src) { |step, src, dst|
$gtk2driver.append_log_view("#{step.ljust(11)}: #{src} -> #{dst}\n")
}
end
}
elsif (stat.file?)
@client.fs.file.upload(dest, src) do |step, src, dst|
$gtk2driver.append_log_view("#{step.ljust(11)}: #{src} -> #{dst}\n")
end
end
end
rescue ::Exception => e
MsfDialog::Warning.new(self, "Upload: Operation failed", e.to_s)
end