2006-09-24 02:16:23 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2007-03-24 07:14:12 +01:00
|
|
|
# This user interface provides users with a web-based interface to the framework
|
2006-09-24 02:16:23 +02:00
|
|
|
#
|
|
|
|
|
2009-01-30 07:27:10 +01:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
2006-09-24 02:16:23 +02:00
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
2008-02-02 22:29:46 +01:00
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2007-03-24 07:14:12 +01:00
|
|
|
|
|
|
|
require 'stringio'
|
2009-09-28 05:12:56 +02:00
|
|
|
require 'rex'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui/web'
|
2006-09-27 04:48:03 +02:00
|
|
|
|
2009-11-11 03:36:56 +01: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 02:16:23 +02:00
|
|
|
|
2006-09-24 02:31:07 +02:00
|
|
|
msfroot = File.join(File.dirname(msfbase), 'data', 'msfweb')
|
|
|
|
Dir.chdir(msfroot)
|
|
|
|
|
|
|
|
msfserv = File.join('script', 'server')
|
2006-09-27 04:48:03 +02: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 05:08:09 +02:00
|
|
|
"-d" => [ false, "Daemonize the web server" ],
|
2007-03-24 07:50:43 +01:00
|
|
|
"-s" => [ false, "Automatically open the browser" ],
|
2006-09-27 04:48:03 +02:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
2009-01-06 17:57:41 +01:00
|
|
|
opts = {
|
|
|
|
'ServerHost' => '127.0.0.1',
|
|
|
|
'ServerPort' => '55555'
|
|
|
|
}
|
2006-09-27 04:48:03 +02:00
|
|
|
background = false
|
2007-03-24 07:50:43 +01:00
|
|
|
browser_start = false
|
2006-09-27 04:48:03 +02:00
|
|
|
|
|
|
|
# Parse command line arguments.
|
2009-10-26 18:33:05 +01:00
|
|
|
arguments.parse(ARGV) do |opt, idx, val|
|
2006-09-27 04:48:03 +02: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 07:50:43 +01:00
|
|
|
when "-s"
|
|
|
|
browser_start = true
|
2006-09-27 04:48:03 +02:00
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: msfweb <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
2009-10-26 18:33:05 +01:00
|
|
|
end
|
2007-03-24 07:14:12 +01:00
|
|
|
|
2009-10-26 18:33:05 +01:00
|
|
|
# Drain ARGV
|
|
|
|
while(ARGV.shift) do
|
|
|
|
end
|
2007-03-24 07:14:12 +01:00
|
|
|
|
2009-10-26 18:33:05 +01:00
|
|
|
# Rebuild ARGV
|
|
|
|
ARGV.unshift([
|
2009-11-11 03:36:56 +01:00
|
|
|
'-p', opts['ServerPort'],
|
2009-01-06 17:57:41 +01:00
|
|
|
'-b', opts['ServerHost'],
|
2007-03-25 00:10:38 +01:00
|
|
|
'-e', 'production',
|
2006-09-27 05:08:09 +02:00
|
|
|
(background ? '-d' : '')
|
2009-10-26 18:33:05 +01:00
|
|
|
])
|
|
|
|
ARGV.flatten!
|
2007-03-24 07:14:12 +01:00
|
|
|
|
2009-01-06 17:57:41 +01:00
|
|
|
$browser_url = "http://#{opts['ServerHost']}:#{opts['ServerPort']}/"
|
2007-03-24 07:50:43 +01:00
|
|
|
$browser_start = browser_start
|
2007-03-24 07:14:12 +01:00
|
|
|
|
|
|
|
$stderr.puts ""
|
2007-03-24 07:50:43 +01:00
|
|
|
$stderr.puts "[*] Starting msfweb v#{Msf::Framework::Version} on #{$browser_url}"
|
2007-03-24 07:14:12 +01:00
|
|
|
$stderr.puts ""
|
2006-09-24 02:16:23 +02:00
|
|
|
|
2009-01-06 17:57:41 +01:00
|
|
|
load(msfserv)
|
2009-11-11 03:36:56 +01:00
|
|
|
|