2007-02-04 01:55:01 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Gtk2
|
|
|
|
|
2007-02-04 21:25:10 +00:00
|
|
|
##
|
2007-02-04 01:55:01 +00:00
|
|
|
# This class help us to retreive all glade widgets and place them in your user instance
|
|
|
|
# like @windows, @widget, ...
|
2007-02-04 21:25:10 +00:00
|
|
|
##
|
2007-02-04 01:55:01 +00:00
|
|
|
class MyGlade
|
|
|
|
include Msf::Ui::Gtk2::MyControls
|
|
|
|
|
|
|
|
def initialize(root)
|
|
|
|
# Give the glade file and instance the glade object
|
2007-02-04 19:30:49 +00:00
|
|
|
file_glade = File.join(driver.resource_directory, 'msfgui.glade')
|
2007-02-04 01:55:01 +00:00
|
|
|
glade = GladeXML.new(file_glade, root) { |handler|method(handler) }
|
|
|
|
|
|
|
|
# For all widget names, instance a variable
|
|
|
|
glade.widget_names.each do |name|
|
|
|
|
begin
|
|
|
|
instance_variable_set("@#{name}".intern, glade[name])
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-02-04 21:25:10 +00:00
|
|
|
##
|
|
|
|
# This is the main class
|
|
|
|
##
|
2007-02-04 01:55:01 +00:00
|
|
|
class MyApp < MyGlade
|
|
|
|
|
|
|
|
include Msf::Ui::Gtk2::MyControls
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super('window')
|
|
|
|
|
|
|
|
# Set a default icon for all widgets
|
|
|
|
Gtk::Window.set_default_icon(driver.get_icon('msfwx.xpm'))
|
|
|
|
@window.set_icon(driver.get_icon('msfwx.xpm'))
|
|
|
|
|
|
|
|
# Set a title with the version
|
|
|
|
@window.set_title("MSF Gui v#{Msf::Framework::Version}")
|
|
|
|
|
|
|
|
# Destroy
|
|
|
|
@window.signal_connect('destroy') { Gtk.main_quit }
|
|
|
|
|
|
|
|
# Default size
|
2007-02-04 21:25:10 +00:00
|
|
|
# @window.set_default_size(1024, 768)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Defaults policies for Gtk::ScrolledWindow
|
|
|
|
@scrolledwindow1.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
|
|
@scrolledwindow2.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
|
|
@scrolledwindow3.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
|
|
@scrolledwindow4.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
|
|
@scrolledwindow16.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
|
|
|
|
|
|
# Logs Buffer
|
|
|
|
@buffer = Gtk::TextBuffer.new
|
2007-02-04 21:25:10 +00:00
|
|
|
@viewlogs.set_buffer(@buffer_logs)
|
|
|
|
@viewlogs.set_editable(false)
|
|
|
|
@viewlogs.set_cursor_visible(false)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Sessions Tree
|
2007-02-11 08:57:43 +00:00
|
|
|
@session_tree = MySessionTree.new(@treeview_session)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Target Tree
|
2007-02-11 08:57:43 +00:00
|
|
|
@target_tree = MyTargetTree.new(@treeview2, @session_tree)
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Module Tree
|
2007-02-11 08:57:43 +00:00
|
|
|
@module_tree = MyModuleTree.new(@treeview1, @viewmodule, @target_tree, @session_tree)
|
|
|
|
|
|
|
|
# Configure the window handles for easy reference
|
|
|
|
$gtk2driver.session_tree = @session_tree
|
|
|
|
$gtk2driver.target_tree = @target_tree
|
|
|
|
$gtk2driver.module_tree = @module_tree
|
|
|
|
$gtk2driver.log_text = @viewlogs
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-13 00:22:05 +00:00
|
|
|
# Initialize the search class
|
2007-02-13 09:14:02 +00:00
|
|
|
ModuleSearch.new(@search_entry, @search_button, @search_cancel_button)
|
2007-02-13 00:22:05 +00:00
|
|
|
|
2007-02-13 17:04:16 +00:00
|
|
|
# Focus on the search widget
|
|
|
|
@search_entry.can_focus = true
|
|
|
|
@search_entry.grab_focus
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Update the StatusBar with all framework modules
|
2007-02-04 19:30:49 +00:00
|
|
|
refresh()
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# TODO: Add an hook for binding all links with browser preference
|
|
|
|
# Gtk::AboutDialog.set_url_hook do |about, link|
|
|
|
|
# puts link
|
|
|
|
# end
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 21:25:10 +00:00
|
|
|
#
|
|
|
|
# Signal to refresh the treeview module
|
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
def on_refresh_activate
|
|
|
|
refresh()
|
|
|
|
end
|
2007-02-04 21:25:10 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bye bye
|
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
def on_leave_activate
|
2007-02-04 01:55:01 +00:00
|
|
|
Gtk.main_quit
|
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
|
|
|
def on_payload_activate
|
|
|
|
puts "TODO: Set preferences for the payload choice"
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
2007-02-04 19:30:49 +00:00
|
|
|
|
2007-02-04 21:25:10 +00:00
|
|
|
#
|
|
|
|
# The About Dialog
|
|
|
|
#
|
2007-02-04 01:55:01 +00:00
|
|
|
def on_about_activate
|
|
|
|
MyAbout.new
|
|
|
|
end
|
|
|
|
|
2007-02-04 21:25:10 +00:00
|
|
|
#
|
|
|
|
# Call the refresh method to reload all module
|
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
def refresh
|
|
|
|
@module_tree.refresh
|
2007-02-04 01:55:01 +00:00
|
|
|
context_id = @statusbar.get_context_id("update")
|
|
|
|
@statusbar.push(
|
|
|
|
context_id,
|
|
|
|
"Loaded " +
|
|
|
|
framework.stats.num_exploits.to_s + " exploits, " +
|
|
|
|
framework.stats.num_payloads.to_s + " payloads, " +
|
|
|
|
framework.stats.num_encoders.to_s + " encoders, " +
|
|
|
|
framework.stats.num_nops.to_s + " nops, and " +
|
|
|
|
framework.stats.num_auxiliary.to_s + " auxiliary"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|