This cleans up the msfweb initialization, removes the need to re-exec ruby, etc.

git-svn-id: file:///home/svn/framework3/trunk@4547 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2007-03-24 06:14:12 +00:00
parent f8453d6283
commit 769596693b
1 changed files with 32 additions and 10 deletions

42
msfweb
View File

@ -1,12 +1,17 @@
#!/usr/bin/env ruby
#
# This user interface provides users with a command console interface to the
# framework.
# This user interface provides users with a web-based interface to the framework
#
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
require 'msf/base'
require 'rex'
require 'stringio'
msfroot = File.join(File.dirname(msfbase), 'data', 'msfweb')
@ -18,7 +23,6 @@ msfserv = File.join('script', 'server')
arguments = Rex::Parser::Arguments.new(
"-a" => [ true, "Bind to this IP address instead of loopback" ],
"-p" => [ true, "Bind to this port instead of 55555" ],
# "-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
"-d" => [ false, "Daemonize the web server" ],
"-h" => [ false, "Help banner" ])
@ -44,11 +48,29 @@ arguments.parse(ARGV) { |opt, idx, val|
end
}
system(
"ruby",
msfserv,
'-p', (opts['ServerPort'] || '55555'),
'-b', (opts['ServerHost'] || '127.0.0.1'),
(background ? '-d' : '')
)
host = (opts['ServerHost'] || '127.0.0.1')
port = (opts['ServerPort'] || '55555')
# This is stupid, but we need to override the ARGV constant
ostderr = $stderr
$stderr = StringIO.new
ARGV = [
'-p', port,
'-b', host,
(background ? '-d' : '')
]
$stderr.close
$stderr = ostderr
$stderr.puts ""
$stderr.puts "[*] Starting msfweb v#{Msf::Framework::Version} on http://#{host}:#{port}/"
$stderr.puts ""
load(msfserv)