2006-09-24 02:16:23 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# This user interface provides users with a command console interface to the
|
|
|
|
# framework.
|
|
|
|
#
|
|
|
|
|
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
2006-09-27 04:48:03 +02:00
|
|
|
require 'rex'
|
|
|
|
|
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" ],
|
|
|
|
# "-v" => [ true, "A number between 0 and 3 that controls log verbosity" ],
|
2006-09-27 05:08:09 +02:00
|
|
|
"-d" => [ false, "Daemonize the web server" ],
|
2006-09-27 04:48:03 +02:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
|
|
|
opts = {}
|
|
|
|
background = false
|
|
|
|
|
|
|
|
# Parse command line arguments.
|
|
|
|
arguments.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-a"
|
|
|
|
opts['ServerHost'] = val
|
|
|
|
when "-p"
|
|
|
|
opts['ServerPort'] = val
|
|
|
|
when "-v"
|
|
|
|
opts['LogLevel'] = val
|
|
|
|
when "-d"
|
|
|
|
background = true
|
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: msfweb <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2006-09-27 05:08:09 +02:00
|
|
|
system(
|
2007-01-21 21:27:15 +01:00
|
|
|
"ruby",
|
2006-09-27 05:08:09 +02:00
|
|
|
msfserv,
|
|
|
|
'-p', (opts['ServerPort'] || '55555'),
|
|
|
|
'-b', (opts['ServerHost'] || '127.0.0.1'),
|
|
|
|
(background ? '-d' : '')
|
|
|
|
)
|
2006-09-24 02:16:23 +02:00
|
|
|
|