2007-02-04 02:55:01 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# This is a basic user interface using the Gtk2 GUI library
|
|
|
|
#
|
|
|
|
|
2009-01-30 07:27:10 +01:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
2008-11-16 22:10:35 +01:00
|
|
|
$:.unshift(File.join(File.expand_path(File.dirname(msfbase)), 'lib'))
|
2008-02-02 22:29:46 +01:00
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2007-02-04 02:55:01 +01:00
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui'
|
|
|
|
|
2007-02-15 22:24:27 +01:00
|
|
|
# Check for ruby packages
|
2007-02-04 02:55:01 +01:00
|
|
|
begin
|
|
|
|
require 'gtk2'
|
|
|
|
require 'libglade2'
|
|
|
|
rescue ::Exception => e
|
2008-02-09 09:17:20 +01:00
|
|
|
$stderr.puts "[*] The msfgui interface requires the ruby-gtk2 and ruby-libglade2 packages"
|
|
|
|
$stderr.puts "[*] Dependencies include ruby-pango, ruby-glib2, ruby-gdkpixbuf2, and ruby-atk"
|
2009-03-11 01:10:27 +01:00
|
|
|
$stderr.puts "[-] Error: #{e.class} #{e}"
|
2007-02-04 02:55:01 +01:00
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
|
2007-02-15 22:24:27 +01:00
|
|
|
# Check for Gtk+ version
|
2007-02-15 23:09:24 +01:00
|
|
|
# Returns: nil if the GTK+ library is compatible with the given version,
|
2007-02-15 22:24:27 +01:00
|
|
|
# or a string describing the version mismatch.
|
2007-05-06 22:47:17 +02:00
|
|
|
if gtkversion = Gtk.check_version(2,8,0)
|
|
|
|
$stderr.puts "[*] The msfgui interface requires Gtk+ 2.8 or later"
|
2007-04-27 20:40:51 +02:00
|
|
|
$stderr.puts "[*] Your Gtk+ version : #{gtkversion}"
|
2007-02-15 22:24:27 +01:00
|
|
|
exit
|
|
|
|
end
|
2007-02-04 02:55:01 +01:00
|
|
|
|
2007-02-15 22:24:27 +01:00
|
|
|
require 'msf/ui/gtk2'
|
2007-02-04 02:55:01 +01:00
|
|
|
|
2007-02-13 16:46:00 +01:00
|
|
|
# Declare the argument parser for msfgui
|
2007-02-04 02:55:01 +01:00
|
|
|
arguments = Rex::Parser::Arguments.new(
|
|
|
|
"-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
|
2008-04-23 01:20:35 +02:00
|
|
|
"-r" => [ true, "Execute the specified resource file" ],
|
2008-10-06 12:50:57 +02:00
|
|
|
"-d" => [ false, "Fork and run in the background" ],
|
2008-01-21 02:48:05 +01:00
|
|
|
"-D" => [ false, "Keep stdio and stderr open for debugging" ],
|
2007-02-04 02:55:01 +01:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
|
|
|
opts = {}
|
2007-02-26 19:45:12 +01:00
|
|
|
foreground = true
|
2008-01-21 02:48:05 +01:00
|
|
|
debug = false
|
2007-02-04 02:55:01 +01:00
|
|
|
|
|
|
|
# Parse command line arguments.
|
|
|
|
arguments.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-v"
|
|
|
|
opts['LogLevel'] = val
|
2008-04-23 01:20:35 +02:00
|
|
|
when "-r"
|
|
|
|
opts['Resource'] = val
|
2007-02-04 02:55:01 +01:00
|
|
|
when "-d"
|
2007-02-26 19:45:12 +01:00
|
|
|
foreground = false
|
2008-01-21 02:48:05 +01:00
|
|
|
when "-D"
|
|
|
|
debug = true
|
2007-02-04 02:55:01 +01:00
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: msfgui <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2007-02-26 19:45:12 +01:00
|
|
|
# Fork into the background if requested
|
|
|
|
begin
|
|
|
|
if (not foreground)
|
|
|
|
exit(0) if Process.fork()
|
|
|
|
end
|
|
|
|
rescue ::NotImplementedError
|
2009-03-11 01:10:27 +01:00
|
|
|
$stderr.puts "[-] Background mode is not available on this platform"
|
2007-02-26 19:45:12 +01:00
|
|
|
end
|
2007-02-04 02:55:01 +01:00
|
|
|
|
2008-01-21 02:48:05 +01:00
|
|
|
class FakeOut
|
|
|
|
def write(buff)
|
|
|
|
buff.length
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(meth, *args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if(not debug)
|
2008-01-22 06:48:16 +01:00
|
|
|
|
|
|
|
begin; $stdout.close; rescue; end
|
|
|
|
begin; $stderr.close; rescue; end
|
|
|
|
|
2008-01-21 02:48:05 +01:00
|
|
|
fake = FakeOut.new
|
|
|
|
$stdout = fake
|
|
|
|
$stderr = fake
|
2008-01-22 06:48:16 +01:00
|
|
|
|
|
|
|
# Only treat super nasty Gtk errors as fatal
|
|
|
|
GLib::Log.set_fatal_mask("GLib", GLib::Log::LEVEL_ERROR)
|
|
|
|
GLib::Log.set_fatal_mask("Gtk", GLib::Log::LEVEL_ERROR)
|
|
|
|
GLib::Log.set_fatal_mask("Gdk", GLib::Log::LEVEL_ERROR)
|
|
|
|
GLib::Log.set_fatal_mask(nil, GLib::Log::LEVEL_ERROR)
|
2008-01-22 07:03:05 +01:00
|
|
|
|
|
|
|
# GLib::Log.log("Gtk", GLib::Log::LEVEL_CRITICAL, "TESTING > /dev/null")
|
2008-01-21 02:48:05 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
$stderr.puts "[*] Debugging mode is enabled"
|
|
|
|
|
2007-02-13 16:46:00 +01:00
|
|
|
# Language is English
|
|
|
|
ENV['LANG'] = 'C'
|
2008-01-22 06:48:16 +01:00
|
|
|
|
2007-02-04 02:55:01 +01:00
|
|
|
# Create the driver instance and run it.
|
2008-11-16 22:10:35 +01:00
|
|
|
Msf::Ui::Gtk2::Driver.new(opts).run
|