Skip to content
Newer
Older
100755 123 lines (100 sloc) 2.98 KB
aca397d Initial import for the msfgui code from Fab
HD Moore authored
1 #!/usr/bin/env ruby
2 #
0e72894 @jduck more cleanups
jduck authored
3 # $Id$
4 #
aca397d Initial import for the msfgui code from Fab
HD Moore authored
5 # This is a basic user interface using the Gtk2 GUI library
6 #
0e72894 @jduck more cleanups
jduck authored
7 # $Revision$
8 #
aca397d Initial import for the msfgui code from Fab
HD Moore authored
9
beb0cc7 Patch from Jonathan Steel to fix double-symlinks
HD Moore authored
10 msfbase = __FILE__
11 while File.symlink?(msfbase)
12 msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
13 end
14
b3ecce5 @jlee-r7 look for files in absolute paths. fixes #252
jlee-r7 authored
15 $:.unshift(File.join(File.expand_path(File.dirname(msfbase)), 'lib'))
271822d Merged revisions 5386-5391 via svnmerge from
HD Moore authored
16 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
aca397d Initial import for the msfgui code from Fab
HD Moore authored
17
18 require 'rex'
19 require 'msf/base'
20 require 'msf/ui'
21
12c4d32 See #502 and see #503.
HD Moore authored
22 $stderr.puts "[*] Warning: As of Metasploit 3.3 this interface is no longer supported:"
23 $stderr.puts " Please see https://metasploit.com/redmine/issues/503"
24 $stderr.puts ""
25
2f2dd4c - add a version Gtk+ check
fab authored
26 # Check for ruby packages
aca397d Initial import for the msfgui code from Fab
HD Moore authored
27 begin
28 require 'gtk2'
29 require 'libglade2'
30 rescue ::Exception => e
cd5d111 Handle situations were ruby-gtk2 is available, but cairo is not. Fixes
HD Moore authored
31 $stderr.puts "[*] The msfgui interface requires the ruby-gtk2 and ruby-libglade2 packages"
32 $stderr.puts "[*] Dependencies include ruby-pango, ruby-glib2, ruby-gdkpixbuf2, and ruby-atk"
2faa983 Use [-] instead of [*] for error messages
kris authored
33 $stderr.puts "[-] Error: #{e.class} #{e}"
aca397d Initial import for the msfgui code from Fab
HD Moore authored
34 exit(0)
35 end
36
2f2dd4c - add a version Gtk+ check
fab authored
37 # Check for Gtk+ version
4b99a04 - add completion to the module search
fab authored
38 # Returns: nil if the GTK+ library is compatible with the given version,
2f2dd4c - add a version Gtk+ check
fab authored
39 # or a string describing the version mismatch.
584d614 update the require to launch msfgui
fab authored
40 if gtkversion = Gtk.check_version(2,8,0)
41 $stderr.puts "[*] The msfgui interface requires Gtk+ 2.8 or later"
af8db5d typo
fab authored
42 $stderr.puts "[*] Your Gtk+ version : #{gtkversion}"
2f2dd4c - add a version Gtk+ check
fab authored
43 exit
12c4d32 See #502 and see #503.
HD Moore authored
44 end
aca397d Initial import for the msfgui code from Fab
HD Moore authored
45
2f2dd4c - add a version Gtk+ check
fab authored
46 require 'msf/ui/gtk2'
aca397d Initial import for the msfgui code from Fab
HD Moore authored
47
9a37531 - update for developpers
fab authored
48 # Declare the argument parser for msfgui
aca397d Initial import for the msfgui code from Fab
HD Moore authored
49 arguments = Rex::Parser::Arguments.new(
50 "-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
16170bd Let the GUI handle -r, change default window size to fit smaller scre…
HD Moore authored
51 "-r" => [ true, "Execute the specified resource file" ],
a9d8ab1 Two patches from antoine
HD Moore authored
52 "-d" => [ false, "Fork and run in the background" ],
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
53 "-D" => [ false, "Keep stdio and stderr open for debugging" ],
aca397d Initial import for the msfgui code from Fab
HD Moore authored
54 "-h" => [ false, "Help banner" ])
55
56 opts = {}
9172103 Prevent the fork() call from triggering a NotImplementedError on Windows
HD Moore authored
57 foreground = true
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
58 debug = false
aca397d Initial import for the msfgui code from Fab
HD Moore authored
59
60 # Parse command line arguments.
61 arguments.parse(ARGV) { |opt, idx, val|
62 case opt
63 when "-v"
64 opts['LogLevel'] = val
16170bd Let the GUI handle -r, change default window size to fit smaller scre…
HD Moore authored
65 when "-r"
66 opts['Resource'] = val
aca397d Initial import for the msfgui code from Fab
HD Moore authored
67 when "-d"
9172103 Prevent the fork() call from triggering a NotImplementedError on Windows
HD Moore authored
68 foreground = false
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
69 when "-D"
70 debug = true
aca397d Initial import for the msfgui code from Fab
HD Moore authored
71 when "-h"
72 print(
73 "\nUsage: msfgui <options>\n" +
74 arguments.usage)
75 exit
76 end
77 }
78
9172103 Prevent the fork() call from triggering a NotImplementedError on Windows
HD Moore authored
79 # Fork into the background if requested
80 begin
81 if (not foreground)
82 exit(0) if Process.fork()
83 end
84 rescue ::NotImplementedError
2faa983 Use [-] instead of [*] for error messages
kris authored
85 $stderr.puts "[-] Background mode is not available on this platform"
9172103 Prevent the fork() call from triggering a NotImplementedError on Windows
HD Moore authored
86 end
aca397d Initial import for the msfgui code from Fab
HD Moore authored
87
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
88 class FakeOut
89 def write(buff)
90 buff.length
91 end
12c4d32 See #502 and see #503.
HD Moore authored
92
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
93 def method_missing(meth, *args)
94 end
95 end
96
97 if(not debug)
221b408 Closer
HD Moore authored
98
99 begin; $stdout.close; rescue; end
100 begin; $stderr.close; rescue; end
12c4d32 See #502 and see #503.
HD Moore authored
101
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
102 fake = FakeOut.new
103 $stdout = fake
104 $stderr = fake
12c4d32 See #502 and see #503.
HD Moore authored
105
106 # Only treat super nasty Gtk errors as fatal
221b408 Closer
HD Moore authored
107 GLib::Log.set_fatal_mask("GLib", GLib::Log::LEVEL_ERROR)
108 GLib::Log.set_fatal_mask("Gtk", GLib::Log::LEVEL_ERROR)
109 GLib::Log.set_fatal_mask("Gdk", GLib::Log::LEVEL_ERROR)
110 GLib::Log.set_fatal_mask(nil, GLib::Log::LEVEL_ERROR)
12c4d32 See #502 and see #503.
HD Moore authored
111
4adece5 Done with rubyw/gtk fixes, this seems to work
HD Moore authored
112 # GLib::Log.log("Gtk", GLib::Log::LEVEL_CRITICAL, "TESTING > /dev/null")
003cc32 Clean up for the 3.1 release, hide features which are not completed o…
HD Moore authored
113 end
114
115 $stderr.puts "[*] Debugging mode is enabled"
116
9a37531 - update for developpers
fab authored
117 # Language is English
118 ENV['LANG'] = 'C'
12c4d32 See #502 and see #503.
HD Moore authored
119
aca397d Initial import for the msfgui code from Fab
HD Moore authored
120 # Create the driver instance and run it.
b3ecce5 @jlee-r7 look for files in absolute paths. fixes #252
jlee-r7 authored
121 Msf::Ui::Gtk2::Driver.new(opts).run
12c4d32 See #502 and see #503.
HD Moore authored
122
Something went wrong with that request. Please try again.