root/framework3/trunk/msfweb

Revision 5392, 1.8 kB (checked in by hdm, 8 months ago)

Merged revisions 5386-5391 via svnmerge from
svn+ssh://metasploit.com/home/svn/framework3/branches/framework-3.1

........

r5391 | hdm | 2008-02-02 15:26:48 -0600 (Sat, 02 Feb 2008) | 3 lines


Prepend a library directory to the search path, if MSF_LOCAL_LIB is set. This lets folks maintain a set of modified libraries that will be used instead of the official ones. Documentation updates as well.

........

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env ruby
2 #
3 # This user interface provides users with a web-based interface to the framework
4 #
5
6 msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
7 $:.unshift(File.join(File.dirname(msfbase), 'lib'))
8 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
9
10
11 require 'msf/base'
12 require 'rex'
13 require 'stringio'
14
15
16
17 msfroot = File.join(File.dirname(msfbase), 'data', 'msfweb')
18 Dir.chdir(msfroot)
19
20 msfserv = File.join('script', 'server')
21
22 # Declare the argument parser for msfweb
23 arguments = Rex::Parser::Arguments.new(
24         "-a" => [ true,  "Bind to this IP address instead of loopback"          ],
25         "-p" => [ true,  "Bind to this port instead of 55555"                   ],
26         "-d" => [ false, "Daemonize the web server"                             ],
27         "-s" => [ false, "Automatically open the browser"                       ],
28         "-h" => [ false, "Help banner"                                          ])
29
30 opts = {}
31 background = false
32 browser_start = false
33
34 # Parse command line arguments.
35 arguments.parse(ARGV) { |opt, idx, val|
36         case opt
37                 when "-a"
38                         opts['ServerHost'] = val
39                 when "-p"
40                         opts['ServerPort'] = val
41                 when "-v"
42                         opts['LogLevel'] = val
43                 when "-d"
44                         background = true
45                 when "-s"
46                         browser_start = true
47                 when "-h"
48                         print(
49                                 "\nUsage: msfweb <options>\n" +
50                                 arguments.usage)
51                         exit
52         end
53 }
54
55
56 host = (opts['ServerHost'] || '127.0.0.1')
57 port = (opts['ServerPort'] || '55555')
58
59
60 # This is stupid, but we need to override the ARGV constant
61
62 ostderr = $stderr
63 $stderr = StringIO.new
64
65 ARGV = [
66         '-p', port,
67         '-b', host,
68         '-e', 'production',
69         (background ? '-d' : '')
70 ]
71
72 $stderr.close
73 $stderr = ostderr
74
75 $browser_url   = "http://#{host}:#{port}/"
76 $browser_start = browser_start
77
78 $stderr.puts ""
79 $stderr.puts "[*] Starting msfweb v#{Msf::Framework::Version} on #{$browser_url}"
80 $stderr.puts ""
81
82 load(msfserv)
83        
Note: See TracBrowser for help on using the browser.