2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-11-28 21:38:48 +00:00
|
|
|
#
|
|
|
|
# This user interface listens on a port and provides clients that connect to
|
|
|
|
# it with an msfconsole instance. The nice thing about this interface is that
|
|
|
|
# it allows multiple clients to share one framework instance and thus makes it
|
|
|
|
# possible for sessions to to be shared from a single vantage point.
|
|
|
|
#
|
2005-11-28 16:36:06 +00:00
|
|
|
|
2006-07-31 15:36:08 +00:00
|
|
|
msfbase = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
|
|
$:.unshift(File.join(File.dirname(msfbase), 'lib'))
|
2005-11-28 16:36:06 +00:00
|
|
|
|
|
|
|
require 'msf/base'
|
|
|
|
require 'msf/ui'
|
|
|
|
|
2005-11-28 16:38:13 +00:00
|
|
|
# Declare the argument parser for msfd
|
2005-11-28 16:36:06 +00:00
|
|
|
arguments = Rex::Parser::Arguments.new(
|
|
|
|
"-a" => [ true, "Bind to this IP address instead of loopback" ],
|
|
|
|
"-p" => [ true, "Bind to this port instead of 55554" ],
|
2005-11-28 16:52:05 +00:00
|
|
|
"-f" => [ false, "Run the daemon in the foreground" ],
|
2005-11-28 16:36:06 +00:00
|
|
|
"-h" => [ false, "Help banner" ])
|
|
|
|
|
2005-11-28 21:38:48 +00:00
|
|
|
opts = { 'RunInForeground' => true }
|
2005-11-28 16:36:06 +00:00
|
|
|
foreground = false
|
|
|
|
|
|
|
|
# Parse command line arguments.
|
|
|
|
arguments.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
|
|
|
when "-a"
|
|
|
|
opts['ServerHost'] = val
|
|
|
|
when "-p"
|
|
|
|
opts['ServerPort'] = val
|
|
|
|
when "-f"
|
|
|
|
foreground = true
|
|
|
|
when "-h"
|
|
|
|
print(
|
|
|
|
"\nUsage: #{File.basename(__FILE__)} <options>\n" +
|
|
|
|
arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create an instance of the framework
|
|
|
|
$framework = Msf::Simple::Framework.create
|
|
|
|
|
|
|
|
exit if (Process.fork()) unless foreground
|
|
|
|
|
2005-11-28 21:38:48 +00:00
|
|
|
# Run the plugin instance in the foreground.
|
|
|
|
$framework.plugins.load('msfd', opts).run
|