metasploit-framework/msfgui

74 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/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'
# Check for ruby packages
begin
require 'gtk2'
require 'libglade2'
rescue ::Exception => e
$stderr.puts "[*] The msfgui interface requires the ruby-gtk2 and ruby-libglade2 package"
exit(0)
end
# Check for Gtk+ version
# Returns: nil if the GTK+ library is compatible with the given version,
# or a string describing the version mismatch.
if gtkversion = Gtk.check_version(2,10,0)
$stderr.puts "[*] The msfgui interface requires Gtk+ 2.10 or later"
$stderr.puts "[*] Your Gtk+ version : #{gtkversion}"
exit
end
require 'msf/ui/gtk2'
# Declare the argument parser for msfgui
arguments = Rex::Parser::Arguments.new(
"-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
"-d" => [ false, "Keep running in the foreground" ],
"-h" => [ false, "Help banner" ])
opts = {}
foreground = true
# Parse command line arguments.
arguments.parse(ARGV) { |opt, idx, val|
case opt
when "-v"
opts['LogLevel'] = val
when "-d"
foreground = false
when "-h"
print(
"\nUsage: msfgui <options>\n" +
arguments.usage)
exit
end
}
# 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
# Language is English
ENV['LANG'] = 'C'
# Create the driver instance and run it.
Msf::Ui::Gtk2::Driver.new(opts).run