2007-02-04 01:55:01 +00:00
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui'
|
|
|
|
|
2007-05-17 22:17:24 +00:00
|
|
|
require 'msf/ui/gtk2/treeviewtooltips'
|
2007-02-04 01:55:01 +00:00
|
|
|
require 'msf/ui/gtk2/controls'
|
|
|
|
require 'msf/ui/gtk2/app'
|
|
|
|
require 'msf/ui/gtk2/about'
|
|
|
|
require 'msf/ui/gtk2/frame'
|
2007-03-08 22:44:55 +00:00
|
|
|
require 'msf/ui/gtk2/assistant'
|
2007-02-04 01:55:01 +00:00
|
|
|
require 'msf/ui/gtk2/dialogs'
|
2007-05-21 22:37:23 +00:00
|
|
|
require 'msf/ui/gtk2/window'
|
2007-12-31 17:03:06 +00:00
|
|
|
require 'msf/ui/gtk2/preferences'
|
2007-05-17 23:33:18 +00:00
|
|
|
require 'msf/ui/gtk2/meterpreter'
|
2007-03-01 22:09:01 +00:00
|
|
|
require 'msf/ui/gtk2/console'
|
2007-02-13 00:22:05 +00:00
|
|
|
require 'msf/ui/gtk2/search'
|
2007-04-22 00:01:56 +00:00
|
|
|
require 'msf/ui/gtk2/opcode'
|
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
|
2007-12-31 00:23:33 +00:00
|
|
|
module Ui
|
|
|
|
module Gtk2
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class implements a user interface driver on a gtk2 interface.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
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"
|
|
|
|
ConfigGroup = "framework/ui/gtk2"
|
|
|
|
|
|
|
|
#
|
|
|
|
# The default resource directory for msfgui
|
|
|
|
#
|
|
|
|
DefaultResourceDirectory = Msf::Config.data_directory + File::SEPARATOR + "msfgui"
|
2007-12-31 01:09:34 +00:00
|
|
|
|
|
|
|
DefaultConfigDirectory = Msf::Config.config_directory + File::SEPARATOR
|
|
|
|
|
2007-12-31 00:23:33 +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
|
|
|
|
|
|
|
|
# Create the gtk2driver global
|
|
|
|
$gtk2driver = self
|
|
|
|
|
|
|
|
# Init GTK2
|
|
|
|
Gtk.init
|
|
|
|
|
2007-12-31 00:27:44 +00:00
|
|
|
# Initialize the splash screen
|
2007-12-31 00:23:33 +00:00
|
|
|
@splash = Msf::Ui::Gtk2::MySplash.new()
|
|
|
|
done_splash = false
|
|
|
|
|
|
|
|
Gtk.idle_add do
|
|
|
|
if(done_splash)
|
2007-12-31 00:27:44 +00:00
|
|
|
self.framework = Msf::Simple::Framework.create
|
2007-12-31 00:23:33 +00:00
|
|
|
@gtk2app = Msf::Ui::Gtk2::MyApp.new()
|
|
|
|
@gtk2app.window.show
|
|
|
|
@splash.destroy
|
|
|
|
register_event_handlers
|
|
|
|
false
|
|
|
|
else
|
2007-12-31 00:27:44 +00:00
|
|
|
# Queue a redraw and let the main window start
|
2007-12-31 00:23:33 +00:00
|
|
|
@splash.queue_draw
|
|
|
|
done_splash = true
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Starts the main gtk2 loop
|
|
|
|
#
|
|
|
|
def run
|
|
|
|
ilog("msfgui has been started", LogSource)
|
|
|
|
Gtk.main
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the local directory that will hold the files to be serviced.
|
|
|
|
#
|
|
|
|
def resource_directory
|
|
|
|
opts['ResourceDirectory'] || DefaultResourceDirectory
|
|
|
|
end
|
|
|
|
|
2007-12-31 01:09:34 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the local directory that will hold the files to be serviced.
|
|
|
|
#
|
|
|
|
def config_directory
|
|
|
|
opts['ConfigDirectory'] || DefaultConfigDirectory
|
|
|
|
end
|
|
|
|
|
2007-12-31 00:23:33 +00:00
|
|
|
#
|
|
|
|
# Saves configuration for MsfAssistant.
|
|
|
|
#
|
|
|
|
def save_config
|
|
|
|
# Build out the assistant config group
|
|
|
|
group = {}
|
|
|
|
|
|
|
|
if (active_module)
|
|
|
|
group['ActiveModule'] = active_module.fullname
|
|
|
|
end
|
|
|
|
|
|
|
|
# Save it
|
|
|
|
begin
|
|
|
|
Msf::Config.save(
|
|
|
|
ConfigGroup => group)
|
|
|
|
rescue
|
|
|
|
MsfDialog::Error.new(self, "Failed to save config file : #{$!}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns a new Gdk::Pixbuf object
|
|
|
|
#
|
|
|
|
def get_icon(name)
|
|
|
|
Gdk::Pixbuf.new(File.join(resource_directory, 'pix', name))
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns only pics
|
|
|
|
#
|
|
|
|
def get_image(name)
|
|
|
|
return File.join(resource_directory, 'pix', name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Adds text to the main logging screen
|
|
|
|
#
|
|
|
|
def append_log_view(data)
|
2008-01-21 02:20:57 +00:00
|
|
|
data.gsub!(/[\x80-\xff\x00]/, '?')
|
2007-12-31 00:23:33 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# The framework instance associated with this driver.
|
|
|
|
#
|
|
|
|
attr_reader :framework
|
|
|
|
|
|
|
|
#
|
|
|
|
# The active module associated with the driver.
|
|
|
|
#
|
|
|
|
attr_accessor :active_module, :exploit
|
|
|
|
|
|
|
|
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
|
2007-02-04 01:55:01 +00:00
|
|
|
end
|