2007-02-04 01:55:01 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# This is a basic user interface using the Gtk2 GUI library
|
|
|
|
#
|
|
|
|
|
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
|
|
|
|
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui'
|
|
|
|
|
2007-02-15 21:24:27 +00:00
|
|
|
# Check for ruby packages
|
2007-02-04 01:55:01 +00:00
|
|
|
begin
|
|
|
|
require 'gtk2'
|
|
|
|
require 'libglade2'
|
|
|
|
rescue ::Exception => e
|
2007-02-04 19:30:49 +00:00
|
|
|
$stderr.puts "[*] The msfgui interface requires the ruby-gtk2 and ruby-libglade2 package"
|
2007-02-04 01:55:01 +00:00
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
|
2007-02-15 21:24:27 +00:00
|
|
|
# Check for Gtk+ version
|
2007-02-15 22:09:24 +00:00
|
|
|
# Returns: nil if the GTK+ library is compatible with the given version,
|
2007-02-15 21:24:27 +00:00
|
|
|
# or a string describing the version mismatch.
|
2007-05-06 20:47:17 +00:00
|
|
|
if gtkversion = Gtk.check_version(2,8,0)
|
|
|
|
$stderr.puts "[*] The msfgui interface requires Gtk+ 2.8 or later"
|
2007-04-27 18:40:51 +00:00
|
|
|
$stderr.puts "[*] Your Gtk+ version : #{gtkversion}"
|
2007-02-15 21:24:27 +00:00
|
|
|
exit
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-15 21:24:27 +00:00
|
|
|
require 'msf/ui/gtk2'
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2007-02-13 15:46:00 +00:00
|
|
|
# Declare the argument parser for msfgui
|
2007-02-04 01:55:01 +00:00
|
|
|
arguments = Rex::Parser::Arguments.new(
|
|
|
|
"-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
|
|
|
|
"-d" => [ false, "Keep running in the foreground" ],
|
2008-01-21 01:48:05 +00:00
|
|
|
"-D" => [ false, "Keep stdio and stderr open for debugging" ],
|
2007-02-04 01:55:01 +00:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
|
|
|
opts = {}
|
2007-02-26 18:45:12 +00:00
|
|
|
foreground = true
|
2008-01-21 01:48:05 +00:00
|
|
|
debug = false
|
2007-02-04 01:55:01 +00:00
|
|
|
|
|
|
|
# Parse command line arguments.
|
|
|
|
arguments.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-v"
|
|
|
|
opts['LogLevel'] = val
|
|
|
|
when "-d"
|
2007-02-26 18:45:12 +00:00
|
|
|
foreground = false
|
2008-01-21 01:48:05 +00:00
|
|
|
when "-D"
|
|
|
|
debug = true
|
2007-02-04 01:55:01 +00:00
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: msfgui <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2007-02-26 18:45:12 +00:00
|
|
|
# Fork into the background if requested
|
|
|
|
begin
|
|
|
|
if (not foreground)
|
|
|
|
exit(0) if Process.fork()
|
|
|
|
end
|
|
|
|
rescue ::NotImplementedError
|
|
|
|
$stderr.puts "[*] Background mode is not available on this platform"
|
|
|
|
end
|
2007-02-04 01:55:01 +00:00
|
|
|
|
2008-01-21 01:48:05 +00:00
|
|
|
class FakeOut
|
|
|
|
def write(buff)
|
|
|
|
buff.length
|
|
|
|
end
|
|
|
|
|
|
|
|
def method_missing(meth, *args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if(not debug)
|
|
|
|
fake = FakeOut.new
|
|
|
|
$stdout = fake
|
|
|
|
$stderr = fake
|
2008-01-22 04:57:06 +00:00
|
|
|
|
|
|
|
if(Rex::Compat.is_windows)
|
|
|
|
nul = Rex::Compat.win32_dev_null()
|
2008-01-22 04:58:47 +00:00
|
|
|
Rex::Compat.win32_set_std_handle('stdout', nul)
|
|
|
|
Rex::Compat.win32_set_std_handle('stderr', nul)
|
|
|
|
Rex::Compat.win32_set_std_handle('stdin', nul)
|
2008-01-22 05:00:13 +00:00
|
|
|
|
|
|
|
# The following will crash rubyw.exe without the above code
|
2008-01-22 05:02:03 +00:00
|
|
|
GLib::Log.log("Gtk", GLib::Log::LEVEL_CRITICAL, "gtk + rubyw problems > /dev/null")
|
2008-01-22 04:57:06 +00:00
|
|
|
end
|
2008-01-21 01:48:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
$stderr.puts "[*] Debugging mode is enabled"
|
|
|
|
|
2007-02-13 15:46:00 +00:00
|
|
|
# Language is English
|
|
|
|
ENV['LANG'] = 'C'
|
|
|
|
|
2007-02-04 01:55:01 +00:00
|
|
|
# Create the driver instance and run it.
|
|
|
|
Msf::Ui::Gtk2::Driver.new(opts).run
|
|
|
|
|
|
|
|
|