2006-09-24 00:16:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
2007-03-24 06:14:12 +00:00
|
|
|
# This user interface provides users with a web-based interface to the framework
|
2006-09-24 00:16:23 +00:00
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2006-09-24 00:16:23 +00:00
|
|
|
|
2009-01-30 06:27:10 +00:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
2006-09-24 00:16:23 +00:00
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
2008-02-02 21:29:46 +00:00
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2007-03-24 06:14:12 +00:00
|
|
|
|
|
|
|
require 'stringio'
|
2009-09-28 03:12:56 +00:00
|
|
|
require 'rex'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui/web'
|
2006-09-27 02:48:03 +00:00
|
|
|
|
2009-11-11 02:36:56 +00:00
|
|
|
$stderr.puts "[*] Warning: As of Metasploit 3.3 this interface is no longer supported:"
|
|
|
|
$stderr.puts " Please see https://metasploit.com/redmine/issues/502"
|
|
|
|
$stderr.puts ""
|
2006-09-24 00:16:23 +00:00
|
|
|
|
2006-09-24 00:31:07 +00:00
|
|
|
msfroot = File.join(File.dirname(msfbase), 'data', 'msfweb')
|
|
|
|
Dir.chdir(msfroot)
|
|
|
|
|
|
|
|
msfserv = File.join('script', 'server')
|
2006-09-27 02:48:03 +00:00
|
|
|
|
|
|
|
# Declare the argument parser for msfweb
|
|
|
|
arguments = Rex::Parser::Arguments.new(
|
|
|
|
"-a" => [ true, "Bind to this IP address instead of loopback" ],
|
|
|
|
"-p" => [ true, "Bind to this port instead of 55555" ],
|
2006-09-27 03:08:09 +00:00
|
|
|
"-d" => [ false, "Daemonize the web server" ],
|
2007-03-24 06:50:43 +00:00
|
|
|
"-s" => [ false, "Automatically open the browser" ],
|
2006-09-27 02:48:03 +00:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
2009-01-06 16:57:41 +00:00
|
|
|
opts = {
|
|
|
|
'ServerHost' => '127.0.0.1',
|
|
|
|
'ServerPort' => '55555'
|
|
|
|
}
|
2006-09-27 02:48:03 +00:00
|
|
|
background = false
|
2007-03-24 06:50:43 +00:00
|
|
|
browser_start = false
|
2006-09-27 02:48:03 +00:00
|
|
|
|
|
|
|
# Parse command line arguments.
|
2009-10-26 17:33:05 +00:00
|
|
|
arguments.parse(ARGV) do |opt, idx, val|
|
2006-09-27 02:48:03 +00:00
|
|
|
case opt
|
|
|
|
when "-a"
|
|
|
|
opts['ServerHost'] = val
|
|
|
|
when "-p"
|
|
|
|
opts['ServerPort'] = val
|
|
|
|
when "-v"
|
|
|
|
opts['LogLevel'] = val
|
|
|
|
when "-d"
|
|
|
|
background = true
|
2007-03-24 06:50:43 +00:00
|
|
|
when "-s"
|
|
|
|
browser_start = true
|
2006-09-27 02:48:03 +00:00
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: msfweb <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
2009-10-26 17:33:05 +00:00
|
|
|
end
|
2007-03-24 06:14:12 +00:00
|
|
|
|
2009-10-26 17:33:05 +00:00
|
|
|
# Drain ARGV
|
|
|
|
while(ARGV.shift) do
|
|
|
|
end
|
2007-03-24 06:14:12 +00:00
|
|
|
|
2009-10-26 17:33:05 +00:00
|
|
|
# Rebuild ARGV
|
|
|
|
ARGV.unshift([
|
2009-11-11 02:36:56 +00:00
|
|
|
'-p', opts['ServerPort'],
|
2009-01-06 16:57:41 +00:00
|
|
|
'-b', opts['ServerHost'],
|
2007-03-24 23:10:38 +00:00
|
|
|
'-e', 'production',
|
2006-09-27 03:08:09 +00:00
|
|
|
(background ? '-d' : '')
|
2009-10-26 17:33:05 +00:00
|
|
|
])
|
|
|
|
ARGV.flatten!
|
2007-03-24 06:14:12 +00:00
|
|
|
|
2009-01-06 16:57:41 +00:00
|
|
|
$browser_url = "http://#{opts['ServerHost']}:#{opts['ServerPort']}/"
|
2007-03-24 06:50:43 +00:00
|
|
|
$browser_start = browser_start
|
2007-03-24 06:14:12 +00:00
|
|
|
|
|
|
|
$stderr.puts ""
|
2007-03-24 06:50:43 +00:00
|
|
|
$stderr.puts "[*] Starting msfweb v#{Msf::Framework::Version} on #{$browser_url}"
|
2007-03-24 06:14:12 +00:00
|
|
|
$stderr.puts ""
|
2006-09-24 00:16:23 +00:00
|
|
|
|
2009-01-06 16:57:41 +00:00
|
|
|
load(msfserv)
|
2009-11-11 02:36:56 +00:00
|
|
|
|