2007-02-04 01:55:01 +00:00
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui'
|
|
|
|
|
|
|
|
require 'msf/ui/gtk2/controls'
|
|
|
|
require 'msf/ui/gtk2/app'
|
|
|
|
require 'msf/ui/gtk2/about'
|
|
|
|
require 'msf/ui/gtk2/frame'
|
|
|
|
require 'msf/ui/gtk2/dialogs'
|
2007-03-01 22:09:01 +00:00
|
|
|
require 'msf/ui/gtk2/console'
|
2007-02-04 21:25:10 +00:00
|
|
|
require 'msf/ui/gtk2/view'
|
2007-02-13 00:22:05 +00:00
|
|
|
require 'msf/ui/gtk2/search'
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-11 08:57:43 +00:00
|
|
|
require 'msf/ui/gtk2/framework_event_manager'
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Gtk2
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements a user interface driver on a gtk2 interface.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Driver < Msf::Ui::Driver
|
|
|
|
|
2007-02-26 23:19:59 +00:00
|
|
|
attr_accessor :session_tree, :module_tree, :job_tree, :log_text, :module_model
|
2007-02-15 22:09:24 +00:00
|
|
|
attr_accessor :module_completion
|
2007-02-11 08:57:43 +00:00
|
|
|
|
|
|
|
include Msf::Ui::Gtk2::FrameworkEventManager
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
ConfigCore = "framework/core"
|
|
|
|
ConfigGroup = "framework/ui/gtk2"
|
2007-02-04 21:49:40 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
# The default resource directory for msfgui
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
2007-02-04 19:30:49 +00:00
|
|
|
DefaultResourceDirectory = Msf::Config.data_directory + File::SEPARATOR + "msfgui"
|
2007-02-04 21:49:40 +00:00
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
|
|
|
# Initializes a gtk2 driver instance
|
|
|
|
#
|
|
|
|
def initialize(opts = {})
|
|
|
|
# Call the parent
|
|
|
|
super()
|
|
|
|
|
|
|
|
# Set the passed options hash for referencing later on.
|
|
|
|
self.opts = opts
|
|
|
|
|
|
|
|
# Initialize configuration
|
|
|
|
Msf::Config.init
|
|
|
|
|
|
|
|
# Initialize logging
|
|
|
|
initialize_logging
|
|
|
|
|
|
|
|
# Initialize attributes
|
|
|
|
self.framework = Msf::Simple::Framework.create
|
|
|
|
|
|
|
|
# Create the gtk2driver global
|
|
|
|
$gtk2driver = self
|
|
|
|
|
|
|
|
# Init GTK2
|
|
|
|
Gtk.init
|
|
|
|
|
|
|
|
# Initialize the Gtk2 application object
|
|
|
|
@gtk2app = Msf::Ui::Gtk2::MyApp.new()
|
2007-02-11 08:57:43 +00:00
|
|
|
|
|
|
|
# Register event handlers
|
|
|
|
register_event_handlers
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Starts the main gtk2 loop
|
|
|
|
#
|
|
|
|
def run
|
2007-02-04 19:30:49 +00:00
|
|
|
ilog("msfgui has been started", LogSource)
|
2007-02-04 01:55:01 +00:00
|
|
|
Gtk.main
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the local directory that will hold the files to be serviced.
|
|
|
|
#
|
|
|
|
def resource_directory
|
|
|
|
opts['ResourceDirectory'] || DefaultResourceDirectory
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2007-02-06 21:43:06 +00:00
|
|
|
# Returns a new Gdk::Pixbuf object
|
2007-02-04 01:55:01 +00:00
|
|
|
#
|
|
|
|
def get_icon(name)
|
|
|
|
Gdk::Pixbuf.new(File.join(resource_directory, 'pix', name))
|
|
|
|
end
|
2007-02-11 08:57:43 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Adds text to the main logging screen
|
|
|
|
#
|
|
|
|
def append_log_view(data)
|
|
|
|
|
|
|
|
data = Time.now.strftime("%H:%m:%S") + " " + data
|
|
|
|
|
|
|
|
return if not self.log_text
|
|
|
|
|
|
|
|
view = self.log_text
|
|
|
|
buff = view.buffer
|
|
|
|
|
|
|
|
if (not buff.get_mark('end_mark'))
|
|
|
|
buff.create_mark('end_mark', buff.end_iter, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
buff.insert(buff.end_iter, Rex::Text.to_utf8(data))
|
|
|
|
buff.move_mark('end_mark', buff.end_iter)
|
|
|
|
view.scroll_mark_onscreen(buff.get_mark('end_mark'))
|
|
|
|
end
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# The framework instance associated with this driver.
|
|
|
|
#
|
|
|
|
attr_reader :framework
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
attr_writer :framework # :nodoc:
|
|
|
|
attr_accessor :opts # :nodoc:
|
|
|
|
|
|
|
|
#
|
|
|
|
# Initializes logging for the Gtk2 driver.
|
|
|
|
#
|
|
|
|
def initialize_logging
|
|
|
|
level = (opts['LogLevel'] || 0).to_i
|
|
|
|
|
|
|
|
Msf::Logging.enable_log_source(LogSource, level)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|